I'm trying to establish a 3-way TCP Handshake with Scapy
I see the SYN-ACK package in Wireshark but sr1 does never terminate and no package seems to be received.
I have a simple setup to test a TCP handshake with Scapy.
DESTINATION_HOST = "194.232.104.142"
DESTINATION_PORT = 80
SOURCE_PORT = 50210
SOURCE_HOST = "192.168.0.31"
#create a TCL Handshake
#SYN
ip = IP(src=SOURCE_HOST,dst=DESTINATION_HOST)
SYN = TCP(sport=SOURCE_PORT, dport=DESTINATION_PORT, flags='S', seq=1000)
SYNACK =sr1(ip/SYN) #send the package and wait for the answer
#ACK
ACK = TCP(sport=SOURCE_PORT, dport=DESTINATION_PORT, flags='A', seq=SYNACK.ack, ack=SYNACK.seq + 1)
send(ip/ACK)
And also as a maybe important comment, I'm running on Windows 10
Because it seems as if the package never reaches my computer I turned on wireshark and found the desired package there, but nethertheless, sr1 does not terminate and even:
ans = sniff(filter=f"tcp port {DESTINATION_HOST}",lfilter=match_packet,count=12,timeout=10)
print(ans)
with
def match_packet(self, pkt):
if pkt.haslayer(IP) and pkt[IP].dst == SOURCE_HOST \
and pkt.haslayer(TCP) and pkt[TCP].dport == SOURCE_PORT:
#and pkt[TCP].ack == self.seq_next:
return True
return False
returns
<Sniffed: TCP:0 UDP:0 ICMP:0 Other:0>
Okay I solved the problem with reinstalling NPcap and I installed it in WinPcap compatibility mode. I don't know if it would have worked with only installing it the ordinary way, without the compatability mode, because I already had the newest version installed
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.