1. 过滤IP,如来源IP或者目标IP等于某个IP
例子:
ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107
或者
ip.addr eq 192.168.1.107 // 都能显示来源IP和目标IP

2. 过滤端口
例子:
tcp.port eq 80 // 不管端口是来源的还是目标的都显示
tcp.port == 80
tcp.port eq 2722
tcp.port eq 80 or udp.port eq 80
tcp.dstport == 80 // 只显tcp协议的目标端口80
tcp.srcport == 80 // 只显tcp协议的来源端口80

udp.port eq 15000

过滤端口范围
tcp.port >= 1 and tcp.port <= 80

3. 过滤协议
例子:
tcp
udp
arp
icmp
http
smtp
ftp
dns
msnms
ip
ssl
oicq
bootp
等等

排除arp包,如!arp 或者 not arp

4. 过滤MAC
太以网头过滤
eth.dst == A0:00:00:04:C5:84 // 过滤目标mac
eth.src eq A0:00:00:04:C5:84 // 过滤来源mac
eth.dst==A0:00:00:04:C5:84
eth.dst==A0-00-00-04-C5-84
eth.addr eq A0:00:00:04:C5:84 // 过滤来源MAC和目标MAC都等于A0:00:00:04:C5:84的

less than 小于 < lt
小于等于 le

等于 eq

大于 gt
大于等于 ge

不等 ne

5. 包长度过滤
例子:
udp.length == 26 这个长度是指udp本身固定长度8加上udp下面那块数据包之和
tcp.len >= 7 指的是ip数据包(tcp下面那块数据),不包括tcp本身
ip.len == 94 除了以太网头固定长度14,其它都算是ip.len,即从ip本身到最后
frame.len == 119 整个数据包长度,从eth开始到最后

eth —> ip or arp —> tcp or udp —> data

6. 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:

7. TCP参数过滤
tcp.flags 显示包含TCP标志的封包。
tcp.flags.syn == 0×02 显示包含TCP SYN标志的封包。
tcp.window_size == 0 && tcp.flags.reset != 1

8. 过滤内容

tcp[20]表示从20开始,取1个字符
tcp[20:]表示从20开始,取1个字符以上
tcp[20:8]表示从20开始,取8个字符
tcp[offset,n]

udp[8:3]==81:60:03 // 偏移8个bytes,再取3个数,是否与==后面的数据相等?
udp[8:1]==32 如果我猜的没有错的话,应该是udp[offset:截取个数]=nValue
eth.addr[0:3]==00:06:5B

例子:
判断upd下面那块数据包前三个是否等于0×20 0×21 0×22
我们都知道udp固定长度为8
udp[8:3]==20:21:22

判断tcp那块数据包前三个是否等于0×20 0×21 0×22
tcp一般情况下,长度为20,但也有不是20的时候
tcp[8:3]==20:21:22
如果想得到最准确的,应该先知道tcp长度

matches(匹配)和contains(包含某字符串)语法
ip.src==192.168.1.107 and udp[8:5] matches "\\x02\\x12\\x21\\x00\\x22"
ip.src==192.168.1.107 and udp contains 02:12:21:00:22
ip.src==192.168.1.107 and tcp contains "GET"
udp contains 7c:7c:7d:7d 匹配payload中含有0x7c7c7d7d的UDP数据包,不一定是从第一字节匹配。

例子:
得到本地qq登陆数据包(判断条件是第一个包==0×02,第四和第五个包等于0x00x22,最后一个包等于0×03)
0×02 xx xx 0×00 0×22 … 0×03
正确
oicq and udp[8:] matches "^\\x02[\\x00-\\xff][\\x00-\\xff]\\x00\\x22[\\x00-\\xff]+\\x03$"
oicq and udp[8:] matches "^\\x02[\\x00-\\xff]{2}\\x00\\x22[\\x00-\\xff]+\\x03$" // 登陆包
oicq and (udp[8:] matches "^\\x02[\\x00-\\xff]{2}\\x03$" or tcp[8:] matches "^\\x02[\\x00-\\xff]{2}\\x03$")
oicq and (udp[8:] matches
"^\\x02[\\x00-\\xff]{2}\\x00\\x22[\\x00-\\xff]+\\x03$" or tcp[20:]
matches "^\\x02[\\x00-\\xff]{2}\\x00\\x22[\\x00-\\xff]+\\x03$")

不单单是00:22才有QQ号码,其它的包也有,要满足下面条件(tcp也有,但没有做):
oicq and udp[8:] matches "^\\x02[\\x00-\\xff]+\\x03$" and !(udp[11:2]==00:00) and !(udp[11:2]==00:80)
oicq and udp[8:] matches "^\\x02[\\x00-\\xff]+\\x03$" and !(udp[11:2]==00:00) and !(udp[15:4]==00:00:00:00)
说明:
udp[15:4]==00:00:00:00 表示QQ号码为空
udp[11:2]==00:00 表示命令编号为00:00
udp[11:2]==00:80 表示命令编号为00:80
当命令编号为00:80时,QQ号码为00:00:00:00

得到msn登陆成功账号(判断条件是"USR 7 OK ",即前三个等于USR,再通过两个0×20,就到OK,OK后面是一个字符0×20,后面就是mail了)
USR xx OK [email]mail@hotmail.com[/email]
正确
msnms and tcp and ip.addr==192.168.1.107 and tcp[20:] matches "^USR\\x20[\\x30-\\x39]+\\x20OK\\x20[\\x00-\\xff]+"

