
关于
使用 Wireshark 执行全面的网络流量分析,捕获、过滤和检查网络数据包,用于安全审计、性能诊断和协议分析。
name: wireshark-analysis description: "使用 Wireshark 执行全面的网络流量分析,捕获、过滤和检查网络数据包,用于安全调查、性能优化和故障排除。" risk: unknown source: community author: zebbern date_added: "2026-02-27"
Wireshark 网络流量分析
用途
使用 Wireshark 执行全面的网络流量分析,捕获、过滤和检查网络数据包,用于安全调查、性能优化和故障排除。本技能支持系统化分析网络协议、检测异常行为,以及从 PCAP 文件中重建网络会话。
输入 / 前置条件
必需工具
- 已安装 Wireshark(Windows、macOS 或 Linux)
- 具有捕获权限的网络接口
- 用于离线分析的 PCAP/PCAPNG 文件
- 实时捕获需要管理员/root 权限
技术要求
- 理解网络协议(TCP、UDP、HTTP、DNS)
- 熟悉 IP 地址和端口
- 了解 OSI 模型各层
- 理解常见攻击模式
使用场景
- 网络故障排除和连接问题诊断
- 安全事件调查
- 恶意软件流量分析
- 性能监控和优化
- 协议学习和教育
输出 / 交付物
主要输出
- 针对特定流量的过滤数据包捕获
- 重建的通信流
- 流量统计和可视化图表
- 事件证据文档
核心工作流
阶段 1:捕获网络流量
启动实时捕获
在网络接口上开始捕获数据包:
1. Launch Wireshark
2. Select network interface from main screen
3. Click shark fin icon or double-click interface
4. Capture begins immediately
捕获控制
| 操作 | 快捷键 | 描述 | |------|--------|------| | 开始/停止捕获 | Ctrl+E | 切换捕获开关 | | 重启捕获 | Ctrl+R | 停止并开始新捕获 | | 打开 PCAP 文件 | Ctrl+O | 加载已有捕获文件 | | 保存捕获 | Ctrl+S | 保存当前捕获 |
捕获过滤器
在捕获前应用过滤器以限制数据收集:
# Capture only specific host
host 192.168.1.100
# Capture specific port
port 80
# Capture specific network
net 192.168.1.0/24
# Exclude specific traffic
not arp
# Combine filters
host 192.168.1.100 and port 443
阶段 2:显示过滤器
基本过滤语法
过滤已捕获的数据包进行分析:
# IP address filters
ip.addr == 192.168.1.1 # All traffic to/from IP
ip.src == 192.168.1.1 # Source IP only
ip.dst == 192.168.1.1 # Destination IP only
# Port filters
tcp.port == 80 # TCP port 80
udp.port == 53 # UDP port 53
tcp.dstport == 443 # Destination port 443
tcp.srcport == 22 # Source port 22
协议过滤器
按特定协议过滤:
# Common protocols
http # HTTP traffic
https or ssl or tls # Encrypted web traffic
dns # DNS queries and responses
ftp # FTP traffic
ssh # SSH traffic
icmp # Ping/ICMP traffic
arp # ARP requests/responses
dhcp # DHCP traffic
smb or smb2 # SMB file sharing
TCP 标志过滤器
识别特定连接状态:
tcp.flags.syn == 1 # SYN packets (connection attempts)
tcp.flags.ack == 1 # ACK packets
tcp.flags.fin == 1 # FIN packets (connection close)
tcp.flags.reset == 1 # RST packets (connection reset)
tcp.flags.syn == 1 && tcp.flags.ack == 0 # SYN-only (initial connection)
内容过滤器
搜索特定内容:
frame contains "password" # Packets containing string
http.request.uri contains "login" # HTTP URIs with string
tcp contains "GET" # TCP packets with string
分析过滤器
识别潜在问题:
tcp.analysis.retransmission # TCP retransmissions
tcp.analysis.duplicate_ack # Duplicate ACKs
tcp.analysis.zero_window # Zero window (flow control)
tcp.analysis.flags # Packets with issues
dns.flags.rcode != 0 # DNS errors
组合过滤器
使用逻辑运算符构建复杂查询:
# AND operator
ip.addr == 192.168.1.1 && tcp.port == 80
# OR operator
dns || http
# NOT operator
!(arp || icmp)
# Complex combinations
(ip.src == 192.168.1.1 || ip.src == 192.168.1.2) && tcp.port == 443
阶段 3:跟踪流
TCP 流重建
查看完整的 TCP 会话:
1. Right-click on any TCP packet
2. Select Follow -> TCP Stream
3. View reconstructed conversation
4. Use stream index to navigate between conversations
统计分析
- Statistics -> Conversations:查看所有网络会话
- Statistics -> Protocol Hierarchy:查看协议分布
- Statistics -> I/O Graphs:查看流量时间线
- Statistics -> Endpoints:查看所有通信端点
阶段 4:安全分析
常见安全指标
- 异常 DNS 查询(可能的数据外泄)
- 大量失败连接(端口扫描)
- 非标准端口上的加密流量
- 异常数据传输模式
- 可疑的 HTTP User-Agent 字符串
导出证据
- File -> Export Objects -> HTTP:提取传输的文件
- File -> Export Packet Dissections:导出分析报告
- File -> Export Specified Packets:导出过滤后的数据包
兼容工具
Claude CodeCursor
标签
安全
