Skip to content
Advertisement

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 ?

Advertisement

Answer

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 stack

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

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement