gpt4 book ai didi

python - scapy 函数 sniff() 中的过滤器表示 libpcap 不可用

转载 作者:行者123 更新时间:2023-12-05 06:56:50 35 4
gpt4 key购买 nike

我在玩 Scapy 嗅探功能,我想在参数中添加一个过滤器。所以我添加了这个过滤器:

pkt = sniff(count=1, filter='arp')

我收到的输出是:

WARNING: Cannot set filter: libpcap is not available. Cannot compile filter !

我仍然收到一个被嗅探到的数据包,但由于某种原因过滤器无法正常工作。

我正在运行 Mac OS Big Sur。我使用 Homebrew 安装了 libpcap,并使用 Homebrew 安装了 tcpdump。

我也在网上看到你可以在 Scapy 上使用手动初始化 pcap

conf.use_pcap = True

然而,当我输入这个时,我得到:

WARNING: No libpcap provider available ! pcap won't be used

我确定这只是一个小修复,但我似乎无法弄清楚我做错了什么。如果有人可以提供帮助,那就太好了!

最佳答案

旧版本的 Python 3 假定,在 macOS 上,所有共享库都位于多个目录之一的文件中。

Big Sur 的情况不是;取而代之的是,为系统共享库生成缓存文件,并且至少生成缓存文件的某些库随操作系统一起提供。

这是 CPython issue 41100 中的问题之一, "支持 macOS 11 和 Apple Silicon Macs";解决方法是查看共享库缓存以及文件系统。

那个问题说

Thank you to everyone who contributed to this major undertaking! A particular thank you to Lawrence for doing much of the initial work and paving the way. Now that 3.8 also supports Big Sur and Apple Silicon Macs as of the imminent 3.8.10 release, it's time to close this issue. If new concerns arise, pleasa open or use other issues.

因此足够新的 Python 版本应该可以解决这个问题。

关于python - scapy 函数 sniff() 中的过滤器表示 libpcap 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65030510/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com