将tshark与时间戳和标志一起使用

时间:2018-09-02 15:48:00

标签: 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。

1 个答案:

答案 0 :(得分: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