Not receiving SYN_ACK from server on sending SYN using scapy

Viewed 44

I'm trying to establish a TCP three way handshake using SCAPY but am encountering some problems. Scapy is able to send the SYN flag to the server (verified from wireshark) but the server is not responding with the SYN_ACK. BUT when I use python socket module to connect with the server using connect(), handshake is done successfully (verified from wireshark)

SCAPY CODE:

src = '1.2.3.4'
dst = '127.0.0.1'
sport = 1234
dport = 9090
ip = IP(src=src,dst=dst)
syn = TCP(sport=sport,dport=dport,flags='S')
synack = sr1(ip/syn)
# code gets stuck here, response packet is never received
ack = TCP(sport=sport,dport=dport,flags='A',seq=synack.ack,ack=synack.seq+1)

But when I try to establish a TCP connection using socket module, everything works fine

CODE:

import socket
host = '127.0.0.1'
port = 9090
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send("HIIII".encode())

Here my server is receiving the connection and messages both, no problem here (verified on wireshark too)

I have seen the similar questions being asked here before but none of them had an answer of my expectations :(

0 Answers
Related