PhotoPost — 2 vulnerability checks
noctis ships 2 vulnerability checks for PhotoPost, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
PhotoPost PHP showgallery.php cat / ppuser SQL injection
| CVE | CVE-2005-0273 |
|---|---|
| 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/photopost/CVE-2005-0273.yaml |
PhotoPost PHP before 4.86 places the cat and ppuser parameters of showgallery.php into its MySQL queries without escaping them, so a remote, unauthenticated attacker can run arbitrary SQL against the gallery database.
For the web root, /photopost, /photos, /gallery and /pp, and for each of the two parameters, this check sends an EXTRACTVALUE expression built from two random numbers. The injection is confirmed when the database error returned by the page carries the product of those numbers, which only the database can have computed. On older MySQL servers without EXTRACTVALUE, it falls back to a stray quote followed by a random word: the flaw is reported when the MySQL syntax error quotes that word while a plain numeric value causes no SQL error. Both proofs also require a PhotoPost signal in the reply (its error page, its category query or its "Powered by: PhotoPost" footer). The requests only make the query fail; nothing is read or written.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%20AND%20extractvalue(1,concat(0x7e,{{sc.a}… - HTTP(S) request
GET {{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%27%20AND%20extractvalue(1,concat(0x7e,{{sc… - Parses / computes the next value with a Rhai script
- Checks
xvforXPATH syntax error carrying ~[0-9]+→ finding QoD 97: PhotoPost PHP showgallery.php SQL injection (CVE-2005-0273) - HTTP(S) request
GET {{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%27{{sc.tok}} - HTTP(S) request
GET {{v.d}}/showgallery.php?{{v.pre}}{{v.p}}={{sc.ctl}} - Parses / computes the next value with a Rhai script
- Checks
fallbackforMySQL syntax error quoting the injected marker→ finding QoD 75: PhotoPost PHP showgallery.php SQL injection (CVE-2005-0273)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-0273
- http://www.gulftech.org/?node=research&article_id=00063-01032005
- http://www.securityfocus.com/bid/12156
- http://marc.info/?l=bugtraq&m=110486165802196&w=2
Feed source — tests/vulnerabilities/photopost/CVE-2005-0273.yaml
# PhotoPost PHP — showgallery.php cat / ppuser SQL injection (CVE-2005-0273).
#
# PhotoPost PHP (All Enthusiast, commercial PHP + MySQL) before 4.86 splices
# the cat and ppuser parameters of showgallery.php into its MySQL queries
# unescaped (GulfTech advisory 2005-01-03, BID 12156):
# showgallery.php?cat=[INT][SQL] (unquoted, numeric context)
# showgallery.php?ppuser=[INT][SQL]&cat=[INT] (inside quotes — the advisory's
# PoC: ppuser=-2' UNION SELECT …)
# On a failed query the page prints "MySQL error reported!" with the script
# name, the raw query (SELECT id,catname,description,photos,… for cat) and the
# MySQL error. The product source was never published; the vectors follow the
# advisory and the column list quoted by the reference check.
#
# Detection, read-only, for the web root, /photopost, /photos, /gallery and
# /pp × the two parameters:
# 1. QoD 97 — value = 1 AND extractvalue(1,concat(0x7e,A*B)) (numeric
# context) then 1' AND extractvalue(1,concat(0x7e,A*B)) AND '1'='1
# (quoted context; each is harmless in the other one). A, B: random
# 6-digit numbers. MySQL >= 5.1 evaluates the constant expression while
# preparing the query and fails with "XPATH syntax error: '~<A*B>'": the
# product never appears in the request, so only the database can have
# computed it. No row is read or written.
# 2. QoD 75 fallback (MySQL < 5.1 has no EXTRACTVALUE) — value =
# 1'NOCTIS<rand> (the reference check's stray quote): the MySQL syntax
# error quotes the random word, while a control value made of digits only
# shows no SQL error. Reported only when no directory / parameter gave the
# stage 1 proof.
# Both stages require a PhotoPost signal in the reply (the echoed
# "catname,description,photos" column list, PhotoPost's "MySQL error
# reported!" error page or its "Powered by: PhotoPost" footer), so another
# gallery's SQL injection on the same file name is not reported as this CVE.
#
# The XSS half of the advisory (CVE-2005-0274) is covered by
# photopost/CVE-2005-0274.yaml.
#
# Reference: OpenVAS/Greenbone NVT `pre2008/photopost_sql_injection.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.16101, GPL-2.0-only) — sends cat=1' only and
# matches "SELECT id,catname,description,photos". This feed adds the ppuser
# vector and the install dirs, replaces the stray quote with a computed (QoD
# 97) proof, and adds a random marker plus a control request to the fallback.
# CVSS: NVD carries only a CVSS v2 score (7.5).
uid: 1afe0303-4b20-4f11-a9c4-201e0bc91d97
name: "PhotoPost PHP showgallery.php cat / ppuser SQL injection (CVE-2005-0273)"
description: |
PhotoPost PHP before 4.86 places the cat and ppuser parameters of
showgallery.php into its MySQL queries without escaping them, so a remote,
unauthenticated attacker can run arbitrary SQL against the gallery database.
For the web root, /photopost, /photos, /gallery and /pp, and for each of the
two parameters, this check sends an EXTRACTVALUE expression built from two
random numbers. The injection is confirmed when the database error returned
by the page carries the product of those numbers, which only the database
can have computed. On older MySQL servers without EXTRACTVALUE, it falls
back to a stray quote followed by a random word: the flaw is reported when
the MySQL syntax error quotes that word while a plain numeric value causes
no SQL error. Both proofs also require a PhotoPost signal in the reply (its
error page, its category query or its "Powered by: PhotoPost" footer). The
requests only make the query fail; nothing is read or written.
cves: [CVE-2005-0273]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [photopost, php, mysql, sqli]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-0273"
- "http://www.gulftech.org/?node=research&article_id=00063-01032005"
- "http://www.securityfocus.com/bid/12156"
- "http://marc.info/?l=bugtraq&m=110486165802196&w=2"
steps:
# ── Random operands and markers (shared by every pass) ────────────────────
- id: gen
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{ a: a, b: b, prod: "~" + (a * b),
tok: "NOCTIS" + rand_int(10000000, 99999999) + "Q",
ctl: "" + rand_int(10000000, 99999999) }
store_as: sc
- id: init-fallback
action: set_var
var_name: fallback
var_value: ""
# ── Per install dir × parameter (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-xvn
action: set_var
var_name: xvn
var_value: {status: 0, body: ""}
loop:
var: v
over:
- {d: "", p: "cat", pre: ""}
- {d: "", p: "ppuser", pre: "cat=500&"}
- {d: "/photopost", p: "cat", pre: ""}
- {d: "/photopost", p: "ppuser", pre: "cat=500&"}
- {d: "/photos", p: "cat", pre: ""}
- {d: "/photos", p: "ppuser", pre: "cat=500&"}
- {d: "/gallery", p: "cat", pre: ""}
- {d: "/gallery", p: "ppuser", pre: "cat=500&"}
- {d: "/pp", p: "cat", pre: ""}
- {d: "/pp", p: "ppuser", pre: "cat=500&"}
- id: init-xvq
action: set_var
var_name: xvq
var_value: {status: 0, body: ""}
- id: init-qm
action: set_var
var_name: qm
var_value: {status: 0, body: ""}
- id: init-ctl
action: set_var
var_name: ctl
var_value: {status: 0, body: ""}
# Stage 1: EXTRACTVALUE error carrying the database-computed product —
# numeric context first …
- id: xv-numeric
action: http_request
method: GET
port: "{{port}}"
path: "{{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: xvn
# … then quoted (skipped when the script is absent from this dir).
- id: xv-quoted
action: http_request
method: GET
port: "{{port}}"
path: "{{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%27%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))%20AND%20%271%27=%271"
condition: "xvn.status != 0 && xvn.status != 404"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: xvq
- id: check-xv
action: script
code: |
let bn = if type_of(xvn.body) == "string" { xvn.body } else { "" };
let bq = if type_of(xvq.body) == "string" { xvq.body } else { "" };
let re = "XPATH syntax error: (?:'|�?39;|'|')?" + sc.prod + "(?:[^0-9]|$)";
// PhotoPost only: its error page, echoed category query or branding.
let pre = "(?i)powered by:?\\s*(?:<[^>]*>\\s*)*photopost|\\bcatname,\\s*description,\\s*photos\\b|MySQL error reported!";
let hn = ereg(re, bn) && ereg(pre, bn);
let hq = !hn && ereg(re, bq) && ereg(pre, bq);
if hn {
v.d + "/showgallery.php?" + v.pre + v.p + "=1 AND extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + ")): XPATH syntax error carrying " + sc.prod + " (HTTP " + xvn.status + ")"
} else if hq {
v.d + "/showgallery.php?" + v.pre + v.p + "=1' AND extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + ")) AND '1'='1: XPATH syntax error carrying " + sc.prod + " (HTTP " + xvq.status + ")"
} else { "" }
store_as: xv
- id: report-xv
action: match
source: xv
pattern: "XPATH syntax error carrying ~[0-9]+"
condition: 'xv != ""'
on_match:
finding:
title: "PhotoPost PHP showgallery.php SQL injection (CVE-2005-0273)"
description: "PhotoPost PHP ran an SQL expression injected through the cat or ppuser parameter of showgallery.php: the database error returned by the page carries the product of two random numbers chosen by the scanner, which never appear in the request. An unauthenticated attacker can run arbitrary SQL against the gallery database (for example read member e-mail addresses and password hashes)."
remediation: "Upgrade PhotoPost PHP to 4.86 or later. If you maintain the code, cast cat and ppuser to integers before building the queries, and do not print database errors to visitors."
confidence_delta: 0.65
qod: 97
evidence: "Error-based SQLi confirmed: {{xv}}"
stop: true
# Stage 2 (MySQL < 5.1): syntax error quoting a random marker + control.
- id: qm-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{v.d}}/showgallery.php?{{v.pre}}{{v.p}}=1%27{{sc.tok}}"
condition: 'fallback == "" && xvn.status != 0 && xvn.status != 404'
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: qm
- id: ctl-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{v.d}}/showgallery.php?{{v.pre}}{{v.p}}={{sc.ctl}}"
condition: 'fallback == "" && qm.status != 0'
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: ctl
# The marker must follow the MySQL parser message ("near '…", quotes may be
# HTML-escaped), the reply must carry a PhotoPost signal, and the control
# must show no SQL error. Keeps the first candidate only.
- id: check-qm
action: script
code: |
if fallback != "" { fallback } else {
let b = if type_of(qm.body) == "string" { qm.body } else { "" };
let cb = if type_of(ctl.body) == "string" { ctl.body } else { "" };
let q = "(?:'|�?39;|'|')";
let isp = ereg("(?i)powered by:?\\s*(?:<[^>]*>\\s*)*photopost|\\bcatname,\\s*description,\\s*photos\\b|MySQL error reported!", b);
let syn = isp && ereg("(?i)error in your SQL syntax[^\\n]{0,200}near " + q + "{1,2}[^\\n]{0,8}" + sc.tok, b);
let cerr = ereg("(?i)error in your SQL syntax|XPATH syntax error|MySQL error", cb);
if ctl.status != 0 && syn && !cerr {
v.d + "/showgallery.php?" + v.pre + v.p + "=1'" + sc.tok + ": MySQL syntax error quoting the injected marker (HTTP " + qm.status + "), control " + v.p + "=" + sc.ctl + " without SQL error (HTTP " + ctl.status + ")"
} else { "" }
}
store_as: fallback
# ── Fallback report (no stage 1 proof in any dir / parameter) ─────────────
- id: once
action: set_var
var_name: done
var_value: true
loop:
var: o
over: ["once"]
- id: report-qm
action: match
source: fallback
pattern: "MySQL syntax error quoting the injected marker"
condition: 'fallback != ""'
on_match:
finding:
title: "PhotoPost PHP showgallery.php SQL injection (CVE-2005-0273)"
description: "A single quote sent in the cat or ppuser parameter of showgallery.php broke PhotoPost's SQL query: the MySQL syntax error quotes the random text that followed it, while a plain numeric value caused no SQL error. The parameter reaches the query unescaped, so an unauthenticated attacker can run arbitrary SQL against the gallery database."
remediation: "Upgrade PhotoPost PHP to 4.86 or later. If you maintain the code, cast cat and ppuser to integers before building the queries, and do not print database errors to visitors."
confidence_delta: 0.50
qod: 75
evidence: "Error-based SQLi: {{fallback}}"
stop: truePhotoPost PHP showgallery.php reflected cross-site scripting
| CVE | CVE-2005-0274 |
|---|---|
| Severity | medium · CVSS 4.3 |
| Category | xss — XSS |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/photopost/CVE-2005-0274.yaml |
PhotoPost PHP before 4.86 prints the si, page and cat parameters of showgallery.php back into the page without escaping them, so an attacker can send a gallery visitor a link that runs script in the site's origin.
For the web root, /photopost, /photos, /gallery and /pp, this check sends each of these parameters a value that closes an HTML attribute and opens an element named after a random marker. The flaw is reported when the page returns that element unescaped, the reply is a PhotoPost page (its footer, error page or category query), and the same request sent to an absent script in the same folder does not reflect it. Nothing is stored on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/showgallery.php?{{v.q}}%22%3E%3C{{sc.marker}}%3E - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/{{sc.marker}}.php?{{v.q}}%22%3E%3C{{sc.marker}}%3E - Parses / computes the next value with a Rhai script
- Checks
hitfor^reflected$→ finding QoD 75: PhotoPost PHP showgallery.php reflected cross-site scripting (CVE-2005-0274)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-0274
- http://www.gulftech.org/?node=research&article_id=00063-01032005
- http://www.securityfocus.com/bid/12156
Feed source — tests/vulnerabilities/photopost/CVE-2005-0274.yaml
# PhotoPost PHP — showgallery.php si / page / cat reflected XSS (CVE-2005-0274).
#
# PhotoPost PHP (All Enthusiast, commercial PHP + MySQL) before 4.86 prints
# several showgallery.php parameters back into the page without escaping them
# (GulfTech advisory 2005-01-03, BID 12156):
# showgallery.php?si=[XSS]
# showgallery.php?cat=[INT]&page=[XSS]
# showgallery.php?cat=[INT][XSS] (the failed query is printed raw on
# PhotoPost's "MySQL error reported!" page)
# The product source was never published; the vectors follow the advisory.
#
# Detection, for the web root, /photopost, /photos, /gallery and /pp × the
# three vectors: the value is "><noctis…> (an attribute break-out followed by
# an element named after a random marker). The flaw is reported when the reply
# carries that element unescaped together with a PhotoPost signal (footer,
# error page or echoed category query), and the same payload sent to an absent
# script of the same folder is not reflected (catch-all pages echoing the URL).
# Nothing is stored on the target.
#
# The SQL injection half of the advisory (CVE-2005-0273) is covered by
# photopost/CVE-2005-0273.yaml.
#
# Reference: the advisory and OpenVAS/Greenbone NVT
# `pre2008/photopost_sql_injection.nasl` (OID 1.3.6.1.4.1.25623.1.0.16101,
# GPL-2.0-only), which lists this CVE but only tests the SQL injection.
# CVSS: NVD carries only a CVSS v2 score (4.3).
uid: 57010563-cdf6-4d01-9481-c5e12b154014
name: "PhotoPost PHP showgallery.php reflected cross-site scripting (CVE-2005-0274)"
description: |
PhotoPost PHP before 4.86 prints the si, page and cat parameters of
showgallery.php back into the page without escaping them, so an attacker can
send a gallery visitor a link that runs script in the site's origin.
For the web root, /photopost, /photos, /gallery and /pp, this check sends
each of these parameters a value that closes an HTML attribute and opens an
element named after a random marker. The flaw is reported when the page
returns that element unescaped, the reply is a PhotoPost page (its footer,
error page or category query), and the same request sent to an absent script
in the same folder does not reflect it. Nothing is stored on the target.
cves: [CVE-2005-0274]
cvss: 4.3
severity: medium
category: xss
confidence_base: 0.30
tags: [photopost, php, xss]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-0274"
- "http://www.gulftech.org/?node=research&article_id=00063-01032005"
- "http://www.securityfocus.com/bid/12156"
steps:
# ── Random marker and the exact element to look for ──────────────────────
- id: gen-marker
action: script
code: |
let m = "noctis" + oob_token.sub_string(0, 8) + oob_token.sub_string(9, 4);
#{ marker: m, want: "<" + m + ">" }
store_as: sc
# ── Loop group: every following step runs once per folder × vector ───────
- id: init-probe-r
action: set_var
var_name: probe_r
var_value: {status: 0, body: ""}
loop:
var: v
over:
- {d: "", q: "si="}
- {d: "", q: "cat=1&page="}
- {d: "", q: "cat=1"}
- {d: "/photopost", q: "si="}
- {d: "/photopost", q: "cat=1&page="}
- {d: "/photopost", q: "cat=1"}
- {d: "/photos", q: "si="}
- {d: "/photos", q: "cat=1&page="}
- {d: "/photos", q: "cat=1"}
- {d: "/gallery", q: "si="}
- {d: "/gallery", q: "cat=1&page="}
- {d: "/gallery", q: "cat=1"}
- {d: "/pp", q: "si="}
- {d: "/pp", q: "cat=1&page="}
- {d: "/pp", q: "cat=1"}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-clean
action: set_var
var_name: ctrl_clean
var_value: false
- id: init-hit
action: set_var
var_name: hit
var_value: ""
- id: probe
action: http_request
method: GET
path: "{{v.d}}/showgallery.php?{{v.q}}%22%3E%3C{{sc.marker}}%3E"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: probe_r
# Raw element + PhotoPost page (footer, error page or category query).
- id: check
action: script
code: |
let body = if type_of(probe_r.body) == "string" { probe_r.body } else { "" };
let isp = ereg("(?i)powered by:?\\s*(?:<[^>]*>\\s*)*photopost|\\bcatname,\\s*description,\\s*photos\\b|MySQL error reported!", body);
if probe_r.status >= 200 && probe_r.status < 400 && body.contains(sc.want) && isp { "reflected" } else { "" }
store_as: hit
# ── Control: the same payload to a random, absent .php script ───────────
- id: control
action: http_request
method: GET
path: "{{v.d}}/{{sc.marker}}.php?{{v.q}}%22%3E%3C{{sc.marker}}%3E"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'hit != ""'
store_as: ctrl_r
- id: control-check
action: script
condition: 'hit != ""'
code: |
let body = if type_of(ctrl_r.body) == "string" { ctrl_r.body } else { "" };
ctrl_r.status != 0 && !body.contains(sc.want)
store_as: ctrl_clean
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: hit
pattern: "^reflected$"
condition: "ctrl_clean == true"
on_match:
finding:
title: "PhotoPost PHP showgallery.php reflected cross-site scripting (CVE-2005-0274)"
description: "An unauthenticated request to PhotoPost's showgallery.php with a parameter set to an attribute break-out followed by an element named after a random marker returned that element unescaped in the page, while an absent script in the same folder did not reflect it. An attacker can send a gallery visitor a link that runs any script in the site's origin, for example to steal the session cookie."
remediation: "Upgrade PhotoPost PHP to 4.86 or later. If you maintain the code, HTML-escape si and page before printing them, cast cat to an integer, and do not print failed SQL queries to visitors."
confidence_delta: 0.50
qod: 75
evidence: "{{v.d}}/showgallery.php?{{v.q}}\"><{{sc.marker}}> was reflected unescaped ({{sc.want}}) on a PhotoPost page; the same payload sent to an absent script ({{v.d}}/{{sc.marker}}.php) was not"
stop: true