如何使用 scapy 嗅探 ARP 公告?

问题描述 投票:0回答:0

我使用以下代码使用 scapy 的 sniff() 函数嗅探 ARP 请求: `

from scapy.all import*

def found_arp_packet(pkt):
    if pkt[ARP].op == 1:
        # An ARP request was detected
        print(f"{pkt[ARP].psrc} is requesting location of {pkt[ARP].pdst}")

sniff(prn=found_arp_packet, filter="arp", iface='eth0')

这段代码可以毫无问题地嗅出 ARP 请求,但我想知道是否有办法嗅探 ARP 公告数据包而不是 ARP 请求?如果不是,是否可以嗅探 ARP 探测数据包?

目前我正在检查操作码 1,表示 ARP 请求。我已经尝试研究 scapy 的 ARP 数据包文档,但我无法找到与 ARP 公告或 ARP 探测相对应的操作码的任何内容。 注意:我还发现 ARP 响应的操作码是 2。

python python-3.x networking network-programming scapy
© www.soinside.com 2019 - 2024. All rights reserved.