Detection rules › Elastic

Potential Initial Access via Rogue RDP Server

Time window
5m
Sequence by
process.entity_id
Source
github.com/elastic/protections-artifacts

Identifies attempts to drop an executable file via a malicious RDP connection file. This may indicate an attempt to get initial access by connecting to an adversary controlled malicious RDP server.

MITRE ATT&CK coverage

TacticTechniques
Initial Access

Rule body

[rule]
description = """
Identifies attempts to drop an executable file via a malicious RDP connection file. This may indicate an attempt to get
initial access by connecting to an adversary controlled malicious RDP server.
"""
id = "4c6cea1d-7c50-4d83-861b-3fee8c079d97"
license = "Elastic License v2"
name = "Potential Initial Access via Rogue RDP Server"
os_list = ["windows"]
reference = [
    "https://www.blackhillsinfosec.com/rogue-rdp-revisiting-initial-access-methods/",
    "https://shorsec.io/blog/malrdp-implementing-rouge-rdp-manually/",
]
version = "1.0.8"

query = '''
sequence by process.entity_id with maxspan=5m
 [process where event.action == "start" and process.name : "mstsc.exe" and process.args_count >= 2 and
  not (process.args : "-Embedding" and process.parent.name : "svchost.exe") and
  not process.parent.executable :
             ("?:\\Program Files\\Thycotic Software Ltd\\Secret Server Protocol Handler\\RDPWin.exe",
              "?:\\Program Files (x86)\\Thycotic Software Ltd\\Secret Server Protocol Handler\\RDPWin.exe")]
 [network where event.action == "connection_attempted" and process.name : "mstsc.exe"]
 [file where event.action != "deletion" and process.name : "mstsc.exe" and 
  (
   (file.extension : ("dll", "exe", "cpl", "pif", "com", "js", "vbs", "wsh", "vbe", "jse", "bat", "cmd") or
    file.Ext.header_bytes : "4d5a*" or file.name : "*.exe.config") or

   file.path : ("?:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*",
               "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*",
               "?:\\Users\\*\\Desktop\\*.lnk")
   ) and
   not file.path : ("?:\\*\\AppData\\Local\\Temp\\*", "?:\\Program Files*") and
   not (file.path : "?:\\ProgramData\\*" and not file.path : "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*")]
'''

min_endpoint_version = "7.16.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1566"
name = "Phishing"
reference = "https://attack.mitre.org/techniques/T1566/"
[[threat.technique.subtechnique]]
id = "T1566.001"
name = "Spearphishing Attachment"
reference = "https://attack.mitre.org/techniques/T1566/001/"



[threat.tactic]
id = "TA0001"
name = "Initial Access"
reference = "https://attack.mitre.org/tactics/TA0001/"

[internal]
min_endpoint_version = "7.16.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 5m, correlated by process.entity_id.

Stage 1: process

[process where event.action == "start" and process.name : "mstsc.exe" and process.args_count >= 2 and
  not (process.args : "-Embedding" and process.parent.name : "svchost.exe") and
  not process.parent.executable :
             ("?:\\Program Files\\Thycotic Software Ltd\\Secret Server Protocol Handler\\RDPWin.exe",
              "?:\\Program Files (x86)\\Thycotic Software Ltd\\Secret Server Protocol Handler\\RDPWin.exe")]

Stage 2: network

[network where event.action == "connection_attempted" and process.name : "mstsc.exe"]

Stage 3: file

[file where event.action != "deletion" and process.name : "mstsc.exe" and 
  (
   (file.extension : ("dll", "exe", "cpl", "pif", "com", "js", "vbs", "wsh", "vbe", "jse", "bat", "cmd") or
    file.Ext.header_bytes : "4d5a*" or file.name : "*.exe.config") or

   file.path : ("?:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*",
               "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*",
               "?:\\Users\\*\\Desktop\\*.lnk")
   ) and
   not file.path : ("?:\\*\\AppData\\Local\\Temp\\*", "?:\\Program Files*") and
   not (file.path : "?:\\ProgramData\\*" and not file.path : "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*")]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseq-Embeddingexcludes:process.args field:"process.args" value:"-Embedding"
process.parent.nameeqsvchost.exeexcludes:process.parent.name field:"process.parent.name" value:"svchost.exe"
process.parent.executableeq?:\Program Files\Thycotic Software Ltd\Secret Server Protocol Handler\RDPWin.exe, ?:\Program Files (x86)\Thycotic Software Ltd\Secret Server Protocol Handler\RDPWin.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Program Files\Thycotic Software Ltd\Secret Server Protocol Handler\RDPWin.exe" field:"process.parent.executable" value:"?:\Program Files (x86)\Thycotic Software Ltd\Secret Server Protocol Handler\RDPWin.exe"
file.pathstarts_with?:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\excludes:file.path field:"file.path" value:"?:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\"
file.pathstarts_with?:\ProgramData\excludes:file.path field:"file.path" value:"?:\ProgramData\"
file.pathwildcard?:\*\AppData\Local\Temp\*, ?:\Program Files*excludes:file.path field:"file.path" value:"?:\*\AppData\Local\Temp\*" field:"file.path" value:"?:\Program Files*"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • connection_attempted corpus 73 (elastic 73)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
file.Ext.header_byteswildcard
  • 4d5a* corpus 46 (elastic 46)
field:"file.Ext.header_bytes" kind:wildcard value:"4d5a*"
file.extensionwildcard
  • bat corpus 13 (elastic 13)
  • cmd corpus 15 (elastic 15)
  • com corpus 16 (elastic 16)
  • cpl corpus 19 (elastic 19)
  • dll corpus 33 (elastic 33)
  • exe corpus 32 (elastic 32)
  • js corpus 23 (elastic 23)
  • jse corpus 18 (elastic 18)
  • pif corpus 18 (elastic 18)
  • vbe corpus 18 (elastic 18)
  • vbs corpus 19 (elastic 19)
  • wsh corpus 16 (elastic 16)
field:"file.extension" kind:wildcard
file.namewildcard
  • *.exe.config corpus 2 (elastic 2)
field:"file.name" kind:wildcard value:"*.exe.config"
file.pathwildcard
  • ?:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\*
  • ?:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\* corpus 13 (elastic 13)
  • ?:\Users\*\Desktop\*.lnk corpus 3 (elastic 3)
field:"TargetFilename" kind:wildcard
process.args_countge
  • 2 transforms: number corpus 18 (elastic 18)
field:"process.args_count" kind:ge value:"2"
process.namewildcard
  • mstsc.exe corpus 7 (elastic 5, splunk 2)
field:"process_name" kind:wildcard value:"mstsc.exe"