简体   繁体   中英

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.
But scapy is taking a long time of getting any answer.
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.

What people call TCP/IP is indeed a TCP layer stacked on top of an IP layer.

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. Then IP tells to which computer the data should be sent. TCP finally announces some data, extensions.....

It needs to be in this order: you need to know where the packet needs to go before specifying the data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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