首页 > 解决方案 > 如何为 scapy 创建一个图层?

问题描述

我正在尝试从 scapy 创建未实现的蓝牙层,但是在尝试了几次之后我没有得到任何结果。根据 scapy 文档,我所做的只是子类Packet,并将新层类绑定到上层......是否需要进行一些其他修改才能使其工作?

PS:我知道它不起作用,因为列出了几个软件包wiresharkbtmon但是在 scappypacket.show()中没有出现

编辑:

我尝试实现的层操作码是 0x33 <用户确认请求>。绑定层是这样的:

bind_layers(HCI_Event_Hdr, HCI_Event_User_Confirmation_Request, code=0x33)

数据包类是这样的:

    name = "User Confirmation Request"
    fields_desc = [LEMACField("address", None), IntField("number", 0)]
    
    def answers(self, other):
        if HCI_Command_Hdr not in other:
            return False

        return other[HCI_Command_Hdr].opcode == self.opcode

该层由 BD_Address 和数值(4 个八位字节/字节)构建

标签: pythonscapy

解决方案


推荐阅读