wireshark学习总结(2)---字节偏移过滤器

本文介绍了如何使用Wireshark的字节偏移过滤器来抓取特定条件的IP数据包,包括根据数据包长度、TTL、协议类型以及源IP和目标IP相同来设计过滤规则。并提供了相关链接以供参考。
摘要由CSDN通过智能技术生成

在设计wiresharek的抓包过滤器时,会用到IP、TCP、UPD、ICMP等协议的包头部中的属性字段值,下面的链接总结了此方面的内容,可以作为参考。

(1)母链接:http://www.packetlevel.ch/html/tcpdumpf.html

(2)子链接:http://www.packetlevel.ch/html/txt/byte_offsets.txt


下面举几个通过使用IP的包头部的属性字段设计的抓包过滤器:

(1)抓取特定长度(如62字节)的IP数据包

ip[2:2] == 62

说明:其中62表示并指定IP包头中的“IP包总长度”字段值

(2)抓取特定TTL(生存时间)的IP数据包

ip[8] == <TTL_value> 

说明:其中TTL_value表示IP包头中的“TTL”字段值

(3)抓取特定协议类型的IP数据包

ip[9] == 6

说明:其中6表示IP包头中的“协议类型”字段值为6,在数据包IP头部中会显示为:Protocol :  TCP (6),即抓取TCP协议的数据包

1表示ICMP、17表示UDP、6表示TCP等等。

(4)抓取源IP地址和目标IP地址相同的IP数据包

ip[12:4] == ip[16:4]

此部分的原理见下图所示:




下面是母链接给出协议头部中所有属性字段的byte_offset内容获取方法:

common Filters
ip	IP
arp	arp
tcp	tcp
udp	udp
icmp	icmp
ip multicast	IP Multicast
ether multicast	Ethernet Multicast

IP Filters
ip[0] & 0x0f	low nibble: header length in 4octet words. should be 5
ip[1]	type of service/QoS/DiffServ
ip[2:2]	total length of datagram in octets
ip[4:2]	IP ID number
ip[6] & 0x80	reserved bit (possibly used for ECN)
ip[6] & 0x40	DF bit
ip[6] & 0x20	MF bit
ip[6:2] & 0x1fff	fragment offset (number of 8octet blocks)
ip[8]	ttl
ip[9]	protocol
ip[10:2]	header checksum
ip[12:4]	source IP
ip[16:4]	destination IP
Samples	
(ip[12:4] = ip[16:4])	Src IP = Dest IP (land attack)
ip[0] & 0xf0	high nibble: IP version. almost always 4
(ip[0] & 0xf0 != 0x40)	IP versions !=4
(ip[0:1] & 0x0f > 5)	IP with options set
(ip[19] = 0xff)	Broadcasts to x.x.x.255
(ip[19] = 0x00)	Broadcasts to x.x.x.0
(ip and ip[1] & 0xfc == 0xb8)	search for EF in DSCP
(ip and ip[1] &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值