Detecting Beaconing Malware
Overview
Beaconing malware, like Cobalt Strike in its default configuration, often communicates with its Command and Control (C2) server at predictable intervals. By monitoring and analyzing the intervals between communications, we can identify patterns indicative of beaconing behavior. This guide provides a Splunk query to detect such patterns in HTTP traffic logs generated by Zeek.
Setting Up the Detection Query
This Splunk query identifies beaconing behavior by analyzing consistent intervals in HTTP traffic. It flags cases where most communication events occur at regular intervals, which may indicate malware beaconing.
Query Explanation
Filter for Beaconing Data:
index="cobaltstrike_beacon"andsourcetype="bro:http:json"specify the relevant data source and sourcetype for Cobalt Strike beaconing data in JSON format from Zeek logs.
Event Time Sorting:
sort 0 _timesorts events in ascending order based on their timestamp, ensuring time-based calculations are accurate.
Calculate Time Differences:
streamstatscomputes the time difference (timedelta) between consecutive events for each unique source-destination pair and destination port, grouping events bysrc,dest, anddest_port.
Calculate Average Time Interval:
eventstatscalculates the average time interval (avg) and total count of events (total) for each source-destination pair and destination port combination.
Define Acceptable Time Interval Range:
eval upper=avg*1.1andeval lower=avg*0.9set upper and lower bounds for time intervals (10% margin above and below the average).
Filter for Consistent Intervals:
where timedelta > lower AND timedelta < upperfilters events that fall within the acceptable time interval range, indicating a consistent beaconing interval.
Calculate Consistency Percentage:
statsaggregates the data and calculates the percentage (prcnt) of events falling within the defined time interval range for each connection.
Threshold Filtering:
where prcnt > 90 AND total > 10includes only results where over 90% of events fall within the beaconing pattern range and there are at least 10 events, making the detection more accurate.
Splunk Query
Field Descriptions
index="cobaltstrike_beacon": Filters events for the specific Cobalt Strike beaconing index.sourcetype="bro:http:json": Specifies the Zeek HTTP logs in JSON format as the source type.sort 0 _time: Sorts events chronologically.streamstats last(_time) as prevtime by src, dest, dest_port: Calculates the time of the previous event for each source-destination pair and port.eventstats avg(timedelta) as avg, count as total: Calculates the average interval and total count for each connection.eval upper=avg*1.1andeval lower=avg*0.9: Sets a margin for the average interval to account for slight variations.where timedelta > lower AND timedelta < upper: Filters for intervals within the margin, indicating a consistent pattern.stats count, values(avg) as TimeInterval: Aggregates results by the average interval and connection details.where prcnt > 90 AND total > 10: Retains connections with high consistency and significant event counts, reducing false positives.
Interpreting Results
Consistent Intervals: Connections showing over 90% of events within the defined time interval range suggest beaconing behavior.
Event Count Threshold: Ensuring a minimum of 10 events avoids false positives from low-activity connections.
Last updated