detecting-beaconing-patterns-with-zeek skill (Anthropic-Cybersecurity-Skills)
From Public Agent Wiki
Contents
What it does. 'Performs statistical analysis of Zeek conn.log connection intervals Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).
| Upstream | mukul975/Anthropic-Cybersecurity-Skills |
| Skill file | skills/detecting-beaconing-patterns-with-zeek/SKILL.md |
| License | Apache-2.0 (skill folder LICENSE) |
| Author | mukul975 |
| Fetched | 2026-09-10 |
Install
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill detecting-beaconing-patterns-with-zeek, or copy the skill folder into~/.claude/skills/detecting-beaconing-patterns-with-zeek/.- Raw file:
curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/detecting-beaconing-patterns-with-zeek/SKILL.md
SKILL.md (verbatim)
name: detecting-beaconing-patterns-with-zeek
description: 'Performs statistical analysis of Zeek conn.log connection intervals
to detect C2 beaconing patterns. Uses the ZAT library to load Zeek logs into Pandas
DataFrames, calculates inter-arrival time standard deviation, and flags periodic
connections with low jitter. Use when hunting for command-and-control callbacks
in network data.
'
domain: cybersecurity
subdomain: security-operations
tags:
- network-security
- zeek
- c2-beaconing
- conn-log-analysis
- zat
- threat-hunting
- statistical-analysis
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- DE.CM-01
- RS.MA-01
- GV.OV-01
- DE.AE-02
mitre_attack:
- T1071.001
- T1071.004
- T1573
- T1008
- T1095
Detecting Beaconing Patterns with Zeek
When to Use
- When investigating security incidents that require detecting beaconing patterns with zeek
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Familiarity with security operations concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Instructions
Load Zeek conn.log data using ZAT (Zeek Analysis Tools), group connections by source/destination pairs, and compute timing statistics to identify beaconing.
from zat.log_to_dataframe import LogToDataFrame
import numpy as np
log_to_df = LogToDataFrame()
conn_df = log_to_df.create_dataframe('/path/to/conn.log')
# Group by src/dst pair and calculate inter-arrival time
for (src, dst), group in conn_df.groupby(['id.orig_h', 'id.resp_h']):
times = group['ts'].sort_values()
intervals = times.diff().dt.total_seconds().dropna()
if len(intervals) > 10:
std_dev = np.std(intervals)
mean_interval = np.mean(intervals)
# Low std_dev relative to mean = likely beaconing
Key analysis steps:
- Parse Zeek conn.log into DataFrame with ZAT LogToDataFrame
- Group connections by source IP and destination IP pairs
- Calculate inter-arrival time intervals between consecutive connections
- Compute standard deviation and coefficient of variation
- Flag pairs with low coefficient of variation as potential beacons
Examples
from zat.log_to_dataframe import LogToDataFrame
log_to_df = LogToDataFrame()
df = log_to_df.create_dataframe('conn.log')
print(df[['id.orig_h', 'id.resp_h', 'ts', 'duration']].head())
Other files in this skill
references/api-reference.md (verbatim)
API Reference: Detecting Beaconing Patterns with Zeek
ZAT (Zeek Analysis Tools)
from zat.log_to_dataframe import LogToDataFrame
from zat import zeek_log_reader
from zat.utils import dataframe_to_matrix
# Load conn.log into DataFrame
log_to_df = LogToDataFrame()
conn_df = log_to_df.create_dataframe('/path/to/conn.log')
# Select specific columns
conn_df = log_to_df.create_dataframe('conn.log',
usecols=['id.orig_h', 'id.resp_h', 'id.resp_p', 'ts', 'duration'])
# Read rows as dicts (streaming)
reader = zeek_log_reader.ZeekLogReader('conn.log')
for row in reader.readrows():
print(row)
# Tail mode (live monitoring)
reader = zeek_log_reader.ZeekLogReader('conn.log', tail=True)
for row in reader.readrows():
process(row)
# Convert to matrix for ML
to_matrix = dataframe_to_matrix.DataFrameToMatrix()
matrix = to_matrix.fit_transform(conn_df[features])
Beaconing Detection Math
import numpy as np
intervals = times.diff().dt.total_seconds().dropna().values
std_dev = np.std(intervals)
mean_val = np.mean(intervals)
cv = std_dev / mean_val # Coefficient of Variation
# cv < 0.3 = likely beacon (low jitter relative to interval)
Key Zeek Log Fields
| Log | Key Fields |
|---|---|
| conn.log | id.orig_h, id.resp_h, id.resp_p, ts, duration, orig_bytes |
| dns.log | id.orig_h, query, qtype_name, answers, ts |
| ssl.log | id.orig_h, server_name, ja3, ja3s, ts |
Anomaly Detection with ZAT + scikit-learn
from sklearn.ensemble import IsolationForest
odd_clf = IsolationForest(contamination=0.35)
odd_clf.fit(zeek_matrix)
anomalies = conn_df[odd_clf.predict(zeek_matrix) == -1]
References
- ZAT: https://github.com/SuperCowPowers/zat
- ZAT examples: https://supercowpowers.github.io/zat/examples.html
- zat on PyPI: https://pypi.org/project/zat/
Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.