Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2024-40275_Scanner — Scanner for CVE-2024-40725 Apache HTTP Server source-code disclosure; probes direct and subrequest paths, fingerprints affected versions, and outputs JSON reports for CI/CD. | Kitploit
Tools/GitHubGitHub/burjoy/cve-2024-40275_scanner
Vulnerability ScannersWeb Vulnerability ScannersVulnerability AnalysisWeb SecurityMisconfiguration
GitHubburjoy/cve-2024-40275_scanner

CVE-2024-40275_Scanner

Scanner for CVE-2024-40725 Apache HTTP Server source-code disclosure; probes direct and subrequest paths, fingerprints affected versions, and outputs JSON reports for CI/CD.

View Repository
623 days agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2024-40725 Scanner

A Python-based detection tool for CVE-2024-40725, an Apache HTTP Server source code disclosure vulnerability affecting versions 2.4.0 and 2.4.61.

Legal notice: Only run this scanner against servers you own or have explicit written authorization to test. Unauthorized use may violate computer fraud laws (e.g., CFAA, Computer Misuse Act).


Background

CVE-2024-40725 is a regression in Apache's internal request pipeline introduced in version 2.4.0 (as an incomplete fix for CVE-2024-39884). When a server is configured using legacy AddType directives (e.g., AddType application/x-httpd-php .php), Apache's internal handler assignment is silently dropped during subrequest processing (triggered by DirectoryIndex, mod_rewrite, or mod_dir).

As a result, the PHP script interpreter is never invoked. Instead, Apache's built-in default-handler opens the file from disk and streams its raw bytes, including database credentials, API keys, and application logic directly to the client.

Affected versions: Apache httpd 2.4.0 – 2.4.61
Fixed in: Apache httpd 2.4.62+


Requirements

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

Installation

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

Usage

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

Options

FlagTypeDefaultDescription
--targetURL(required)Base URL of the Apache server to test
--pathsPATH [PATH ...]built-in listOne or more PHP paths to probe directly
--wordlistFILE—Path to a wordlist file (one path per line)
--no-directory-checkflagoffSkip subrequest/directory-index probe (Probe B)
--timeoutint (seconds)10Per-request timeout
--delayfloat (seconds)0.0Delay between requests (rate limiting)
--no-verify-sslflagoffDisable SSL certificate verification
--outputFILE—Write full JSON report to this file
--verboseflagoffEnable debug output

Examples

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"

Wordlist Format

One path per line. Lines starting with # are treated as comments and skipped. Blank lines are ignored. Leading slashes are normalized automatically.

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

How It Works

The scanner runs two probes per path:

Probe A — Direct File Request

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

Checks whether requesting the PHP file directly returns its raw source code. Affected in misconfigured servers where AddType is broken even for direct requests.

Probe B — Subrequest Trigger (the actual CVE path)

root@kitploit:~
GET / HTTP/1.1

Requests the parent directory instead of the file itself. Apache internally resolves DirectoryIndex → index.php, spawning a subrequest. This is the exact code path where r->handler is dropped to NULL in Apache 2.4.0–2.4.61.

Probe B is the more important and realistic test. Many servers are only vulnerable through the subrequest path, not the direct file path.

Leak Detection

The scanner checks the response body for PHP source code signatures:

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

When a match is found, it extracts a 150-character snippet around the leak location for triage without printing the entire response body.

Server Fingerprinting

Reads the Server: response header to detect the Apache version. Flags servers reporting version 2.4.0 or 2.4.61 even before a confirmed leak.

Note: Hardened servers may suppress the Server: header (ServerTokens Prod). The scanner still runs all probes regardless.


Output

Terminal output example

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 report structure (--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": [...]
}

Exit Codes

CodeMeaning
0No vulnerable paths detected
1One or more vulnerable paths found

Exit codes make the scanner suitable for use in CI/CD pipelines and automated infrastructure audits.


Remediation

Option 1: Upgrade Apache (Recommended)

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

Option 2: Replace AddType with SetHandler

Replace any AddType directives used for PHP execution:

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>

Vulnerable vs. Safe Configuration Reference

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>

Related CVEs

CVEVersionDescription
CVE-2024-398842.4.0Original source disclosure regression
CVE-2024-407252.4.61Incomplete fix — same class of bug
CVE-2024-408982.4.61Separate SSRF in mod_rewrite (Windows only)
Download Tool