我正在尝试使用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库中更改什么代码?
答案 0 :(得分:4)
似乎是 BlueBorne 和 Scapy 之间的兼容性问题。
您(很可能)已经安装了最新的 Scapy 版本( v2。 4.0 ),该版本删除了 scapy.layers.bluetooth.HCI_ACL_Hdr
的初始值设定项中的字段 kwarg ,而 BlueBorne ( l2cap_infra.py 其他)未进行相应的更新(或分支)。
仍然具有的最新版本是 v2。 3.3 ([GitHub]: secdev/scapy - (v2.3.3) scapy/scapy/layers/bluetooth.py)。
可能的解决方案:
pip uninstall scapy
),然后安装 v2.3.3 (pip install scapy==2.3.3
)。也许这对您来说是最简单(也是最合适的)([PyPI]: scapy 2.3.3)