AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL unreviewed Apache-2.0 Self-run

Analyzing Network Traffic Of Malware

skill-killvxk-cybersecurity-skills-zh-analyzing-network-traffic-of-malware · by killvxk

>

No reviews yet
0 installs
6 views
0.0% view→install

Install

$ agentstack add skill-killvxk-cybersecurity-skills-zh-analyzing-network-traffic-of-malware

Open-source listing, not yet scanned by AgentStack. Follow the source repository for install instructions.

Security review

⚠ Flagged

1 finding(s); flagged for manual review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures
  • high Dangerous shell/eval execution.

What it can access

  • Network access Used
  • Filesystem access No
  • Shell / process execution Used
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Reliability & compatibility

Not yet reviewed
0 installs to date
no reviews yet
3mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Analyzing Network Traffic Of Malware? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

分析恶意软件的网络流量

适用场景

  • 沙箱执行已捕获 PCAP 文件,需要详细分析网络行为
  • 识别 C2 协议结构,用于编写网络检测签名
  • 确定恶意软件泄露的数据及其目标外部基础设施
  • 分析 DNS 隧道、域名生成算法(DGA)或快速通量行为
  • 根据观察到的恶意软件网络模式创建 Suricata/Snort 签名

不适用于恶意软件行为的基于主机的分析;请使用 Cuckoo 沙箱报告或 Volatility 内存分析进行进程级活动分析。

前置条件

  • Wireshark 4.x,用于交互式 PCAP 分析
  • tshark(Wireshark CLI),用于脚本化数据包提取
  • Zeek,用于从 PCAP 自动生成元数据
  • Suricata,带 ET Open/ET Pro 规则集用于签名匹配
  • NetworkMiner,用于从 PCAP 中提取文件和检测凭据
  • Python 3.8+,安装 scapydpkt 用于程序化数据包分析

工作流程

步骤 1:PCAP 初步概览

获取网络流量的高层次理解:

# 捕获统计
capinfos malware.pcap

# 协议层次
tshark -r malware.pcap -q -z io,phs

# 端点统计(主要通信方)
tshark -r malware.pcap -q -z endpoints,ip

# 会话统计
tshark -r malware.pcap -q -z conv,tcp

# DNS 查询摘要
tshark -r malware.pcap -q -z dns,tree

步骤 2:分析 DNS 活动

检查 DNS 查询中的 DGA、隧道或 C2 域名解析:

# 提取所有 DNS 查询
tshark -r malware.pcap -T fields -e frame.time -e dns.qry.name -e dns.a \
  -Y "dns.flags.response == 1" | sort

# 检测 DGA 模式(高熵域名)
python3  0)

# 从 tshark 输出解析 DNS 查询
import subprocess
result = subprocess.run(
    ["tshark", "-r", "malware.pcap", "-T", "fields", "-e", "dns.qry.name",
     "-Y", "dns.flags.response == 0"],
    capture_output=True, text=True
)

domains = set(result.stdout.strip().split('\n'))
print("可疑 DNS 查询(高熵):")
for domain in domains:
    if domain:
        subdomain = domain.split('.')[0]
        ent = entropy(subdomain)
        if ent > 3.5 and len(subdomain) > 10:
            print(f"  {domain}(熵值:{ent:.2f})")
PYEOF

# 检测 DNS 隧道(大型 TXT 响应)
tshark -r malware.pcap -T fields -e dns.qry.name -e dns.txt \
  -Y "dns.resp.type == 16 and dns.resp.len > 100"

步骤 3:分析 HTTP/HTTPS C2 通信

检查基于 Web 的命令与控制流量:

# 提取 HTTP 请求
tshark -r malware.pcap -T fields \
  -e frame.time -e ip.src -e ip.dst -e http.host \
  -e http.request.method -e http.request.uri -e http.user_agent \
  -Y "http.request"

# 提取 HTTP 响应体(潜在的载荷下载)
tshark -r malware.pcap -T fields \
  -e http.host -e http.request.uri -e http.content_type -e tcp.len \
  -Y "http.response and tcp.len > 1000"

