Scapy 无法过滤某些数据包

Scapy fails to filter certain packets

我用 scapy 设置了一个简单的嗅探功能,它将数据包转发到握手功能(我在 端口 102 上设置了一个网络服务器。但是一些奇怪的错误有过来,然后我决定打印 pkt.show(),我发现有些包确实通过了过滤器。

我的嗅探功能:

a=sniff(filter="port 102", count=10, prn=handshake)

这个数据包设法通过:

###[ Ethernet ]###
  dst       = 84:8f:69:f5:fe:ac
  src       = b8:27:eb:92:a3:3b
  type      = 0x800
###[ IP ]###
     version   = 4L
     ihl       = 5L
     tos       = 0x0
     len       = 44
     id        = 1
     flags     =
     frag      = 0L
     ttl       = 64
     proto     = tcp
     chksum    = 0xe6c6
     src       = 192.168.137.178
     dst       = 192.168.137.1
     \options   \
###[ TCP ]###
        sport     = iso_tsap
        dport     = 2426
        seq       = 605952828
        ack       = 605952829
        dataofs   = 6L
        reserved  = 0L
        flags     = SA
        window    = 8192
        chksum    = 0x5b7c
        urgptr    = 0
        options   = [('MSS', 1460)]

如您所见,目标端口是 2426,这肯定不是 端口 102

我是不是做了什么蠢事?

封装包中的源端口是iso_tsap which is 102. If you want to filter by the destination port try the filter "dst port 102". If you need something a bit more sophisticated, hereBPF的语法,被scapy使用。