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

Analyzing Network Traffic With Wireshark

skill-killvxk-cybersecurity-skills-zh-analyzing-network-traffic-with-wireshark · by killvxk

>

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

Install

$ agentstack add skill-killvxk-cybersecurity-skills-zh-analyzing-network-traffic-with-wireshark

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

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

What it can access

  • Network access Used
  • Filesystem access No
  • Shell / process execution No
  • 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 →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-killvxk-cybersecurity-skills-zh-analyzing-network-traffic-with-wireshark)

Reliability & compatibility

Security review passed
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 With Wireshark? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

使用 Wireshark 分析网络流量

适用场景

  • 通过检查命令与控制(command-and-control)流量、数据外泄或横向移动(lateral movement)的数据包级证据,调查疑似网络入侵
  • 诊断网络性能问题,如重传、分片或 DNS 解析失败
  • 通过捕获沙盒或隔离主机的流量,分析恶意软件的通信模式
  • 通过确认实际穿越网络分段的流量,验证防火墙(firewall)和入侵检测系统(IDS)规则
  • 从捕获的网络会话中提取文件、凭据或失陷指标(IOC)

不适用于:在未经授权的网络上捕获流量、在没有法律授权的情况下拦截私人通信,或作为生产监控中全功能 SIEM 平台的替代品。

前置条件

  • 已安装 Wireshark 4.0+ 和 tshark 命令行工具
  • 进行实时数据包捕获需要 root/sudo 权限或隶属于 wireshark
  • 访问受监控网段的网络接口(物理网卡、SPAN 端口或网络分路器)
  • 足够的磁盘空间用于数据包捕获文件(繁忙的千兆链路估计每分钟 1 GB)
  • 熟悉 TCP/IP 协议、HTTP、DNS、TLS 和 SMB 的数据包层级细节

工作流程

步骤 1:配置捕获环境

设置捕获接口和过滤器,锁定相关流量:

# 列出可用接口
tshark -D

# 在 eth0 上启动捕获,使用捕获过滤器限制范围
tshark -i eth0 -f "host 10.10.5.23 and (port 80 or port 443 or port 445)" -w /tmp/capture.pcapng

# 使用环形缓冲区捕获以管理磁盘占用(10 个文件,每个 100MB)
tshark -i eth0 -b filesize:102400 -b files:10 -w /tmp/rolling_capture.pcapng

# 同时在多个接口上捕获
tshark -i eth0 -i eth1 -w /tmp/multi_interface.pcapng

对于 Wireshark GUI,在开始捕获前在"Capture Options"对话框中设置捕获过滤器。

步骤 2:应用显示过滤器进行针对性分析

# 过滤包含可疑 User-Agent 的 HTTP 流量
tshark -r capture.pcapng -Y "http.user_agent contains \"curl\" or http.user_agent contains \"Wget\""

# 查找指向可疑顶级域名的 DNS 查询
tshark -r capture.pcapng -Y "dns.qry.name contains \".xyz\" or dns.qry.name contains \".top\" or dns.qry.name contains \".tk\""

# 识别表明网络问题的 TCP 重传
tshark -r capture.pcapng -Y "tcp.analysis.retransmission"

# 过滤用于横向移动检测的 SMB 流量
tshark -r capture.pcapng -Y "smb2.cmd == 5 or smb2.cmd == 3" -T fields -e ip.src -e ip.dst -e smb2.filename

# 查找明文凭据传输
tshark -r capture.pcapng -Y "ftp.request.command == \"PASS\" or http.authbasic"

# 检测信标模式(规律间隔的连接)
tshark -r capture.pcapng -Y "ip.dst == 203.0.113.50" -T fields -e frame.time_relative -e ip.src -e tcp.dstport

步骤 3:协议专项深度分析

# 跟踪 TCP 流以重建对话
tshark -r capture.pcapng -q -z follow,tcp,ascii,0

# 分析 HTTP 请求/响应对
tshark -r capture.pcapng -Y "http" -T fields -e frame.time -e ip.src -e ip.dst -e http.request.method -e http.request.uri -e http.response.code

# 提取 DNS 查询/响应统计
tshark -r capture.pcapng -q -z dns,tree

# 分析 TLS 握手以检测弱密码套件
tshark -r capture.pcapng -Y "tls.handshake.type == 2" -T fields -e ip.src -e ip.dst -e tls.handshake.ciphersuite

# SMB 文件访问枚举
tshark -r capture.pcapng -Y "smb2" -T fields -e frame.time -e ip.src -e ip.dst -e smb2.filename -e smb2.cmd

步骤 4:提取工件和 IOC

# 导出 HTTP 对象(通过 HTTP 传输的文件)
tshark -r capture.pcapng --export-objects http,/tmp/http_objects/

# 导出 SMB 对象(通过 SMB 传输的文件)
tshark -r capture.pcapng --export-objects smb,/tmp/smb_objects/

# 提取所有唯一目标 IP 用于威胁情报查询
tshark -r capture.pcapng -T fields -e ip.dst | sort -u > unique_dest_ips.txt

# 提取 SSL/TLS 证书信息
tshark -r capture.pcapng -Y "tls.handshake.type == 11" -T fields -e x509sat.uTF8String -e x509ce.dNSName

# 提取所有访问的 URL
tshark -r capture.pcapng -Y "http.request" -T fields -e http.host -e http.request.uri | sort -u > urls.txt

# 对提取的文件进行哈希,用于 IOC 匹配
find /tmp/http_objects/ -type f -exec sha256sum {} \; > extracted_file_hashes.txt

