scapy数据包处理程序无输出

问题描述 投票:0回答:1

(os:pop_os 20.04)我正在尝试一个非常简单的脚本来嗅探数据包,但是无论我如何简化脚本,我都不会获得任何输出(只是光标闪烁):

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 == 2:
            # do your stuff here
            print(pkt.show())

sniff(iface='wlp4s0mon', prn=packet_handler)

没有错误,并且是ifconfig:

wlp4s0mon: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        unspec E2-A6-A0-23-39-67-40-3A-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 40  bytes 9277 (9.2 KB)
        RX errors 0  dropped 40  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

似乎是正确的。我已经写了上述内容的许多变体,其中包括我认为最简化的内容,以便调试问题

python-3.x scapy
1个回答
0
投票

问题解决了,我想要Dot11FCS:

    if pkt.haslayer(Dot11FCS) and pkt.type == 2:

尽管我不太确定为什么。

© www.soinside.com 2019 - 2024. All rights reserved.