使用带有时间戳和标志的tshark

问题描述 投票:1回答:1

我试图使用带有一些标志的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版。

packet-capture tshark
1个回答
1
投票

在你的命令中,-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
© www.soinside.com 2019 - 2024. All rights reserved.