抓包过滤器:
语法说明:
(1)BPF语法(berkeley packet filter)
(2)类型Type:host(主机)、net(网段)、port(端口)
(3)方向dir:src(源)、dst(目的)
(4)协议proto:ether(以太网)、ip、tcp、udp、http、ftp
(5)逻辑运算符:
1.&& 与
2.|| 或
3.! 非
举例说明:
- src host 192.168.1.1 && dst port 80 抓取源地址为192.168.1.1,目的为80端口的流量
- host 192.168.1.1 || host 192.168.1.2 抓取192.168.1.1和192.168.1.2的流量
- !broadcast 不要抓取广播包
- port 80 抓取80端口的流量
注意:抓包过滤器是抓包之前进行的操作
- 首选项里面选择网卡,输入过滤选项进行抓包
- 图中操作只会抓取源地址为192.168.1.1的流量
更多举例:
- 过滤MAC地址案例:ether host 00:88:ca:86:f8:0d
src ether host 00:88:ca:86:f8:0d
dst ether host 00:88:ca:86:f8:0d
- 过滤IP地址案例:host 192.168.1.1 源和目的为192.168.1.1都抓取
src host 192.168.1.1
dst host 192.168.1.1
- 过滤端口案例:port 80
!port 80
dst port 80
src port 80
- 过滤协议案例:arp
icmp
- 综合过滤案例:host 192.168.1.100 && port 8080
显示过滤器:在已经抓好包的基础上进行过滤
语法说明:
比较操作符
== 等于
!= 不等于
> 大于
< 小于
>= 大于等于
<= 小于等于
逻辑操作符
and 两个条件同时满足
or 其中一个条件满足
xor 有且仅有一个条件满足
not 没有条件被满足
IP地址
ip.addr
ip.src
ip.dst
端口过滤
tcp.port
tcp.srcport
tcp.dstport
tcp.flags.syn
tcp.flags.ack
协议过滤
arp
ip
icmp
udp
tcp
bootp
dns
举例
过滤IP地址
ip.addr == 192.168.1.1
ip.src == 192.168.1.1
ip.dst == 192.168.1.1
ip.src == 192.168.1.1 and ip.dst == 192.168.1.2
过滤端口案例
tcp.port == 80
tcp.srcport == 80
tcp.dstport == 80
tcp.flag.syn == 1
过滤协议案例
arp
tcp
udp
not http 除了http
not arp
综合过滤案例
ip.src == 192.168.1.1 and tcp.dstport == 80
ip.addr == 192.168.1.100 and udp.port == 4000