packet-capture - 使用带有时间戳和标志的 tshark
问题描述
我正在尝试将 tshark 与一些标志一起使用,并为每个过滤的跟踪获取时间戳。我正在使用它来过滤系统中的所有 DNS 查询。我无法获得时间戳以及过滤器工作。例如,如果我尝试类似
tshark -t ad -n -T fields -e ip.src -e dns.qry.name -f 'dst port 53' -Y "dns.flags.response eq 0"
我得到了我想要的输出
192.168.1.3 clientservices.googleapis.com
192.168.1.3 play.google.com
192.168.1.3 play.google.com
我得到时间戳
tshark -t ad
1 2018-09-02 21:12:20.536204429 61.223.125.209 → 192.168.1.3 UDP 174 12929 → 51465 Len=132
2 2018-09-02 21:12:20.536355008 192.168.1.3 → 61.223.125.209 UDP 126 51465 → 12929 Len=84
3 2018-09-02 21:12:20.599264715 192.168.1.3 → 176.31.225.118 TCP 54 45942 → 80 [FIN, ACK] Seq=1 Ack=1 Win=30016 Len=0
但是我无法让两者一起工作。虽然命令运行它只是输出没有时间戳。
tshark -t ad -T fields -e ip.src -e dns.qry.name -Y "dns.flags.response eq 0"
192.168.1.3 captive.apple.com
192.168.1.3 myip.opendns.com
192.168.1.3 ipv4.icanhazip.com
192.168.1.3 slack.com
任何可以在这方面提供帮助的指针。我在 Debian 9 上使用 tshark 版本 2.2.6。
解决方案
在您的命令中,-t ad
没有效果,因为-T fields
会覆盖输出格式。您需要fields
使用以下格式将时间戳显示为新字段-e frame.time
:
$ tshark -n -T fields -e frame.time -e ip.src -e dns.qry.name -f 'dst port 53' -Y "dns.flags.response eq 0"
Capturing on 'eno1'
Sep 3, 2018 15:49:46.354055274 CEST 10.0.0.1 google.co.uk
Sep 3, 2018 15:49:52.034315960 CEST 10.0.0.1 google.jp
Sep 3, 2018 15:49:54.561493702 CEST 10.0.0.1 google.cn
推荐阅读
- c - 在调试控制台 VScode 中使用输入(stdin)
- sql - Oracle SQL,以不超过参考日期的最近日期连接表
- typescript - 为什么过滤具有未定义键的对象会在 TypeScript 严格模式下出错
- typescript - 在Typescript中按日期变量将数组元素分组为周
- python - 按索引行值与前一行值比较数据帧组
- reactjs - 我如何为我的搜索栏做后端反应?
- reactjs - 来自自定义 React Hook 和 React 组件的 NPM 包
- android - Android FCM:当应用程序在后台时,FCM 显示(通知)消息登录
- powershell - 是否可以在 Powershell 中使用 Send-PnPMail 发送附件?
- azure-web-app-service - 适用于 Visual Studio Code 的 Azure 应用服务插件看不到我的订阅