| name | detecting-beaconing-patterns-with-zeek |
| description | 对 Zeek conn.log 连接间隔进行统计分析,检测 C2 信标(Beaconing)模式。使用 ZAT 库将 Zeek 日志加载到 Pandas DataFrame,计算到达时间间隔标准差,标记具有低抖动(Low Jitter)的周期性连接。适用于在网络数据中狩猎命令与控制(C2)回调行为。
|
| domain | cybersecurity |
| subdomain | security-operations |
| tags | ["detecting","beaconing","patterns","with"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 Zeek 检测信标模式
使用说明
使用 ZAT(Zeek 分析工具)加载 Zeek conn.log 数据,按源/目标对分组连接,并计算时序统计信息以识别信标行为。
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')
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)
关键分析步骤:
- 使用 ZAT LogToDataFrame 将 Zeek conn.log 解析为 DataFrame
- 按源 IP 和目标 IP 对分组连接
- 计算连续连接之间的到达时间间隔
- 计算标准差和变异系数
- 将变异系数低的对标记为潜在信标
示例
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())