scapy3.0.0和python3.5中的IPOptions抛出错误

时间:2017-08-04 07:33:32

标签: scapy

我的信息包:

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.p‌​y", 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' –

1 个答案:

答案 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'))