9. dns模式过滤

10. DHCP
以寻找伪造DHCP服务器为例,介绍Wireshark的用法。在显示过滤器中加入过滤规则,
显示所有非来自DHCP服务器并且bootp.type==0×02(Offer/Ack)的信息:
bootp.type==0×02 and not ip.src==192.168.1.1

11.msn
msnms && tcp[23:1] == 20 // 第四个是0×20的msn数据包
msnms && tcp[20:1] >= 41 && tcp[20:1] <= 5A
&& tcp[21:1] >= 41 && tcp[21:1] <= 5A &&
tcp[22:1] >= 41 && tcp[22:1] <= 5A
msnms && tcp[20:3]=="USR" // 找到命令编码是USR的数据包
msnms && tcp[20:3]=="MSG" // 找到命令编码是MSG的数据包
tcp.port == 1863 || tcp.port == 80

如何判断数据包是含有命令编码的MSN数据包?
1)端口为1863或者80,如:tcp.port == 1863 || tcp.port == 80
2)数据这段前三个是大写字母,如:
tcp[20:1] >= 41 && tcp[20:1] <= 5A && tcp[21:1]
>= 41 && tcp[21:1] <= 5A && tcp[22:1] >= 41
&& tcp[22:1] <= 5A
3)第四个为0×20,如:tcp[23:1] == 20
4)msn是属于TCP协议的,如tcp

WireShark 过滤语法的更多相关文章

  1. wireshark过滤语法总结-重点偏移过滤

    http://chenjiji.com/post/3371.html 作者: CHAN | 发布: 2013 年 10 月 24 日 做应用识别这一块经常要对应用产生的数据流量进行分析. 抓包采用wi ...

  2. 转: wireshark过滤语法总结

    from: http://blog.csdn.net/cumirror/article/details/7054496 wireshark过滤语法总结 原创 2011年12月09日 22:38:50 ...

  3. (十八)WireShark 过滤语法

    1.过滤IP,如来源IP或者目标IP等于某个IP例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.addr eq 192.168.1. ...

  4. wireshark过滤语法总结

    抓包采用wireshark,提取特征时,要对session进行过滤,找到关键的stream,这里总结了wireshark过滤的基本语法,供自己以后参考.(脑子记不住东西) wireshark进行过滤时 ...

  5. wireshark过滤语法总结 (转载)

    做应用识别这一块经常要对应用产生的数据流量进行分析. 抓包采用wireshark,提取特征时,要对session进行过滤,找到关键的stream,这里总结了wireshark过滤的基本语法,供自己以后 ...

  6. WireShark过滤语法

    1.过 滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.addr eq 192.168. ...

  7. 【转】wireshark过滤规则

    WireShark过滤语法 1.过滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.add ...

  8. wireshark过滤规则

    WireShark过滤语法 1.过 滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.ad ...

  9. 转: wireshark过滤规则

    转: http://blog.sina.com.cn/s/blog_48a0f2740100ka71.html WireShark过滤语法 1.过 滤IP,如来源IP或者目标IP等于某个IP 例子: ...

随机推荐

  1. SteamVR Unity工具包(VRTK)之激光和移动

    简单激光指针(VRTK_ SimplePointer) 简单指针(Simple Pointer)脚本从控制器尾部发出一个有色光束来模拟激光束.这在场景中指向对象很有用,它能判断所指向的对象以及对象距控 ...

  2. 解决edittext输入多行可以滑动的问题

    解决edittext输入多行可以滑动的问题  Java代码:   public class ScrollEditLayout extends ScrollView { public ScrollEdi ...

  3. js跳转页面方法整理

    1.window.location.href方式 window.location.href="http://www.zgw8.com"; 2.window.navigate方式跳转 ...

  4. 谈Objective-C Block的实现

    来源:http://blog.devtang.com/blog/2013/07/28/a-look-inside-blocks/ 前言 这里有关于block的5道测试题,建议你阅读本文之前先做一下测试 ...

  5. Hibernate注解:一对多外键关联

    情形:两个表,cms_mode是主表,cms_model_field是子表,cms_model_field的model_id字段关联到cms_model的主键. # # Source for tabl ...

  6. java自定义注解注解方法、类、属性等等【转】

    http://anole1982.iteye.com/blog/1450421 http://www.open-open.com/doc/view/51fe76de67214563b20b385320 ...

  7. What is Split Brain in Oracle Clusterware and Real Application Cluster (文档 ID 1425586.1)

    In this Document   Purpose   Scope   Details   1. Clusterware layer   2. Real Application Cluster (d ...

  8. SVN小小用法(一)svn服务器搭建

    最近由于公司项目用SVN作为版本控制工具,本着学一点是一点的原则,今天小配了下svn,给大家介绍一下 软件:TortoiseSVN-1.8.3.24901-win32-svn-1.8.4.msi(本人 ...

  9. Codeforces Round #219 (Div. 1) C. Watching Fireworks is Fun

    C. Watching Fireworks is Fun time limit per test 4 seconds memory limit per test 256 megabytes input ...

  10. Appnium移动自动化框架初探

    作者:cryanimal QQ:164166060 本文简要介绍了appnium自动化框架的架构.加载流程.支持语言.相关配置,以及元素定位工具等. 官方网站: http://appium.io Ap ...