From f5db8a18bc02eb152aaacea9d4b10b53f895fa5b Mon Sep 17 00:00:00 2001 From: Connor Nelson Date: Thu, 27 Feb 2025 23:57:32 -0500 Subject: [PATCH] Fix TCP Handshake --- intercepting-communication/level-11/run | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intercepting-communication/level-11/run b/intercepting-communication/level-11/run index 7da19e7..1bb6d4d 100755 --- a/intercepting-communication/level-11/run +++ b/intercepting-communication/level-11/run @@ -43,11 +43,12 @@ class RawPacketHost(Host): self.seq = random.randrange(0, 2**32) response_packet = (scapy.IP(src=packet["IP"].dst, dst=packet["IP"].src) / scapy.TCP(sport=packet["TCP"].dport, dport=packet["TCP"].sport, - seq=self.seq, ack=(packet["TCP"].seq + 1) & (2**32 - 1), + seq=self.seq, ack=(packet["TCP"].seq + 1) % (2**32), flags="SA")) scapy.send(response_packet, verbose=False) - if (packet["TCP"].seq == (31337 + 1) and packet["TCP"].ack == self.seq and + if (packet["TCP"].seq == (31337 + 1) and + packet["TCP"].ack == ((self.seq + 1) % (2**32)) and packet["TCP"].flags == "A"): print(flag, flush=True)