用tcpdump -s 0 -w outputfile监听获得一个文件命名为*.cap然后用echereal读取这个文件分析之
注意:-s 0意思就是按包的大小抓取,不然tcpdump默认是抓96bit.一定要关闭了tcpdump之后再下载*.cap文件,不然这个cap文件不完整。
1.tcpdump要注意有个参数-i,这个参数是用来指定网卡的的.公司的机器都装了两个网卡,eth0外网,eth1内网.所以要监听内网用-i eth1.
tcpdump -n -ieth1 src host 10.130.129.109 and port 10000 -s0 -X -c40|grep -A11 "(116)"
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
15:42:50.146844 IP 10.130.129.109.10000 > 10.134.11.87.60726: P 297:413(116) ack 227 win 1448 <nop,nop,timestamp 1790901657 3935156447>
0x0000: 4500 00a8 347c 4000 3b06 6908 0a82 816d E...4|@.;.i....m
0x0010: 0a86 0b57 2710 ed36 a9be cd80 5802 4d05 ...W'..6....X.M.
0x0020: 8018 05a8 1dff 0000 0101 080a 6abe fd99 ............j...
0x0030: ea8d b8df 0100 2a52 ed00 7400 4300 0001 ......*R..t.C...
0x0040: 3367 0000 0000 0000 0000 0000 0000 0000 3g..............
0x0050: 3864 6338 3861 0000 0000 0000 0000 0000 8dc88a..........
0x0060: 570b 860a 0000 2b67 0800 0000 0000 0000 W.....+g........
0x0070: 0000 0000 0003 0000 0000 0000 0000 0000 ................
0x0080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x0090: 0000 0000 0000 0000 0000 0000 0000 0a0c ................
0x00a0: 1600 0b1c 290c 390c ....).9.
116代表数据包长为116,从390c倒数160个字节就是0x0030:的第三个0100,这个就是数据包的起点.
参考:http://sanyk.is-programmer.com/posts/14645