executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
performing-dns-tunneling-detection通过计算 DNS 查询名称的香农熵(Shannon Entropy)、分析查询长度分布、检测 TXT 记录载荷以及 识别高子域名基数,检测 DNS 隧道(DNS Tunneling)攻击。使用 scapy 进行数据包捕获分析, 结合统计方法区分合法 DNS 流量和隐蔽信道。适用于数据泄露猎威场景。
Independent GitHub snapshot · Automated classification · Original documentation governs
使用熵分析和统计方法对查询名称特征进行分析,检测 DNS 流量中的 DNS 隧道指标。
import math
from collections import Counter
def shannon_entropy(data):
if not data:
return 0
counter = Counter(data)
length = len(data)
return -sum((c/length) * math.log2(c/length) for c in counter.values())
# 合法域名:低熵(~3.0-3.5)
print(shannon_entropy("www.google.com"))
# DNS 隧道:高熵(~4.0-5.0)
print(shannon_entropy("aGVsbG8gd29ybGQ.tunnel.example.com"))
关键检测指标:
from scapy.all import rdpcap, DNS, DNSQR
packets = rdpcap("dns_traffic.pcap")
for pkt in packets:
if pkt.haslayer(DNSQR):
query = pkt[DNSQR].qname.decode()
entropy = shannon_entropy(query)
if entropy > 4.0:
print(f"可疑:{query}(entropy={entropy:.2f})")