Detection rules › Elastic

Windows Command Shell Spawned via Microsoft Office

Source
github.com/elastic/protections-artifacts

Identifies a Microsoft Office application starting a Windows command prompt with suspicious command line arguments. This behavior is consistent with a victim opening a malicious document and executing an attacker's malicious code.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies a Microsoft Office application starting a Windows command prompt with suspicious command line arguments. This
behavior is consistent with a victim opening a malicious document and executing an attacker's malicious code.
"""
id = "2a396a3c-b343-42a9-b74b-c5b9925b6ee2"
license = "Elastic License v2"
name = "Windows Command Shell Spawned via Microsoft Office"
os_list = ["windows"]
reference = ["https://github.com/danielbohannon/Invoke-DOSfuscation"]
version = "1.0.33"

query = '''
process where event.action == "start" and
  process.parent.name : ("excel.exe", "powerpnt.exe", "winword.exe") and
  (process.pe.original_file_name == "Cmd.Exe" or process.name : "cmd.exe") and
  process.command_line :
              ("*^*^*^*^*^*",
              "*set *set *set *",
              "*set *for *call *",
              "*set *for *cmd *",
              "*$*$*$*$*",
              "*comspec*",
              "*powershell*",
              "*wscript*",
              "*cscript*",
              "*mshta*", 
              "*certutil*", 
              "*bitsadmin*", 
              "*/transfer*",
              "*-transfer*",
              "*urlcache*", 
              "*-decode*", 
              "*addfile*",
              "*msbuild*",
              "*msiexec*",
              "*rundll32*",
              "*regsvr32*", 
              "*ping * -n *&*",
              "*http://*",
              "*%%*%%*%%*", 
              "*copy*.exe*") and
  not process.command_line : 
             ("*:\\Program Files\\Tableau\\*--server*http://tableau*", 
              "*:\\Program Files (x86)\\Tableau\\*--server*http://tableau*", 
              "\"C:\\Windows\\System32\\cmd.exe\" /c C:\\windows\\System32\\rundll32 advpack.dll,LaunchINFSection \"C:\\Users\\*\\AppData\\Roaming\\McGowan Partners LLC UAT\\setup.inf\", DefaultInstall*") and 
  not process.args : "$bytes=[System.Text.Encoding]::UTF8.GetBytes('*');$hash=[System.Security.Cryptography.SHA256]::Create().ComputeHash($bytes);[BitConverter]::ToString($hash).Replace('-','').ToLower()"
'''

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

[[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.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.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.002"
name = "Malicious File"
reference = "https://attack.mitre.org/techniques/T1204/002/"



[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.parent.name : ("excel.exe", "powerpnt.exe", "winword.exe") and
  (process.pe.original_file_name == "Cmd.Exe" or process.name : "cmd.exe") and
  process.command_line :
              ("*^*^*^*^*^*",
              "*set *set *set *",
              "*set *for *call *",
              "*set *for *cmd *",
              "*$*$*$*$*",
              "*comspec*",
              "*powershell*",
              "*wscript*",
              "*cscript*",
              "*mshta*", 
              "*certutil*", 
              "*bitsadmin*", 
              "*/transfer*",
              "*-transfer*",
              "*urlcache*", 
              "*-decode*", 
              "*addfile*",
              "*msbuild*",
              "*msiexec*",
              "*rundll32*",
              "*regsvr32*", 
              "*ping * -n *&*",
              "*http://*",
              "*%%*%%*%%*", 
              "*copy*.exe*") and
  not process.command_line : 
             ("*:\\Program Files\\Tableau\\*--server*http://tableau*", 
              "*:\\Program Files (x86)\\Tableau\\*--server*http://tableau*", 
              "\"C:\\Windows\\System32\\cmd.exe\" /c C:\\windows\\System32\\rundll32 advpack.dll,LaunchINFSection \"C:\\Users\\*\\AppData\\Roaming\\McGowan Partners LLC UAT\\setup.inf\", DefaultInstall*") and 
  not process.args : "$bytes=[System.Text.Encoding]::UTF8.GetBytes('*');$hash=[System.Security.Cryptography.SHA256]::Create().ComputeHash($bytes);[BitConverter]::ToString($hash).Replace('-','').ToLower()"

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argswildcard$bytes=[System.Text.Encoding]::UTF8.GetBytes('*');$hash=[System.Security.Cryptography.SHA256]::Create().ComputeHash($bytes);[BitConverter]::ToString($hash).Replace('-','').ToLower()excludes:process.args field:"process.args" value:"$bytes=[System.Text.Encoding]::UTF8.GetBytes('*');$hash=[System.Security.Cryptography.SHA256]::Create().ComputeHash($bytes);[BitConverter]::ToString($hash).Replace('-','').ToLower()"
process.command_linewildcard*:\Program Files\Tableau\*--server*http://tableau*, *:\Program Files (x86)\Tableau\*--server*http://tableau*, "C:\Windows\System32\cmd.exe" /c C:\windows\System32\rundll32 advpack.dll,LaunchINFSection "C:\Users\*\AppData\Roaming\McGowan Partners LLC UAT\setup.inf", DefaultInstall*excludes: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.command_linewildcard
  • *$*$*$*$* corpus 3 (elastic 3)
  • *%%*%%*%%* corpus 2 (elastic 2)
  • *-decode* corpus 2 (elastic 1, kusto 1)
  • *-transfer*
  • */transfer* corpus 2 (sigma 1, kusto 1)
  • *^*^*^*^*^*
  • *addfile* corpus 2 (elastic 2)
  • *bitsadmin* corpus 10 (sigma 10)
  • *certutil* corpus 12 (sigma 10, kusto 2)
  • *comspec*
  • *copy*.exe*
  • *cscript* corpus 15 (sigma 15)
  • *http://* corpus 23 (sigma 18, elastic 2, kusto 2, splunk 1)
  • *msbuild*
  • *mshta* corpus 14 (sigma 14)
  • *msiexec* corpus 5 (sigma 5)
  • *ping * -n *&*
  • *powershell* corpus 25 (sigma 24, chronicle 1)
  • *regsvr32* corpus 15 (sigma 15)
  • *rundll32* corpus 26 (sigma 23, chronicle 2, kusto 1)
  • *set *for *call * corpus 2 (elastic 2)
  • *set *for *cmd * corpus 2 (elastic 2)
  • *set *set *set * corpus 4 (elastic 4)
  • *urlcache* corpus 2 (sigma 1, splunk 1)
  • *wscript* corpus 16 (sigma 16)
field:"CommandLine" kind:wildcard
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
field:"process_name" kind:wildcard value:"cmd.exe"
process.parent.namewildcard
  • excel.exe corpus 28 (elastic 27, splunk 1)
  • powerpnt.exe corpus 23 (elastic 23)
  • winword.exe corpus 26 (elastic 26)
field:"parent_process_name" kind:wildcard
process.pe.original_file_nameeq
  • Cmd.Exe corpus 81 (sigma 43, elastic 21, splunk 17)
field:"OriginalFileName" kind:eq value:"Cmd.Exe"