步骤 5:统计分析与异常检测

# 协议层级统计
tshark -r capture.pcapng -q -z io,phs

# 按字节数排序的对话统计
tshark -r capture.pcapng -q -z conv,tcp -z conv,udp

# 识别最活跃主机
tshark -r capture.pcapng -q -z endpoints,ip

# IO 图数据(每秒数据包数)
tshark -r capture.pcapng -q -z io,stat,1,"COUNT(frame) frame"

# 检测端口扫描模式
tshark -r capture.pcapng -Y "tcp.flags.syn == 1 and tcp.flags.ack == 0" -T fields -e ip.src -e tcp.dstport | sort | uniq -c | sort -rn | head -20

步骤 6:生成报告和导出证据

# 将过滤后的数据包导出到新 PCAP 用于证据保全
tshark -r capture.pcapng -Y "ip.addr == 10.10.5.23 and tcp.port == 4444" -w evidence_c2_traffic.pcapng

# 以 CSV 格式生成数据包摘要
tshark -r capture.pcapng -T fields -E header=y -E separator=, -e frame.number -e frame.time -e ip.src -e ip.dst -e ip.proto -e tcp.srcport -e tcp.dstport -e frame.len > traffic_summary.csv

# 创建 PDML(XML)输出用于程序化分析
tshark -r capture.pcapng -T pdml > capture_analysis.xml

# 计算捕获文件哈希值用于证据监管链
sha256sum capture.pcapng > capture_hash.txt

核心概念

| 术语 | 定义 | |------|------------| | 捕获过滤器(BPF) | 在捕获时应用的伯克利数据包过滤器(Berkeley Packet Filter)语法,用于限制记录的数据包,减小文件大小并提升性能 | | 显示过滤器 | Wireshark 特有的过滤器语法,应用于已捕获的数据包以进行聚焦分析,不修改捕获文件 | | PCAPNG | 下一代数据包捕获格式,支持在单个文件中存储多个接口、名称解析、注释和元数据 | | TCP 流 | 重组后的 TCP 分段序列,代表两个端点之间完整的双向会话 | | 协议解析器 | Wireshark 模块,用于解码特定协议的字段和结构,实现对数据包内容的深度检查 | | IO 图 | 捕获期间数据包或字节速率的时序可视化,用于识别流量峰值或信标行为 |

工具与系统

  • Wireshark 4.0+:基于 GUI 的数据包分析器,支持 3000+ 协议的解析器、流重组和导出功能
  • tshark:Wireshark 的命令行版本,用于无界面捕获、批量处理和脚本化分析流程
  • tcpdump:轻量级数据包捕获工具,适合在无 GUI 依赖的远程系统上快速捕获
  • mergecap:Wireshark 工具,用于将多个捕获文件合并为单个 PCAP 进行统一分析
  • editcap:Wireshark 工具,用于拆分、过滤和转换捕获文件格式

常见场景

场景:调查疑似通过 DNS 隧道的数据外泄

场景背景:安全运营中心(SOC)团队检测到一台工作站(10.10.3.45)向外部域名发出异常高频的 DNS 查询。SIEM 告警显示 DNS 查询平均每分钟 200 次,而基线为 15 次。已在工作站所在 VLAN 的网络分路器上启动数据包捕获。

方法

  1. 使用 tshark -i eth2 -f "host 10.10.3.45 and port 53" -w dns_exfil_investigation.pcapng 从工作站子网捕获流量
  2. 分析 DNS 查询模式:tshark -r dns_exfil_investigation.pcapng -Y "dns.qry.name contains \"suspect-domain.xyz\"" -T fields -e frame.time -e dns.qry.name
  3. 检查子域名标签中的编码数据(长 base64 类子域名表明存在隧道):tshark -r dns_exfil_investigation.pcapng -Y "dns.qry.type == 16" -T fields -e dns.qry.name -e dns.txt
  4. 通过累加查询名称长度计算数据量,估算外泄带宽
  5. 提取唯一查询名称并解码 base64 子域名以恢复外泄内容
  6. 将证据数据包导出到独立 PCAP,并生成 SHA-256 哈希用于证据监管链

常见陷阱

  • 在繁忙网络上捕获未过滤流量,在收集到相关数据前磁盘空间耗尽
  • 使用显示过滤器代替捕获过滤器,导致文件过大、处理缓慢
  • 忽视绕过传统 53 端口 DNS 捕获的加密 DNS(DoH/DoT)流量
  • 未建立数据包捕获哈希和证据监管链文档以用于取证证据

输出格式

## 流量分析报告

**案例 ID**: IR-2024-0847
**捕获文件**: dns_exfil_investigation.pcapng
**SHA-256**: a3f2b8c1d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1
**时间范围**: 2024-03-15 14:00:00 至 14:45:00 UTC
**源接口**: eth2(VLAN 30 SPAN 端口)

### 发现

**1. DNS 隧道确认**
- 源:10.10.3.45
- 目标 DNS:8.8.8.8(转发至 ns1.suspect-domain.xyz)
- 查询量:45 分钟内 9,247 次查询(205 次/分,基线为 15 次/分)
- 平均子域名标签长度:63 字符(base64 编码数据)
- 估计外泄数据量:通过 TXT 记录响应约 2.3 MB

**2. 失陷指标**
- 域名:suspect-domain.xyz(注册于 3 天前)
- 名称服务器:ns1.suspect-domain.xyz(203.0.113.50)
- 查询模式:带 base64 编码子域名的 TXT 记录请求
- 响应模式:包含 base64 编码载荷的 TXT 记录

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.