Detection rules › Elastic

Command Shell Execution from Untrusted Origin

Source
github.com/elastic/protections-artifacts

Identifies the execution of Windows commands to open a file originating from an unknown remote source. Adversaries may embed malicious files in a shortcut file before delivering it to their target in order to trick them into executing the payload.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of Windows commands to open a file originating from an unknown remote source. Adversaries may
embed malicious files in a shortcut file before delivering it to their target in order to trick them into executing the
payload.
"""
id = "9287bf52-d1d8-499e-a135-a64645da6870"
license = "Elastic License v2"
name = "Command Shell Execution from Untrusted Origin"
os_list = ["windows"]
reference = [
    "https://docs.microsoft.com/en-us/windows/security/threat-protection/microsoft-defender-smartscreen/microsoft-defender-smartscreen-overview",
]
version = "1.0.2"

query = '''
process where event.action == "start" and
 process.name : ("cmd.exe", "powershell.exe") and process.parent.name : "explorer.exe" and
 process.Ext.token.security_attributes : "SMARTLOCKER://SMARTSCREENORIGINCLAIM" and
 process.parent.thread.Ext.call_stack_summary : "ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|windows.storage.dll|shell32.dll*" and
 not process.parent.thread.Ext.call_stack_summary : ("*coremessagingxp.dll*", "*ExplorerFrame.dll*") and process.args_count >= 2 and
 process.working_directory :
                 ("C:\\Windows\\System32\\*",
                  "?:\\Users\\*\\AppData\\Local\\Temp\\Temp?_*",
                  "?:\\Users\\*\\AppData\\Local\\Temp\\7z*",
                  "?:\\Users\\*\\Content.Outlook\\*",
                  "?:\\Users\\*\\Downloads\\*") and
  not (process.name : "cmd.exe" and
       process.command_line : ("*\\AppData\\Local\\Microsoft\\OneDrive\\*", "*.bat*", "*.cmd*",
       "*reg.exe delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v Bomgar_Cleanup*")) and
  not (process.name : "powershell.exe" and
       process.args : ("*-file*", "*.ps1*", "*.xml*", "*Remove-AppxPackage*", "*Get-AppxPackage*", "*Remove-ItemProperty*"))
'''

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.technique.subtechnique]]
id = "T1566.001"
name = "Spearphishing Attachment"
reference = "https://attack.mitre.org/techniques/T1566/001/"

[[threat.technique.subtechnique]]
id = "T1566.002"
name = "Spearphishing Link"
reference = "https://attack.mitre.org/techniques/T1566/002/"



[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.technique.subtechnique]]
id = "T1204.001"
name = "Malicious Link"
reference = "https://attack.mitre.org/techniques/T1204/001/"



[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") and process.parent.name : "explorer.exe" and
 process.Ext.token.security_attributes : "SMARTLOCKER://SMARTSCREENORIGINCLAIM" and
 process.parent.thread.Ext.call_stack_summary : "ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|windows.storage.dll|shell32.dll*" and
 not process.parent.thread.Ext.call_stack_summary : ("*coremessagingxp.dll*", "*ExplorerFrame.dll*") and process.args_count >= 2 and
 process.working_directory :
                 ("C:\\Windows\\System32\\*",
                  "?:\\Users\\*\\AppData\\Local\\Temp\\Temp?_*",
                  "?:\\Users\\*\\AppData\\Local\\Temp\\7z*",
                  "?:\\Users\\*\\Content.Outlook\\*",
                  "?:\\Users\\*\\Downloads\\*") and
  not (process.name : "cmd.exe" and
       process.command_line : ("*\\AppData\\Local\\Microsoft\\OneDrive\\*", "*.bat*", "*.cmd*",
       "*reg.exe delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v Bomgar_Cleanup*")) and
  not (process.name : "powershell.exe" and
       process.args : ("*-file*", "*.ps1*", "*.xml*", "*Remove-AppxPackage*", "*Get-AppxPackage*", "*Remove-ItemProperty*"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argsmatch-file, .ps1, .xml, Remove-AppxPackage, Get-AppxPackage, Remove-ItemPropertyexcludes:process.args
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.command_linematch\AppData\Local\Microsoft\OneDrive\, .bat, .cmd, reg.exe delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v Bomgar_Cleanupexcludes:process.command_line
process.nameeqcmd.exeexcludes:process.name field:"process.name" value:"cmd.exe"
process.parent.thread.Ext.call_stack_summarymatchcoremessagingxp.dll, ExplorerFrame.dllexcludes:process.parent.thread.Ext.call_stack_summary field:"process.parent.thread.Ext.call_stack_summary" value:"coremessagingxp.dll" field:"process.parent.thread.Ext.call_stack_summary" value:"ExplorerFrame.dll"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.Ext.token.security_attributeswildcard
  • SMARTLOCKER://SMARTSCREENORIGINCLAIM corpus 2 (elastic 2)
field:"process.Ext.token.security_attributes" kind:wildcard value:"SMARTLOCKER://SMARTSCREENORIGINCLAIM"
process.args_countge
  • 2 transforms: number corpus 18 (elastic 18)
field:"process.args_count" kind:ge value:"2"
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
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
  • ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|windows.storage.dll|shell32.dll*
field:"process.parent.thread.Ext.call_stack_summary" kind:wildcard value:"ntdll.dll|kernelbase.dll|kernel32.dll|windows.storage.dll|shell32.dll|windows.storage.dll|shell32.dll*"
process.working_directorywildcard
  • ?:\Users\*\AppData\Local\Temp\7z* corpus 2 (elastic 2)
  • ?:\Users\*\AppData\Local\Temp\Temp?_* corpus 2 (elastic 2)
  • ?:\Users\*\Content.Outlook\*
  • ?:\Users\*\Downloads\* corpus 2 (elastic 2)
  • C:\Windows\System32\*
field:"CurrentDirectory" kind:wildcard