Python从数据包中提取字段
我需要帮助从scapy捕获的数据包中提取一个字段,并将其放入一个变量中进行处理 Q:我想将“notdecoded”字段数据捕获到一个变量中 使用以下内容捕获:Python从数据包中提取字段,python,wireless,scapy,packet-capture,wifi,Python,Wireless,Scapy,Packet Capture,Wifi,我需要帮助从scapy捕获的数据包中提取一个字段,并将其放入一个变量中进行处理 Q:我想将“notdecoded”字段数据捕获到一个变量中 使用以下内容捕获: from scapy.all import * def packet_handler(pkt) : # if packet has 802.11 layer, and type of packet is Data frame if pkt.haslayer(Dot11) and pkt.type == 0:
from scapy.all import *
def packet_handler(pkt) :
# if packet has 802.11 layer, and type of packet is Data frame
if pkt.haslayer(Dot11) and pkt.type == 0:
# do your stuff here
print(pkt.show())
sniff(iface="wlan0mon", prn=packet_handler)
输出:
要从scapy数据包中提取字段,请使用类似于
pkt[Layer].field的语法(要从TCP层提取dport字段,请使用pkt[TCP].dport)
pkt[RadioTap].notdecoded
应该适用于您的情况
###[ RadioTap dummy ]###
version = 0
pad = 0
len = 36
present = TSFT+Flags+Rate+Channel+dBm_AntSignal+b14+b29+Ext
notdecoded= ' \x08\x00\x00\x00\x00\x00\x00\xf4\x82\xc2\xc6\x01\x00\x00\x00\x10\x02\x99\t\xa0\x00\xb1\x00\x00\x00\xb1\x00'