Detection rules › Elastic
Suspicious Command Execution via Windows Run
Identifies the execution of Windows commands via the Windows Run window. Adversaries may use phishing to instruct the victim to copy and paste malicious commands for execution via the Windows Run menu.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Initial Access | |
| Execution |
Rule body
[rule]
description = """
Identifies the execution of Windows commands via the Windows Run window. Adversaries may use phishing to instruct the
victim to copy and paste malicious commands for execution via the Windows Run menu.
"""
id = "f4f436c8-5c4a-4f61-b0cc-17b154920887"
license = "Elastic License v2"
name = "Suspicious Command Execution via Windows Run"
os_list = ["windows"]
reference = [
"https://www.cloudsek.com/blog/unmasking-the-danger-lumma-stealer-malware-exploits-fake-captcha-pages",
]
version = "1.0.9"
query = '''
process where event.action == "start" and
(
process.name : ("cmd.exe", "powershell.exe", "curl.exe", "msiexec.exe", "mshta.exe", "wscript.exe", "cscript.exe") or
(process.name : "rundll32.exe" and process.command_line : "*\\\\*@*,*")
) and
process.parent.name : "explorer.exe" and process.args_count >= 2 and
(
process.parent.thread.Ext.call_stack_summary like "ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|user32.dll|shell32.dll|explorer.exe|shcore.dll|*" or
(process.parent.thread.Ext.call_stack_summary like "*|user32.dll|shell32.dll|explorer.exe|shcore.dll|*" and
_arraysearch(process.parent.thread.Ext.call_stack, $entry,
$entry.symbol_info like ("C:\\Windows\\System32\\user32.dll!DialogBoxParamW*",
"C:\\Windows\\System32\\user32.dll!DialogBoxIndirectParamW*",
"C:\\Windows\\System32\\shell32.dll!GetFileNameFromBrowse*")))
) and
not (process.name : "cmd.exe" and
process.args : ("*.bat*", "*.cmd", "dir", "ipconfig", "C:\\WINDOWS\\system32\\sconfig.cmd ", "Code\\bin\\code.cmd ", "mkdir",
"C:\\Users\\*.cmd ")) and
not (process.name : "powershell.exe" and process.args : ("Start-Process powershell -Verb RunAs", "C:\\*.ps1", "-SPLAGroup", "\\\\*\\netlogon\\*.ps1")) and
not (process.name : "msiexec.exe" and process.args : "?:\\*.msi") and
not process.command_line : ("\"C:\\WINDOWS\\system32\\cmd.exe\" /k net use",
"\"C:\\WINDOWS\\system32\\cmd.exe\" -a",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start terminal",
"\"C:\\WINDOWS\\system32\\cmd.exe\" D:\\",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /admin",
"\"C:\\Windows\\system32\\msiexec.exe\" /regserver",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start WindowsTerminal",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start chrome --app=D:\\Notify\\index.html",
"\"C:\\windows\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -ep bypass",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" ise",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -Command Start-Process PowerShell -Verb RunAs",
"C:\\WINDOWS\\system32\\cmd.exe /c \"\"C:\\Users\\*\\AppData\\Roaming\\npm\\*z.cmd\" \"",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -ExecutionPolicy Bypass") and
not (process.name : ("wscript.exe", "cscript.exe") and process.args : ("\\\\*\\MapNetworkDrives.vbs", "?:\\*.js", "?:\\*.vbs")) and
not (process.name : "powershell.exe" and process.args : "-command" and process.args : "vnc") and
not (process.name : ("msiexec.exe", "powershell.exe", "wscript.exe") and process.working_directory : "\\\\*") and
not (process.name : "msiexec.exe" and process.args : "\\\\*\\SYSVOL\\*.msi")
'''
min_endpoint_version = "8.10.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1566"
name = "Phishing"
reference = "https://attack.mitre.org/techniques/T1566/"
[threat.tactic]
id = "TA0001"
name = "Initial Access"
reference = "https://attack.mitre.org/tactics/TA0001/"
[[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.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"
[[threat.technique]]
id = "T1204"
name = "User Execution"
reference = "https://attack.mitre.org/techniques/T1204/"
[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[internal]
min_endpoint_version = "8.10.0"
Stages and Predicates
Stage 1: process
process where event.action == "start" and
(
process.name : ("cmd.exe", "powershell.exe", "curl.exe", "msiexec.exe", "mshta.exe", "wscript.exe", "cscript.exe") or
(process.name : "rundll32.exe" and process.command_line : "*\\\\*@*,*")
) and
process.parent.name : "explorer.exe" and process.args_count >= 2 and
(
process.parent.thread.Ext.call_stack_summary like "ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|user32.dll|shell32.dll|explorer.exe|shcore.dll|*" or
(process.parent.thread.Ext.call_stack_summary like "*|user32.dll|shell32.dll|explorer.exe|shcore.dll|*" and
_arraysearch(process.parent.thread.Ext.call_stack, $entry,
$entry.symbol_info like ("C:\\Windows\\System32\\user32.dll!DialogBoxParamW*",
"C:\\Windows\\System32\\user32.dll!DialogBoxIndirectParamW*",
"C:\\Windows\\System32\\shell32.dll!GetFileNameFromBrowse*")))
) and
not (process.name : "cmd.exe" and
process.args : ("*.bat*", "*.cmd", "dir", "ipconfig", "C:\\WINDOWS\\system32\\sconfig.cmd ", "Code\\bin\\code.cmd ", "mkdir",
"C:\\Users\\*.cmd ")) and
not (process.name : "powershell.exe" and process.args : ("Start-Process powershell -Verb RunAs", "C:\\*.ps1", "-SPLAGroup", "\\\\*\\netlogon\\*.ps1")) and
not (process.name : "msiexec.exe" and process.args : "?:\\*.msi") and
not process.command_line : ("\"C:\\WINDOWS\\system32\\cmd.exe\" /k net use",
"\"C:\\WINDOWS\\system32\\cmd.exe\" -a",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start terminal",
"\"C:\\WINDOWS\\system32\\cmd.exe\" D:\\",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /admin",
"\"C:\\Windows\\system32\\msiexec.exe\" /regserver",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start WindowsTerminal",
"\"C:\\WINDOWS\\system32\\cmd.exe\" /c start chrome --app=D:\\Notify\\index.html",
"\"C:\\windows\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -ep bypass",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" ise",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -Command Start-Process PowerShell -Verb RunAs",
"C:\\WINDOWS\\system32\\cmd.exe /c \"\"C:\\Users\\*\\AppData\\Roaming\\npm\\*z.cmd\" \"",
"\"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe\" -ExecutionPolicy Bypass") and
not (process.name : ("wscript.exe", "cscript.exe") and process.args : ("\\\\*\\MapNetworkDrives.vbs", "?:\\*.js", "?:\\*.vbs")) and
not (process.name : "powershell.exe" and process.args : "-command" and process.args : "vnc") and
not (process.name : ("msiexec.exe", "powershell.exe", "wscript.exe") and process.working_directory : "\\\\*") and
not (process.name : "msiexec.exe" and process.args : "\\\\*\\SYSVOL\\*.msi")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | eq | -command | excludes:process.args field:"process.args" value:"-command" |
process.args | eq | vnc | excludes:process.args field:"process.args" value:"vnc" |
process.name | eq | powershell.exe | excludes:process.name field:"process.name" value:"powershell.exe" |
process.args | wildcard | *.bat*, *.cmd, dir, ipconfig, C:\WINDOWS\system32\sconfig.cmd , Code\bin\code.cmd , mkdir, C:\Users\*.cmd | excludes:process.args |
process.name | eq | cmd.exe | excludes:process.name field:"process.name" value:"cmd.exe" |
process.args | wildcard | ?:\*.msi | excludes:process.args field:"process.args" value:"?:\*.msi" |
process.name | eq | msiexec.exe | excludes:process.name field:"process.name" value:"msiexec.exe" |
process.args | wildcard | Start-Process powershell -Verb RunAs, C:\*.ps1, -SPLAGroup, \\*\netlogon\*.ps1 | excludes:process.args |
process.args | wildcard | \\*\MapNetworkDrives.vbs, ?:\*.js, ?:\*.vbs | excludes:process.args field:"process.args" value:"\\*\MapNetworkDrives.vbs" field:"process.args" value:"?:\*.js" field:"process.args" value:"?:\*.vbs" |
process.name | eq | wscript.exe, cscript.exe | excludes:process.name field:"process.name" value:"wscript.exe" field:"process.name" value:"cscript.exe" |
process.args | wildcard | \\*\SYSVOL\*.msi | excludes:process.args field:"process.args" value:"\\*\SYSVOL\*.msi" |
process.name | eq | msiexec.exe, powershell.exe, wscript.exe | excludes:process.name field:"process.name" value:"msiexec.exe" field:"process.name" value:"powershell.exe" field:"process.name" value:"wscript.exe" |
process.working_directory | starts_with | \\ | excludes:process.working_directory field:"process.working_directory" value:"\\" |
process.command_line | wildcard | "C:\WINDOWS\system32\cmd.exe" /k net use, "C:\WINDOWS\system32\cmd.exe" -a, "C:\WINDOWS\system32\cmd.exe" /c start terminal, "C:\WINDOWS\system32\cmd.exe" D:\, "C:\WINDOWS\system32\cmd.exe" /admin, "C:\Windows\system32\msiexec.exe" /regserver, "C:\WINDOWS\system32\cmd.exe" /c start WindowsTerminal, "C:\WINDOWS\system32\cmd.exe" /c start chrome --app=D:\Notify\index.html, "C:\windows\system32\WindowsPowerShell\v1.0\PowerShell.exe" -ep bypass, "C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe" ise, "C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe" -Command Start-Process PowerShell -Verb RunAs, C:\WINDOWS\system32\cmd.exe /c ""C:\Users\*\AppData\Roaming\npm\*z.cmd" ", "C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe" -ExecutionPolicy Bypass | excludes:process.command_line |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"start" |
process.args_count | ge |
| field:"process.args_count" kind:ge value:"2" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard value:"*\\*@*,*" |
process.name | wildcard |
| field:"process_name" kind:wildcard |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard value:"explorer.exe" |
process.parent.thread.Ext.call_stack_summary | wildcard |
| field:"process.parent.thread.Ext.call_stack_summary" kind:wildcard |