我想向我的路由器发送一个简单的 SYN 请求以获得 ACK 响应,以便使用 python 和 scapy 学习网络(TCP/IP)。
但是 scapy 需要很长时间才能得到任何答案。
脚本-
#!/usr/bin/env python
from scapy.all import *
pack=TCP(sport=22,dport=80,flags='S')/IP(src="192.168.0.13",dst="192.168.0.1")
# tried with retry and timeout options using both sr() and sr1()
# but it comes with no answer from the router.
# ran this with sudo and iptables policy is default [ACCEPT]
ans = sr1(pack)
解决方案是什么?
最佳答案
总而言之,您需要颠倒IP
和TCP
的顺序。
人们所说的 TCP/IP 实际上是在 IP 层之上堆叠了 TCP 层。
例如,这里是基本层的堆栈:
每个堆栈都会添加新信息:以太网提供 MAC 地址,以便数据包进入路由器。然后 IP 告诉应该将数据发送到哪台计算机。 TCP终于公布了一些数据,扩展......
需要按照这个顺序:在指定数据之前需要知道数据包需要去哪里
关于python - scapy 花费无限时间发送 TCP SYN 数据包而没有回复。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51798304/