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

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

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

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

工具目录

分类

查看所有分类
Loading categories
CVE-2024-40275_Scanner — 用于检测 CVE-2024-40725 Apache HTTP Server 源代码泄露的扫描器;探测直接路径与子请求路径,对受影响版本进行指纹识别,并输出 JSON 报告供 CI/CD 使用。 | Kitploit
工具/GitHubGitHub/burjoy/cve-2024-40275_scanner
漏洞扫描器Web漏洞扫描器漏洞分析Web安全错误配置
GitHubburjoy/cve-2024-40275_scanner

CVE-2024-40275_Scanner

用于检测 CVE-2024-40725 Apache HTTP Server 源代码泄露的扫描器;探测直接路径与子请求路径,对受影响版本进行指纹识别,并输出 JSON 报告供 CI/CD 使用。

查看仓库
623天前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2024-40725 扫描器

一个基于 Python 的检测工具,用于 CVE-2024-40725,这是一个影响 2.4.0 和 2.4.61 版本的 Apache HTTP Server 源代码泄露漏洞。

法律声明: 仅可对您拥有或已获得明确书面授权进行测试的服务器运行此扫描器。未经授权使用可能违反计算机欺诈法律(例如 CFAA、Computer Misuse Act)。


背景

CVE-2024-40725 是 Apache 内部请求管道中的一个回归问题,该问题在 2.4.0 版本中引入(是对 CVE-2024-39884 的不完整修复)。当服务器使用旧式 AddType 指令(例如 AddType application/x-httpd-php .php)进行配置时,Apache 的内部处理程序分配会在子请求处理(由 DirectoryIndex、mod_rewrite 或 mod_dir 触发)期间被静默丢弃。

因此,PHP 脚本解释器永远不会被调用。取而代之的是,Apache 内置的 default-handler 会从磁盘打开文件并将原始字节流直接传送给客户端,其中可能包含数据库凭据、API 密钥以及应用程序逻辑。

受影响版本: Apache httpd 2.4.0 – 2.4.61
已修复版本: Apache httpd 2.4.62+


环境要求

  • Python 3.8+
  • requests 库
root@kitploit:~
pip install requests

安装

root@kitploit:~
# Clone or download the scanner
curl -O https://your-host/cve_2024_40725_scanner.py

# Make executable (optional)
chmod +x cve_2024_40725_scanner.py

使用方法

root@kitploit:~
python3 cve_2024_40725_scanner.py --target <URL> [OPTIONS]

选项


示例

root@kitploit:~
# Quickstart: scan localhost with built-in default paths
python3 cve_2024_40725_scanner.py --target http://localhost

# Scan specific paths
python3 cve_2024_40725_scanner.py \
  --target http://192.168.1.10 \
  --paths /index.php /admin/config.php /wp-config.php

# Use a wordlist file
python3 cve_2024_40725_scanner.py \
  --target http://192.168.1.10 \
  --wordlist php_paths.txt

# Combine wordlist + extra inline paths (merged, deduplicated)
python3 cve_2024_40725_scanner.py \
  --target http://192.168.1.10 \
  --wordlist php_paths.txt \
  --paths /extra/secret.php

# HTTPS with self-signed certificate
python3 cve_2024_40725_scanner.py \
  --target https://myserver.local \
  --no-verify-ssl

# Polite scan with 1 second delay and JSON report
python3 cve_2024_40725_scanner.py \
  --target http://myserver.local \
  --wordlist php_paths.txt \
  --delay 1.0 \
  --output results.json \
  --verbose

# CI/CD usage (exit code 1 = vulnerable, 0 = clean)
python3 cve_2024_40725_scanner.py --target http://localhost || echo "VULNERABLE"

字典文件格式

每行一个路径。以 # 开头的行被视为注释并跳过。空白行将被忽略。前导斜杠会自动规范化。

root@kitploit:~
# Common PHP entrypoints
/index.php
/info.php
/phpinfo.php

# Admin panels
/admin/index.php
/admin/config.php

# CMS files
/wp-config.php
/wp-login.php
/configuration.php

# API internals
/api/v1/status.php

工作原理

扫描器对每个路径运行两种探测:

探测 A — 直接文件请求

root@kitploit:~
GET /index.php HTTP/1.1

检查直接请求 PHP 文件是否会返回其原始源代码。在 AddType 配置错误、即使直接请求也会受影响的服务器上,此探测会命中。

探测 B — 子请求触发(实际的 CVE 路径)

root@kitploit:~
GET / HTTP/1.1

请求 父目录 而不是文件本身。Apache 在内部解析 DirectoryIndex → index.php,从而产生一个子请求。这正是 Apache 2.4.0–2.4.61 中 r->handler 被置为 NULL 的代码路径。

探测 B 是更重要、更切合实际的测试。许多服务器仅通过子请求路径易受攻击,而直接文件路径不受影响。

泄漏检测

