我的信息包:
a=IP(src="30.1.1.2",dst="20.1.1.2",options=IPOption('\x83\x07\x04\x00\x00\x00\x00\x00'),)
我收到错误:
a=bytes(IP(src="30.1.1.2",dst="20.1.1.2",options=IPOption('\x83\x07\x04\x00\x00\x00\x00\x00'),))
Traceback (most recent call last):
File "/usr/lib/python3.4/code.py", line 90, in runcode exec(code, self.locals)
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/scapy/base_classes.py", line 197, in call
cls = cls.dispatch_hook(*args, **kargs)
File "/usr/local/lib/python3.4/dist-packages/scapy/layers/inet.py", line 161, in dispatch_hook
opt = pkt[0] & 0x1f
TypeError: unsupported operand type(s) for &: 'str' and 'int' –
答案 0 :(得分:1)
由于您使用的是Python 3,因此您应该使用bytes
代替str
来获取IP选项:
a = bytes(IP(src="30.1.1.2", dst="20.1.1.2",
options=IPOption(b'\x83\x07\x04\x00\x00\x00\x00\x00'))