Detection rules › Elastic

Suspicious Oversized Script Execution

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

Identifies the execution of oversized Windows scripts. Adversaries may employ script padding with random data to evade sandbox detection restriction based on file size.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of oversized Windows scripts. Adversaries may employ script padding with random data to evade
sandbox detection restriction based on file size.
"""
id = "7be3d607-5c11-4609-91b9-0a3cf10cac8e"
license = "Elastic License v2"
name = "Suspicious Oversized Script Execution"
os_list = ["windows"]
version = "1.0.4"

query = '''
sequence with maxspan=2m
 [file where event.action != "deletion" and
  file.extension : ("js", "vbs", "jse", "vbe", "wsh", "hta", "wsf") and
  (
   process.name : ("explorer.exe", "cmd.exe", "powershell.exe", "winrar.exe", "expand.exe", "wscript.exe", "cscript.exe", "msiexec.exe",
                  "chrome.exe", "msedge.exe", "firefox.exe", "7zFM.exe", "7zG.exe", "python*.exe", "certutil.exe", "mshta.exe") or
   (process.code_signature.exists == false or process.code_signature.trusted == false)
   ) and
  /* more than 0.4MB */
  file.size >= 400000 and file.path : ("?:\\Users\\*", "?:\\ProgramData\\*", "?:\\Windows\\Temp\\*", "?:\\Windows\\Tasks\\*")] as event0
 [process where event.action == "start" and
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe") and process.args_count >= 2 and
  stringcontains~(process.command_line, event0.file.name)]
'''

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 = "T1027"
name = "Obfuscated Files or Information"
reference = "https://attack.mitre.org/techniques/T1027/"
[[threat.technique.subtechnique]]
id = "T1027.001"
name = "Binary Padding"
reference = "https://attack.mitre.org/techniques/T1027/001/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Stage 1: file

[file where event.action != "deletion" and
  file.extension : ("js", "vbs", "jse", "vbe", "wsh", "hta", "wsf") and
  (
   process.name : ("explorer.exe", "cmd.exe", "powershell.exe", "winrar.exe", "expand.exe", "wscript.exe", "cscript.exe", "msiexec.exe",
                  "chrome.exe", "msedge.exe", "firefox.exe", "7zFM.exe", "7zG.exe", "python*.exe", "certutil.exe", "mshta.exe") or
   (process.code_signature.exists == false or process.code_signature.trusted == false)
   ) and
  file.size >= 400000 and file.path : ("?:\\Users\\*", "?:\\ProgramData\\*", "?:\\Windows\\Temp\\*", "?:\\Windows\\Tasks\\*")] as event0

Stage 2: process

[process where event.action == "start" and
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe") and process.args_count >= 2 and
  stringcontains~(process.command_line, event0.file.name)]

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
file.extensionwildcard
  • 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)
  • wsf corpus 10 (elastic 10)
  • wsh corpus 16 (elastic 16)
field:"file.extension" kind:wildcard
file.pathwildcard
  • ?:\ProgramData\* corpus 2 (elastic 2)
  • ?:\Users\* corpus 4 (elastic 4)
  • ?:\Windows\Tasks\* corpus 7 (elastic 7)
  • ?:\Windows\Temp\* corpus 2 (elastic 2)
field:"TargetFilename" kind:wildcard
file.sizege
  • 400000 transforms: number
field:"file.size" kind:ge value:"400000"
process.args_countge
  • 2 transforms: number corpus 18 (elastic 18)
field:"process.args_count" kind:ge value:"2"
process.code_signature.existseq
  • false transforms: boolean corpus 119 (elastic 119)
field:"process.code_signature.exists" kind:eq value:"false"
process.code_signature.trustedeq
  • false transforms: boolean corpus 115 (elastic 115)
field:"process.code_signature.trusted" kind:eq value:"false"
process.command_linecontains
  • event0.file.name (field reference) corpus 10 (elastic 10)
field:"CommandLine" kind:contains value:"event0.file.name"
process.namewildcard
  • 7zFM.exe corpus 7 (elastic 7)
  • 7zG.exe corpus 2 (elastic 2)
  • certutil.exe corpus 44 (elastic 38, splunk 6)
  • chrome.exe corpus 16 (elastic 14, splunk 2)
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • expand.exe corpus 8 (elastic 7, splunk 1)
  • explorer.exe corpus 21 (elastic 19, splunk 2)
  • firefox.exe corpus 5 (elastic 5)
  • msedge.exe corpus 12 (elastic 12)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • msiexec.exe corpus 46 (elastic 41, splunk 5)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • python*.exe corpus 4 (elastic 4)
  • winrar.exe corpus 9 (elastic 9)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard