scapy 嗅探 ZigBee 流量,不检测 ZigBee 层

问题描述

我正在尝试使用 scapy 使用 ZigBee 协议,但无法正确识别捕获的流量。我创建了以下脚本:

import sys
from scapy.sendrecv import sniff

def pkt_hnd(pkt):
    print(pkt.summary())

sniff(offline=sys.stdin.buffer,prn=pkt_hnd,store=0)

我正在向它提供来自 https://github.com/homewsn/whsniff 的数据。但是数据包在 scapy 中似乎被错误分类SixLoWPAN / LoWPANFragmentationFirst / Raw:

Dot15d4FCS / 802.15.4 Data ( None:0x0 -> 0x2c2b:0xffff ) / SixLoWPAN / LoWPANFragmentationFirst / Raw

为了比较,这是wireshark解析它的方式:

enter image description here

我能否以某种方式告诉 scapy 它应该假设这些数据包中的 ZigBee 流量?

解决方法

我找到了答案: https://github.com/secdev/scapy/blob/cfe00d5c952e9048a40150390e0025b5ceff7228/scapy/layers/zigbee.py#L1175

目前的解决方案:

import sys
from scapy.sendrecv import sniff
from scapy.config import conf

conf.dot15d4_protocol = "zigbee"

def pkt_hnd(pkt):
    print(pkt.summary())

sniff(offline=sys.stdin.buffer,prn=pkt_hnd,store=0)