gpt4 book ai didi

python - 新来的。试图理解 sr()

转载 作者:太空狗 更新时间:2023-10-29 22:22:21 25 4
gpt4 key购买 nike

我是 scapy 的新手,我正在尝试使用 srsr1 函数来了解它们的工作原理。

我试图制作以下数据包,我看到它发送了 1 个数据包,但它说它收到了 581 个数据包。谁能帮我理解为什么它显示收到了这么多数据包。

收到1373个包,得到0个回复,剩余1个包

>>> p=sr(IP(dst="192.168.25.1")/TCP(dport=23))
.Begin emission:
.....Finished to send 1 packets.
...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^C
Received 581 packets, got 0 answers, remaining 1 packets
>>> p
(<Results: TCP:0 UDP:0 ICMP:0 Other:0>, <Unanswered: TCP:1 UDP:0 ICMP:0 Other:0>)

我的 TCPDump 输出没有显示它收到了这么多数据包。

最佳答案

sr()sr1() 函数将发送一个数据包并在网络上监听 sr()< 的情况下的相应答案, sr1() 将只等待一个答案。

收到但未回复的数据包是 Scapy 在寻找对原始数据包的响应时嗅探的数据包。我不确定在使用 Scapy 的同时使用 tcpdump 进行嗅探会如何影响您的结果 - 不确定内核会将数据包传递给哪个进程。

这是关于 Sending and Receiving with Scapy 的优秀教程来自 PacketGeek。

还要确保在解释器中使用各种 Scapy 函数的 __doc__ 属性来获取相关文档。

>>> print sr1.__doc__
Send packets at layer 3 and return only the first answer
nofilter: put 1 to avoid use of bpf filters
retry: if positive, how many times to resend unanswered packets
if negative, how many times to retry when no more packets are answered
timeout: how much time to wait after the last packet has been sent
verbose: set verbosity level
multi: whether to accept multiple answers for the same stimulus
filter: provide a BPF filter
iface: listen answers only on the given interface
>>>

关于python - 新来的。试图理解 sr(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25980777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com