phux Download Manager — 1 vulnerability check

noctis ships 1 vulnerability check for phux Download Manager, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

phux Download Manager download.php file SQL Injection

CVECVE-2012-0980
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/phux-download-manager/CVE-2012-0980.yaml

phux Download Manager 0.1 and earlier pass the `file` parameter of download.php to the database without sanitising it, allowing unauthenticated SQL injection. A query that fails makes PHP print a mysql_num_rows() warning.

This check first recognises the application from its index page, then sends a random value followed by a quote and confirms the mysql_num_rows() warning appears while the same request without the quote does not. It then proves the injection with three boolean 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

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{pdir}}/index.php
  3. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}
  4. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%27
  5. Parses / computes the next value with a Rhai script
  6. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad1…
  7. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.sum}…
  8. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%27%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad2…
  9. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad1}},…
  10. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.sum}},1…
  11. HTTP(S) request GET {{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad2}},…
  12. Parses / computes the next value with a Rhai script
  13. Checks bp.found for ^BOOL$ → finding QoD 97: phux Download Manager download.php file SQL Injection (CVE-2012-0980)
  14. Checks qm.found for ^QUOTE$ → finding QoD 75: phux Download Manager download.php file SQL Injection (CVE-2012-0980)

References:

Feed source — tests/vulnerabilities/phux-download-manager/CVE-2012-0980.yaml
# phux Download Manager <= 0.1 — download.php `file` SQL injection (CVE-2012-0980)
#
# download.php passes the `file` parameter to a database query without
# sanitising it (Red Security TEAM, EDB-18432, BID 51725: "download.php?file=
# [BlindSQLi]"). With a failing query the page shows PHP's
# "mysql_num_rows(): supplied argument is not a valid MySQL result resource".
# The product source (phux-download_manager_v0.1.zip) is no longer reachable, so
# the quoting context of `file` is not known: both a string context
# (`file='<v>'`) and a numeric one (`file=<v>`) are tried.
#
# The product is recognised first, as the source check does: the index page of
# the install dir must carry ">phux.org's<" and "Public Download Center<".
#   1. QoD 97 — boolean proof computed by the database: `AND 1=IF(A+B=S,1,
#      (SELECT 1 UNION SELECT 2))` sent with S wrong, right, wrong (random A/B).
#      A wrong sum selects the two-row subquery, the query fails and PHP prints
#      the mysql_num_rows warning; the right sum is valid SQL and does not.
#   2. QoD 75 — the source check's quote probe, made specific: `file=<n>'` must
#      print the warning while the control `file=<n>` does not (a page that
#      always prints it stays clean).
# Read-only: nothing is written and no data is extracted. Beyond the source
# check this adds the control request and the computed proof.
#
# Source: OpenVAS/Greenbone NASL 2012/gb_phux_download_manager_sql_inj_vuln.nasl
#   (OID 1.3.6.1.4.1.25623.1.0.802586, GPL-2.0-only)
uid: 0cd5bec8-79c0-41a7-89a1-998922f548da
name: "phux Download Manager download.php file SQL Injection (CVE-2012-0980)"
description: |
  phux Download Manager 0.1 and earlier pass the `file` parameter of download.php
  to the database without sanitising it, allowing unauthenticated SQL injection.
  A query that fails makes PHP print a mysql_num_rows() warning.

  This check first recognises the application from its index page, then sends a
  random value followed by a quote and confirms the mysql_num_rows() warning
  appears while the same request without the quote does not. It then proves the
  injection with three boolean 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-2012-0980]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [phux, download-manager, sqli, boolean-based, error-based]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-0980"
  - "https://www.exploit-db.com/exploits/18432"
  - "https://www.securityfocus.com/bid/51725"

