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

IPOptions in scapy3.0.0 and python3.5 is throwing the error

我的包裹:

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' –

由于您使用的是 Python 3,因此 IP 选项应使用 bytes 而不是 str

a = bytes(IP(src="30.1.1.2", dst="20.1.1.2",
             options=IPOption(b'\x83\x07\x04\x00\x00\x00\x00\x00'))