在我的Python代码中,我导入 from scapy.all import ARP, Ether, srp, ICMP, sr1, IP 但是当我启动程序时,它显示这些错误:
WARNING: Wireshark is installed, but cannot read manuf !
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\scapy\layers\ipsec.py:512: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
cipher=algorithms.TripleDES,
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\scapy\layers\ipsec.py:516: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
cipher=algorithms.TripleDES,
我认为wireshark错误是因为我必须下载manuf文件,但对于其他文件,我不知道如何从输出中删除它们,我只想要一个干净的输出。
我尝试了几次 warnings.filterwarnings() 来删除输出中的错误,但没有任何效果。我如何尝试filterwarnings:
from cryptography.utils import CryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)
warnings.filterwarnings("ignore")
original_stderr = sys.stderr
sys.stderr = open(os.devnull, 'w')
sys.stderr.close() sys.stderr = original_stderr
warnings.filterwarnings("ignore", category=UserWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning)
要抑制这些警告,您需要在导入 Scapy 模块之前设置警告过滤器。
导入warnings
并在脚本的最顶部设置过滤器,然后再进行任何其他导入: 导入警告 warnings.filterwarnings("忽略")
import warnings
from cryptography.exceptions import CryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)
现在,设置警告过滤器后导入 Scapy 模块:
从 scapy.all 导入 ARP、Ether、srp、ICMP、sr1、IP
对于
Wireshark 警告,Scapy 无法读取 manuf 文件,其中包含 MAC 地址的制造商详细信息。要修复此警告:
选项 1:抑制警告。您可以通过调整日志级别来抑制 Scapy 的警告:
导入日志记录logging.getLogger(“scapy.runtime”).setLevel(logging.ERROR)
manuf
文件。您可能需要下载
manuf
文件或将 Scapy 指向正确的位置。