Detection rules › Elastic

Execution of a File Written by Windows Script Host

Time window
5m
Sequence by
file.path, process.executable
Source
github.com/elastic/protections-artifacts

Identifies the execution of a file written or modified by Microsoft Windows Script Host processes (cscript or wscript).

MITRE ATT&CK coverage

Rule body

[rule]
description = "Identifies the execution of a file written or modified by Microsoft Windows Script Host processes (cscript or wscript)."
id = "49e47c2a-307f-4591-939a-dfdae6e5156c"
license = "Elastic License v2"
name = "Execution of a File Written by Windows Script Host"
os_list = ["windows"]
version = "1.0.38"

query = '''
sequence with maxspan=5m
  [file where event.action != "deletion" and
   process.name : ("cscript.exe", "wscript.exe") and
   not file.path : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe")] by file.path
  [process where event.action == "start" and
   not process.Ext.token.integrity_level_name == "system" and
   not process.parent.executable : "?:\\Windows\\System32\\drvinst.exe" and
   not (process.code_signature.trusted == true and
        process.code_signature.subject_name :
                ("Microsoft *",
                 "ESET, spol. s r.o.",
                 "VORTECH SOLUTIONS PTY LTD",
                 "Western Union Holdings Inc.",
                 "KOBIL Systems GmbH")) and
   not (process.pe.original_file_name : "Packman.exe" and process.args : "checkCompileErrors=true") and
   not process.pe.original_file_name : ("CCCLauncher.exe", "Bginfo.exe") and
   not process.executable : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*") and
   not (process.pe.original_file_name == "cognosrcp.exe" and
        process.code_signature.subject_name == "IBM Canada Ltd." and process.code_signature.trusted == true) and
   not (process.code_signature.subject_name : ("The Qt Company Oy", "ci solution GmbH", "Spotify AB", "Nextech Systems, LLC") and 
        process.code_signature.trusted == true) and
   not process.hash.sha256 :
                   ("9c3b9f4d38e6c7a9614d99260078c8f05f8e187eb25a23f03ea53f0120179494",
                    "6c6c55cc9411700ad806ca9b2894fd339bfef23e1f836611c1d617485c13d91f",
                    "dd05bbbbb72b847b7e404a9011404ca058b9144b3a1648ce9cd4edd4868052dc",
                    "ebdef325ca2c3c6ded43b1e85263746719c609a9f8a0f43927764d80e92a865a")
   ] by process.executable
'''

min_endpoint_version = "7.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/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 5m, correlated by file.path, process.executable.

Stage 1: file

[file where event.action != "deletion" and
   process.name : ("cscript.exe", "wscript.exe") and
   not file.path : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe")] by file.path

Stage 2: process

[process where event.action == "start" and
   not process.Ext.token.integrity_level_name == "system" and
   not process.parent.executable : "?:\\Windows\\System32\\drvinst.exe" and
   not (process.code_signature.trusted == true and
        process.code_signature.subject_name :
                ("Microsoft *",
                 "ESET, spol. s r.o.",
                 "VORTECH SOLUTIONS PTY LTD",
                 "Western Union Holdings Inc.",
                 "KOBIL Systems GmbH")) and
   not (process.pe.original_file_name : "Packman.exe" and process.args : "checkCompileErrors=true") and
   not process.pe.original_file_name : ("CCCLauncher.exe", "Bginfo.exe") and
   not process.executable : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*") and
   not (process.pe.original_file_name == "cognosrcp.exe" and
        process.code_signature.subject_name == "IBM Canada Ltd." and process.code_signature.trusted == true) and
   not (process.code_signature.subject_name : ("The Qt Company Oy", "ci solution GmbH", "Spotify AB", "Nextech Systems, LLC") and 
        process.code_signature.trusted == true) and
   not process.hash.sha256 :
                   ("9c3b9f4d38e6c7a9614d99260078c8f05f8e187eb25a23f03ea53f0120179494",
                    "6c6c55cc9411700ad806ca9b2894fd339bfef23e1f836611c1d617485c13d91f",
                    "dd05bbbbb72b847b7e404a9011404ca058b9144b3a1648ce9cd4edd4868052dc",
                    "ebdef325ca2c3c6ded43b1e85263746719c609a9f8a0f43927764d80e92a865a")
   ] by process.executable

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathwildcard?:\Program Files (x86)\*.exe, ?:\Program Files\*.exeexcludes:file.path field:"file.path" value:"?:\Program Files (x86)\*.exe" field:"file.path" value:"?:\Program Files\*.exe"
process.argseqcheckCompileErrors=trueexcludes:process.args field:"process.args" value:"checkCompileErrors=true"
process.pe.original_file_nameeqPackman.exeexcludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"Packman.exe"
process.code_signature.subject_nameeqIBM Canada Ltd.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"IBM Canada Ltd."
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.pe.original_file_nameeqcognosrcp.exeexcludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"cognosrcp.exe"
process.code_signature.subject_nameeqThe Qt Company Oy, ci solution GmbH, Spotify AB, Nextech Systems, LLCexcludes:process.code_signature.subject_name
process.code_signature.subject_namewildcardMicrosoft *, ESET, spol. s r.o., VORTECH SOLUTIONS PTY LTD, Western Union Holdings Inc., KOBIL Systems GmbHexcludes:process.code_signature.subject_name
process.Ext.token.integrity_level_nameeqsystemexcludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system"
process.executablestarts_with?:\Program Files (x86)\, ?:\Program Files\excludes:process.executable field:"process.executable" value:"?:\Program Files (x86)\" field:"process.executable" value:"?:\Program Files\"
process.hash.sha256eq9c3b9f4d38e6c7a9614d99260078c8f05f8e187eb25a23f03ea53f0120179494, 6c6c55cc9411700ad806ca9b2894fd339bfef23e1f836611c1d617485c13d91f, dd05bbbbb72b847b7e404a9011404ca058b9144b3a1648ce9cd4edd4868052dc, ebdef325ca2c3c6ded43b1e85263746719c609a9f8a0f43927764d80e92a865aexcludes:process.hash.sha256
process.parent.executableeq?:\Windows\System32\drvinst.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\System32\drvinst.exe"
process.pe.original_file_nameeqCCCLauncher.exe, Bginfo.exeexcludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"CCCLauncher.exe" field:"process.pe.original_file_name" value:"Bginfo.exe"

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"
process.namewildcard
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard