如何正确还原ARP缓存?

时间:2018-09-21 02:31:21

标签: python python-3.x network-programming scapy

我正在具有Scapy的Windows 7计算机上使用Python3.6。

我想建立一个系统来拦截网络上的流量并将其记录下来,并有可能冒险对其进行过滤。我的ARP中毒和日志记录工作正常,但是尝试恢复连接后的尝试似乎总是失败,因此我必须手动重新连接到我正在ARP的系统上的网络。

这里是我的代码:

def restore_network(gateway_ip, gateway_mac, target_ip, target_mac):
    send(ARP(op=2, hwdst=gateway_mac, pdst=gateway_ip, hwsrc=target_mac, psrc=target_ip), count=4)
    send(ARP(op=2, hwdst=target_mac, pdst=target_ip, hwsrc=gateway_mac, psrc=gateway_ip), count=4)

我本来是想像这样将其冲洗掉的,但无济于事:

def restore_network(gateway_ip, gateway_mac, target_ip, target_mac):
    send(ARP(op=2, hwdst="ff:ff:ff:ff:ff:ff", pdst=gateway_ip, hwsrc=target_mac, psrc=target_ip), count=4)
    send(ARP(op=2, hwdst="ff:ff:ff:ff:ff:ff", pdst=target_ip, hwsrc=gateway_mac, psrc=gateway_ip), count=4)

我仍在学习网络,因此可能很明显,但是Google的帮助无济于事。任何朝着正确方向的指针将不胜感激!

0 个答案:

没有答案