Detecting Cobalt Strike's PSExec
Splunk Query for Detecting Cobalt Strike’s PSExec
The following query detects the specific behavior patterns associated with Cobalt Strike’s psexec tool, which involves opening executable files over SMB in specific paths typically used for administrative tasks.
index="cobalt_strike_psexec"
sourcetype="bro:smb_files:json"
action="SMB::FILE_OPEN"
name IN ("*.exe", "*.dll", "*.bat")
path IN ("*\\c$", "*\\ADMIN$")
size>0Query Breakdown
Data Source Selection:
index="cobalt_strike_psexec": Searches within the specified index for logs related to Cobalt Strikepsexecactivity.sourcetype="bro:smb_files:json": Filters events to include only those that match thebro:smb_files:jsonsourcetype, which represents SMB file operation logs captured by Zeek.
Filtering for File Open Actions:
action="SMB::FILE_OPEN": This narrows the search to events where a file was opened over SMB, aspsexectypically opens an executable file on the target system.
Suspicious File Names:
name IN ("*.exe", "*.dll", "*.bat"): Filters events to focus on file types commonly associated with executable code, such as.exe,.dll, and.batfiles. These file types are typical payloads that attackers use to deploy malicious services.
Administrative SMB Paths:
path IN ("*\\c$", "*\\ADMIN$"): This filters for SMB activity on administrative shares commonly used for remote administration and file transfers. The pathsC$andADMIN$are often accessed bypsexectools during payload deployment.
File Size Greater Than Zero:
size>0: Ensures that the event pertains to files that are not empty, as non-empty files are more likely to be executables or payloads rather than benign artifacts.
Interpretation and Detection Strategy
This query is designed to detect a sequence of actions consistent with Cobalt Strike’s psexec execution:
Service Creation and Payload Delivery: When
psexecdeploys a payload, it typically opens an executable file (e.g.,.exe) on the target system over SMB. Filtering by specific paths (C$andADMIN$) helps isolate activity on administrative shares, which is indicative of remote administration attempts.Identifying Potential Malicious Activity: Since legitimate administrative file operations typically do not involve arbitrary
.exe,.dll, or.batfiles on these paths, this search helps surface potential malicious activity. Additionally, focusing on non-zero file sizes eliminates irrelevant entries, further refining the results to show executable files likely linked topsexecoperations.
Last updated