TypeError send_arp_reply missing 4 required positional arguments src_ip src_mac dst_ip and dst_macdef scan_networkifname active_hosts = for i in range1 255 dst_ip = 192168197 + stri
需要修改send_arp_reply函数的参数,将缺失的4个参数添加进去。
修改后的代码如下:
def send_arp_reply(ifname, src_ip, src_mac, dst_ip, dst_mac): # 发送ARP响应 arp_reply = ARP(op=2, hwsrc=src_mac, psrc=src_ip, hwdst=dst_mac, pdst=dst_ip) ether = Ether(dst=dst_mac, src=src_mac) packet = ether / arp_reply sendp(packet, iface=ifname, verbose=False)
# 接收ARP响应
timeout = time.time() + 1
while True:
if time.time() > timeout:
break
response = sniff(iface=ifname, filter='arp and src host ' + dst_ip, count=1, timeout=1)
if len(response) > 0:
return {'src_ip': response[0][ARP].psrc, 'src_mac': response[0][ARP].hwsrc}
return None
然后在调用send_arp_reply函数时,需要传入缺失的4个参数,如下所示:
response = send_arp_reply(ifname, '192.168.197.1', get_mac_address(ifname), dst_ip, 'ff:ff:ff:ff:ff:ff'
原文地址: https://www.cveoy.top/t/topic/fnBn 著作权归作者所有。请勿转载和采集!