Encoded Powershell Execution via MsiExec


Description

Detects attempts to execute encoded powershell commands via Windows Installers.

Query · eql

process where event.action == "start" and
 (process.name : "powershell.exe" or process.pe.original_file_name == "PowerShell.EXE") and
 process.args : ("-e", "-enc", "-ec", "-encod", "-encode", "iex (gc *") and
 (
  descendant of [process where event.action == "start" and process.name : "msiexec.exe"] or
  process.parent.name : "msiexec.exe"
  )
Raw source Encoded Powershell Execution via MsiExec · Elastic TOML
Esc
Published by elastic/protections-artifacts ↗, licensed under Elastic License 2.0 ↗. Reproduced here unmodified.
[rule]
description = "Detects attempts to execute encoded powershell commands via Windows Installers."
id = "5a7148dc-338a-4998-8adb-5b64d7557dfc"
license = "Elastic License v2"
name = "Encoded Powershell Execution via MsiExec"
os_list = ["windows"]
version = "1.0.3"

query = '''
process where event.action == "start" and
 (process.name : "powershell.exe" or process.pe.original_file_name == "PowerShell.EXE") and
 process.args : ("-e", "-enc", "-ec", "-encod", "-encode", "iex (gc *") and
 (
  descendant of [process where event.action == "start" and process.name : "msiexec.exe"] or
  process.parent.name : "msiexec.exe"
  )
'''

min_endpoint_version = "7.16.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[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.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"



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

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.