Scapy BPF filter not working

心不动则不痛 提交于 2019-12-04 03:49:32

Scapy requires numerous dependencies for many different systems. It is quiet possible that you don't have the required dependency for BPF filters to work.

http://www.secdev.org/projects/scapy/portability.html

It's scapy fault!!! It seems that scapy starts receiving packets before applying the BPF filter (filter argument of sniff function). It takes a while to get work properly! Two methods to get rid of this:

  1. Use lfilter to define your filtering function inside the script. It's not efficient on busy link because filter is applied in your script, instead of kernel. Consider using pypy to speed it up.
  2. For some first packets check destination MAC address inside your script and then don't check it anymore; i.e check correctness of the packet in the beginning time of sniffing to pass unstable phase of scapy and then rely on scapy to filter the unwanted packets.

Installing tcpdump solved the problem for me - now the filter on sniff works

In my case, upgrading to 2.3.3dev (github version), fixed it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!