gpt4 book ai didi

python - Scapy - 创建一个数据包并显示它导致 >NoneType 对象没有属性 'route' <

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:52 30 4
gpt4 key购买 nike

我刚刚发现了一些奇怪的东西。执行以下操作

>>> from scapy.layers.inet import Ether,IP,UDP
>>> e=Ether()
>>> i=IP()
>>> u=UDP()
>>> p=e/i/u
>>> p.show()

导致这个错误

###[ Ethernet ]###
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/packet.py", line 838, in show
reprval = f.i2repr(self,fvalue)
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/fields.py", line 191, in i2repr
x = self.i2h(pkt, x)
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/layers/l2.py", line 89, in i2h
x = conf.neighbor.resolve(pkt,pkt.payload)
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/layers/l2.py", line 38, in resolve
return self.resolvers[k](l2inst,l3inst)
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/layers/inet.py", line 732, in <lambda>
conf.neighbor.register_l3(Ether, IP, lambda l2,l3: getmacbyip(l3.dst))
File "/home/lk/virtualenvs/FuzzingEnv/local/lib/python2.7/site-packages/scapy/layers/l2.py", line 57, in getmacbyip
iff,a,gw = conf.route.route(ip)
AttributeError: 'NoneType' object has no attribute 'route'
>>> ...

但是只是在出现这样的错误之后从 scapy 导入所有内容

>>> ...
>>> from scapy.all import *
WARNING: No route found for IPv6 destination :: (no default route?)
>>> p.show()
###[ Ethernet ]###
dst = ff:ff:ff:ff:ff:ff
src = 00:00:00:00:00:00
type = 0x800
###[ IP ]###
version = 4
ihl = None
tos = 0x0
len = None
id = 1
flags =
frag = 0
ttl = 64
proto = udp
chksum = None
src = 127.0.0.1
dst = 127.0.0.1
\options \
###[ UDP ]###
sport = domain
dport = domain
len = None
chksum = None
>>>

似乎以某种方式修复了它。怎么会这样?我需要导入一些特殊模块吗?

最佳答案

你还需要引入 scapy 路由模块。

from scapy import route
from scapy.layers.inet import Ether,IP,UDP
e=Ether()
i=IP()
u=UDP()
p=e/i/u
p.show()

关于python - Scapy - 创建一个数据包并显示它导致 >NoneType 对象没有属性 'route' <,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35038513/

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