Detection rules › Elastic

Indirect Command Execution via Console Window Host

Source
github.com/elastic/protections-artifacts

Identifies abuse of the Console Window Host (conhost.exe) to execute an arbitrary executable. This behavior is used as a defense evasion technique to blend-in malicious activity with legitimate Windows software.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies abuse of the Console Window Host (conhost.exe) to execute an arbitrary executable. This behavior is used as a
defense evasion technique to blend-in malicious activity with legitimate Windows software.
"""
id = "4b61b37d-c569-444a-bafa-e29d221ee55c"
license = "Elastic License v2"
name = "Indirect Command Execution via Console Window Host"
os_list = ["windows"]
reference = ["https://lolbas-project.github.io/lolbas/Binaries/Conhost/"]
version = "1.0.32"

query = '''
process where event.action == "start" and
  process.parent.name : "conhost.exe" and process.parent.args_count >= 2 and
  process.parent.command_line : ("*conhost* *.exe*", "*cmd /c *", "*powershell*", "*script*", "*mshta*", "* curl *") and
  not process.command_line :
            ("?:\\windows\\system32\\cmd.exe",
             "?:\\windows\\SysWOW64\\cmd.exe", "cmd.exe",
             "?:\\windows\\system32\\windowspowershell\\*\\powershell.exe",
             "powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-upgrade.ps1",
             "powershell.exe -NoProfile -ExecutionPolicy Bypass -File WAU-Notify.ps1") and
  not process.parent.executable : "\\Device\\Mup\\*\\IBM\\ClientSolutions\\Start_Programs\\Windows*\\acslaunch_win-*.exe" and 
  not process.hash.sha256 : "b37565fabde8680ef7d0de3c808096b7512f42c62071f2fb486da14b773ec04a" and
  not process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
  not (process.code_signature.subject_name == "International Business Machines Corporation" and process.code_signature.trusted == true) and
  not (process.name : "powershell.exe" and process.args : "-ExecutionPolicy" and process.args : ("-F", "Stop-Process*")) and
  not (process.args in ("/bin/sh", "bash") and process.parent.args == "--height" and process.parent.args == "24")
'''

min_endpoint_version = "7.15.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 = "T1202"
name = "Indirect Command Execution"
reference = "https://attack.mitre.org/techniques/T1202/"


[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
  process.parent.name : "conhost.exe" and process.parent.args_count >= 2 and
  process.parent.command_line : ("*conhost* *.exe*", "*cmd /c *", "*powershell*", "*script*", "*mshta*", "* curl *") and
  not process.command_line :
            ("?:\\windows\\system32\\cmd.exe",
             "?:\\windows\\SysWOW64\\cmd.exe", "cmd.exe",
             "?:\\windows\\system32\\windowspowershell\\*\\powershell.exe",
             "powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-upgrade.ps1",
             "powershell.exe -NoProfile -ExecutionPolicy Bypass -File WAU-Notify.ps1") and
  not process.parent.executable : "\\Device\\Mup\\*\\IBM\\ClientSolutions\\Start_Programs\\Windows*\\acslaunch_win-*.exe" and 
  not process.hash.sha256 : "b37565fabde8680ef7d0de3c808096b7512f42c62071f2fb486da14b773ec04a" and
  not process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
  not (process.code_signature.subject_name == "International Business Machines Corporation" and process.code_signature.trusted == true) and
  not (process.name : "powershell.exe" and process.args : "-ExecutionPolicy" and process.args : ("-F", "Stop-Process*")) and
  not (process.args in ("/bin/sh", "bash") and process.parent.args == "--height" and process.parent.args == "24")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseq-ExecutionPolicyexcludes:process.args field:"process.args" value:"-ExecutionPolicy"
process.argswildcard-F, Stop-Process*excludes:process.args field:"process.args" value:"-F" field:"process.args" value:"Stop-Process*"
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.argsin/bin/sh, bashexcludes:process.args field:"process.args" value:"/bin/sh" field:"process.args" value:"bash"
process.parent.argseq--heightexcludes:process.parent.args field:"process.parent.args" value:"--height"
process.parent.argseq24excludes:process.parent.args field:"process.parent.args" value:"24"
process.code_signature.subject_nameeqInternational Business Machines Corporationexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"International Business Machines Corporation"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.command_linewildcard?:\windows\system32\cmd.exe, ?:\windows\SysWOW64\cmd.exe, cmd.exe, ?:\windows\system32\windowspowershell\*\powershell.exe, powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-upgrade.ps1, powershell.exe -NoProfile -ExecutionPolicy Bypass -File WAU-Notify.ps1excludes:process.command_line
process.executablewildcard?:\Program Files\*.exe, ?:\Program Files (x86)\*.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files\*.exe" field:"process.executable" value:"?:\Program Files (x86)\*.exe"
process.hash.sha256eqb37565fabde8680ef7d0de3c808096b7512f42c62071f2fb486da14b773ec04aexcludes:process.hash.sha256 field:"process.hash.sha256" value:"b37565fabde8680ef7d0de3c808096b7512f42c62071f2fb486da14b773ec04a"
process.parent.executablewildcard\Device\Mup\*\IBM\ClientSolutions\Start_Programs\Windows*\acslaunch_win-*.exeexcludes:process.parent.executable field:"process.parent.executable" value:"\Device\Mup\*\IBM\ClientSolutions\Start_Programs\Windows*\acslaunch_win-*.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.parent.args_countge
  • 2 transforms: number corpus 4 (elastic 4)
field:"process.parent.args_count" kind:ge value:"2"
process.parent.command_linewildcard
  • * curl *
  • *cmd /c *
  • *conhost* *.exe*
  • *mshta*
  • *powershell*
  • *script*
field:"ParentCommandLine" kind:wildcard
process.parent.namewildcard
  • conhost.exe corpus 8 (elastic 8)
field:"parent_process_name" kind:wildcard value:"conhost.exe"