steps:
  - id: gen-operands
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ n: rand_int(10000, 99999), a: a, b: b, sum: a + b,
         bad1: a + b + rand_int(1, 9), bad2: a + b - rand_int(1, 9) }
    store_as: sc

  # Pre-initialise every stored result a script reads (a failed request leaves
  # store_as unset and an undefined var would abort the test).
  - id: init-idx_resp
    action: set_var
    var_name: idx_resp
    var_value: {status: 0, body: null}
    loop:
      over: ["", "/download_manager", "/phux"]
      var: pdir

  - id: init-ctl_resp
    action: set_var
    var_name: ctl_resp
    var_value: {status: 0, body: null}

  - id: init-qm_resp
    action: set_var
    var_name: qm_resp
    var_value: {status: 0, body: null}

  - id: init-qf1_resp
    action: set_var
    var_name: qf1_resp
    var_value: {status: 0, body: null}

  - id: init-qt_resp
    action: set_var
    var_name: qt_resp
    var_value: {status: 0, body: null}

  - id: init-qf2_resp
    action: set_var
    var_name: qf2_resp
    var_value: {status: 0, body: null}

  - id: init-uf1_resp
    action: set_var
    var_name: uf1_resp
    var_value: {status: 0, body: null}

  - id: init-ut_resp
    action: set_var
    var_name: ut_resp
    var_value: {status: 0, body: null}

  - id: init-uf2_resp
    action: set_var
    var_name: uf2_resp
    var_value: {status: 0, body: null}


  # ── Product gate, per candidate install dir (loop group) ──────────────────
  - id: idx-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/index.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: idx_resp

  - id: ctl-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{sc.n}}"
    condition: "idx_resp.status == 200 && type_of(idx_resp.body) == \"string\" && stridx(idx_resp.body, \">phux.org's<\") >= 0 && stridx(idx_resp.body, \"Public Download Center<\") >= 0"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: ctl_resp

  - id: qm-probe
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{sc.n}}%27"
    condition: "ctl_resp.status > 0"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: qm_resp

  - id: check-qm
    action: script
    code: |
      let e = "mysql_num_rows\\(\\): supplied argument is not a valid MySQL";
      let cb = if type_of(ctl_resp.body) == "string" { ctl_resp.body } else { "" };
      let qb = if type_of(qm_resp.body) == "string" { qm_resp.body } else { "" };
      let hit = ctl_resp.status > 0 && qm_resp.status > 0 && !ereg(e, cb, true) && ereg(e, qb, true);
      #{ hit: hit, found: if hit { "QUOTE" } else { "" } }
    store_as: qm

  # ── Boolean proof, string context (q) and numeric context (u) ─────────────
  - id: qf1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{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: qf1_resp

  - id: qt
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{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: qt_resp

  - id: qf2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{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: qf2_resp

  - id: uf1
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad1}},1,(SELECT%201%20UNION%20SELECT%202))"
    condition: "qm.hit"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: uf1_resp

  - id: ut
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.sum}},1,(SELECT%201%20UNION%20SELECT%202))"
    condition: "qm.hit"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: ut_resp

  - id: uf2
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{pdir}}/download.php?file={{sc.n}}%20AND%201%3DIF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad2}},1,(SELECT%201%20UNION%20SELECT%202))"
    condition: "qm.hit"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: uf2_resp

  - id: check-bool
    action: script
    code: |
      let e = "mysql_num_rows\\(\\): supplied argument is not a valid MySQL";
      let qf1 = if type_of(qf1_resp.body) == "string" { qf1_resp.body } else { "" };
      let qt = if type_of(qt_resp.body) == "string" { qt_resp.body } else { "" };
      let qf2 = if type_of(qf2_resp.body) == "string" { qf2_resp.body } else { "" };
      let uf1 = if type_of(uf1_resp.body) == "string" { uf1_resp.body } else { "" };
      let ut = if type_of(ut_resp.body) == "string" { ut_resp.body } else { "" };
      let uf2 = if type_of(uf2_resp.body) == "string" { uf2_resp.body } else { "" };
      let qok = qt_resp.status > 0 && ereg(e, qf1, true) && !ereg(e, qt, true) && ereg(e, qf2, true);
      let uok = ut_resp.status > 0 && ereg(e, uf1, true) && !ereg(e, ut, true) && ereg(e, uf2, true);
      let ok = qm.hit && (qok || uok);
      #{ ok: ok, ctx: if qok { "string" } else if uok { "numeric" } else { "" }, 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: "phux Download Manager download.php file SQL Injection (CVE-2012-0980)"
        confidence_delta: 0.65
        qod: 97
        evidence: "Boolean SQLi confirmed on {{pdir}}/download.php ({{bp.ctx}} context): file={{sc.n}} with an AND 1=IF({{sc.a}}+{{sc.b}}=S,1,(SELECT 1 UNION SELECT 2)) made the query fail (mysql_num_rows warning) for S={{sc.bad1}} and S={{sc.bad2}} but not for the correct sum S={{sc.sum}}"
      stop: true

  - id: report-qm
    action: match
    source: qm.found
    pattern: "^QUOTE$"
    condition: "qm.hit"
    on_match:
      finding:
        title: "phux Download Manager download.php file SQL Injection (CVE-2012-0980)"
        confidence_delta: 0.50
        qod: 75
        evidence: "SQL injection: file={{sc.n}}' on {{pdir}}/download.php printed the mysql_num_rows() warning (HTTP {{qm_resp.status}}), while the control file={{sc.n}} did not (HTTP {{ctl_resp.status}})"
      stop: true

View these feeds on GitHub