Scapy sniff the packet multiple times?

北战南征 提交于 2019-12-02 09:43:59

问题


I am using Scapy to capture packets by using the following code

from scapy.all import *

def verify(p):
     p.display()

sniff(prn=verify, iface="lo")

The sniff function captures every packet multiple times. For example, if I have a DNS query packet, this packet will display two times. How can make The sniff function to capture each packet only single time?


回答1:


This is expected behavior. Scapy sees the packets on the loopback interface both when they "leave" and when they "arrive." So everything is duplicated with no distinction, because loopback is a special interface. Perhaps you should yourself just skip every second packet.

It was reported as a bug once, but rejected: https://bitbucket.org/secdev/scapy/issues/887/sniff-sends-packets-twice



来源:https://stackoverflow.com/questions/52232080/scapy-sniff-the-packet-multiple-times

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