Python-3.4 Scapy发送ARP包

Python-3.4 Scapy Sending ARP packet

我有这个脚本:

from scapy.all import *
def ip1(ip):
    pkt = send(ARP(op=ARP.who_has, psrc="192.168.5.51", pdst=ip))
    x = sniff(filter="arp", count=10)
    print (x.summary())
    print ("done")

ip1("192.168.5.46")

现在,它卡在发送线上:它说:

 . Sent 1 packets.

但不会继续执行脚本(并且不会真正发送数据包)。当我 ctrl+c 脚本时,然后它发送数据包并打印 x.summary() 并打印完成....我想知道为什么 提前致谢。

编辑:答案是关于 sr()、sr1()、srp() 和 srp1() 函数的吗?

. Sent 1 packets.”输出实际上证明脚本发送了数据包。但是,它停留在 sniff 函数上,直到 Ctrl-C 被命中。此函数触发无限嗅探操作,除非 timeout 参数另有指定。

Scapy's official API documentation 读作:

timeout: stop sniffing after a given time (default: None).