Microsoft RDP (BlueKeep) — 1 vulnerability check
noctis ships 1 vulnerability check for Microsoft RDP (BlueKeep), covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Microsoft Remote Desktop BlueKeep pre-auth RCE
| CVE | CVE-2019-0708 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | rdp, ms-wbt-server |
| Ports | 3389 |
| Detection | script, tcp_open, tcp_send, tcp_starttls, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/bluekeep/CVE-2019-0708.yaml |
Opens an RDP session the way a client does, without logging in: X.224 negotiation (TLS first, Standard RDP Security with RC4 session keys when the host refuses TLS or its TLS handshake fails), MCS connection with a static virtual channel named "MS_T120", channel joins, client info, licensing and the activation sequence. After short Virtual Channel PDUs sent on another static channel (snddbg) leave the session up, it sends the same PDUs on the MS_T120 channel. A vulnerable host binds that channel to its internal MS_T120 handler and answers by tearing the session down with an MCS Disconnect Provider Ultimatum; a patched host keeps the session. That reply is the finding. Hosts that require Network Level Authentication are not reported. The check uses the non-crashing payload sizes; no code is executed on the target.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Upgrades the open socket to TLS (STARTTLS)
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Sends a binary frame on the open socket
- Parses / computes the next value with a Rhai script
- Sends a binary frame on the open socket
- … and 14 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-0708
- https://msrc.microsoft.com/update-guide/vulnerability/CVE-2019-0708
- https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/rdp/cve_2019_0708_bluekeep.rb
- https://github.com/robertdavidgraham/rdpscan
- https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/
Feed source — tests/vulnerabilities/bluekeep/CVE-2019-0708.yaml
# Microsoft Remote Desktop "BlueKeep" pre-authentication RCE (CVE-2019-0708).
#
# Non-crashing check, same logic as the Metasploit scanner
# auxiliary/scanner/rdp/cve_2019_0708_bluekeep and rdpscan: a client that lists a
# static virtual channel named "MS_T120" gets it bound, on an unpatched host, to
# the server's internal MS_T120 channel. Data of a valid "disconnect" size sent on
# that channel makes the unpatched server tear the internal channel down and drop
# the client with an MCS Disconnect Provider Ultimatum (TPKT 03 00 00 09 02 f0 80
# 21 80). A patched host never binds the client's MS_T120 and keeps the session.
#
# Flow (one TCP connection, two when the host refuses TLS):
# 1. X.224 Connection Request asking for TLS (PROTOCOL_SSL). An NLA-only host
# answers HYBRID_REQUIRED_BY_SERVER: CredSSP mitigates the bug pre-auth, no
# finding. A host that refuses TLS (SSL_NOT_ALLOWED_BY_SERVER) or does not
# know the negotiation at all (Windows XP / 2003 RTM: Connection Confirm
# without RDP_NEG_RSP) is reconnected with Standard RDP Security (PROTOCOL_RDP),
# and so is a host whose TLS handshake fails: tcp_starttls speaks TLS 1.2+
# while Windows 7 / 2008 R2 / 2003 SP1 offer TLS 1.0 out of the box.
# 2. TLS: tcp_starttls on the socket, nothing else encrypted. Standard RDP
# Security: the server's proprietary certificate (RSA modulus + exponent)
# and server random are read from the MCS Connect Response, a random client
# random is RSA-encrypted (rsa_public_le_hex) in the Security Exchange PDU,
# and every later PDU is RC4-encrypted and MAC-signed with the session keys
# derived per MS-RDPBCGR 5.3.5 (40/56/128-bit). Not supported, as in the
# Metasploit check: FIPS encryption level and X.509 server certificate
# chains (no finding, never a false one).
# 3. MCS Connect Initial with the channels cliprdr, MS_T120, rdpsnd, snddbg,
# rdpdr; the MS_T120 channel ID is read from the server network data.
# Erect Domain, Attach User, Channel Joins, Client Info, licensing (a new
# license request when the server asks for one), Confirm Active,
# Synchronize, Control, Input Synchronize, Font List — the activation
# sequence the Metasploit check sends.
# 4. Control: one more Input Synchronize event, then the check payloads on the
# snddbg channel, read for 6 s; the session must still be up (no
# Disconnect Provider Ultimatum so far), so a server that drops us for
# another reason (licensing, capability mismatch, any channel data) is not
# reported. The MS_T120 and snddbg joins must both have been confirmed.
# 5. Up to three rounds of Virtual Channel PDUs on MS_T120, the x86 (16-byte)
# and x64 (32-byte) payloads Metasploit proved safe. Only an Ultimatum
# after these, and not before, is the finding.
#
# Issue #2387: the previous version matched the text "BlueKeep-Vulnerable" in an
# unsolicited greeting. RDP servers send nothing before the client speaks and no
# server sends that text: it existed only in the mock (false negative on every
# real host). Handshake validated against a real xrdp 0.9.24 (TLS and Standard
# RDP Security at high/medium/low encryption): full session, no Ultimatum.
uid: e8b3c742-5f1a-4d90-a261-7c9f0e3b5d68
name: "Microsoft Remote Desktop BlueKeep pre-auth RCE (CVE-2019-0708)"
description: |
Opens an RDP session the way a client does, without logging in: X.224
negotiation (TLS first, Standard RDP Security with RC4 session keys when the
host refuses TLS or its TLS handshake fails), MCS connection with a static
virtual channel named "MS_T120", channel joins, client info, licensing and
the activation sequence. After short Virtual Channel PDUs sent on another
static channel (snddbg) leave the session up, it sends the same PDUs on the
MS_T120 channel. A vulnerable host binds that channel to its internal
MS_T120 handler and answers by tearing the session down with an MCS
Disconnect Provider Ultimatum; a patched host keeps the session. That reply
is the finding. Hosts that require Network Level Authentication are not
reported. The check uses the non-crashing payload sizes; no code is executed
on the target.
cves: [CVE-2019-0708]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [rdp, pre-auth, rce, kev, bluekeep, windows, ms-t120]
services: [rdp, ms-wbt-server]
ports: [3389]
author: noctis
version: "2.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-0708"
- "https://msrc.microsoft.com/update-guide/vulnerability/CVE-2019-0708"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/rdp/cve_2019_0708_bluekeep.rb"
- "https://github.com/robertdavidgraham/rdpscan"
- "https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/"
steps:
# Stored results read by later conditions (an undefined variable aborts).
- id: init
action: script
store_as: st
code: |
#{ mode: "", ok: false, alive: false, hit: false, round: 0 }
# ── 1. X.224 negotiation, TLS first ─────────────────────────────────────────
- id: open
action: tcp_open
handle: rdp
port: "{{port}}"
tls: false
timeout_secs: 10
store_as: conn
- id: cr-tls
action: tcp_send
handle: rdp
condition: "conn.connected == true"
send_hex: "0300002c27e00000000000436f6f6b69653a206d737473686173683d6e6f637469730d0a0100080001000000"
timeout_secs: 10
store_as: neg1
# mode: "tls" | "rdp" (reconnect with Standard RDP Security) | "nla" | "".
- id: parse-neg1
action: script
condition: "conn.connected == true"
store_as: n1
code: |
let mode = "";
let h = "";
if neg1.responded == true && type_of(neg1.response_hex) == "string" { h = tolower(neg1.response_hex); }
if strlen(h) >= 14 && substr(h, 0, 3) == "0300" && substr(h, 10, 11) == "d0" {
if strlen(h) >= 38 && substr(h, 22, 23) == "02" {
let sel = u32le(substr(h, 30, 37));
if sel == 1 { mode = "tls"; } else if sel == 0 { mode = "rdp"; }
} else if strlen(h) >= 38 && substr(h, 22, 23) == "03" {
let code = u32le(substr(h, 30, 37));
if code == 5 || code == 6 { mode = "nla"; } else if code == 2 || code == 3 { mode = "rdp"; }
} else if strlen(h) < 38 {
mode = "rdp";
}
}
#{ mode: mode, reply: h }
- id: starttls
action: tcp_starttls
handle: rdp
condition: 'n1.mode == "tls"'
timeout_secs: 10
store_as: tls
# Fallback to Standard RDP Security also when the TLS handshake fails:
# tcp_starttls speaks TLS 1.2+ only, while Windows 7 / 2008 R2 / 2003 SP1+
# offer TLS 1.0 (or CBC / RSA key-exchange suites only) and, in the default
# "Negotiate" mode, accept Standard RDP Security on a new connection.
- id: fallback
action: script
condition: "conn.connected == true"
store_as: fb
code: |
n1.mode == "rdp" || (n1.mode == "tls" && tls.upgraded != true)
- id: close-for-rdp
action: tcp_close
handle: rdp
condition: "fb == true"
- id: reopen
action: tcp_open
handle: rdp
condition: "fb == true"
port: "{{port}}"
tls: false
timeout_secs: 10
store_as: conn2
- id: cr-rdp
action: tcp_send
handle: rdp
condition: "fb == true && conn2.connected == true"
send_hex: "0300002c27e00000000000436f6f6b69653a206d737473686173683d6e6f637469730d0a0100080000000000"
timeout_secs: 10
store_as: neg2
# m.mode: "tls" or "rdp" once the transport is ready, else "".
- id: transport
action: script
condition: "conn.connected == true"
store_as: m
code: |
let mode = "";
if n1.mode == "tls" && tls.upgraded == true { mode = "tls"; }
if fb == true && conn2.connected == true && neg2.responded == true && type_of(neg2.response_hex) == "string" {
let h = tolower(neg2.response_hex);
if strlen(h) >= 14 && substr(h, 0, 3) == "0300" && substr(h, 10, 11) == "d0" {
if strlen(h) < 38 { mode = "rdp"; }
else if substr(h, 22, 23) == "02" && u32le(substr(h, 30, 37)) == 0 { mode = "rdp"; }
}
}
let ci = "";
if mode == "tls" { ci = "030001b802f0807f658201ac0401010401010101ff30190201220201020201000201010201000201010202ffff020102301902010102010102010102010102010002010102020420020102301c0202ffff0202fc170202ffff0201010201000201010202ffff0201020482014b000500147c00018142000800100001c00044756361813401c0d800040008002003580201ca03aa09040000280a00006e006f006300740069007300000000000000000000000000000000000000000004000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ca0100000000001800070001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000004c00c00090000000000000002c00c000b0000000000000003c0440005000000636c6970726472000000a0c04d535f543132300000008080726470736e640000000000c0736e646462670000000000c0726470647200000000008080"; }
if mode == "rdp" { ci = "030001b802f0807f658201ac0401010401010101ff30190201220201020201000201010201000201010202ffff020102301902010102010102010102010102010002010102020420020102301c0202ffff0202fc170202ffff0201010201000201010202ffff0201020482014b000500147c00018142000800100001c00044756361813401c0d800040008002003580201ca03aa09040000280a00006e006f006300740069007300000000000000000000000000000000000000000004000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ca0100000000001800070001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c00c00090000000000000002c00c000b0000000000000003c0440005000000636c6970726472000000a0c04d535f543132300000008080726470736e640000000000c0736e646462670000000000c0726470647200000000008080"; }
#{ mode: mode, ci: ci }
# ── 2. MCS Connect Initial / Response ───────────────────────────────────────
- id: connect-initial
action: tcp_send
handle: rdp
condition: 'm.mode != ""'
send_hex: "{{m.ci}}"
timeout_secs: 10
store_as: cresp
# Server data blocks follow the "McDn" H.221 key of the GCC Conference Create
# Response: SC_SECURITY (0x0c02) gives the encryption method/level, server
# random and proprietary certificate; SC_NET (0x0c03) the channel IDs, in the
# order of our list (cliprdr, MS_T120, …).
- id: parse-connect
action: script
condition: 'm.mode != ""'
store_as: srv
code: |
fn b(h, o, n) { substr(h, o * 2, o * 2 + n * 2 - 1) }
let r = #{ ok: false, method: 0, level: 0, sr: "", exp: "", modulus: "", keylen: 0, t120: 0, other: 0, chans: [] };
let h = "";
if cresp.responded == true && type_of(cresp.response_hex) == "string" { h = tolower(cresp.response_hex); }
let at = -1;
let i = 0;
while i + 8 <= strlen(h) {
if substr(h, i, i + 7) == "4d63446e" { at = i; break; }
i += 2;
}
if at >= 0 && substr(h, 14, 17) == "7f66" {
let p = at / 2 + 4;
let l = u8(b(h, p, 1));
if l >= 128 { p += 2; } else { p += 1; }
let net = false;
let sec = false;
while p + 4 <= strlen(h) / 2 {
let t = u16le(b(h, p, 2));
let len = u16le(b(h, p + 2, 2));
if len < 4 || p + len > strlen(h) / 2 { break; }
if t == 0x0c02 && len >= 12 {
sec = true;
r.method = u32le(b(h, p + 4, 4));
r.level = u32le(b(h, p + 8, 4));
if r.method != 0 && len >= 88 && u32le(b(h, p + 12, 4)) == 32 && (u32le(b(h, p + 52, 4)) % 0x80000000) == 1 && b(h, p + 68, 4) == "52534131" {
r.keylen = u32le(b(h, p + 72, 4));
if r.keylen > 8 && 88 + r.keylen - 8 <= len {
r.sr = b(h, p + 20, 32);
r.exp = b(h, p + 84, 4);
r.modulus = b(h, p + 88, r.keylen - 8);
}
}
}
if t == 0x0c03 && len >= 8 {
let n = u16le(b(h, p + 6, 2));
let k = 0;
while k < n && 8 + k * 2 + 2 <= len {
r.chans.push(u16le(b(h, p + 8 + k * 2, 2)));
k += 1;
}
if r.chans.len() >= 4 && r.chans[1] != 0 && r.chans[3] != 0 && r.chans[1] != r.chans[3] {
r.t120 = r.chans[1];
r.other = r.chans[3];
net = true;
}
}
p += len;
}
if net && sec {
if m.mode == "tls" { r.ok = true; }
if m.mode == "rdp" && r.method == 0 { r.ok = true; }
if m.mode == "rdp" && (r.method == 1 || r.method == 2 || r.method == 8) && r.modulus != "" { r.ok = true; }
}
}
r
# ── 3. Erect Domain + Attach User, then Channel Joins ───────────────────────
- id: attach
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true"
send_hex: "0300000c02f08004010001000300000802f08028"
timeout_secs: 10
store_as: au
# Attach User Confirm: 0x2e, result 0, initiator (user ID - 1001).
- id: joins
action: script
condition: "m.mode != \"\" && srv.ok == true"
store_as: j
code: |
let r = #{ ok: false, uid: 0, frame: "" };
if au.responded == true && type_of(au.response_hex) == "string" {
let h = tolower(au.response_hex);
if strlen(h) >= 22 && substr(h, 14, 15) == "2e" && substr(h, 16, 17) == "00" {
r.uid = u16be(substr(h, 18, 21));
let ids = [1001 + r.uid, 1003];
for c in srv.chans { ids.push(c); }
for c in ids { r.frame += "0300000c02f08038" + p16be(r.uid) + p16be(c); }
r.ok = true;
}
}
r
- id: channel-join
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true && j.ok == true"
send_hex: "{{j.frame}}"
timeout_secs: 10
store_as: jr
# ── 4. Security Exchange (Standard RDP Security) + Client Info ──────────────
# k: session keys and the PDUs up to Client Info. Every PDU after the
# Security Exchange goes through one RC4 stream, so k.n counts the bytes
# already encrypted (the `skip` of rc4_hex).
- id: keys
action: script
condition: "m.mode != \"\" && srv.ok == true && j.ok == true"
store_as: k
code: |
fn salted(s, i, cr, sr) { md5_hex(s + sha1_hex(i + s + cr + sr)) }
fn mcs(uid, chan, pdu) {
let x = "64" + p16be(uid) + p16be(chan) + "70" + p16be(0x8000 + strlen(pdu) / 2) + pdu;
"0300" + p16be(strlen(x) / 2 + 7) + "02f080" + x
}
let r = #{ ok: false, enc: false, key: "", mac: "", n: 0, uid: j.uid, pre: "", joined: false };
if jr.responded == true && type_of(jr.response_hex) == "string" {
// The MS_T120 and snddbg (control) joins must both be confirmed (result 0).
let h = tolower(jr.response_hex);
r.joined = h.contains("3e00" + p16be(j.uid) + p16be(srv.t120) + p16be(srv.t120)) && h.contains("3e00" + p16be(j.uid) + p16be(srv.other) + p16be(srv.other));
}
if r.joined {
let info = "000000003301000000000c0000000000000000006e006f00630074006900730000000000000000000200020000003c0043003a005c00570049004e004e0054005c00530079007300740065006d00330032005c006d007300740073006300610078002e0064006c006c000000a40100004700540042002c0020006e006f0072006d0061006c0074006900640000000000000000000000000000000000000000000000000000000000000000000000000000000a00000005000300000000000000000000004700540042002c00200073006f006d006d006100720074006900640000000000000000000000000000000000000000000000000000000000000000000000000000000300000005000200000000000000c4ffffff00000000270000000000";
if m.mode == "rdp" && srv.method != 0 {
let cr = rand_hex(32);
let sr = srv.sr;
let g = substr(cr, 0, 47) + substr(sr, 0, 47);
let ms = salted(g, "41", cr, sr) + salted(g, "4242", cr, sr) + salted(g, "434343", cr, sr);
let blob = salted(ms, "58", cr, sr) + salted(ms, "5959", cr, sr) + salted(ms, "5a5a5a", cr, sr);
let mac = substr(blob, 0, 31);
let key = md5_hex(substr(blob, 64, 95) + cr + sr);
if srv.method == 1 { key = "d1269e" + substr(key, 6, 15); mac = "d1269e" + substr(mac, 6, 15); }
if srv.method == 8 { key = "d1" + substr(key, 2, 15); mac = "d1" + substr(mac, 2, 15); }
let ecr = rsa_public_le_hex(cr, srv.exp, srv.modulus);
if ecr != "" {
let sx = "01000000" + p32le(strlen(ecr) / 2 + 8) + ecr + "0000000000000000";
let inner = sha1_hex(mac + crap(80, "36") + p32le(strlen(info) / 2) + info);
let sig = substr(md5_hex(mac + crap(96, "5c") + inner), 0, 15);
let ct = rc4_hex(key, info, 0);
r.pre = mcs(j.uid, 1003, sx) + mcs(j.uid, 1003, "48000000" + sig + ct);
r.n = strlen(info) / 2;
r.key = key;
r.mac = mac;
r.enc = true;
r.ok = true;
}
} else {
r.pre = mcs(j.uid, 1003, "40000000" + info);
r.ok = true;
}
}
r
- id: client-info
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true"
send_hex: "{{k.pre}}"
timeout_secs: 10
store_as: lic
# ── 5. Licensing, activation, control and check PDUs ────────────────────────
# Server License PDU: security header (4 bytes) then bMsgType. 0x01 = License
# Request → answer with a New License Request (as the Metasploit check does).
- id: frames
action: script
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true"
store_as: f
code: |
fn mcs(uid, chan, pdu) {
let x = "64" + p16be(uid) + p16be(chan) + "70" + p16be(0x8000 + strlen(pdu) / 2) + pdu;
"0300" + p16be(strlen(x) / 2 + 7) + "02f080" + x
}
fn wrap(k, flags, n, body) {
if k.enc {
let inner = sha1_hex(k.mac + crap(80, "36") + p32le(strlen(body) / 2) + body);
let sig = substr(md5_hex(k.mac + crap(96, "5c") + inner), 0, 15);
p16le(flags + 8) + "0000" + sig + rc4_hex(k.key, body, n)
} else if flags != 0 {
p16le(flags) + "0000" + body
} else {
body
}
}
let r = #{ ok: false, licreq: false, lic: "", act: "", ctl: "", c1: "", c2: "", c3: "" };
if lic.responded == true && type_of(lic.response_hex) == "string" {
let h = tolower(lic.response_hex);
if !h.contains("0300000902f0802180") {
r.ok = true;
if strlen(h) >= 40 && substr(h, 0, 3) == "0300" {
let off = 18;
if u8(substr(h, 26, 27)) >= 128 { off = 19; }
r.licreq = substr(h, off * 2, off * 2 + 1) == "01";
}
}
}
if r.ok {
let n = k.n;
if r.licreq {
let body = "130386000100000000000104000000000000000000000000000000000000000000000000000000000000000002004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0007006e6f6374697300100007006e6f6374697300";
r.lic = mcs(k.uid, 1003, wrap(k, 0x80, n, body));
if k.enc { n += strlen(body) / 2; }
}
for body in ["a4011300f103ea030100ea0306008e014d53545343000e00000001001800010003000002000000000d04000000000000000002001c00100001000100010020035802000001000100000001000000030058000000000000000000000000000000000000000000010014000000010047012a000101010100000000010101010001010000000000010101000001010100000000a1060000000000000084030000000000e40400001300280000000003780000007800000050010000000000000000000000000000000000000000000008000a000100140014000a0008000600000007000c00000000000000000005000c00000000000200020009000800000000000f000800010000000d005800010000000904000004000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000800010000000e0008000100000010003400fe000400fe000400fe000800fe000800fe001000fe002000fe004000fe008000fe000001400000080001000102000000", "16001700f103ea030100000108001f0000000100f103", "1a001700f103ea03010000010c00140000000400000000000000", "1a001700f103ea03010000010c00140000000100000000000000", "22001700f103ea030100000114001c00000001000000000000000000000000000000", "1a001700f103ea03010000010c00270000000000000003003200"] {
r.act += mcs(k.uid, 1003, wrap(k, 0, n, body));
if k.enc { n += strlen(body) / 2; }
}
let body = "22001700f103ea030100000114001c00000001000000000000000000000000000000";
r.ctl = mcs(k.uid, 1003, wrap(k, 0, n, body));
if k.enc { n += strlen(body) / 2; }
// Same Virtual Channel PDUs as the check, on the snddbg channel: an
// Ultimatum here means the server drops any such data, not MS_T120.
for body in ["100000000300000000000000020000000000000000000000", "20000000030000000000000000000000020000000000000000000000000000000000000000000000"] {
r.ctl += mcs(k.uid, srv.other, wrap(k, 0, n, body));
if k.enc { n += strlen(body) / 2; }
}
let rounds = ["", "", ""];
for i in 0..3 {
for body in ["100000000300000000000000020000000000000000000000", "20000000030000000000000000000000020000000000000000000000000000000000000000000000"] {
rounds[i] += mcs(k.uid, srv.t120, wrap(k, 0, n, body));
if k.enc { n += strlen(body) / 2; }
}
}
r.c1 = rounds[0];
r.c2 = rounds[1];
r.c3 = rounds[2];
}
r
- id: license
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true && f.ok == true && f.licreq == true"
send_hex: "{{f.lic}}"
timeout_secs: 10
store_as: lic2
- id: activate
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true && f.ok == true"
send_hex: "{{f.act}}"
timeout_secs: 5
store_as: act
- id: control
action: tcp_send
handle: rdp
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true && f.ok == true"
send_hex: "{{f.ctl}}"
timeout_secs: 6
store_as: ctl
# The session must still be up after activation and the control packets (an
# Input Synchronize, then the check payloads on snddbg, read for 6 s): no
# Ultimatum yet, and the control packets were written.
- id: alive
action: script
condition: "m.mode != \"\" && srv.ok == true && j.ok == true && k.ok == true && f.ok == true"
store_as: st
code: |
fn dpu(r) {
if type_of(r.response_hex) != "string" { return false; }
tolower(r.response_hex).contains("0300000902f0802180")
}
let seen = dpu(act) || dpu(ctl);
if f.licreq { seen = seen || dpu(lic2); }
#{ mode: m.mode, ok: true, alive: ctl.sent == true && !seen, hit: false, round: 0 }
- id: check-1
action: tcp_send
handle: rdp
condition: "st.alive == true"
send_hex: "{{f.c1}}"
timeout_secs: 5
store_as: r1
- id: eval-1
action: script
condition: "st.alive == true"
store_as: st
code: |
let hit = type_of(r1.response_hex) == "string" && tolower(r1.response_hex).contains("0300000902f0802180");
#{ mode: st.mode, ok: true, alive: !hit && r1.sent == true, hit: hit, round: 1 }
- id: check-2
action: tcp_send
handle: rdp
condition: "st.alive == true"
send_hex: "{{f.c2}}"
timeout_secs: 5
store_as: r2
- id: eval-2
action: script
condition: "st.alive == true"
store_as: st
code: |
let hit = type_of(r2.response_hex) == "string" && tolower(r2.response_hex).contains("0300000902f0802180");
#{ mode: st.mode, ok: true, alive: !hit && r2.sent == true, hit: hit, round: 2 }
- id: check-3
action: tcp_send
handle: rdp
condition: "st.alive == true"
send_hex: "{{f.c3}}"
timeout_secs: 5
store_as: r3
- id: eval-3
action: script
condition: "st.alive == true"
store_as: st
code: |
let hit = type_of(r3.response_hex) == "string" && tolower(r3.response_hex).contains("0300000902f0802180");
#{ mode: st.mode, ok: true, alive: false, hit: hit, round: 3 }
- id: close
action: tcp_close
handle: rdp
- id: verdict
action: match
source: st.hit
pattern: "^true$"
condition: "st.hit == true"
on_match:
finding:
title: "Microsoft Remote Desktop BlueKeep pre-auth RCE (CVE-2019-0708)"
description: "The Remote Desktop server bound the client-requested MS_T120 static virtual channel to its internal MS_T120 channel: Virtual Channel PDUs sent on it before any login made the server tear the session down with an MCS Disconnect Provider Ultimatum, while the same session had stayed up after the activation sequence and after the same PDUs sent on another static channel (snddbg). Unpatched hosts behave this way (CVE-2019-0708), which allows unauthenticated remote code execution."
remediation: "Apply the May 2019 Microsoft security update for CVE-2019-0708 (also issued for Windows XP and Server 2003), or disable Remote Desktop Services. Requiring Network Level Authentication and blocking TCP/3389 at the perimeter mitigate pre-authentication exploitation."
confidence_delta: 0.65
qod: 97
evidence: "security layer {{st.mode}}; MS_T120 channel ID {{srv.t120}}; MCS Disconnect Provider Ultimatum (0300000902f0802180) after MS_T120 check round {{st.round}}, none after activation nor after the same PDUs on the snddbg channel"