工具使用要点60 条

tshark 字段提取统计

tshark 命令行处理 pcap:-Y 显示过滤、-T fields -e 提取字段,把流量证据转成可统计表格(HTTP 主机、URI、DNS 查询等)。

-Y显示过滤器
-T fields -e字段提取输出
统计管道 sort/uniq -c 汇总
输入-r 读取 pcap 文件

提取示例

提取示例
tshark -r http.pcap -Y 'http.request' -T fields -e http.host -e http.request.uri | sort | uniq -c | sort -rn | head
tshark -r dns.pcap -Y 'dns.flags.response == 0' -T fields -e dns.qry.name | sort -u
大文件先用捕获过滤器切片,或分片读取,避免内存压力。

易错点

  • 无过滤解析超大 pcap 导致内存爆掉
  • 字段名拼写错误得到空列未察觉

数据来源与参考

  • Wireshark 官方文档(tshark 字段与过滤器)
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