Detection rules › Elastic
Execution of a Windows Script Downloaded via a LOLBIN
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | loadpromo.vbs, LoadMasterStocks.vbs | excludes:process.args field:"process.args" value:"loadpromo.vbs" field:"process.args" value:"LoadMasterStocks.vbs" |
process.name | eq | cscript.exe | excludes:process.name field:"process.name" value:"cscript.exe" |
process.working_directory | starts_with | E:\ | excludes:process.working_directory field:"process.working_directory" value:"E:\" |
process.parent.args | eq | C:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_?.bat-ninjascript.bat, C:\Storage\VisualStudioProjects\connect_wise_script\install_speerity.bat | excludes:process.parent.args field:"process.parent.args" value:"C:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_?.bat-ninjascript.bat" field:"process.parent.args" value:"C:\Storage\VisualStudioProjects\connect_wise_script\install_speerity.bat" |
process.parent.name | eq | cmd.exe | excludes:process.parent.name field:"process.parent.name" value:"cmd.exe" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard |
process.executable | wildcard |
| field:"Image" kind:wildcard value:"?:\Windows\Sys*\OpenSSH\sftp.exe" |
process.pe.original_file_name | wildcard |
| field:"OriginalFileName" kind:wildcard |