Scapy:未定义的变量 'Dot11Beacon' 和 'Dot11Elt'
Scapy: Undefined variable 'Dot11Beacon' and 'Dot11Elt'
我正在 Ubuntu 上尝试使用 scapy 做一个简单的 wifi 嗅探器,但是当我尝试 运行 应用程序时遇到以下问题:
Undefined variable 'Dot11Beacon'
Undefined variable 'Dot11Elt'
现在我尝试 运行 以下教程中的代码:https://www.shellvoide.com/python/how-to-code-a-simple-wireless-sniffer-in-python/
由于上述错误,它简单地不起作用。我正在使用 Python 3 和最新版本的 scapy,通过 pip 安装。
即使它与教程中的相同,以下是我使用的代码部分:
from scapy.all import *
sniff(iface=interface, prn=process_packet)
def process_packet(pak):
if pak.haslayer(Dot11Beacon):
if pak.getlayer(Dot11).addr2 not in F_bssids:
F_bssids.append(pak.getlayer(Dot11).addr2)
ssid = pak.getlayer(Dot11Elt).info
if ssid == '' or pak.getlayer(Dot11Elt).ID != 0:
print("Hidden Network Detected")
print("Network Detected: %s" % (ssid))
如果编译器说变量未定义,则在您的库中定义它们而不使用 *
。使用 from scapy.all import (Dot11,Dot11Beacon,Dot11Elt)
而不是 from scapy.all import *
你遇到了同样的问题
PyCharm 和 Visual studio 也是如此。
看看我的回答。
The workaround is to import whatever you need from their related scapy file, without using all. It is cleaner but longer to do. Or you can use "add an exception" in your IDE, if you’re not looking for something clean.
我正在 Ubuntu 上尝试使用 scapy 做一个简单的 wifi 嗅探器,但是当我尝试 运行 应用程序时遇到以下问题:
Undefined variable 'Dot11Beacon'
Undefined variable 'Dot11Elt'
现在我尝试 运行 以下教程中的代码:https://www.shellvoide.com/python/how-to-code-a-simple-wireless-sniffer-in-python/
由于上述错误,它简单地不起作用。我正在使用 Python 3 和最新版本的 scapy,通过 pip 安装。
即使它与教程中的相同,以下是我使用的代码部分:
from scapy.all import *
sniff(iface=interface, prn=process_packet)
def process_packet(pak):
if pak.haslayer(Dot11Beacon):
if pak.getlayer(Dot11).addr2 not in F_bssids:
F_bssids.append(pak.getlayer(Dot11).addr2)
ssid = pak.getlayer(Dot11Elt).info
if ssid == '' or pak.getlayer(Dot11Elt).ID != 0:
print("Hidden Network Detected")
print("Network Detected: %s" % (ssid))
如果编译器说变量未定义,则在您的库中定义它们而不使用 *
。使用 from scapy.all import (Dot11,Dot11Beacon,Dot11Elt)
而不是 from scapy.all import *
你遇到了同样的问题
The workaround is to import whatever you need from their related scapy file, without using all. It is cleaner but longer to do. Or you can use "add an exception" in your IDE, if you’re not looking for something clean.