# 提取 POST 数据(潜在的数据泄露)
tshark -r malware.pcap -T fields \
  -e http.host -e http.request.uri -e http.file_data \
  -Y "http.request.method == POST"

# TLS 分析(SNI、JA3 指纹)
tshark -r malware.pcap -T fields \
  -e tls.handshake.extensions_server_name \
  -e tls.handshake.ja3 \
  -Y "tls.handshake.type == 1"

# 提取 TLS 证书详情
tshark -r malware.pcap -T fields \
  -e x509ce.dNSName -e x509af.serialNumber \
  -e x509sat.utf8String \
  -Y "tls.handshake.type == 11"

# 导出 HTTP 对象(下载的文件)
tshark -r malware.pcap --export-objects http,exported_files/

步骤 4:检测信标模式

识别表明 C2 信标的规律周期性通信:

# 从 PCAP 进行信标检测
from scapy.all import rdpcap, IP, TCP
from collections import defaultdict
import statistics

packets = rdpcap("malware.pcap")

# 按目标 IP:端口分组连接
connections = defaultdict(list)
for pkt in packets:
    if IP in pkt and TCP in pkt:
        if pkt[TCP].flags & 0x02:  # SYN 标志
            dst = f"{pkt[IP].dst}:{pkt[TCP].dport}"
            connections[dst].append(float(pkt.time))

# 分析时序间隔以检测信标
print("信标分析:")
for dst, times in connections.items():
    if len(times) >= 5:
        intervals = [times[i+1] - times[i] for i in range(len(times)-1)]
        avg = statistics.mean(intervals)
        stdev = statistics.stdev(intervals) if len(intervals) > 1 else 0
        jitter = (stdev / avg * 100) if avg > 0 else 0

        if 10  custom_malware.rules
# 基于观察到的 URI 模式的 C2 信标检测
alert http $HOME_NET any -> $EXTERNAL_NET any (
    msg:"MALWARE MalwareX C2 Beacon";
    flow:established,to_server;
    http.method; content:"POST";
    http.uri; content:"/gate.php?id=";
    http.user_agent; content:"Mozilla/5.0 (compatible; MSIE 10.0)";
    sid:9000001; rev:1;
)

# 已知 C2 域名的 DNS 查询
alert dns $HOME_NET any -> any any (
    msg:"MALWARE MalwareX C2 DNS Query";
    dns.query; content:"update.malicious.com";
    sid:9000002; rev:1;
)

# 恶意软件 TLS 客户端的 JA3 哈希匹配
alert tls $HOME_NET any -> $EXTERNAL_NET any (
    msg:"MALWARE MalwareX JA3 Match";
    ja3.hash; content:"a0e9f5d64349fb13191bc781f81f42e1";
    sid:9000003; rev:1;
)
EOF

步骤 6:从流量中提取文件和工件

恢复传输的文件和嵌入数据:

# 使用 Zeek 提取文件
zeek -r malware.pcap /opt/zeek/share/zeek/policy/frameworks/files/extract-all-files.zeek
ls extract_files/

# 使用 NetworkMiner 提取文件(GUI)
# 或使用 tshark 导出特定协议
tshark -r malware.pcap --export-objects http,http_objects/
tshark -r malware.pcap --export-objects smb,smb_objects/
tshark -r malware.pcap --export-objects tftp,tftp_objects/

