Detection rules › Elastic

Execution of a Windows Script Downloaded via a LOLBIN

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

Identifies when a Windows script interpreter executes a file downloaded via commonly abused legit Windows binaries such as Certutil or BitsAdmin.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies when a Windows script interpreter executes a file downloaded via commonly abused legit Windows binaries such
as Certutil or BitsAdmin.
"""
id = "f60d4c82-2de5-4c70-95f5-cde9f3ad41a7"
license = "Elastic License v2"
name = "Execution of a Windows Script Downloaded via a LOLBIN"
os_list = ["windows"]
version = "1.0.30"

query = '''
sequence by process.parent.entity_id with maxspan=1m
 [process where event.type == "start" and
  (process.pe.original_file_name : ("certutil.exe", "bitsadmin.exe", "CertReq.exe", "curl.exe") or
   process.executable : "?:\\Windows\\Sys*\\OpenSSH\\sftp.exe") and
  process.command_line : ("*download*", "*transfer*", "*-decode*", "*http*", "* -o*", "* --output*")]
 [process where event.type == "start" and process.pe.original_file_name : ("wscript.exe", "mshta.exe") and
  not (process.working_directory : "E:\\*" and process.name : "cscript.exe" and process.args : ("loadpromo.vbs", "LoadMasterStocks.vbs")) and
  not (process.parent.name : "cmd.exe" and
       process.parent.args :
            ("C:\\ProgramData\\NinjaRMMAgent\\scripting\\customscript_gen_?.bat-ninjascript.bat",
             "C:\\Storage\\VisualStudioProjects\\connect_wise_script\\install_speerity.bat"))]
'''

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

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

[[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 = "T1197"
name = "BITS Jobs"
reference = "https://attack.mitre.org/techniques/T1197/"

[[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 = "7.15.0"

Stages and Predicates

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

Stage 1: process

[process where event.type == "start" and
  (process.pe.original_file_name : ("certutil.exe", "bitsadmin.exe", "CertReq.exe", "curl.exe") or
   process.executable : "?:\\Windows\\Sys*\\OpenSSH\\sftp.exe") and
  process.command_line : ("*download*", "*transfer*", "*-decode*", "*http*", "* -o*", "* --output*")]

Stage 2: process

[process where event.type == "start" and process.pe.original_file_name : ("wscript.exe", "mshta.exe") and
  not (process.working_directory : "E:\\*" and process.name : "cscript.exe" and process.args : ("loadpromo.vbs", "LoadMasterStocks.vbs")) and
  not (process.parent.name : "cmd.exe" and
       process.parent.args :
            ("C:\\ProgramData\\NinjaRMMAgent\\scripting\\customscript_gen_?.bat-ninjascript.bat",
             "C:\\Storage\\VisualStudioProjects\\connect_wise_script\\install_speerity.bat"))]

Exclusions

The rule actively suppresses these predicates.

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.typeeq
  • start corpus 1078 (elastic 1078)
field:"event.type" kind:eq value:"start"
process.command_linewildcard
  • * --output*
  • * -o* corpus 8 (sigma 6, elastic 1, chronicle 1)
  • *-decode* corpus 2 (elastic 1, kusto 1)
  • *download* corpus 4 (elastic 3, sigma 1)
  • *http* corpus 52 (sigma 34, elastic 15, chronicle 2, splunk 1)
  • *transfer* corpus 3 (elastic 3)
field:"CommandLine" kind:wildcard
process.executablewildcard
  • ?:\Windows\Sys*\OpenSSH\sftp.exe corpus 3 (elastic 3)
field:"Image" kind:wildcard value:"?:\Windows\Sys*\OpenSSH\sftp.exe"
process.pe.original_file_namewildcard
  • CertReq.exe corpus 5 (elastic 4, sigma 1)
  • bitsadmin.exe corpus 20 (sigma 9, elastic 8, splunk 2, kusto 1)
  • certutil.exe corpus 30 (sigma 14, elastic 10, splunk 6)
  • curl.exe corpus 24 (sigma 13, elastic 8, splunk 3)
  • mshta.exe corpus 40 (elastic 21, sigma 13, splunk 6)
  • wscript.exe corpus 38 (elastic 21, sigma 17)
field:"OriginalFileName" kind:wildcard