安装 Wireshark
- macOS:从 Homebrew 安装 Wireshark,命令为
brew install wireshark。 - Windows:使用
apt-get安装,命令为apt-get install wireshark。 - Linux:使用
brew或apt安装,命令为brew install wireshark或sudo apt install wireshark。
初始化 Wireshark
- 命令
Wireshark --version:查看当前版本信息。 - 命令
Wireshark --list-flows:列出流量包。
设置默认协议
- 使用命令
Wireshark --set-default-protocol=TCP或UDP,具体取决于你的网络服务。
引用 Wireshark 的包结构信息
- 命令
Wireshark --help:查看帮助文档。 - 命令
Wireshark --list-flows --help:更详细地列出流量包。
分析流量包
- 查看包头和包尾:
Wireshark -u --list-flows --head -v Wireshark -u --list-flows --tail -v
- 查看包 body:
Wireshark -u --list-flows --body -v
使用插件分析网络流量
- 插件推荐:
- Wireshark Stack:用于高级流量分析。
- Wireshark Bridge:用于网络服务的监控。
- 安装插件:
sudo apt-get install wireshark-stack wireshark-bridge
使用图形化工具
- Wireshark Graphical User Interface (GUI):
- macOS:使用
Wireshark的 GUI 工具。 - Windows:使用
Wireshark的 GUI 工具。 - Linux:使用
Wireshark的 GUI 工具。
- macOS:使用
处理异常流量包
- DDoS攻击包:
- 使用命令
Wireshark --count-flows --stream --filter=type=DDoS。
- 使用命令
- DDoS注入:
- 使用命令
Wireshark --count-flows --stream --filter=type=DDoS注入。
- 使用命令
流程包统计分析
- 流量包大小分布:
Wireshark -u --count-flows --size --min=1 --max=2
- 类型比例:
Wireshark -u --list-flows --size --filter=type=TCP --filter=type=UDP
网络服务配置
- 配置 Wireshark:
Wireshark -u --set-default-protocol=TCP --set-default-url=http://localhost:88
- 配置网络服务:
Wireshark -u --set-default-protocol=UDP --set-default-url=http://localhost:443
使用其他工具
- Netcat:
netcat -c Wireshark -u --list-flows
- 网络分析工具:
使用工具如 NetworkAnalyzer(可从https://github.com/NetworkAnalyzer/NetworkAnalyzer)进行流量分析。
实时监控
- 实时监控流量包:
Wireshark --stream --output=packet
- 实时检测异常流量:
Wireshark --stream --filter=type=DDoS
多用户环境
- 多用户协议:
Wireshark --set-default-protocol=TCP -p 127...1:4555
- 配置不同用户:
Wireshark --set-default-protocol=TCP -p 127...1:4555
- 基础:安装和配置协议和网络服务。
- 高级:使用插件、包结构分析、异常检测、图形化工具、统计分析和实时监控。
- 工具:引用 Wireshark 的命令和文档,使用插件扩展功能,使用其他工具辅助分析。
通过以上步骤,你已经掌握了一个基本的Wireshark 使用指南,可以开始根据需要进行具体的流量包分析和监控了。


