首页 > 其他分享 >wireshark抓包常识与常用命令

wireshark抓包常识与常用命令

时间:2023-08-28 10:24:14浏览次数:31  
标签:src ip dst ne 192.168 filter 常用命令 抓包 wireshark

本文章分wireshark抓包常识,常用命令,实际使用中自己用到的一些命令。

常识

Comparison operators

The comparison operators can be expressed either through English-like abbreviations or through C-like symbols:

eq, ==    Equal
ne, !=    Not Equal
gt, >     Greater Than
lt, <     Less Than
ge, >=    Greater than or Equal to
le, <=    Less than or Equal to

总结:可以使用两种方式来设置表达式。

 

Arithmetic operators

Arithmetic expressions are supported with the usual operators:

+   Addition
-   Subtraction
*   Multiplication
/   Division
%   Modulo (integer remainder)

For example it is possible to filter for UDP destination ports greater or equal by one to the source port with the expression:

udp.dstport >= udp.srcport + 1

It is possible to group arithmetic expressions using curly brackets (parenthesis will not work for this):

tcp.dstport >= 4 * {tcp.srcport + 3}

Do not confuse this usage of curly brackets with set membership.

An unfortunate quirk in the filter syntax is that the subtraction operator must be preceded by a space character, so "A-B" must be written as "A -B" or "A - B".

总结:减号前面留个空格。

 

Logical expressions

Tests can be combined using logical expressions. These too are expressible in C-like syntax or with English-like abbreviations. The following table lists the logical operators from highest to lowest precedence:

not, !    Logical NOT   (right-associative)
and, &&   Logical AND   (left-associative)
or,  ||   Logical OR    (left-associative)

The evaluation is always performed left to right. Expressions can be grouped by parentheses as well. The expression "A and B or not C or D and not E or F" is read:

(A and B) or (not C) or (D and (not E)) or F

It’s usually better to be explicit about grouping using parenthesis. The following are all valid display filter expressions:

tcp.port == 80 and ip.src == 192.168.2.1
not llc
http and frame[100-199] contains "wireshark"
(ipx.src.net == 0xbad && ipx.src.node == 0.0.0.0.0.1) || ip

Remember that whenever a protocol or field name occurs in an expression, the "exists" operator is implicitly called. The "exists" operator has the highest priority. This means that the first filter expression must be read as "show me the packets for which tcp.port exists and equals 80, and ip.src exists and equals 192.168.2.1". The second filter expression means "show me the packets where not exists llc", or in other words "where llc does not exist" and hence will match all packets that do not contain the llc protocol. The third filter expression includes the constraint that offset 199 in the frame exists, in other words the length of the frame is at least 200.

Each comparison has an implicit exists test for any field value. Care must be taken when using the display filter to remove noise from the packet trace. If, for example, you want to filter out all IP multicast packets to address 224.1.2.3, then using:

ip.dst ne 224.1.2.3

may be too restrictive. This is the same as writing:

ip.dst and ip.dst ne 224.1.2.3

The filter selects only frames that have the "ip.dst" field. Any other frames, including all non-IP packets, will not be displayed. To display the non-IP packets as well, you can use one of the following two expressions:

not ip.dst or ip.dst ne 224.1.2.3
not ip.dst eq 224.1.2.3

The first filter uses "not ip.dst" to include all non-IP packets and then lets "ip.dst ne 224.1.2.3" filter out the unwanted IP packets. The second filter also negates the implicit existance test and so is a shorter way to write the first.

 

常用命令

选出需要ip地址

IPv4 addresses can be represented in either dotted decimal notation or by using the hostname:

总结:ip地址表达可以使用两种方式。

ip.src == 192.168.1.1
ip.dst eq www.mit.edu

去掉不要的ip地址

ip.dst ne 224.1.2.3
ip.dst and ip.dst ne 224.1.2.3


等价命令:去掉不要的ip地址。
ip.src ne 192.168.0.17
ip.src and ip.src ne 192.168.0.17
not ip.src eq 192.168.0.17
not ip.src or ip.src ne 192.168.0.17

 

not ip.src eq 192.168.0.17

 

not ip.src or ip.src ne 192.168.0.17

ip.src ne 192.168.0.17过滤的好像是更细腻点。

 

去掉不要的协议

过滤条件后,加上and not icmp,去掉icmp协议。

xxxxxxxx and not icmp

还可以:
not arp
not dns
rtcp and not icmp

测试结果:

 

wireshark过滤实操:

