Detection rules › Elastic

Execution of a Windows Script Downloaded from the Internet

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

Identifies the execution of a Windows script that was downloaded from the internet.

MITRE ATT&CK coverage

Rule body

[rule]
description = "Identifies the execution of a Windows script that was downloaded from the internet."
id = "a87d8240-0b80-4255-8680-cee8c68b2d1e"
license = "Elastic License v2"
name = "Execution of a Windows Script Downloaded from the Internet"
os_list = ["windows"]
version = "1.0.5"

query = '''
sequence with maxspan=5m
 [file where event.action == "creation" and
  file.Ext.windows.zone_identifier == 3 and file.origin_url : "http*" and
  file.extension in~ ("js", "jse", "vbs", "vbe", "wsh", "hta") and
  not file.origin_url like ("https://www.manageengine.com/products/*",
                            "https://*.sharepoint.com/*",
                            "https://artifacts.elastic.co/downloads/*",
                            "https://ajax.googleapis.com/ajax*",
                            "https://api.media.atlassian.com/*",
                            "https://gitlab.com/blooket/blooket-cheats/*", 
                            "https://dl.driverpack.io/test/PROD_Start_DriverPack.hta")
  ] as event0
 [process where event.action == "start" and
  (process.name in~ ("wscript.exe", "cscript.exe", "mshta.exe") or
   process.pe.original_file_name in ("cscript.exe", "wscript.exe", "MSHTA.EXE")) and
   (
    /* substring used to remove Zone.Identifier from file.name */
    stringcontains~(process.command_line, substring(event0.file.name, 0, length(event0.file.name) - 16)) or

    stringcontains~(process.command_line, event0.file.name) or

    startswith~(event0.file.path, process.working_directory)
   )]
'''

min_endpoint_version = "8.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1
tree = true

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

[internal]
min_endpoint_version = "8.15.0"

Stages and Predicates

Stage 1: file

[file where event.action == "creation" and
  file.Ext.windows.zone_identifier == 3 and file.origin_url : "http*" and
  file.extension in~ ("js", "jse", "vbs", "vbe", "wsh", "hta") and
  not file.origin_url like ("https://www.manageengine.com/products/*",
                            "https://*.sharepoint.com/*",
                            "https://artifacts.elastic.co/downloads/*",
                            "https://ajax.googleapis.com/ajax*",
                            "https://api.media.atlassian.com/*",
                            "https://gitlab.com/blooket/blooket-cheats/*", 
                            "https://dl.driverpack.io/test/PROD_Start_DriverPack.hta")
  ] as event0

Stage 2: process

[process where event.action == "start" and
  (process.name in~ ("wscript.exe", "cscript.exe", "mshta.exe") or
   process.pe.original_file_name in ("cscript.exe", "wscript.exe", "MSHTA.EXE")) and
   (
    stringcontains~(process.command_line, substring(event0.file.name, 0, length(event0.file.name) - 16)) or
    stringcontains~(process.command_line, event0.file.name) or
    startswith~(event0.file.path, process.working_directory)
   )]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.origin_urlwildcardhttps://www.manageengine.com/products/*, https://*.sharepoint.com/*, https://artifacts.elastic.co/downloads/*, https://ajax.googleapis.com/ajax*, https://api.media.atlassian.com/*, https://gitlab.com/blooket/blooket-cheats/*, https://dl.driverpack.io/test/PROD_Start_DriverPack.htaexcludes:file.origin_url

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • creation corpus 58 (elastic 58)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
event0.file.pathstarts_with
  • process.working_directory (field reference) corpus 4 (elastic 4)
field:"event0.file.path" kind:starts_with value:"process.working_directory"
file.Ext.windows.zone_identifiereq
  • 3 transforms: number corpus 6 (elastic 6)
field:"file.Ext.windows.zone_identifier" kind:eq value:"3"
file.extensionin
  • hta corpus 20 (elastic 20)
  • js corpus 23 (elastic 23)
  • jse corpus 18 (elastic 18)
  • vbe corpus 18 (elastic 18)
  • vbs corpus 19 (elastic 19)
  • wsh corpus 16 (elastic 16)
field:"file.extension" kind:in
file.origin_urlwildcard
  • http*
field:"file.origin_url" kind:wildcard value:"http*"
process.command_linecontains
  • event0.file.name (field reference) corpus 10 (elastic 10)
  • substring(event0.file.name, 0, (length(event0.file.name) - 16)) (expression) corpus 3 (elastic 3)
field:"CommandLine" kind:contains
process.namein
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:in
process.pe.original_file_namein
  • MSHTA.EXE corpus 40 (elastic 21, sigma 13, splunk 6)
  • cscript.exe corpus 32 (sigma 17, elastic 15)
  • wscript.exe corpus 38 (elastic 21, sigma 17)
field:"OriginalFileName" kind:in