Detection rules › Elastic

Suspicious Command Execution via Windows Run

Source
github.com/elastic/protections-artifacts

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

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.

FieldKindExcluded valuesSearch
process.argseq-commandexcludes:process.args field:"process.args" value:"-command"
process.argseqvncexcludes:process.args field:"process.args" value:"vnc"
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.argswildcard*.bat*, *.cmd, dir, ipconfig, C:\WINDOWS\system32\sconfig.cmd , Code\bin\code.cmd , mkdir, C:\Users\*.cmd excludes:process.args
process.nameeqcmd.exeexcludes:process.name field:"process.name" value:"cmd.exe"
process.argswildcard?:\*.msiexcludes:process.args field:"process.args" value:"?:\*.msi"
process.nameeqmsiexec.exeexcludes:process.name field:"process.name" value:"msiexec.exe"
process.argswildcardStart-Process powershell -Verb RunAs, C:\*.ps1, -SPLAGroup, \\*\netlogon\*.ps1excludes:process.args
process.argswildcard\\*\MapNetworkDrives.vbs, ?:\*.js, ?:\*.vbsexcludes:process.args field:"process.args" value:"\\*\MapNetworkDrives.vbs" field:"process.args" value:"?:\*.js" field:"process.args" value:"?:\*.vbs"
process.nameeqwscript.exe, cscript.exeexcludes:process.name field:"process.name" value:"wscript.exe" field:"process.name" value:"cscript.exe"
process.argswildcard\\*\SYSVOL\*.msiexcludes:process.args field:"process.args" value:"\\*\SYSVOL\*.msi"
process.nameeqmsiexec.exe, powershell.exe, wscript.exeexcludes:process.name field:"process.name" value:"msiexec.exe" field:"process.name" value:"powershell.exe" field:"process.name" value:"wscript.exe"
process.working_directorystarts_with\\excludes:process.working_directory field:"process.working_directory" value:"\\"
process.command_linewildcard"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 Bypassexcludes:process.command_line

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.args_countge
  • 2 transforms: number corpus 18 (elastic 18)
field:"process.args_count" kind:ge value:"2"
process.command_linewildcard
  • *\\*@*,* corpus 2 (elastic 2)
field:"CommandLine" kind:wildcard value:"*\\*@*,*"
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • curl.exe corpus 34 (elastic 31, splunk 3)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • msiexec.exe corpus 46 (elastic 41, splunk 5)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard
process.parent.namewildcard
  • explorer.exe corpus 51 (elastic 50, splunk 1)
field:"parent_process_name" kind:wildcard value:"explorer.exe"
process.parent.thread.Ext.call_stack_summarywildcard
  • *|user32.dll|shell32.dll|explorer.exe|shcore.dll|*
  • ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|user32.dll|shell32.dll|explorer.exe|shcore.dll|*
field:"process.parent.thread.Ext.call_stack_summary" kind:wildcard