Python KeyError: 'flags', when running BlueBorne script

Python KeyError: 'flags', when running BlueBorne script

我正在尝试使用 Python 2 运行 文件 l2cap_infra.py,但出现以下错误:

Traceback (most recent call last):
  File "l2cap_infra.py", line 524, in <module>
    main(*sys.argv[1:])
  File "l2cap_infra.py", line 508, in main
    l2cap_loop, _ = create_l2cap_connection(src_hci, dst_bdaddr, pcap_path=pcap_path)
  File "l2cap_infra.py", line 489, in create_l2cap_connection
    handle_information_negotiation_process(l2cap_loop)
  File "l2cap_infra.py", line 425, in handle_information_negotiation_process
    l2cap_loop.send(info_req)
  File "l2cap_infra.py", line 142, in send
    self._sock.send(packet)
  File "l2cap_infra.py", line 213, in send
    self.send_fragment(Raw(str(l2cap)[i:i+L2CAP_DEFAULT_MTU]), i == 0)
  File "l2cap_infra.py", line 223, in send_fragment
    hci = HCI_Hdr() / HCI_ACL_Hdr(handle=scapy_handle, flags=scapy_flags) / frag
  File "/usr/local/lib/python2.7/dist-packages/scapy/base_classes.py", line 227, in __call__
    i.__init__(*args, **kargs)
  File "/usr/local/lib/python2.7/dist-packages/scapy/packet.py", line 135, in __init__
    self.fields[f] = self.get_field(f).any2i(self, v)
  File "/usr/local/lib/python2.7/dist-packages/scapy/packet.py", line 170, in get_field
    return self.fieldtype[fld]
KeyError: 'flags'

这可能是版本冲突;我有一个类似的问题,我不得不在 /usr/local/lib/python2.7/.

中编辑一个文件

我必须在该链接文件或我的 pip 库之一中更改哪些代码才能使此代码正常工作?

这似乎是 BlueBorneScapy 之间的兼容性问题。

您(很可能)已经安装了最新的 Scapy 版本(v2.4.0 ),它从 scapy.layers.bluetooth.HCI_ACL_Hdr 的初始化器中删除了 fields kwarg,而 BlueBornel2cap_infra.py,可能还有其他)未相应更新(或分支)。

还有它的最新版本是v2.3.3([GitHub]: secdev/scapy - (v2.3.3) scapy/scapy/layers/bluetooth.py).

可能的解决方案:

  • 卸载当前的 Scapy 版本 (pip uninstall scapy) 并安装 v2.3.3 (pip install scapy==2.3.3)。大概,这是最简单(也是最适合)你的了([PyPI]: scapy 2.3.3)
  • BlueBorne 提交错误并等待他们添加对更新的 Scapy 版本的支持
  • 自己修复(字段”(v2.3.3)到“PB " + "BC" (v2.4.0) kwargs 转换), 也许提交一个补丁: )