1.含有IP地址:192.168.0.17 且是udp协议,同时端口是6801到6803。

 ip.addr == 192.168.0.17 and udp.dstport>=6801 and udp.dstport<=6803

2.源地址,目的地址,udp端口。

 ip.src == 192.168.90.51 and ip.dst == 192.168.90.85 and udp.port == 60000

3.源地址,目的地址,udp协议

 ip.src == 192.168.90.51 and ip.dst == 192.168.90.85 and udp

4.只过滤ip地址,不分源地址还是目的地址。udp协议

 ip.addr == 192.168.90.51 and udp

5.只过滤ip地址

 ip.addr == 192.168.90.51

 

差不多了,剩下的就是举一反三了。可以多参考Logical expressions小节。

 

参考官方文档:

 file:///D:/Program%20Files/Wireshark/wireshark-filter.html

 

标签:src,ip,dst,ne,192.168,filter,常用命令,抓包,wireshark
From: https://www.cnblogs.com/bluemapleleaf/p/17661550.html

相关文章

  • 遇到的Docker常用命令
    遇到的Docker常用命令一、安装Docker1)Docker要求CentOS系统的内核版本高于3.10,首先查看系统内核版本是否满足uname-r2)使用root权限登录系统,确保yum包更新到最新sudoyumupdate-y3)假如安装过旧版本,先卸载旧版本sudoyumremovedockerdocker-commondocker-sel......
  • 【面试宝典】Git 版本控制常用命令
    一.Git概述Git是目前世界上最先进的分布式版本控制工具,主要用于管理开发过程中的源代码文件(Java类、xml文件、html页面等),包括:代码回溯:Git在管理文件过程中会记录日志,方便回退到历史版本版本切换:Git存在分支的概念,一个项目可以有多个分支(版本),可以任意切换多人协作:Git支......
  • Allure常用命令
    命令格式:allure [option]  [command]  [commandoptions]allure--help帮助allure--version查看版本信息allureserve 生成在线版本的测试alluregenerate<allure-result中间文件> -o  输出目录(默认路径:allure-report)引入依赖<?xmlversion="1.0"e......
  • 安卓 adb常用命令
    什么是adb:adb是PC电脑与android手机进行通信操作的工具软件,类似于Xshell可以通过windows访问操作Linux如何安装adb软件(环境):下载adb绿色免安装版什么是adbshell:切换进入Linux内核的命令行界面(android的底层使用的是Linux内核,所以切换进入Linux内核命令行界面后,可以使用Lin......
  • fiddler抓包手机端HTTPS协议:安卓或鸿蒙端-小程序/APP
    问题描述:fiddler抓包安卓或者鸿蒙端的HTTPS协议时,fiddler日志报错:AuthenticationException调用SSPI失败;访问app时提示:Trustanchorforcertificationnotfound原因:    1)安卓端下载使用了fiddler自带的HTTPS证书,导致与手机版本不兼容    2)andriod7以后,用户......
  • npm 常用命令 常用知识
    1、常用命令参考:https://www.cnblogs.com/BJQE/p/16510627.htmlhttps://zhuanlan.zhihu.com/p/4424078791、清除缓存有时候安装或卸载模块时,出现错误,有可能是缓存未清理的缘故。npmcacheclean--force2、知识点2.1 npmi和npminstall的区别实际使用的区别点主要如下(......
  • centos系统firewalld&iptables常用命令
    firewalld添加规则:firewall-cmd--permanent--add-rich-rule="rulefamily="ipv4"sourceaddress="192.168.142.166"portprotocol="tcp"port="5432"accept" 允许192.168.142.166访问5432端口firewall-cmd--add-port=80/t......
  • WireShark抓包探究TCP/HTTP之间的关系
    WireShark抓包探究TCP/HTTP之间的关系_wireshark追踪tcp流和http流的区别__微风轻起的博客-CSDN博客使用wireshark抓取httphttpstcpip协议进行学习-胖大星--博客园(cnblogs.com)......
  • 防火墙常用命令(Centos)
    开放端口firewall-cmd--zone=public--add-port=80/tcp--permanent#开放80端口systemctlrestartfirewalls.service#重启防火墙查看已开启的端口firewall-cmd--list-ports启动与停止firewall-cmd--state#查看防火墙状态systemctlstopfirewalls.service......
  • Git 常用命令
    Git基础部分配置用户gitconfig--globaluser.name'USERName'gitconfig--globaluser.email'USEREmail'初始化仓库#初始化一个git仓库gitinit#克隆远程仓库gitclone<url>[directory]上传仓库将文件添加到缓存#将所有文件添加到缓存gitadd.#......