使用WireShark对ARP、ICMP、TCP、UDP、DNS、HTTP协议分别进行抓包并分析。
1、ARP协议:
使用 nmap 来基于 ARP 协议进行扫描:
抓包:
分析:
请求包:
应答包:
可以看到应答包补全了自己的MAC地址,目的地址和源地址做了交换。
2、ICMP协议:
ping命令是基于ICMP协议的,基于ping命令进行扫描:
抓包:
分析:
请求包:
应答包:
工作过程:
本机发送一个 ICMP Echo Request 的包。
接收方返回一个 ICMP Echo Reply,包含了接受到数据拷贝和一些其他指令。
3、TCP协议:
(1)通过Xshell远程连接 Kali Linux 捕获完整的TCP 3次握手的数据包:
抓包:
分析:
第一个SYN包(序列号Seq和告知收悉号ACK都是 0):
第二个SYN/ACK包(Seq=0,Ack=1):
第三个ACK包(Seq=1,Ack=1):
第一个包中seq=x,第二个包中的ack=x+1,seq=y,第三个包中的ack=y+1。
点击流量图查看:
(2)在Xshell中输入exit断开连接,以此来抓取TCP协议的四次挥手过程:
4、UDP协议:
nmap基于UDP连接的端口扫描:
抓包:
UDP无需连接,所以较TCP简单,没有Seq和Ack号,省去了建立连接的过程,UDP协议头中,只有端口号、包长度和校验码等少量信息。
5、DNS协议:
DNS也是UDP的上层协议,可以直接用UDP筛选:
就这么简单的两行。
6、HTTP协议:
curl 是一个在命令行下工作的文件传输工具,可用来发送 http 请求。
-I 大写的 i 表示仅返回头部信息。
发送请求:
抓包分析:
因为HTTP是TCP的上层协议,所以过滤TCP的数据会包含HTTP协议的数据包:
第一步:我们我们发送了一个 HTTP 的 HEAD 请求;
第二步:服务器收到我们的请求返回了一个 Seq/ACK 进行确认;
第三步:服务器将 HTTP 的头部信息返回给我们客户端,状态码为200,表示页面正常;
第四步:客户端收到服务器返回的头部信息向服务器发送Seq/ACK进行确认,发送完成之后客户端就会发送 FIN/ACK 来进行关闭链接的请求。