scapy 构造 IP 报文时 options 字段填充出错

2015-07-30 17:57:58 +08:00
 weiyu

from scapy.all import *
WARNING: No route found for IPv6 destination :: (no default route?)
packet = IP(options='0x11')
packet.display()

[ IP ]

version = 4
ihl = None
tos = 0x0
len = None
id = 1
flags =
frag = 0
ttl = 64
proto = ip
chksum = None
src = 127.0.0.1
dst = 127.0.0.1
\options \
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 794, in display
self.show(args,*kargs)
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 816, in show
fvalue.show(indent=indent, labellvl=label_lvl+lvl+" |")
AttributeError: 'str' object has no attribute 'show'
send(packet)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/scapy/sendrecv.py", line 251, in send
__gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
File "/usr/lib/python2.7/site-packages/scapy/sendrecv.py", line 234, in __gen_send
s.send(p)
File "/usr/lib/python2.7/site-packages/scapy/arch/linux.py", line 387, in send
sx = str(ll(x))
File "/usr/lib/python2.7/site-packages/scapy/arch/linux.py", line 385, in <lambda>
ll = lambda x:conf.l2typessn[3]/x
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 267, in __div
_
cloneB = other.copy()
File "/usr/lib/python2.7/site-packages/scapy/packet.py", line 147, in copy
clone.fields[k]=self.get_field(k).do_copy(clone.fields[k])
File "/usr/lib/python2.7/site-packages/scapy/fields.py", line 413, in do_copy
return map(lambda p:p.copy(), x)
File "/usr/lib/python2.7/site-packages/scapy/fields.py", line 413, in <lambda>
return map(lambda p:p.copy(), x)
AttributeError: 'str' object has no attribute 'copy'

3582 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/209629

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX