Ric*_*cky 6 terminal protocols tshark
现在我正在使用
tshark -i wlan0 -c 10 -T fields -e ip.src -e ip.dst -e ip.proto -e tcp.srcport -e tcp.dstport -e udp.srcport -e udp.dstport > test.txt
Run Code Online (Sandbox Code Playgroud)
哪个工作正常,它给了我这样的输出:
192.168.1.240 198.38.110.157 6 50735 80 198.38.110.157 192.168.1.240 6 80 50735 192.168.1.240 198.38.110.157 6 50735 80 198.38.110.157 192.168.1.240 6 80 50735 192.168.1.240 198.38.110.157 6 50735 80 198.38.110.157 192.168.1.240 6 80 50735 192.168.1.240 198.38.110.157 6 50735 80 198.38.110.157 192.168.1.240 6 80 50735 192.168.1.240 198.38.110.157 6 50735 80 198.38.110.157 192.168.1.240 6 80 50735
很酷,但是有没有人能为每个协议提供一个像这样的简单堆栈?只是一个简单的制表符分隔字段,我似乎无法在 tshark 手册页中找到此选项。
小智 6
您可以尝试使用-otshark 的选项来格式化 tshark 的输出。
例如,
\ntshark.exe -o "gui.column.format:\\"Source\\",\\"%us\\",\\"Destination\\",\\"%ud\\",\\"src port\\",\\"%S\\",\\"dest port\\",\\"%D\\"" -r sample_001.cap.pcapng\nRun Code Online (Sandbox Code Playgroud)\n结果:
\n10.191.144.161 \xe2\x86\x92 10.210.62.164 57434 8888\n10.191.144.161 \xe2\x86\x92 10.210.62.164 57434 8888\n10.210.62.164 \xe2\x86\x92 10.191.144.161 8888 57434\nRun Code Online (Sandbox Code Playgroud)\n(然后,您只需删除“\xe2\x86\x92”)
\n要查看可以选择的输出字段的完整列表,请使用以下命令tshark.exe -G column-formats:
c:\\Program Files\\Wireshark>tshark.exe -G column-formats\n%q 802.1Q VLAN id\n%Yt Absolute date, as YYYY-MM-DD, and time\n%YDOYt Absolute date, as YYYY/DOY, and time\n%At Absolute time\n%V Cisco VSAN\n%B Cumulative Bytes\n%Cus Custom\n%y DCE/RPC call (cn_call_id / dg_seqnum)\n%Tt Delta time\n%Gt Delta time displayed\n%rd Dest addr (resolved)\n%ud Dest addr (unresolved)\n%rD Dest port (resolved)\n%uD Dest port (unresolved)\n%d Destination address\n%D Destination port\n%a Expert Info Severity\n%I FW-1 monitor if/direction\n%F Frequency/Channel\n%hd Hardware dest addr\n%hs Hardware src addr\n%rhd Hw dest addr (resolved)\n%uhd Hw dest addr (unresolved)\n%rhs Hw src addr (resolved)\n%uhs Hw src addr (unresolved)\n%e IEEE 802.11 RSSI\n%x IEEE 802.11 TX rate\n%f IP DSCP Value\n%i Information\n%rnd Net dest addr (resolved)\n%und Net dest addr (unresolved)\n%rns Net src addr (resolved)\n%uns Net src addr (unresolved)\n%nd Network dest addr\n%ns Network src addr\n%m Number\n%L Packet length (bytes)\n%p Protocol\n%Rt Relative time\n%s Source address\n%S Source port\n%rs Src addr (resolved)\n%us Src addr (unresolved)\n%rS Src port (resolved)\n%uS Src port (unresolved)\n%E TEI\n%Yut UTC date, as YYYY-MM-DD, and time\n%YDOYut UTC date, as YYYY/DOY, and time\n%Aut UTC time\n%t Time (format as specified)\nRun Code Online (Sandbox Code Playgroud)\n例如,要使用 tshark 打印 Wireshark 的默认列:
\ntshark.exe -o "gui.column.format:\\"No.\\",\\"%m\\",\\"Time\\",\\"%t\\",\\"Source\\",\\"%s\\",\\"Destination\\",\\"%d\\",\\"Protocol\\",\\"%p\\",\\"Length\\",\\"%L\\",\\"Info\\",\\"%i\\""\nRun Code Online (Sandbox Code Playgroud)\nc:\\Program Files\\Wireshark>
\n