# 对所有提取的文件计算哈希值
sha256sum http_objects/* smb_objects/* 2>/dev/null

# 生成 Zeek 日志以获取全面的元数据
zeek -r malware.pcap
# 输出:conn.log, dns.log, http.log, ssl.log, files.log 等

核心概念

| 术语 | 定义 | |------|------------| | 信标(Beaconing) | 恶意软件到 C2 服务器的规律性周期连接,通过一致的时间间隔和数据包大小识别 | | JA3/JA3S | TLS 指纹方法,通过 ClientHello/ServerHello 参数创建哈希值,唯一标识恶意软件 TLS 实现 | | DGA(域名生成算法) | 生成恶意软件查询以定位 C2 服务器的伪随机域名的算法,规避静态域名黑名单 | | DNS 隧道 | 将数据编码在 DNS 查询和响应中,通过 DNS 基础设施建立 C2 信道或泄露数据 | | 快速通量(Fast Flux) | DNS 技术,快速轮换域名的 IP 地址以避免下线,并将 C2 分布到许多被攻陷的主机 | | SNI(服务器名称指示) | TLS 扩展,显示客户端连接的主机名;即使在加密的 HTTPS 连接中也可见 | | 网络签名 | Suricata/Snort 规则,匹配网络流量(头部、载荷、时序)中的特定模式以检测恶意通信 |

工具与系统

  • Wireshark:开源数据包分析器,用于在协议级深入交互检查网络流量
  • Zeek:网络分析框架,从实时或捕获的流量生成结构化元数据日志(conn、dns、http、ssl)
  • Suricata:高性能网络 IDS/IPS,带 Lua 脚本支持签名检测和自定义检测逻辑
  • NetworkMiner:网络取证分析工具,用于从 PCAP 文件中提取文件、图像和凭据
  • Scapy:Python 数据包处理库,用于程序化数据包分析、信标检测和协议解码

常见场景

场景:解码自定义二进制 C2 协议

场景背景:恶意软件通过 TCP 端口 8443 使用自定义二进制协议与 C2 服务器通信。标准 HTTP 分析无结果。需要从 PCAP 逆向工程协议结构。

方法

  1. 过滤 TCP 端口 8443 的会话并跟踪 TCP 流
  2. 识别消息框架(长度前缀、分隔符、固定大小头部)
  3. 比较多条消息以识别静态头部字段与可变数据字段
  4. 与 Ghidra 的逆向工程结果交叉验证(如果已分析二进制文件)
  5. 为自定义协议编写 Wireshark 解析器或 Scapy 解析器
  6. 创建 Suricata 规则,匹配静态头部字节用于网络检测
  7. 记录完整的协议规范用于威胁情报共享

常见陷阱

  • 只分析最初几个数据包;某些 C2 协议在初始握手后会改变行为
  • 当沙箱具有 MITM 能力时未解密 TLS 流量
  • 将合法的 CDN 或云流量与 C2 混淆(验证目标 IP)
  • 遗漏使用 DNS 或 ICMP 而非 TCP/UDP 的 C2 流量

输出格式

恶意软件网络流量分析
===================================
PCAP 文件:      malware_sandbox.pcap
时长:           300 秒
总数据包:       12,847
总字节数:       4.2 MB

DNS 活动
总查询数:       47
检测到 DGA:     是(23 个高熵查询到 .com TLD)
隧道:           否
解析的 C2:      update.malicious[.]com -> 185.220.101[.]42

C2 通信
协议:           HTTPS(TLS 1.2)
服务器:         185.220.101[.]42:443
SNI:            update.malicious[.]com
JA3 哈希:       a0e9f5d64349fb13191bc781f81f42e1
信标间隔:       60.2s ± 6.8s(抖动 11.3%)
总会话数:       237
发送数据:       147 MB
接收数据:       2.3 MB
证书:           CN=update.malicious[.]com(自签名,已过期)

载荷下载
GET /payload.dll from compromised-site[.]com
  大小:98,304 字节
  SHA-256:abc123def456...
  Content-Type:application/octet-stream

数据泄露
方法:           HTTPS POST 到 /gate.php
Content-Type:   application/octet-stream
平均大小:       每次请求 15,432 字节
总量:           4 小时内 147 MB

SURICATA 告警
[1:2028401] ET MALWARE Generic C2 Beacon Pattern
[1:2028500] ET POLICY Self-Signed Certificate

生成的签名
SID 9000001:MalwareX HTTP 信标模式
SID 9000002:MalwareX DNS C2 域名
SID 9000003:MalwareX JA3 TLS 指纹

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.