scapy 数据包处理程序没有输出

No output from scapy packet handler

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

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

好像是对的。我写了上面的许多变体,我已经包含了我认为是 most 简化的内容以调试问题

问题已解决,我想要 Dot11FCS:

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

虽然我不太清楚为什么。