扫描器检查响应体中是否存在 PHP 源代码特征:

  • <?php
  • <?PHP
  • <?=

当发现匹配时,它会提取泄漏位置附近 150 个字符的片段用于分析,而不会打印整个响应体。

服务器指纹识别

读取 Server: 响应头以检测 Apache 版本。即使在确认泄漏之前,也会标记报告版本为 2.4.0 或 2.4.61 的服务器。

注意:加固的服务器可能会隐藏 Server: 响应头(ServerTokens Prod)。扫描器仍会无条件运行所有探测。


输出

终端输出示例

root@kitploit:~
============================================================
  CVE-2024-40725 -- Apache Source Code Disclosure Scanner
============================================================
  Target : http://localhost
  Paths  : 6
  Time   : 2024-08-01T12:00:00

  [*] Fingerprinting server: http://localhost
      Server Header : Apache/2.4.61 (Debian)
      Apache Version: 2.4.61
      [!] Version is in vulnerable range (2.4.0 - 2.4.61)

  [*] Testing 6 path(s)...

  --- /index.php
      Direct  (HTTP 200): OK
      Subreq  (HTTP 200): LEAKED
      [!] VULNERABLE via: subrequest (directory index)
         Leaked snippet: '<?php\n$db_pass = "supersecretpassword";'

  --- /info.php
      Direct  (HTTP 404): OK
      Subreq  (HTTP 404): OK
      [+] Safe

============================================================
  SCAN SUMMARY
============================================================
  Target            : http://localhost
  Apache Version    : 2.4.61
  Paths Tested      : 6
  Vulnerable Paths  : 1
  Safe Paths        : 5

  [!] RESULT: VULNERABLE
      Vulnerable paths:
        * /index.php  (trigger: subrequest (directory index))

  Remediation:
    1. Upgrade to Apache httpd >= 2.4.62
    2. Replace 'AddType' with 'SetHandler' in <FilesMatch> blocks
============================================================

JSON 报告结构(--output results.json)

root@kitploit:~
{
  "target": "http://localhost",
  "scan_time": "2024-08-01T12:00:00",
  "apache_version": "2.4.61",
  "apache_in_range": true,
  "paths_tested": 6,
  "vulnerable_paths": [
    {
      "path": "/index.php",
      "direct_url": "http://localhost/index.php",
      "directory_url": "http://localhost/",
      "direct_status": 200,
      "direct_leaked": false,
      "direct_snippet": null,
      "directory_status": 200,
      "directory_leaked": true,
      "directory_snippet": "<?php\n$db_pass = \"supersecretpassword\";",
      "server_header": "Apache/2.4.61 (Debian)",
      "vulnerable": true,
      "trigger": "subrequest (directory index)"
    }
  ],
  "safe_paths": [...]
}

退出代码

代码含义
0未检测到易受攻击的路径
1发现一个或多个易受攻击的路径

退出代码使扫描器适用于 CI/CD 流水线和自动化基础设施审计。


修复措施

方案一:升级 Apache(推荐)

root@kitploit:~
# Debian / Ubuntu
sudo apt update && sudo apt install apache2

# RHEL / CentOS / AlmaLinux
sudo dnf update httpd

# Verify version (must be >= 2.4.62)
apache2 -v

方案二:将 AddType 替换为 SetHandler

替换所有用于 PHP 执行的 AddType 指令:

root@kitploit:~
# ❌ Vulnerable Configs
AddType application/x-httpd-php .php

# ✅ Safe Configs
<FilesMatch "\.php$">
    SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
</FilesMatch>

易受攻击与安全配置参考

root@kitploit:~
# VULNERABLE
<VirtualHost *:80>
    DocumentRoot /var/www/html
    AddType application/x-httpd-php .php     # ← triggers CVE
    DirectoryIndex index.php
</VirtualHost>

# SAFE
<VirtualHost *:80>
    DocumentRoot /var/www/html
    <FilesMatch "\.php$">
        SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
    </FilesMatch>
    DirectoryIndex index.php
</VirtualHost>

相关 CVE

CVE版本描述
CVE-2024-398842.4.0原始源代码泄露回归问题
下载工具
标志类型默认值描述
--targetURL(必需)要测试的 Apache 服务器的基础 URL
--pathsPATH [PATH ...]内置列表要直接探测的一个或多个 PHP 路径
--wordlistFILE—字典文件的路径(每行一个路径)
--no-directory-check标志关闭跳过子请求/目录索引探测(探测 B)
--timeoutint(秒)10每个请求的超时时间
--delayfloat(秒)0.0请求之间的延迟(速率限制)
--no-verify-ssl标志关闭禁用 SSL 证书验证
--outputFILE—将完整 JSON 报告写入此文件
--verbose标志关闭启用调试输出
CVE-2024-407252.4.61不完整的修复——同类缺陷
CVE-2024-408982.4.61mod_rewrite 中的独立 SSRF(仅限 Windows)