技能 数据科学 Zeek日志回波行为检测

Zeek日志回波行为检测

v20260601
detecting-beaconing-patterns-with-zeek
本工具旨在对Zeek网络连接日志(conn.log)执行统计分析,用于检测潜在的C2(命令与控制)回波行为。通过计算连接时间间隔的标准差和变异系数,可以识别出具有高度规律性、低抖动特征的周期性网络通信,是安全威胁狩猎和事件调查的关键技术。
获取技能
389 次下载
概览

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:

  1. Parse Zeek conn.log into DataFrame with ZAT LogToDataFrame
  2. Group connections by source IP and destination IP pairs
  3. Calculate inter-arrival time intervals between consecutive connections
  4. Compute standard deviation and coefficient of variation
  5. 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())
信息
Category 数据科学
Name detecting-beaconing-patterns-with-zeek
版本 v20260601
大小 8.41KB
更新时间 2026-07-13
语言