Detecting Beaconing Patterns With Zeek

对 Zeek conn.log 连接间隔进行统计分析,检测 C2 信标(Beaconing)模式。使用 ZAT 库将 Zeek 日志加载到 Pandas DataFrame,计算到达时间间隔标准差,标记具有低抖动(Low Jitter)的周期性连接。适用于在网络数据中狩猎命令与控制(C2)回调行为。

killvxk 88ab2be 4 files · 20.8 KB Updated

File contents

使用 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)
        # 相对于均值标准差低 = 可能是信标行为

关键分析步骤:

  1. 使用 ZAT LogToDataFrame 将 Zeek conn.log 解析为 DataFrame
  2. 按源 IP 和目标 IP 对分组连接
  3. 计算连续连接之间的到达时间间隔
  4. 计算标准差和变异系数
  5. 将变异系数低的对标记为潜在信标

示例

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())

killvxk/cybersecurity-skills-zh/tree/main/skills/detecting-beaconing-patterns-with-zeek commit 88ab2beb30

Frequently asked questions

npx skillmds@latest add killvxk/detecting-beaconing-patterns-with-zeek