Detection rules › Elastic

Execution of a File Downloaded via Windows OpenSSH

Time window
2m
Source
github.com/elastic/protections-artifacts

Identifies the execution of a file downloaded via SSH Windows binaries. Adversaries may abuse those utilities to download remote content.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of a file downloaded via SSH Windows binaries. Adversaries may abuse those utilities to
download remote content.
"""
id = "2d8c7caa-a661-4989-be4f-289e4678bd5a"
license = "Elastic License v2"
name = "Execution of a File Downloaded via Windows OpenSSH"
os_list = ["windows"]
version = "1.0.2"

query = '''
sequence with maxspan=2m
 [file where event.action != "deletion" and
  process.executable : ("?:\\Windows\\System32\\OpenSSH\\scp.exe", "?:\\Windows\\System32\\OpenSSH\\ssh.exe") and
  (file.extension : ("exe", "pif", "scr", "js", "vbs", "wsh", "hta", "cpl", "jse", "vbe", "bat", "cmd", "dll", "msi", "ps1") or
   file.Ext.header_bytes : "4d5a*")] as event0
 [any where event.category in ("process", "library") and
   (
   (event.action == "start" and process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe") and
    stringcontains~(process.command_line, event0.file.name)) or

   (event.action == "load" and (dll.code_signature.trusted == false or dll.code_signature.exists == false) and
    stringcontains~(event0.file.path, dll.path))
    )]
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

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

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.005"
name = "Visual Basic"
reference = "https://attack.mitre.org/techniques/T1059/005/"

[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1218"
name = "System Binary Proxy Execution"
reference = "https://attack.mitre.org/techniques/T1218/"
[[threat.technique.subtechnique]]
id = "T1218.005"
name = "Mshta"
reference = "https://attack.mitre.org/techniques/T1218/005/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1105"
name = "Ingress Tool Transfer"
reference = "https://attack.mitre.org/techniques/T1105/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Stage 1: file

[file where event.action != "deletion" and
  process.executable : ("?:\\Windows\\System32\\OpenSSH\\scp.exe", "?:\\Windows\\System32\\OpenSSH\\ssh.exe") and
  (file.extension : ("exe", "pif", "scr", "js", "vbs", "wsh", "hta", "cpl", "jse", "vbe", "bat", "cmd", "dll", "msi", "ps1") or
   file.Ext.header_bytes : "4d5a*")] as event0

Stage 2: any

[any where event.category in ("process", "library") and
   (
   (event.action == "start" and process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe") and
    stringcontains~(process.command_line, event0.file.name)) or

   (event.action == "load" and (dll.code_signature.trusted == false or dll.code_signature.exists == false) and
    stringcontains~(event0.file.path, dll.path))
    )]

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.code_signature.existseq
  • false transforms: boolean corpus 22 (elastic 22)
field:"dll.code_signature.exists" kind:eq value:"false"
dll.code_signature.trustedeq
  • false transforms: boolean corpus 21 (elastic 21)
field:"dll.code_signature.trusted" kind:eq value:"false"
event.actioneq
  • load corpus 24 (elastic 24)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
event.categoryin
  • library corpus 22 (elastic 22)
  • process corpus 142 (elastic 142)
field:"event.category" kind:in
event0.file.pathcontains
  • dll.path (field reference)
field:"event0.file.path" kind:contains value:"dll.path"
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)
  • cpl corpus 19 (elastic 19)
  • dll corpus 33 (elastic 33)
  • exe corpus 32 (elastic 32)
  • hta corpus 20 (elastic 20)
  • js corpus 23 (elastic 23)
  • jse corpus 18 (elastic 18)
  • msi corpus 3 (elastic 3)
  • pif corpus 18 (elastic 18)
  • ps1 corpus 9 (elastic 9)
  • scr corpus 17 (elastic 17)
  • vbe corpus 18 (elastic 18)
  • vbs corpus 19 (elastic 19)
  • wsh corpus 16 (elastic 16)
field:"file.extension" kind:wildcard
process.command_linecontains
  • event0.file.name (field reference) corpus 10 (elastic 10)
field:"CommandLine" kind:contains value:"event0.file.name"
process.executablewildcard
  • ?:\Windows\System32\OpenSSH\scp.exe
  • ?:\Windows\System32\OpenSSH\ssh.exe corpus 3 (elastic 3)
field:"Image" kind:wildcard
process.namewildcard
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • regsvr32.exe corpus 73 (elastic 68, splunk 5)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard