Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2112079
  • 博文数量: 288
  • 博客积分: 10594
  • 博客等级: 上将
  • 技术积分: 3469
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-27 19:27
文章分类

全部博文(288)

文章存档

2012年(4)

2011年(30)

2010年(40)

2009年(32)

2008年(71)

2007年(79)

2006年(32)

分类:

2008-09-19 14:02:19

捕获过滤器(Filtering while capturing)

ethereal使用libpcap filter language 过滤,在tcpdump的man page中有解释,但是比较难理解


一个捕获过滤器 规则类似于 下面的表达式


[not] primitive [and|or [not] primitive ...


primitive 原始的, 远古的, 粗糙的, 简单的

由表示式 和 and/or/not 组成




过滤器 Filter name
过滤法则 Filter string



捕获到IP为10.0.0.5的主机的telnet数据

tcp port 23 and host 10.0.0.5



只捕获DNS数据

port 53



只捕获IP为 172.18.5.4 的主机的包

host 172.18.5.4


1.捕获 MAC地址为 00:d0:f8:00:00:03 网络设备通信的所有报文
Filter string就是
ether host 00:d0:f8:00:00:03


2.捕获 IP地址为 192.168.10.1 网络设备通信的所有报文
Filter string就是
host 192.168.10.1


3.捕获网络web的所有报文
Filter string就是
tcp port 80


4. 捕获192.168.10.1除了http外的所有通信数据报文
Filter string就是
host 192.168.10.1 and not tcp port 80


5.

捕获非http和非smtp 报文,在你的器上的(下面两个过滤法则是等价的)

host and not (port 80 or port 25)
host and not port 80 and not port 25




6.捕获所有除了dns和arp的报文

port not 53 and not arp


7.堪称最短的过滤器,只捕获IP包,对于除去底层通信协议ARP和STP很有用

ip




一些其他的过滤器

Blaster worm是RPC wordm,下面的规则可以捕捉它的包

dst port 135 and tcp port 135 and ip[2:2]==48


Welchia worm
icmp[icmptype]==icmp-echo and ip[2:2]==92 and icmp[8:4]==0xAAAAAAAA


[src|dst] host


这个表达式,允许你过滤一个用IP地址或者主机名来过滤一个主机。
可以在 前面加上 src|dst 关键字来指定你感的 源主机 或者 目的主机
如果没有 src|dst 关键字,则所有进出的包都会捕获


ether [src|dst] host


过滤 以太网 主机地址(就是mac地址),可在前面加上src|dst 关键字


gateway host


This primitive allows you to filter on packets that used host as a gateway. That is, where the Ethernet source or destination was host but neither the source nor destination IP address was host.
过滤使用这个这个主机作为 网关的 所有包


less|greater


过滤 报文长度


[tcp|udp] [src|dst] port
过滤端口,可在前面 加 tcp|udp 或者 src|dst关键字
阅读(3338) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~