Wireshark Network Traffic Analysis
Purpose
Execute comprehensive network traffic analysis using Wireshark to capture, filter, and examine network packets for security investigations, performance optimization, and troubleshooting. This skill enables systematic analysis of network protocols, detection of anomalies, and reconstruction of network conversations from PCAP files.
Inputs / Prerequisites
Required Tools
- - Wireshark installed (Windows, macOS, or Linux)
- Network interface with capture permissions
- PCAP/PCAPNG files for offline analysis
- Administrator/root privileges for live capture
Technical Requirements
- - Understanding of network protocols (TCP, UDP, HTTP, DNS)
- Familiarity with IP addressing and ports
- Knowledge of OSI model layers
- Understanding of common attack patterns
Use Cases
- - Network troubleshooting and connectivity issues
- Security incident investigation
- Malware traffic analysis
- Performance monitoring and optimization
- Protocol learning and education
Outputs / Deliverables
Primary Outputs
- - Filtered packet captures for specific traffic
- Reconstructed communication streams
- Traffic statistics and visualizations
- Evidence documentation for incidents
Core Workflow
Phase 1: Capturing Network Traffic
Start Live Capture
Begin capturing packets on network interface:
CODEBLOCK0
Capture Controls
| Action | Shortcut | Description |
|---|
| Start/Stop Capture | Ctrl+E | Toggle capture on/off |
| Restart Capture |
Ctrl+R | Stop and start new capture |
| Open PCAP File | Ctrl+O | Load existing capture file |
| Save Capture | Ctrl+S | Save current capture |
Capture Filters
Apply filters before capture to limit data collection:
CODEBLOCK1
Phase 2: Display Filters
Basic Filter Syntax
Filter captured packets for analysis:
CODEBLOCK2
Protocol Filters
Filter by specific protocols:
CODEBLOCK3
TCP Flag Filters
Identify specific connection states:
CODEBLOCK4
Content Filters
Search for specific content:
CODEBLOCK5
Analysis Filters
Identify potential issues:
CODEBLOCK6
Combining Filters
Use logical operators for complex queries:
CODEBLOCK7
Phase 3: Following Streams
TCP Stream Reconstruction
View complete TCP conversation:
CODEBLOCK8
Stream Types
| Stream | Access | Use Case |
|---|
| TCP Stream | Follow > TCP Stream | Web, file transfers, any TCP |
| UDP Stream |
Follow > UDP Stream | DNS, VoIP, streaming |
| HTTP Stream | Follow > HTTP Stream | Web content, headers |
| TLS Stream | Follow > TLS Stream | Encrypted traffic (if keys available) |
Stream Analysis Tips
- - Review request/response pairs
- Identify transmitted files or data
- Look for credentials in plaintext
- Note unusual patterns or commands
Phase 4: Statistical Analysis
Protocol Hierarchy
View protocol distribution:
CODEBLOCK9
Conversations
Analyze communication pairs:
CODEBLOCK10
Endpoints
View active network participants:
CODEBLOCK11
Flow Graph
Visualize packet sequence:
CODEBLOCK12
I/O Graphs
Plot traffic over time:
CODEBLOCK13
Phase 5: Security Analysis
Detect Port Scanning
Identify reconnaissance activity:
CODEBLOCK14
Identify Suspicious Traffic
Filter for anomalies:
CODEBLOCK15
ARP Spoofing Detection
Identify ARP attacks:
CODEBLOCK16
Examine Downloads
Analyze file transfers:
CODEBLOCK17
DNS Analysis
Investigate DNS activity:
CODEBLOCK18
Phase 6: Expert Information
Access Expert Analysis
View Wireshark's automated findings:
CODEBLOCK19
Common Expert Findings
| Finding | Meaning | Action |
|---|
| TCP Retransmission | Packet resent | Check for packet loss |
| Duplicate ACK |
Possible loss | Investigate network path |
| Zero Window | Buffer full | Check receiver performance |
| RST | Connection reset | Check for blocks/errors |
| Out-of-Order | Packets reordered | Usually normal, excessive is issue |
Quick Reference
Keyboard Shortcuts
| Action | Shortcut |
|---|
| Open file | Ctrl+O |
| Save file |
Ctrl+S |
| Start/Stop capture | Ctrl+E |
| Find packet | Ctrl+F |
| Go to packet | Ctrl+G |
| Next packet | ↓ |
| Previous packet | ↑ |
| First packet | Ctrl+Home |
| Last packet | Ctrl+End |
| Apply filter | Enter |
| Clear filter | Ctrl+Shift+X |
Common Filter Reference
CODEBLOCK20
Export Options
CODEBLOCK21
Constraints and Guardrails
Operational Boundaries
- - Capture only authorized network traffic
- Handle captured data according to privacy policies
- Avoid capturing sensitive credentials unnecessarily
- Properly secure PCAP files containing sensitive data
Technical Limitations
- - Large captures consume significant memory
- Encrypted traffic content not visible without keys
- High-speed networks may drop packets
- Some protocols require plugins for full decoding
Best Practices
- - Use capture filters to limit data collection
- Save captures regularly during long sessions
- Use display filters rather than deleting packets
- Document analysis findings and methodology
Examples
Example 1: HTTP Credential Analysis
Scenario: Investigate potential plaintext credential transmission
CODEBLOCK22
Finding: Credentials transmitted in cleartext form data.
Example 2: Malware C2 Detection
Scenario: Identify command and control traffic
CODEBLOCK23
Indicators:
- - Regular timing intervals
- Encoded/encrypted payloads
- Unusual ports or protocols
Example 3: Network Troubleshooting
Scenario: Diagnose slow web application
CODEBLOCK24
Finding: TCP retransmissions indicating network congestion.
Troubleshooting
No Packets Captured
- - Verify correct interface selected
- Check for admin/root permissions
- Confirm network adapter is active
- Disable promiscuous mode if issues persist
Filter Not Working
- - Verify filter syntax (red = error)
- Check for typos in field names
- Use Expression button for valid fields
- Clear filter and rebuild incrementally
Performance Issues
- - Use capture filters to limit traffic
- Split large captures into smaller files
- Disable name resolution during capture
- Close unnecessary protocol dissectors
Cannot Decrypt TLS/SSL
- - Obtain server private key
- Configure at Edit > Preferences > Protocols > TLS
- For ephemeral keys, capture pre-master secret from browser
- Some modern ciphers cannot be decrypted passively
Wireshark 网络流量分析
目的
使用 Wireshark 执行全面的网络流量分析,以捕获、过滤和检查网络数据包,用于安全调查、性能优化和故障排除。该技能能够系统性地分析网络协议、检测异常,并从 PCAP 文件中重建网络会话。
输入/前提条件
所需工具
- - 已安装 Wireshark(Windows、macOS 或 Linux)
- 具有捕获权限的网络接口
- 用于离线分析的 PCAP/PCAPNG 文件
- 实时捕获的管理员/root 权限
技术要求
- - 理解网络协议(TCP、UDP、HTTP、DNS)
- 熟悉 IP 地址和端口
- 了解 OSI 模型各层
- 理解常见攻击模式
使用场景
- - 网络故障排除和连接问题
- 安全事件调查
- 恶意软件流量分析
- 性能监控与优化
- 协议学习与教育
输出/交付物
主要输出
- - 针对特定流量的过滤数据包捕获
- 重建的通信流
- 流量统计与可视化
- 事件证据文档
核心工作流程
阶段 1:捕获网络流量
启动实时捕获
在网络接口上开始捕获数据包:
- 1. 启动 Wireshark
- 从主屏幕选择网络接口
- 点击鲨鱼鳍图标或双击接口
- 捕获立即开始
捕获控制
| 操作 | 快捷键 | 描述 |
|---|
| 开始/停止捕获 | Ctrl+E | 切换捕获开关 |
| 重新开始捕获 |
Ctrl+R | 停止并开始新捕获 |
| 打开 PCAP 文件 | Ctrl+O | 加载现有捕获文件 |
| 保存捕获 | Ctrl+S | 保存当前捕获 |
捕获过滤器
在捕获前应用过滤器以限制数据收集:
仅捕获特定主机
host 192.168.1.100
捕获特定端口
port 80
捕获特定网络
net 192.168.1.0/24
排除特定流量
not arp
组合过滤器
host 192.168.1.100 and port 443
阶段 2:显示过滤器
基本过滤器语法
过滤已捕获的数据包进行分析:
IP 地址过滤器
ip.addr == 192.168.1.1 # 所有进出 IP 的流量
ip.src == 192.168.1.1 # 仅源 IP
ip.dst == 192.168.1.1 # 仅目标 IP
端口过滤器
tcp.port == 80 # TCP 端口 80
udp.port == 53 # UDP 端口 53
tcp.dstport == 443 # 目标端口 443
tcp.srcport == 22 # 源端口 22
协议过滤器
按特定协议过滤:
常见协议
http # HTTP 流量
https or ssl or tls # 加密网络流量
dns # DNS 查询和响应
ftp # FTP 流量
ssh # SSH 流量
icmp # Ping/ICMP 流量
arp # ARP 请求/响应
dhcp # DHCP 流量
smb or smb2 # SMB 文件共享
TCP 标志过滤器
识别特定连接状态:
tcp.flags.syn == 1 # SYN 数据包(连接尝试)
tcp.flags.ack == 1 # ACK 数据包
tcp.flags.fin == 1 # FIN 数据包(连接关闭)
tcp.flags.reset == 1 # RST 数据包(连接重置)
tcp.flags.syn == 1 && tcp.flags.ack == 0 # 仅 SYN(初始连接)
内容过滤器
搜索特定内容:
frame contains password # 包含字符串的数据包
http.request.uri contains login # 包含字符串的 HTTP URI
tcp contains GET # 包含字符串的 TCP 数据包
分析过滤器
识别潜在问题:
tcp.analysis.retransmission # TCP 重传
tcp.analysis.duplicate_ack # 重复 ACK
tcp.analysis.zero_window # 零窗口(流量控制)
tcp.analysis.flags # 有问题的数据包
dns.flags.rcode != 0 # DNS 错误
组合过滤器
使用逻辑运算符进行复杂查询:
AND 运算符
ip.addr == 192.168.1.1 && tcp.port == 80
OR 运算符
dns || http
NOT 运算符
!(arp || icmp)
复杂组合
(ip.src == 192.168.1.1 || ip.src == 192.168.1.2) && tcp.port == 443
阶段 3:跟踪流
TCP 流重建
查看完整的 TCP 会话:
- 1. 右键单击任意 TCP 数据包
- 选择 跟踪 > TCP 流
- 查看重建的会话
- 在 ASCII、十六进制、原始视图之间切换
- 过滤以仅显示此流
流类型
| 流 | 访问方式 | 使用场景 |
|---|
| TCP 流 | 跟踪 > TCP 流 | 网页、文件传输、任何 TCP |
| UDP 流 |
跟踪 > UDP 流 | DNS、VoIP、流媒体 |
| HTTP 流 | 跟踪 > HTTP 流 | 网页内容、头部 |
| TLS 流 | 跟踪 > TLS 流 | 加密流量(如有密钥) |
流分析技巧
- - 检查请求/响应对
- 识别传输的文件或数据
- 查找明文凭据
- 注意异常模式或命令
阶段 4:统计分析
协议层次结构
查看协议分布:
统计 > 协议层次结构
显示:
- - 每种协议的百分比
- 数据包数量
- 传输字节数
- 协议分解树
会话
分析通信对:
统计 > 会话
选项卡:
- - 以太网:MAC 地址对
- IPv4/IPv6:IP 地址对
- TCP:连接详情(端口、字节、数据包)
- UDP:数据报交换
端点
查看活跃的网络参与者:
统计 > 端点
显示:
- - 所有源/目标地址
- 数据包和字节计数
- 地理信息(如启用)
流量图
可视化数据包序列:
统计 > 流量图
选项:
- - 所有数据包或仅显示的数据包
- 标准或 TCP 流
- 显示数据包时序和方向
I/O 图表
绘制随时间变化的流量:
统计 > I/O 图表
功能:
- - 每秒数据包数
- 每秒字节数
- 自定义过滤器图表
- 多图表叠加
阶段 5:安全分析
检测端口扫描
识别侦察活动:
SYN 扫描检测(多个端口,同一源)
ip.src == 可疑IP && tcp.flags.syn == 1
检查统计 > 会话中的异常
查找单个源命中多个目标端口
识别可疑流量
过滤异常:
到异常端口的流量
tcp.dstport > 1024 && tcp.dstport < 49152
可信网络外的流量
!(ip.addr == 192.168.1.0/24)
异常 DNS 查询
dns.qry.name contains 可疑域名
大数据传输
frame.len > 1400
ARP 欺骗检测
识别 ARP 攻击:
重复的 ARP 响应
arp.duplicate-address-frame
ARP 流量分析
arp
查找:
- 同一 IP 对应多个 MAC
- 免费 ARP 泛洪
- 异常 ARP 模式
检查下载
分析文件传输:
HTTP 文件下载
http.request.method == GET && http contains Content-Disposition
跟踪 HTTP 流以查看文件内容
使用 文件 > 导出对象 > HTTP 提取文件
DNS 分析
调查 DNS 活动:
所有 DNS 流量
dns
仅 DNS 查询
dns.flags.response == 0
仅 DNS 响应
dns.flags.response == 1
失败的 DNS 查找
dns.flags.rcode != 0
特定域名查询
dns.qry.name contains domain.com
阶段 6:专家信息
访问专家分析
查看 Wireshark 的自动发现结果: