1.使用Python制造免费ARP(Gratuitous ARP)
任务一: 让两台路由器配置相同的IP地址, 路由器Console会产生如下图的日志告警

任务二: 使用抓包工具,捕获免费ARP(Gratuitous ARP)的数据包,并分析包结构
通过wireshark来抓到ARP的包,如下:
任务三: 使用Python构造ARP(Gratuitous ARP)的数据包,让路由器产生同样的日志告警
脚本:
from scapy.all import ARP, sendimport time# 目标IP地址(路由器的IP)target_ip = "10.10.1.1"# 构造Gratuitous ARP数据包# Gratuitous ARP的特点是:# 1. 源IP和目标IP都是我们想要伪造的IP(路由器的IP)# 2. 源MAC地址是我们自己的MAC地址(可以是任意合法的MAC地址)# 3. op=2表示这是一个ARP响应包arp_packet = ARP( op=2, # ARP响应 psrc=target_ip, # 源IP(伪造为路由器的IP) pdst=target_ip, # 目标IP(与源IP相同) hwsrc="00:11:22:33:44:55" # 伪造的源MAC地址)print("正在发送Gratuitous ARP数据包,目标IP:", target_ip)print("伪造的MAC地址:00:11:22:33:44:55")print("按Ctrl+C停止发送")try: while True: # 发送ARP数据包 send(arp_packet, verbose=0) print("已发送一个Gratuitous ARP数据包") time.sleep(1) # 每秒发送一次except KeyboardInterrupt: print("\n发送停止")
效果:

#Python,#SRE,#CCIE,#NetDevops,#AIops,#Linux,#Trae