(1)对源地址为192.168.0.1的包的过滤,即抓取源地址满足要求的包。
表达式为:ip.src == 192.168.0.1
(2)对目的地址为192.168.0.1的包的过滤,即抓取目的地址满足要求的包。
表达式为:ip.dst == 192.168.0.1
(3)对源或者目的地址为192.168.0.1的包的过滤,即抓取满足源或者目的地址的ip地址是192.168.0.1的包。
表达式为:ip.addr == 192.168.0.1,或者 ip.src == 192.168.0.1 or ip.dst == 192.168.0.1
(4)要排除以上的数据包,我们只需要将其用括号囊括,然后使用 "!" 即可。
表达式为:!(表达式)
二、针对协议的过滤
(1)仅仅需要捕获某种协议的数据包,表达式很简单仅仅需要把协议的名字输入即可。
表达式为:http
(2)需要捕获多种协议的数据包,也只需对协议进行逻辑组合即可。
表达式为:http or telnet (多种协议加上逻辑符号的组合即可)
(3)排除某种协议的数据包
表达式为:not arp !tcp
三、针对端口的过滤(视协议而定)
(1)捕获某一端口的数据包
表达式为:tcp.port == 80
(2)捕获多端口的数据包,可以使用and来连接,下面是捕获高端口的表达式
表达式为:udp.port >= 2048
四、针对长度和内容的过滤
(1)针对长度的过虑(这里的长度指定的是数据段的长度)
表达式为:udp.length < 30 http.content_length <=20
(2)针对数据包内容的过滤
表达式为:http.request.uri matches "vipscu" (匹配http请求中含有vipscu字段的请求信息)
/----------------------------------------------------------------------------------------------------------------------------------------------/
首先说几个最常用的关键字,“eq” 和 “==”等同,可以使用 “and” 表示并且,“or”表示或者。“!" 和 "not” 都表示取反。
比如:ip.src==119.75.217.56 或 ip.src eq 119.75.217.56 //显示来源IP
二、端口过滤:
比如:tcp.port==80 或 tcp.port eq 80 //来源或目标的tcp端口是80
过滤端口范围 tcp.port >= 1 and tcp.port <= 80
三、协议过滤:捕获某种协议的数据包,表达式仅需要把协议名字输入。
如http tcp udp arp icmp http smtp ftp dns msnms ip ssl
排除某种协议的数据包:not arp 或 !tcp
四、包长度过滤:
udp.length == 26 指udp本身固定长度8加上udp下面那块数据包之和
tcp.len >= 7
ip.len == 94
frame.len == 119 整个数据包长度,从eth开始到最后
五、http模式过滤:
例子:
http.request.method == “GET”
http.request.method == “POST”
http.request.uri == “/img/logo-edu.gif”
http contains “GET”
http contains “HTTP/1.”
// GET包
http.request.method == “GET” && http contains “Host: ”
http.request.method == “GET” && http contains “User-Agent: ”
// POST包
http.request.method == “POST” && http contains “Host: ”
http.request.method == “POST” && http contains “User-Agent: ”
// 响应包
http contains “HTTP/1.1 200 OK” && http contains “Content-Type: ”
http contains “HTTP/1.0 200 OK” && http contains “Content-Type: ”
一定包含如下
Content-Type:
六、连接符 and / or
七、表达式:!(arp.src==192.168.1.1) and !(arp.dst.proto_ipv4==192.168.1.243)