Scapy,IndexError:未找到[dot11]
我正在尝试使用SCAPY发送HTTP响应。我嗅出一个请求,然后尝试制造答复。我以此问题的问题为基础。 。这是引起问题的代码:
import scapy.all as scapy
from scapy.layers.http import HTTPRequest
from scapy.layers.dot11 import RadioTap
from scapy.layers.dot11 import Dot11
packets = scapy.sniff(count=30)
for i in range(len(packets)):
if packets[i].haslayer(HTTPRequest):
pkt = packets[i]
dot11_frame = RadioTap()/Dot11(
type = "Data",
FCfield = "from-DS",
addr1 = pkt[scapy.Dot11].addr2,
addr2 = pkt[scapy.Dot11].addr1,
addr3 = pkt[scapy.Dot11].addr1,
)
在我嗅到数据包并获取所需的所有信息之后,我要做另一个人所做的事情,问题是我继续遇到此错误,并定义dot11_frame,indexError:层[dot11]找不到
,这发生在行addr1 = pkt [scapy.dot11] .addr2
时发生。我什至没有像一些的答案。那么如何解决此错误?
I am trying to send a HTTP response using scapy. I sniff out an request and then attempt to fabricate a response. I am basing this off the code in this question. Here is the code that is causing problems:
import scapy.all as scapy
from scapy.layers.http import HTTPRequest
from scapy.layers.dot11 import RadioTap
from scapy.layers.dot11 import Dot11
packets = scapy.sniff(count=30)
for i in range(len(packets)):
if packets[i].haslayer(HTTPRequest):
pkt = packets[i]
dot11_frame = RadioTap()/Dot11(
type = "Data",
FCfield = "from-DS",
addr1 = pkt[scapy.Dot11].addr2,
addr2 = pkt[scapy.Dot11].addr1,
addr3 = pkt[scapy.Dot11].addr1,
)
After I sniff the packet and get all the information required I do what the other guy did, and the problem is that I keep on getting this error with the part defining dot11_frame, IndexError: Layer [Dot11] not found
, this happens when the line addr1 = pkt[scapy.Dot11].addr2
is run. I have not even done a wildcard import like some answers suggested. So how do I fix this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您可能是指
pkt [dot11]
,而不是[scapy.dot11]
,因为您导入了名称dot11
。其次,似乎您捕获的数据包不包含
dot11
层。例如,如果您从非Wi-Fi接口捕获数据包,或者是从不配置为监视器接口的Wi-Fi接口中捕获数据包。为了帮助您调试问题,可以在分配
pkt
变量后添加print(pkt.command())
。另外,您可能想在认真使用Scapy之前学习一些Python。例如,而不是:
您想写:
希望这会有所帮助!
First, you probably mean
pkt[Dot11]
, not[scapy.Dot11]
, as you imported the nameDot11
.Second, it seems that the packet you are capturing do not contain a
Dot11
layer. This will happen, for example, if you capture packets from a non-Wi-Fi interface, or from a Wi-Fi interface that is not configured as a monitor interface.To help you debug your problem, you could add a
print(pkt.command())
just after assigning thepkt
variable.Also, you probably want to learn a bit of Python before using Scapy seriously. For example, rather than:
You want to write:
Hope this helps!