码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu捕包时可能用到的命令

时间:2015-11-23 14:52:37      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:linux

1. tcpdump

tcpdump    #捕捉包

tcpdump -i eth1    #捕捉指定接口eth1捕捉数据

tcpdump -i any

tcpdump host sundown

tcpdump host 210.27.48.1 

tcpdump host helios and \( hot or ace \)

tcpdump host 210.27.48.1 and \ (210.27.48.2 or 210.27.48.3 \) 

tcpdump ip host ace and not helios

tcpdump ip host 210.27.48.1 and ! 210.27.48.2

tcpdump -i eth0 src host hostname

tcpdump -i eth0 dst host hostname

tcpdump tcp port 23 and host 210.27.48.1

tcpdump udp port 123 

tcpdump net ucb-ether

tcpdump ‘gateway snup and (port ftp or ftp-data)‘

tcpdump ip and not net localnet

tcpdump ‘tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet‘

tcpdump ‘tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)‘

tcpdump ‘gateway snup and ip[2:2] > 576‘

tcpdump ‘ether[0] & 1 = 0 and ip[16] >= 224‘

tcpdump ‘icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply‘

tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap

tcpdump  -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854


tcpdump -i eth0 -s 0    #用-s 0来忽略捕获大小

tcpdump -c 1    #收到1个包后停止

tcpdump -nn    #不进行端口名称的转换

tcpdump -n    #不把网络地址转换成名字

tcpdump -b arp    #在数据链路层上选择协议, arp、rarp、ip、ipx

tcpdump -t    #在输出的每一行不打印时间戳

tcpdump -w    #直接将分组写入文件中,而不是不分析并打印出来


2. 查看网卡信息

ethtool eth1    #查看网卡详细信息

ethtool -i eth2    #查看驱动信息

lspci    #查看网卡详细信息,太多,看不懂

lspci | grep -i net    #查看网卡类型,intel或者其他类型


3. 历史记录

history    #查看历史记录

history | grep -i "www"    #查看

history -c    #删除历史记录


4. tcpreplay的使用

$tcpprep --port --cachefile=cache_test.cache --pcap=http.pcap

整个指令的意思就是采用port-spllit模式来处理http.pcap文件(区分http.pcap中的客户端和服务器),然后将处理结果存到cache_test.cache文件中。

$tcprewrite --endpoints=192.168.0.1:192.168.0.2 --cachefile=cache_test.cache --infile=http.pcap --outfile=http_rewrite.pcap

两个ip分别为修改后的客户端:服务器ip,cache_test.cache文件用来区分方向,http.pcap是要处理的pcap文件,处理结果存到http_rewrite.pcap文件中。

$tcpreplay --intf1=eth0 --intf2=eth0 -t --cachefile=cache_test.cache http_rewrite.pcap

用.cache文件区分方向,intf1主接口:客户端->服务器数据包发送接口,intf2从接口,.pcap文件是发送的数据包来源。-t为尽可能快速地发送。

$tcpreplay --mbps=1000 --intf1=eth0 --intf2=eth0 --cachefile=cache_test.cache http_rewrite.pcap


5. 修改MTU值

sudo ifconfig eth0 mtu 3000    #经过试探,本服务器最大mtu为9710



Ubuntu捕包时可能用到的命令

标签:linux

原文地址:http://yuzwei.blog.51cto.com/10126623/1715932

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!