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

gsk*_*308 5 packet-capture tshark

我正在尝试将 tshark 与一些标志一起使用,并获取每个过滤跟踪的时间戳。我用它来过滤系统中的所有 DNS 查询。\n我无法在过滤器工作的情况下获取时间戳。例如,如果我尝试类似的事情

\n\n
tshark -t ad -n -T fields -e ip.src -e dns.qry.name -f \'dst port 53\' -Y "dns.flags.response eq 0"\n
Run Code Online (Sandbox Code Playgroud)\n\n

我得到了我想要的输出

\n\n
192.168.1.3 clientservices.googleapis.com\n192.168.1.3 play.google.com\n192.168.1.3 play.google.com\n
Run Code Online (Sandbox Code Playgroud)\n\n

我得到时间戳

\n\n
 tshark -t ad \n    1 2018-09-02 21:12:20.536204429 61.223.125.209 \xe2\x86\x92 192.168.1.3  UDP 174 12929 \xe2\x86\x92 51465 Len=132\n    2 2018-09-02 21:12:20.536355008  192.168.1.3 \xe2\x86\x92 61.223.125.209 UDP 126 51465 \xe2\x86\x92 12929 Len=84\n    3 2018-09-02 21:12:20.599264715  192.168.1.3 \xe2\x86\x92 176.31.225.118 TCP 54 45942 \xe2\x86\x92 80 [FIN, ACK] Seq=1 Ack=1 Win=30016 Len=0\n
Run Code Online (Sandbox Code Playgroud)\n\n

但是我无法让两者一起工作。尽管该命令运行它只是输出没有时间戳。

\n\n
tshark -t ad -T fields -e ip.src -e dns.qry.name -Y "dns.flags.response eq 0"\n  192.168.1.3 captive.apple.com\n  192.168.1.3 myip.opendns.com\n  192.168.1.3 ipv4.icanhazip.com\n  192.168.1.3 slack.com\n
Run Code Online (Sandbox Code Playgroud)\n\n

任何可以在这方面提供帮助的指示。我在 Debian 9 上使用 tshark 版本 2.2.6。

\n

pch*_*gno 10

在您的命令中,-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
Run Code Online (Sandbox Code Playgroud)