Detection rules › Elastic

Suspicious Cmd Execution via WMI

Source
github.com/elastic/protections-artifacts

Identifies suspicious command execution (cmd) via Windows Management Instrumentation (WMI) on a remote host. This could be indicative of adversary lateral movement.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies suspicious command execution (cmd) via Windows Management Instrumentation (WMI) on a remote host. This could
be indicative of adversary lateral movement.
"""
id = "242ccb88-5e28-4a74-ac6a-ff0e4c814ad8"
license = "Elastic License v2"
name = "Suspicious Cmd Execution via WMI"
os_list = ["windows"]
reference = [
    "https://www.elastic.co/security-labs/elastic-protects-against-data-wiper-malware-targeting-ukraine-hermeticwiper",
    "https://www.elastic.co/security-labs/operation-bleeding-bear",
    "https://www.elastic.co/security-labs/unmasking-financial-services-intrusion-ref0657",
]
version = "1.0.35"

query = '''
process where event.action == "start" and
(
 (process.name : "cmd.exe" and process.args : "/c" and process.args:"/Q" and process.parent.name : "WmiPrvSE.exe" and
  process.args : "2>&1" and process.args: "1>" and
  process.args : ("C:\\windows\\temp\\*.txt",
                  "\\Windows\\Temp\\*",
                  "-encodehex",
                  "\\\\127.0.0.1\\C$\\Windows\\Temp\\*") and
  not process.command_line : ("*servicenow\\psscript_output*", "*Impact360\\Software*")) or

 descendant of [process where event.action == "start" and process.name : "cmd.exe" and process.args : "/c" and process.args:"/Q" and
                process.parent.name : "WmiPrvSE.exe" and
                process.args : "2>&1" and process.args: "1>" and
                process.args : ("C:\\windows\\temp\\*.txt",
                                "\\Windows\\Temp\\*",
                                "-encodehex",
                                "\\\\127.0.0.1\\C$\\Windows\\Temp\\*") and
                not process.command_line : ("*servicenow\\psscript_output*", "*Impact360\\Software*")]
 ) and
 not process.executable : ("?:\\Windows\\system32\\conhost.exe", "?:\\Windows\\System32\\findstr.exe", "?:\\Windows\\System32\\chcp.com") and
 not (process.parent.name : "cmd.exe" and process.parent.command_line : "*\\127.0.0.1\\c$\\temp\\cotportal\\COT_Mid_Cluster*") and
 not process.executable : "?:\\Program Files\\MySQL\\MySQL Server *\\bin\\mysqld.exe" and
 not (process.name : ("mysqld.exe", "mysql.exe") and process.parent.args : "\\\\127.0.0.1\\c$\\temp\\*\\psscript_output_*.txt") and
 not process.command_line : ("sc  query RemoteRegistry ", "sc  start RemoteRegistry ") and
 not (process.code_signature.subject_name == "MariaDB Corporation Ab" and process.code_signature.trusted == true) and
 not (process.name : ("powershell.exe", "cmd.exe") and
      process.command_line : ("powershell  -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ*",
                              "C:\\Windows\\system32\\cmd.exe /C powershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ*"))
'''

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

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1047"
name = "Windows Management Instrumentation"
reference = "https://attack.mitre.org/techniques/T1047/"

[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
(
 (process.name : "cmd.exe" and process.args : "/c" and process.args:"/Q" and process.parent.name : "WmiPrvSE.exe" and
  process.args : "2>&1" and process.args: "1>" and
  process.args : ("C:\\windows\\temp\\*.txt",
                  "\\Windows\\Temp\\*",
                  "-encodehex",
                  "\\\\127.0.0.1\\C$\\Windows\\Temp\\*") and
  not process.command_line : ("*servicenow\\psscript_output*", "*Impact360\\Software*")) or

 descendant of [process where event.action == "start" and process.name : "cmd.exe" and process.args : "/c" and process.args:"/Q" and
                process.parent.name : "WmiPrvSE.exe" and
                process.args : "2>&1" and process.args: "1>" and
                process.args : ("C:\\windows\\temp\\*.txt",
                                "\\Windows\\Temp\\*",
                                "-encodehex",
                                "\\\\127.0.0.1\\C$\\Windows\\Temp\\*") and
                not process.command_line : ("*servicenow\\psscript_output*", "*Impact360\\Software*")]
 ) and
 not process.executable : ("?:\\Windows\\system32\\conhost.exe", "?:\\Windows\\System32\\findstr.exe", "?:\\Windows\\System32\\chcp.com") and
 not (process.parent.name : "cmd.exe" and process.parent.command_line : "*\\127.0.0.1\\c$\\temp\\cotportal\\COT_Mid_Cluster*") and
 not process.executable : "?:\\Program Files\\MySQL\\MySQL Server *\\bin\\mysqld.exe" and
 not (process.name : ("mysqld.exe", "mysql.exe") and process.parent.args : "\\\\127.0.0.1\\c$\\temp\\*\\psscript_output_*.txt") and
 not process.command_line : ("sc  query RemoteRegistry ", "sc  start RemoteRegistry ") and
 not (process.code_signature.subject_name == "MariaDB Corporation Ab" and process.code_signature.trusted == true) and
 not (process.name : ("powershell.exe", "cmd.exe") and
      process.command_line : ("powershell  -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ*",
                              "C:\\Windows\\system32\\cmd.exe /C powershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ*"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.code_signature.subject_nameeqMariaDB Corporation Abexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"MariaDB Corporation Ab"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.command_linestarts_withpowershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ, C:\Windows\system32\cmd.exe /C powershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQexcludes:process.command_line field:"process.command_line" value:"powershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ" field:"process.command_line" value:"C:\Windows\system32\cmd.exe /C powershell -EncodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACIAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQ"
process.nameeqpowershell.exe, cmd.exeexcludes:process.name field:"process.name" value:"powershell.exe" field:"process.name" value:"cmd.exe"
process.nameeqmysqld.exe, mysql.exeexcludes:process.name field:"process.name" value:"mysqld.exe" field:"process.name" value:"mysql.exe"
process.parent.argswildcard\\127.0.0.1\c$\temp\*\psscript_output_*.txtexcludes:process.parent.args field:"process.parent.args" value:"\\127.0.0.1\c$\temp\*\psscript_output_*.txt"
process.parent.command_linematch\127.0.0.1\c$\temp\cotportal\COT_Mid_Clusterexcludes:process.parent.command_line field:"process.parent.command_line" value:"\127.0.0.1\c$\temp\cotportal\COT_Mid_Cluster"
process.parent.nameeqcmd.exeexcludes:process.parent.name field:"process.parent.name" value:"cmd.exe"
process.command_lineeqsc query RemoteRegistry , sc start RemoteRegistry excludes:process.command_line field:"process.command_line" value:"sc query RemoteRegistry " field:"process.command_line" value:"sc start RemoteRegistry "
process.executableeq?:\Windows\system32\conhost.exe, ?:\Windows\System32\findstr.exe, ?:\Windows\System32\chcp.comexcludes:process.executable field:"process.executable" value:"?:\Windows\system32\conhost.exe" field:"process.executable" value:"?:\Windows\System32\findstr.exe" field:"process.executable" value:"?:\Windows\System32\chcp.com"
process.executablewildcard?:\Program Files\MySQL\MySQL Server *\bin\mysqld.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files\MySQL\MySQL Server *\bin\mysqld.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.argswildcard
  • -encodehex
  • /Q corpus 7 (elastic 7)
  • /c corpus 7 (elastic 7)
  • 1> corpus 2 (elastic 2)
  • 2>&1 corpus 2 (elastic 2)
  • C:\windows\temp\*.txt corpus 2 (elastic 2)
  • \Windows\Temp\*
  • \\127.0.0.1\C$\Windows\Temp\*
field:"process.args" kind:wildcard
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
field:"process_name" kind:wildcard value:"cmd.exe"
process.parent.namewildcard
  • WmiPrvSE.exe corpus 25 (elastic 19, splunk 5, kusto 1)
field:"parent_process_name" kind:wildcard value:"WmiPrvSE.exe"