Detection rule
Potential CobaltStrike Process Patterns
Overview
Detects potential process patterns related to Cobalt Strike beacon activity
- Rule id
f35c5d71-b489-4e22-a115-f003df287317- ATT&CK techniques
- T1059 Command and Scripting Interpreter
- Severity
- High
- Confidence
- Low
- Origin
- SigmaHQ (community)
- SigmaHQ status
test- Used in defense packs
- n0n, The Gentlemen, Akira, safepay, rhysida, Play, nightspire, majinahanashi
Validation
- ExperimentalSyntax checked only. Not yet tested on events.
- Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
- SIEM-validatedRun in a real SIEM, with a recorded result.
2 of 2 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.
Detection logic and queries
Queries are shown exactly as generated. Test them in your environment before you deploy them.
Sigma
Sigma (YAML) · f35c5d71-b489-4e22-a115-f003df287317
title: Potential CobaltStrike Process Patterns
id: f35c5d71-b489-4e22-a115-f003df287317
status: test
description: Detects potential process patterns related to Cobalt Strike beacon activity
references:
- https://hausec.com/2021/07/26/cobalt-strike-and-tradecraft/
- https://thedfirreport.com/2021/08/29/cobalt-strike-a-defenders-guide/
author: Florian Roth (Nextron Systems), Nasreddine Bencherchali (Nextron Systems)
date: 2021-07-27
modified: 2023-03-29
tags:
- attack.execution
- attack.t1059
logsource:
category: process_creation
product: windows
detection:
selection_generic_1:
CommandLine|endswith: 'cmd.exe /C whoami'
ParentImage|startswith: 'C:\Temp\'
selection_generic_2:
ParentImage|endswith:
- '\runonce.exe'
- '\dllhost.exe'
CommandLine|contains|all:
- 'cmd.exe /c echo'
- '> \\\\.\\pipe'
selection_conhost_1:
ParentCommandLine|contains|all:
- 'cmd.exe /C echo'
- ' > \\\\.\\pipe'
CommandLine|endswith: 'conhost.exe 0xffffffff -ForceV1'
selection_conhost_2:
ParentCommandLine|endswith: '/C whoami'
CommandLine|endswith: 'conhost.exe 0xffffffff -ForceV1'
condition: 1 of selection_*
falsepositives:
- Unknown
level: highQRadar AQL
IBM QRadar AQL (hunting query)Hunting query
Hunting search for the Log Activity tab or the API. It is not a QRadar rule.
AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).
SELECT * FROM events WHERE devicetype=12 AND ((LOWER(Command) LIKE '%cmd.exe /c whoami' AND LOWER("Parent Process Path") LIKE 'c:\temp\%') OR ((LOWER("Parent Process Path") LIKE '%\runonce.exe' OR LOWER("Parent Process Path") LIKE '%\dllhost.exe') AND (LOWER(Command) LIKE '%cmd.exe /c echo%' AND LOWER(Command) LIKE '%> \\.\pipe%')) OR ((LOWER("Parent Command") LIKE '%cmd.exe /c echo%' AND LOWER("Parent Command") LIKE '% > \\.\pipe%') AND LOWER(Command) LIKE '%conhost.exe 0xffffffff -forcev1') OR (LOWER("Parent Command") LIKE '%/c whoami' AND LOWER(Command) LIKE '%conhost.exe 0xffffffff -forcev1'))QRadar CRE
Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.
- Rule name
OffSet7: Potential CobaltStrike Process Patterns- Rule type
- Event rule (Local)
- Log source types
- Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1
Building blocks
BB:OffSet7:Potential CobaltStrike Process Patterns:selection_generic_1(match)All test lines must match (AND).Commandends with:cmd.exe /C whoamiParent Process Pathstarts with:C:\Temp\
BB:OffSet7:Potential CobaltStrike Process Patterns:selection_generic_2(match)All test lines must match (AND).Parent Process Pathends with:\runonce.exe,\dllhost.exeCommandcontains:cmd.exe /c echo,> \\\\.\\pipe
BB:OffSet7:Potential CobaltStrike Process Patterns:selection_conhost_1(match)All test lines must match (AND).Parent Commandcontains:cmd.exe /C echo,> \\\\.\\pipeCommandends with:conhost.exe 0xffffffff -ForceV1
BB:OffSet7:Potential CobaltStrike Process Patterns:selection_conhost_2(match)All test lines must match (AND).Parent Commandends with:/C whoamiCommandends with:conhost.exe 0xffffffff -ForceV1
Main rule, option A (building blocks)
- when the event(s) were detected by one or more of these log source types:
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1 - when an event matches the condition built from these building blocks:
(ANY of [BB:OffSet7:Potential CobaltStrike Process Patterns:selection_generic_1, BB:OffSet7:Potential CobaltStrike Process Patterns:selection_generic_2, BB:OffSet7:Potential CobaltStrike Process Patterns:selection_conhost_1, BB:OffSet7:Potential CobaltStrike Process Patterns:selection_conhost_2])
Main rule, option B (AQL filter test)
- when the event matches this AQL filter query:
devicetype=12 AND ((LOWER(Command) LIKE '%cmd.exe /c whoami' AND LOWER("Parent Process Path") LIKE 'c:\temp\%') OR ((LOWER("Parent Process Path") LIKE '%\runonce.exe' OR LOWER("Parent Process Path") LIKE '%\dllhost.exe') AND (LOWER(Command) LIKE '%cmd.exe /c echo%' AND LOWER(Command) LIKE '%> \\.\pipe%')) OR ((LOWER("Parent Command") LIKE '%cmd.exe /c echo%' AND LOWER("Parent Command") LIKE '% > \\.\pipe%') AND LOWER(Command) LIKE '%conhost.exe 0xffffffff -forcev1') OR (LOWER("Parent Command") LIKE '%/c whoami' AND LOWER(Command) LIKE '%conhost.exe 0xffffffff -forcev1'))
Rule response
- Severity 7, credibility 6, relevance 7
- Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
- Respond no more than once per 30 minutes per Log Source (tune per environment)
Limitations
- QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.
Splunk
Splunk SPLSearch
Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.
(CommandLine="*cmd.exe /C whoami" ParentImage="C:\\Temp\\*") OR ((ParentImage IN ("*\\runonce.exe", "*\\dllhost.exe")) CommandLine="*cmd.exe /c echo*" CommandLine="*> \\\\.\\pipe*") OR (ParentCommandLine="*cmd.exe /C echo*" ParentCommandLine="* > \\\\.\\pipe*" CommandLine="*conhost.exe 0xffffffff -ForceV1") OR (ParentCommandLine="*/C whoami" CommandLine="*conhost.exe 0xffffffff -ForceV1")Splunk savedsearches.conf stanzaScheduled search template
Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.
[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now
[Potential CobaltStrike Process Patterns]
description = Detects potential process patterns related to Cobalt Strike beacon activity
search = (CommandLine="*cmd.exe /C whoami" ParentImage="C:\\Temp\\*") OR ((ParentImage IN ("*\\runonce.exe", "*\\dllhost.exe")) CommandLine="*cmd.exe /c echo*" CommandLine="*> \\\\.\\pipe*") OR (ParentCommandLine="*cmd.exe /C echo*" ParentCommandLine="* > \\\\.\\pipe*" CommandLine="*conhost.exe 0xffffffff -ForceV1") OR (ParentCommandLine="*/C whoami" CommandLine="*conhost.exe 0xffffffff -ForceV1")Microsoft Sentinel
Microsoft Sentinel KQL (ASIM)Hunting query
Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.
imProcessCreate
| where (TargetProcessCommandLine endswith "cmd.exe /C whoami" and (ParentProcessName startswith "C:\\Temp\\" or ActingProcessName startswith "C:\\Temp\\")) or (((ParentProcessName endswith "\\runonce.exe" or ParentProcessName endswith "\\dllhost.exe") or (ActingProcessName endswith "\\runonce.exe" or ActingProcessName endswith "\\dllhost.exe")) and (TargetProcessCommandLine contains "cmd.exe /c echo" and TargetProcessCommandLine contains "> \\\\.\\pipe")) or ((ActingProcessCommandLine contains "cmd.exe /C echo" and ActingProcessCommandLine contains " > \\\\.\\pipe") and TargetProcessCommandLine endswith "conhost.exe 0xffffffff -ForceV1") or (ActingProcessCommandLine endswith "/C whoami" and TargetProcessCommandLine endswith "conhost.exe 0xffffffff -ForceV1")Defender XDR
Microsoft Defender XDR KQLHunting query
Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.
DeviceProcessEvents
| where (ProcessCommandLine endswith "cmd.exe /C whoami" and InitiatingProcessFolderPath startswith "C:\\Temp\\") or ((InitiatingProcessFolderPath endswith "\\runonce.exe" or InitiatingProcessFolderPath endswith "\\dllhost.exe") and (ProcessCommandLine contains "cmd.exe /c echo" and ProcessCommandLine contains "> \\\\.\\pipe")) or ((InitiatingProcessCommandLine contains "cmd.exe /C echo" and InitiatingProcessCommandLine contains " > \\\\.\\pipe") and ProcessCommandLine endswith "conhost.exe 0xffffffff -ForceV1") or (InitiatingProcessCommandLine endswith "/C whoami" and ProcessCommandLine endswith "conhost.exe 0xffffffff -ForceV1")Elastic
Elastic Lucene (ECS)Hunting query
Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.
(process.command_line:*cmd.exe\ \/C\ whoami AND process.parent.executable:C\:\\Temp\\*) OR ((process.parent.executable:(*\\runonce.exe OR *\\dllhost.exe)) AND (process.command_line:*cmd.exe\ \/c\ echo* AND process.command_line:*\>\ \\\\.\\pipe*)) OR ((process.parent.command_line:*cmd.exe\ \/C\ echo* AND process.parent.command_line:*\ \>\ \\\\.\\pipe*) AND process.command_line:*conhost.exe\ 0xffffffff\ \-ForceV1) OR (process.parent.command_line:*\/C\ whoami AND process.command_line:*conhost.exe\ 0xffffffff\ \-ForceV1)Elastic EQL (ECS)Hunting query
EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.
any where (process.command_line:"*cmd.exe /C whoami" and process.parent.executable:"C:\\Temp\\*") or ((process.parent.executable like~ ("*\\runonce.exe", "*\\dllhost.exe")) and (process.command_line:"*cmd.exe /c echo*" and process.command_line:"*> \\\\.\\pipe*")) or ((process.parent.command_line:"*cmd.exe /C echo*" and process.parent.command_line:"* > \\\\.\\pipe*") and process.command_line:"*conhost.exe 0xffffffff -ForceV1") or (process.parent.command_line:"*/C whoami" and process.command_line:"*conhost.exe 0xffffffff -ForceV1")Elastic ES|QL (ECS)Hunting query
ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.
from * metadata _id, _index, _version | where ends_with(process.command_line, "cmd.exe /C whoami") and starts_with(process.parent.executable, "C:\\Temp\\") or (ends_with(process.parent.executable, "\\runonce.exe") or ends_with(process.parent.executable, "\\dllhost.exe")) and process.command_line like "*cmd.exe /c echo*" and process.command_line like "*> \\\\\\\\.\\\\pipe*" or process.parent.command_line like "*cmd.exe /C echo*" and process.parent.command_line like "* > \\\\\\\\.\\\\pipe*" and ends_with(process.command_line, "conhost.exe 0xffffffff -ForceV1") or ends_with(process.parent.command_line, "/C whoami") and ends_with(process.command_line, "conhost.exe 0xffffffff -ForceV1")Required telemetry
- Log source
product: windows · category: process_creation- Fields used
CommandLineParentCommandLineParentImage
False positives
- Unknown
Investigation and response
No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.
References
Author and attribution
- Author
- Florian Roth (Nextron Systems), Nasreddine Bencherchali (Nextron Systems)
- Source
- SigmaHQ ·
rules/windows/process_creation/proc_creation_win_hktl_cobaltstrike_process_patterns.yml - Upstream commit
9688134317a2- Licence
- Detection Rule License (DRL) 1.1
Version history
- Version 1Imported from SigmaHQ
- OffSet7 build · SigmaHQ
9688134317a2