可以在代码中加入一个计数器,当检测到一定次数未发现攻击时,就可以提前结束。例如:

no_attack_count = 0 # 计数器,记录连续未检测到攻击的次数 while True: # 发送ARP欺骗数据包并监听响应 # ... for packet in sniff_packets: if packet[ARP].op == 2: # ARP响应数据包 # ... else: no_attack_count += 1 if no_attack_count >= 3: # 连续未检测到攻击3次,提前结束 messagebox.showinfo("提示", "未检测到ARP欺骗攻击!") with open("detection_log.txt", "a") as f: f.write("ARP欺骗攻击检测 - 检测结果:未检测到ARP欺骗攻击\n") retur

def arp_spoofing target_ip = 192168197132 # 目标主机IP地址 target_mac = # 目标主机MAC地址 gateway_ip = 1921681972 # 网关IP地址 gateway_mac = # 网关MAC地址 # 发送ARP请求获取目标主机MAC地址 arp_request = ARPpdst=ta

原文地址: https://www.cveoy.top/t/topic/fsW6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录