wireshark,世界上最受欢迎的网络协议分析器。是一个网络流量分析器,或"嗅探器",适用于Linux、macOS、*BSD和其他Unix和类Unix操作系统以及Windows。它使用图形用户界面库Qt以及libpcap和npcap作为数据包捕获和过滤库。
wireshark,是一个网络封包分析软件。网络封包分析软件的功能是截取网络封包,并尽可能显示出最为详细的网络封包资料。Wireshark使用WinPCAP作为接口,直接与网卡进行数据报文交换。一般称为网络抓包工具。
目录
1、官网下载并安装
wireshark 官网:https://www.wireshark.org/
wireshark 官网下载地址:https://www.wireshark.org/download.html
根据自己电脑系统,下载对应版本

下载完成

双击安装

next

noted

next

next

next

可修改安装目录
next

next

install

next

安装完成
2、使用介绍
通过菜单找到 wireshark,并打开

打开wireshark 界面

双击网络连接进行捕获,可以看到通过这个网络连接的数据包信息

wireshark 是不能自己捕获自己的,至少要在局域网下,可以使用2台电脑在局域网下进行测试
下面介绍几种常用的过滤规则,用来筛选需要的数据包
(1)、指定来源 ip,ip.src == 来源ip地址
如来源 ip 地址是 192.168.5.240,即过滤从 192.168.5.240 发送过来的请求
bash
ip.src == 192.168.5.240
(2),指定协议,如 http
(3)、指定端口,tcp.port == 端口,
如端口是80
bash
tcp.port == 80
(4)、指定目标 ip,ip.dst == 目标ip
如去向 192.168.5.240 的请求
bash
ip.dst == 192.168.5.240
(5)、多个条件使用 and 表示并且
如 http 协议并且端口是 80
bash
http and tcp.port == 80
3、测试抓包
笔者使用2台电脑,一台是192.168.5.25,另一台是192.168.5.240
从192.168.5.240向192.168.5.25发送请求
这里使用springboot新建一个项目,过程就不赘述了,直接看接收请求的代码,以验证捕获的请求
controller代码
java
package com.wsjzzcbq.wsjzwebserver.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* DemoController
*
* @author wsjz
* @date 2023/08/08
*/
@RestController
public class DemoController {
@RequestMapping("/demo")
public String demo() {
return "人悄悄,月依依,翠帘垂。更挼残蕊,更捻余香,更得些时。";
}
}
启动项目,项目端口是80
笔者从192.168.5.240 电脑发送请求http://192.168.5.25/demo,然后使用 wireshark 查看数据包
输入过滤规则 ip.dst == 192.168.5.240 and http and tcp.port == 80
目标地址是192.168.5.240,即 http 的响应
bash
ip.dst == 192.168.5.240 and http and tcp.port == 80
效果图

成功获取 http响应
至此完