1. 简介
Wireshark 是一款世界范围最广,最好用的网络封包分析软件,功能强大,界面友好直观,操作起来非常方便。它的创始人是 Gerald Combs,前身是 Ethereal,作为开源项目经过众多开发者的完善它已经成为使用量最大的安全工具之一。在CTF中也经常会使用 wireshark 进行流量数据包分析,可以快速检测网络通讯数据,获取最为详细的网络封包资料。Wireshark使用 WinPCAP 作为接口,直接与网卡进行数据报文交换。用户将在图形界面中浏览这些数据,实时监控TCP、session等网络动态,轻松完成网络管理工作。
2. 当前软件版本
WireShark-V3.4.6
3. 数据包分析
数据包嗅探或协议分析:指捕获和解析网络上传输的数据的过程,以便更好地了解网络上正在发生的事情。
4. 界面介绍
- Display Filter (显示过滤器) 用于显示过滤
- Packet List Pane(封包列表)显示捕获到的封包,有序号、时间、源IP、目标IP、协议、长度、基本信息等,使用不同颜色来代表
- Packet Details Pane(封包详细信息)显示封包中的字段
- Dissector Pane(16进制原始数据)
- Miscellanous(地址栏,杂项)
5. 捕获选项设置
捕获设置菜单,点击这个菜单就可以得到下方的三个窗口
input选项卡
接口电脑端口列表
Enable promisecuous mode on all interfaces所有端口开启混杂模式
Manage Interfaces管理网卡
Capture filter for selected interfaces
抓包过滤器输入栏
output选项卡
Capture to a permanent file把抓包的数据保存到指定的路径,在Brower…中选择文件路径和文件名
Output formate抓包数据输出的文件格式
create a new file automatically…自动创建一个文件,以下是满足以下条件之一就会自动生成一个文件
例如:选择第一个after后,把100000改成1后,意思是在每产生一个数据包后自动生成一个文件 第二个after是按字节大小来划分文件,第三个 after 按时间秒数来分
选项
Update list of packets in real-time勾选后,抓包主窗口将会实时显示提取到的所有数据包
Automatically scroll during live capture勾选后,抓包主窗口将会实时自动滚屏
Resolve MAC Address勾选后,在主窗口显示抓包的数据时,将MAC地址中的网络设置制造商ID解析为相对应的厂商名称
Resolve network names勾选后,在主窗口显示抓包数据时,将IP地址解析为相对应的DNS名称
Resolve transport names勾选后,在主窗口显示数据时,将第四层协议端口号解析为相应的应用程序名称
Stop capture aut omatically after…自动停止捕获,以下是满足以下条件之一就会自动停止捕获
6. 过滤
6.1. 过滤器分类
显示过滤器:即主界面所显示的,用于在捕获的记录中找到所需要的记录
捕获过滤器:用来过滤捕获的封包,以免捕获太多的记录,扰乱我们搜索。
6.2. 过滤表达式编写规则
我们可以通过编写表达式的方式来定制我们需要的过滤规则。
IP地址过滤
ip.src == x
,过滤出源 IP 地址为 x 的数据包
例如ip.src == 192.168.0.1
,对源地址为192.168.0.1的包的过滤,即抓取源地址满足要求的包ip.dst == x
,过滤出目标 IP 地址为 x 的数据包
例如ip.dst == 192.168.0.1
,对目标地址为192.168.0.1的包的过滤,即抓取源地址满足要求的包ip.addr == x
过滤出满足源或者目的地址的ip地址是 x 的包
例如ip.addr == 192.168.0.1
过滤出满足源或者目的地址的ip地址是 192.168.0.1 的包!(ip.src == x)
排除的源IP为 x 的数据包
例如!(ip.src == 192.168.0.1)
排除源IP为 192.168.0.1 的数据包
协议过滤
http
过滤出 http 协议的数据包tcp
过滤出 tcp 协议的数据包udp
过滤出 udp 协议的数据包arp
过滤出 arp 协议的数据包icmpv6
过滤出 icmpv6 协议的数据包http or telnet
要捕获多种协议的数据包,也只需对协议进行逻辑组合即可not tcp
或!tcp
排除 某种协议的数据包,这里排除的是 tcp 协议
当然协议并不只上面列出的部分
端口过滤
tcp.port == x
udp.port == x
过滤出某个端口的数据包,这里还有协议上的区分tcp.port >= x
udp.port >= x
过滤出大于某个端口的数据包,这里还有协议上的区分
长度和内容过滤
udp.length < 30
http.content_length <=20
过滤出某个长度范围的数据包http.request.uri matches "vipscu"
过滤出 http 请求中含有vipscu字段的请求信息的数据包
7. 数据包详细信息分析
Frame: 物理层的数据帧概况
Ethernet II: 数据链路层以及以太网头部信息
Internet Protocol Version 4: 网络层IP包头部信息
Transmission Control Protocol:运输层T的数据段头部信息,此处是TCP
Hypertext Transfer Protocol:应用层信息,此处是HTTP协议
这是某一次抓包中抓取的某数据 TCP 报文,主要存在4行数据详细信息:
1. Frame 9: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{7B569D3D-0E8F-456E-AEC1-AC74E1E8284D}, id 0
2. Ethernet II, Src: Micro-St_58:61:80 (00:d8:61:58:61:80), Dst: RuijieNe_72:d3:e2 (80:05:88:72:d3:e2)
3. Internet Protocol Version 4, Src: 192.168.3.79, Dst: 112.34.111.108
4. Transmission Control Protocol, Src Port: 10443, Dst Port: 80, Seq: 1, Ack: 1, Len: 0
- 1
- 2
- 3
- 4
第一行,帧Frame 9指的是要发送的数据块,其中,所抓帧的序号为9,捕获字节数等于传送字节数:54字节
第二行,以太网,有线局域网技术,是数据链路层。源Mac地址为00:d8:61:58:61:80,目标Mac地址为80:05:88:72:d3:e2
第三行,IPV4协议,也称网际协议,是网络层,源IP地址为192.168.3.79;目标IP地址为112.34.111.108
第四行,TCP协议,也称传输控制协议,是传输层,源端口(80),目标端口(52066),序列号(15585403);ACK是TCP数据包首部中的确认标志,对已接收到的TCP报文进行确认,值为1表示确认号有效;长度为0
这4行信息展开后是这样的,注意前面的标号是个人添加的,便于可读性:
1. Frame 9: 54 bytes on wire (432 bits), 54 bytes captured (432 bits) on interface \Device\NPF_{7B569D3D-0E8F-456E-AEC1-AC74E1E8284D}, id 0
1.1. Interface id: 0 (\Device\NPF_{7B569D3D-0E8F-456E-AEC1-AC74E1E8284D})
1.1.1. Interface name: \Device\NPF_{7B569D3D-0E8F-456E-AEC1-AC74E1E8284D}
1.1.2. Interface description: 以太网
1.2. Encapsulation type: Ethernet (1)
1.3. Arrival Time: Jun 19, 2021 23:50:04.258836000 中国标准时间
1.4. [Time shift for this packet: 0.000000000 seconds]
1.5. Epoch Time: 1624117804.258836000 seconds
1.6. [Time delta from previous captured frame: 0.421582000 seconds]
1.7. [Time delta from previous displayed frame: 0.421582000 seconds]
1.8. [Time since reference or first frame: 1.118163000 seconds]
1.9. Frame Number: 9
1.10. Frame Length: 54 bytes (432 bits)
1.11. Capture Length: 54 bytes (432 bits)
1.12. [Frame is marked: False]
1.13. [Frame is ignored: False]
1.14. [Protocols in frame: eth:ethertype:ip:tcp]
1.15. [Coloring Rule Name: TCP RST]
1.16. [Coloring Rule String: tcp.flags.reset eq 1]
2. Ethernet II, Src: Micro-St_58:61:80 (00:d8:61:58:61:80), Dst: RuijieNe_72:d3:e2 (80:05:88:72:d3:e2)
2.1. Destination: RuijieNe_72:d3:e2 (80:05:88:72:d3:e2)
2.1.1. Address: RuijieNe_72:d3:e2 (80:05:88:72:d3:e2)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
2.2. Source: Micro-St_58:61:80 (00:d8:61:58:61:80)
2.2.1. Address: Micro-St_58:61:80 (00:d8:61:58:61:80)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
2.3. Type: IPv4 (0x0800)
3. Internet Protocol Version 4, Src: 192.168.3.79, Dst: 112.34.111.108
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
3.1. Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint: Default (0)
.... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
3.2. Total Length: 40
3.3. Identification: 0x6bed (27629)
3.4. Flags: 0x40, Don't fragment
0... .... = Reserved bit: Not set
.1.. .... = Don't fragment: Set
..0. .... = More fragments: Not set
3.5. Fragment Offset: 0
3.6. Time to Live: 128
3.7. Protocol: TCP (6)
3.8. Header Checksum: 0xeb5c [validation disabled]
3.9. [Header checksum status: Unverified]
3.10. Source Address: 192.168.3.79
3.11. Destination Address: 112.34.111.108
4. Transmission Control Protocol, Src Port: 10443, Dst Port: 80, Seq: 1, Ack: 1, Len: 0
4.1. Source Port: 10443
4.2. Destination Port: 80
4.3. [Stream index: 1]
4.4. [TCP Segment Len: 0]
4.5. Sequence Number: 1 (relative sequence number)
4.6. Sequence Number (raw): 406645877
4.7. [Next Sequence Number: 1 (relative sequence number)]
4.8. Acknowledgment Number: 1 (relative ack number)
4.9. Acknowledgment number (raw): 230375547
0101 .... = Header Length: 20 bytes (5)
4.10. Flags: 0x014 (RST, ACK)
000. .... .... = Reserved: Not set
...0 .... .... = Nonce: Not set
.... 0... .... = Congestion Window Reduced (CWR): Not set
.... .0.. .... = ECN-Echo: Not set
.... ..0. .... = Urgent: Not set
.... ...1 .... = Acknowledgment: Set
.... .... 0... = Push: Not set
4.10.1. .... .... .1.. = Reset: Set
4.10.1.1. [Expert Info (Warning/Sequence): Connection reset (RST)]
4.10.1.1.1. [Connection reset (RST)]
4.10.1.1.2. [Severity level: Warning]
4.10.1.1.3. [Group: Sequence]
.... .... ..0. = Syn: Not set
.... .... ...0 = Fin: Not set
4.10.2. [TCP Flags: ·······A·R··]
4.11. Window: 0
4.12. [Calculated window size: 0]
4.13. [Window size scaling factor: -1 (unknown)]
4.14. Checksum: 0x9047 [unverified]
4.15. [Checksum Status: Unverified]
4.16. Urgent Pointer: 0
4.17. [Timestamps]
4.17.1. [Time since first frame in this TCP stream: 0.000000000 seconds]
4.17.2. [Time since previous frame in this TCP stream: 0.000000000 seconds]
对上方的数据按标题归类
Frame
Arrival Time: Jun 19, 2021 23:50:04.258836000 中国标准时间
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1624117804.258836000 seconds
[Time delta from previous captured frame: 0.421582000 seconds]
[Time delta from previous displayed frame: 0.421582000 seconds]
[Time since reference or first frame: 1.118163000 seconds]
Frame Number: 9
Frame Length: 54 bytes (432 bits)
Capture Length: 54 bytes (432 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:tcp]
[Coloring Rule Name: TCP RST]
[Coloring Rule String: tcp.flags.reset eq 1]
Ethernet II
Destination: RuijieNe_72:d3:e2 (80:05:88:72:d3:e2)
Source: Micro-St_58:61:80 (00:d8:61:58:61:80)
Type: IPv4 (0x0800)
Internet Protocol Version 4
Version: 4
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Flags: 0x40, Don’t fragment
Fragment Offset: 0
Time to Live: 128
Protocol: TCP (6)
Header Checksum: 0xeb5c [validation disabled]
[Header checksum status: Unverified]
Source Address: 192.168.3.79
Destination Address: 112.34.111.108
Transmission Control Protocol
Source Port: 10443
Destination Port: 80
[Stream index: 1]
[TCP Segment Len: 0]
Sequence Number: 1 (relative sequence number)
Sequence Number (raw): 406645877
[Next Sequence Number: 1 (relative sequence number)]
Acknowledgment Number: 1 (relative ack number)
Acknowledgment number (raw): 230375547
Header Length: 20 bytes (5)
Flags: 0x014 (RST, ACK)
Window: 0
[Calculated window size: 0]
[Window size scaling factor: -1 (unknown)]
Checksum: 0x9047 [unverified]
[Checksum Status: Unverified]
Urgent Pointer: 0TCP数据报的所有详细信息都展示在上面了,但是,注意并不是所有的网络协议都以上面的数据格式呈现,不同的协议其数据格式不同,比如有些协议它不止三行内容,它可以是四行,五行等等。
8. 图标