`
peng_wp
  • 浏览: 41866 次
社区版块
存档分类
最新评论

wireshark 抓包

阅读更多
   wireshark是一款非常不错的抓包工具。
   但是如果使用wireshark抓包却不配置filter的话,估计找到我们需要的包,会花费半天时间。
   不过还好wireshark自带了很好的帮助文档,有它们几乎可以解决所有的问题。
   如果要使用wireshark抓包,强烈建议看一下http://wiki.wireshark.org/CaptureFilters
   下面是其中部分内容,已经可见其价值了。
引用

Examples

Capture only traffic to or from IP address 172.18.5.4:
host 172.18.5.4

Capture traffic to or from a range of IP addresses:
net 192.168.0.0/24
or
net 192.168.0.0 mask 255.255.255.0

Capture traffic from a range of IP addresses:
src net 192.168.0.0/24
or
src net 192.168.0.0 mask 255.255.255.0

Capture traffic to a range of IP addresses:
dst net 192.168.0.0/24
or
dst net 192.168.0.0 mask 255.255.255.0

Capture only DNS (port 53) traffic:
port 53

Capture non-HTTP and non-SMTP traffic on your server (both are equivalent):
host www.example.com and not (port 80 or port 25)
host www.example.com and not port 80 and not port 25

Capture except all ARP and DNS traffic:
port not 53 and not arp

Capture traffic within a range of ports
(tcp[0:2] > 1500 and tcp[0:2] < 1550) or (tcp[2:2] > 1500 and tcp[2:2] < 1550)
or, with newer versions of libpcap (0.9.1 and later):
tcp portrange 1501-1549

Capture only Ethernet type EAPOL:
ether proto 0x888e

Reject ethernet frames towards the Link Layer Discovery Protocol Multicast group:
not ether dst 01:80:c2:00:00:0e

Capture only IP traffic - the shortest filter, but sometimes very useful to get rid of lower layer protocols like ARP and STP:
ip

Capture only unicast traffic - useful to get rid of noise on the network if you only want to see traffic to and from your machine, not, for example, broadcast and multicast announcements:
not broadcast and not multicast

Capture IPv6 "all nodes" (router and neighbor advertisement) traffic. Can be used to find rogue RAs:
dst host ff02::1

Capture HTTP GET requests. This looks for the bytes 'G', 'E', 'T', and ' ' (hex values 47, 45, 54, and 20) just after the TCP header. "tcp[12:1] & 0xf0) >> 2" figures out the TCP header length. From Jefferson Ogata via the tcpdump-workers mailing list.
port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420

Useful Filters

Blaster and Welchia are RPC worms. (Does anyone have better links, i.e. ones that describe or show the actual payload?)

Blaster worm:
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
The filter looks for an icmp echo request that is 92 bytes long and has an icmp payload that begins with 4 bytes of A's (hex). It is the signature of the welchia worm just before it tries to compromise a system.
Many worms try to spread by contacting other hosts on ports 135, 445, or 1433. This filter is independent of the specific worm instead it looks for SYN packets originating from a local network on those specific ports. Please change the network filter to reflect your own network.


dst port 135 or dst port 445 or dst port 1433  and tcp[tcpflags] & (tcp-syn) != 0 and tcp[tcpflags] & (tcp-ack) = 0 and src net 192.168.0.0/24



在抓HTTP GET包的时候,官方文档没有详细解释表达式的含义,这里做一点解释,权当补充材料。

想明白这个表达式( tcp[((tcp[12:1] & 0xf0) >> 2):4] )做了些什么事,需要对TCP报文有一定的了解。





由于TCP协议的设计,在报文部首部分有一个选项部分(options field),其可有可无,所以TCP报文部首长度是不固定的。在选项部分(options field)为空的情况下,部首为20个字节。
所以如果我们希望定位到具体的数据段,需要知道部首的长度。部首中有一个部首长度字段,它说明了部首的长度。
从上图可以看出,我们需要跳过12个字节才能到部首长度字段(head length field)。
部首长度字段为4bit,该字段以字(32bit)为单位说明了TCP部首长度。
所以tcp[12:1]就是读部首长度字段,由于部首长度字段是4bit的,所有了后面的 &0xf0,右移2为是因为其是以字为单位的。
得到部首长度后,我们就可以知道HTTP数据所在位置了,后面的事相信大家就都知道了。这里就不在赘述了。
类似的,我们可以写出抓取HTTP POST请求包的表达式:
tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354(只需要把GET换成POST即可)
  • 大小: 6.9 KB
分享到:
评论

相关推荐

    Wireshark抓包全集-85种协议

    本资源"Wireshark抓包全集-85种协议"涵盖了85种不同的网络通信协议,包括基础的和复杂的协议,对于深入理解网络工作原理和提升网络问题解决能力非常有帮助。 首先,我们来探讨一下其中一些核心协议: 1. ARP(地址...

    Wireshark抓包全集(85种协议、类别的抓包文件

    总之,这份Wireshark抓包文件集合是一份宝贵的工具,它可以帮助我们学习网络协议、诊断网络问题、提升安全意识,并且为教学和研究提供丰富的实例。通过深入研究这些抓包文件,不仅可以提升个人技能,也能更好地应对...

    Wireshark抓包全集(85种协议、类别的抓包文件)

    Wireshark抓包文件可揭示UDP数据包发送与接收的实时特性,以及可能出现的丢包问题。 4. HTTP(超文本传输协议):HTTP是应用层的主要协议,用于Web浏览。Wireshark能显示HTTP请求和响应的详细信息,包括方法、状态...

    Wireshark抓包全集(85种协议、类别的抓包文件).zip

    本资源"Wireshark抓包全集(85种协议、类别的抓包文件).zip"包含了85种不同协议和类别的抓包文件,对于学习和理解各种网络协议有极大的帮助。 首先,让我们了解Wireshark的基本操作和功能。Wireshark提供了图形化...

    RTSP wireshark抓包分析

    RTSP wireshark抓包分析

    使用wireshark抓包软件分析微信协议-大作业详细报告+抓取的包文件.zip

    2024.6 新增说明 偏向新手基础,有基础的不需要下载!不需要下载!不需要下载!重要的事说三遍! 和blog配套,没看过blog...使用wireshark抓包软件分析微信协议 计算机网络大作业 压缩包包含做实验时候配套抓取的包文件

    wireshark 抓包 实验报告

    "Wireshark 抓包实验报告详解" Wireshark 是一款功能强大的网络协议分析工具,广泛应用于网络安全、网络管理和网络优化等领域。本实验报告旨在对 Wireshark 的基本使用和抓包技术进行详细的讲解和实验,帮助读者更...

    Wireshark抓包全集(85种协议、类别的抓包文件)

    这份"Wireshark抓包全集(85种协议、类别的抓包文件)"是网络专家们收集和整理的宝贵资源,包含了85种不同类型的网络协议和类别,为学习和理解网络通信提供了丰富的实例。 首先,让我们来了解一下Wireshark的基本功能...

    Wireshark抓包分析TCP“三次握手,四次挥手”.doc

    Wireshark 抓包分析 TCP“三次握手,四次挥手” Wireshark 是一个功能强大的网络抓包工具,通过它我们可以抓包并分析 TCP/IP 传输过程。在本文中,我们将通过 Wireshark 来抓包和分析 TCP“三次握手,四次挥手”...

    wireshark抓包教程

    ### Wireshark抓包教程详解 #### 一、网络结构 在进行Wireshark抓包之前,理解网络结构至关重要。本教程中提到两种主要的抓包场景:抓取AC(接入控制器)的LAN口数据以及AC的WAN口数据。 **1.1 抓取AC的LAN口数据...

    Wireshark抓包分析微信功能----tcp/ip选修课期末大作业

    **TCP/IP通信协议详解与Wireshark抓包分析** 在信息技术领域,TCP/IP通信协议是互联网上数据交换的基础。TCP(传输控制协议)和IP(因特网协议)是这个协议族中的两个核心组件,负责确保数据的可靠传输和网络寻址。...

    MDNS协议wireshark抓包分析

    arduino的MDNS库,开发测试时的wireshark抓包分析,已过滤其他杂包

    LTE S1接口wireshark抓包 attach流程

    本文将详细解析S1接口的attach流程,并结合wireshark抓包工具进行深入分析。 一、attach流程概述 在LTE网络中,UE(用户设备)初次接入网络或从非连接状态转变为连接状态时,需要执行attach流程。这个过程包括以下...

    wireshark抓包GB28181示例.zip

    gb28181 协议的注册,注销(包含鉴权),catalog,invite,录像查询,录像回放,回放控制,告警订阅,移动位置订阅等协议的wireshark抓包详细报文,对初学者有帮助! 打包格式为ZIP,可以用360工具解压。

    Wireshark抓包全集(85种协议、类别的抓包文件)分少.zip

    这个压缩包文件“Wireshark抓包全集(85种协议、类别的抓包文件)分少.zip”显然是一个包含多种网络协议抓包样本的集合,适合IT专业人士和学习者用来理解和分析各种网络通信过程。 首先,让我们来了解下Wireshark的...

    wireshark抓包分析tcp三次握手四次挥手详解及网络命令

    ### Wireshark抓包分析TCP三次握手四次挥手详解及网络命令 #### 一、OSI与TCP/IP体系结构模型 在深入理解Wireshark抓包分析TCP三次握手及四次挥手之前,我们首先需要了解OSI七层模型与TCP/IP四层/五层模型的基础...

Global site tag (gtag.js) - Google Analytics