Scapy 多次嗅探数据包? [英] Scapy sniff the packet multiple times?

查看:51
本文介绍了Scapy 多次嗅探数据包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Scapy 通过使用以下代码捕获数据包

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")

嗅探函数多次捕获每个数据包.比如我有一个DNS查询包,这个包会显示两次.如何让嗅探功能只捕获每个数据包一次?

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?

推荐答案

这是预期的行为.Scapy 在离开"和到达"时都能看到环回接口上的数据包.所以一切都没有区别地复制,因为环回是一个特殊的接口.也许你应该自己跳过每一个数据包.

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.

曾被报告为错误,但被拒绝:https://bitbucket.org/secdev/scapy/issues/887/sniff-sends-packets-twice

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

这篇关于Scapy 多次嗅探数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