Detection rules › Elastic

Msiexec Execution via a Windows Script Interpreter

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

Identifies when a Windows script attempts to execute commands using the Windows Installer service via Component Object Model.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies when a Windows script attempts to execute commands using the Windows Installer service via Component Object
Model.
"""
id = "1eae6aaf-7854-4fa7-8470-f19f87f9802a"
license = "Elastic License v2"
name = "Msiexec Execution via a Windows Script Interpreter"
os_list = ["windows"]
version = "1.0.5"

query = '''
sequence with maxspan=1m
 [process where event.action == "start" and not user.id : "S-1-5-18" and
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "powershell.exe", "mshta.exe", "cmstp.exe", "msxsl.exe") and
  not (process.name : "powershell.exe" and
       process.parent.executable : ("?:\\Program Files (x86)\\Microsoft Intune Management Extension\\agentexecutor.exe",
                                    "?:\\Program Files (x86)\\ScreenConnect Client*\\ScreenConnect.WindowsBackstageShell.exe",
                                    "?:\\Program Files (x86)\\ManageEngine\\UEMS_Agent\\bin\\dctask64.exe",
                                    "C:\\Program Files (x86)\\FastTrack Software\\Admin By Request\\AdminByRequest.exe",
                                    "C:\\Program Files\\Oracle Cloud Agent\\plugins\\unifiedmonitoring\\unifiedmonitoring.exe"))
  ] by process.entity_id
 [process where event.action == "start" and process.parent.name : "msiexec.exe" and
  not (process.name : "regsvr32.exe" and user.id : "S-1-5-18") and
  not (process.name : "cmd.exe" and
       process.command_line : "cmd /C if exist \"%appdata%/Messenger\" rmdir \"%appdata%/Messenger\" /s /q & if exist \"%appdata%/chatgenie\" rmdir \"%appdata%/chatgenie\" /s /q") and
  not (process.executable : "?:\\Windows\\Sys*\\msiexec.exe" and
       process.args : "/Z" and process.args : ("C:\\Program Files (x86)\\*.dll", "C:\\Program Files\\*.dll"))
  ] by process.Ext.effective_parent.entity_id
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 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 = "T1218"
name = "System Binary Proxy Execution"
reference = "https://attack.mitre.org/techniques/T1218/"
[[threat.technique.subtechnique]]
id = "T1218.007"
name = "Msiexec"
reference = "https://attack.mitre.org/techniques/T1218/007/"



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

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

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

Stage 1: process

[process where event.action == "start" and not user.id : "S-1-5-18" and
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "powershell.exe", "mshta.exe", "cmstp.exe", "msxsl.exe") and
  not (process.name : "powershell.exe" and
       process.parent.executable : ("?:\\Program Files (x86)\\Microsoft Intune Management Extension\\agentexecutor.exe",
                                    "?:\\Program Files (x86)\\ScreenConnect Client*\\ScreenConnect.WindowsBackstageShell.exe",
                                    "?:\\Program Files (x86)\\ManageEngine\\UEMS_Agent\\bin\\dctask64.exe",
                                    "C:\\Program Files (x86)\\FastTrack Software\\Admin By Request\\AdminByRequest.exe",
                                    "C:\\Program Files\\Oracle Cloud Agent\\plugins\\unifiedmonitoring\\unifiedmonitoring.exe"))
  ] by process.entity_id

Stage 2: process

[process where event.action == "start" and process.parent.name : "msiexec.exe" and
  not (process.name : "regsvr32.exe" and user.id : "S-1-5-18") and
  not (process.name : "cmd.exe" and
       process.command_line : "cmd /C if exist \"%appdata%/Messenger\" rmdir \"%appdata%/Messenger\" /s /q & if exist \"%appdata%/chatgenie\" rmdir \"%appdata%/chatgenie\" /s /q") and
  not (process.executable : "?:\\Windows\\Sys*\\msiexec.exe" and
       process.args : "/Z" and process.args : ("C:\\Program Files (x86)\\*.dll", "C:\\Program Files\\*.dll"))
  ] by process.Ext.effective_parent.entity_id

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.parent.executablewildcard?:\Program Files (x86)\Microsoft Intune Management Extension\agentexecutor.exe, ?:\Program Files (x86)\ScreenConnect Client*\ScreenConnect.WindowsBackstageShell.exe, ?:\Program Files (x86)\ManageEngine\UEMS_Agent\bin\dctask64.exe, C:\Program Files (x86)\FastTrack Software\Admin By Request\AdminByRequest.exe, C:\Program Files\Oracle Cloud Agent\plugins\unifiedmonitoring\unifiedmonitoring.exeexcludes:process.parent.executable
user.ideqS-1-5-18excludes:user.id field:"user.id" value:"S-1-5-18"
process.argseq/Zexcludes:process.args field:"process.args" value:"/Z"
process.argswildcardC:\Program Files (x86)\*.dll, C:\Program Files\*.dllexcludes:process.args field:"process.args" value:"C:\Program Files (x86)\*.dll" field:"process.args" value:"C:\Program Files\*.dll"
process.executablewildcard?:\Windows\Sys*\msiexec.exeexcludes:process.executable field:"process.executable" value:"?:\Windows\Sys*\msiexec.exe"
process.command_lineeqcmd /C if exist "%appdata%/Messenger" rmdir "%appdata%/Messenger" /s /q & if exist "%appdata%/chatgenie" rmdir "%appdata%/chatgenie" /s /qexcludes:process.command_line
process.nameeqcmd.exeexcludes:process.name field:"process.name" value:"cmd.exe"
process.nameeqregsvr32.exeexcludes:process.name field:"process.name" value:"regsvr32.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.namewildcard
  • cmstp.exe corpus 25 (elastic 25)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • msxsl.exe corpus 23 (elastic 22, splunk 1)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard
process.parent.namewildcard
  • msiexec.exe corpus 19 (elastic 14, splunk 3, kusto 2)
field:"parent_process_name" kind:wildcard value:"msiexec.exe"