简体   繁体   English

scapy花费无限时间发送TCP SYN数据包而没有回复。

[英]scapy takes infinite time sending TCP SYN packet with no reply.

I want to send a simple SYN request to my router to get an ACK response in a bid to learn network (TCP/IP) using python and scapy. 我想向路由器发送一个简单的SYN请求以获取ACK响应,以尝试使用python和scapy学习网络(TCP / IP)。
But scapy is taking a long time of getting any answer. 但是,scapy需要很长时间才能得到任何答案。
script- 脚本-

#!/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)

What is the solution ? 解决办法是什么 ?

So to summarize, you need to reverse IP and TCP order. 因此,总结起来,您需要颠倒IPTCP顺序。

What people call TCP/IP is indeed a TCP layer stacked on top of an IP layer. 人们所说的TCP / IP实际上是一个堆叠在IP层之上的TCP层。

Here is for instance the stack of basic layers: 例如,这是基本层的堆栈:

TCP / IP堆栈

Each stack adds new informations: Ethernet gives the MAC addresses so that the packet goes to the router. 每个堆栈都会添加新信息:以太网提供MAC地址,以便数据包到达路由器。 Then IP tells to which computer the data should be sent. 然后IP告诉数据应该发送到哪台计算机。 TCP finally announces some data, extensions..... TCP最终宣布一些数据,扩展.....

It needs to be in this order: you need to know where the packet needs to go before specifying the data 它必须按此顺序排列:在指定数据之前,您需要知道数据包需要到达的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM