scapy sr 函数没有 return 答案
scapy sr function does not return answers
我正在尝试使用 scapy 进行隐形 SYN 扫描。我在 scapy usage documantation 中读到了关于 sr 函数的内容。它应该对我发送的数据包做出响应。
例如,我尝试 运行 以下命令:
>>> ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=[22,80,443],flags="S"))
即,我想通过 TCP/IP 向 192.168.1.1 发送一个 SYN 数据包。
我本以为会立即得到以下答案:
>>> Begin emission:
.......*.**.......Finished to send 3 packets.
**.*.*..*..................
Received 362 packets, got 3 answers, remaining 0 packets
但是,我让它 运行 超过 2 分钟,但 sr 没有完成。此外,强制停止(CTRL+C)后,我得到以下答案:
Begin emission:
.Finished to send 3 packets.
......................................^C
Received 2040 packets, got 0 answers, remaining 3 packets
我也试了很多例子,结果都是这样。
有谁知道为什么会这样?我该如何解决?我的网络配置有问题吗?
此外,我想补充一点,我已经在两台不同计算机但位于同一家庭网络上的两个不同 ubuntu 虚拟机上进行了尝试。
谢谢。
您需要添加超时选项,否则 sr() 将永远运行
ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=[22,80,443],flags="S", timeout =1))
timeout: how much time to wait after the last packet has been sent. By
default, sr will wait forever and the user will have to interrupt
(CtrlC) it when he expects no more answers.
我正在尝试使用 scapy 进行隐形 SYN 扫描。我在 scapy usage documantation 中读到了关于 sr 函数的内容。它应该对我发送的数据包做出响应。
例如,我尝试 运行 以下命令:
>>> ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=[22,80,443],flags="S"))
即,我想通过 TCP/IP 向 192.168.1.1 发送一个 SYN 数据包。
我本以为会立即得到以下答案:
>>> Begin emission:
.......*.**.......Finished to send 3 packets.
**.*.*..*..................
Received 362 packets, got 3 answers, remaining 0 packets
但是,我让它 运行 超过 2 分钟,但 sr 没有完成。此外,强制停止(CTRL+C)后,我得到以下答案:
Begin emission:
.Finished to send 3 packets.
......................................^C
Received 2040 packets, got 0 answers, remaining 3 packets
我也试了很多例子,结果都是这样。
有谁知道为什么会这样?我该如何解决?我的网络配置有问题吗?
此外,我想补充一点,我已经在两台不同计算机但位于同一家庭网络上的两个不同 ubuntu 虚拟机上进行了尝试。
谢谢。
您需要添加超时选项,否则 sr() 将永远运行
ans,unans = sr(IP(dst="192.168.1.1")/TCP(dport=[22,80,443],flags="S", timeout =1))
timeout: how much time to wait after the last packet has been sent. By default, sr will wait forever and the user will have to interrupt (CtrlC) it when he expects no more answers.