Skip to content

Commit

Permalink
Fix TCP Handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Feb 23, 2025
1 parent 50cbbc6 commit 7483084
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion intercepting-communication/level-11/run
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
#!/usr/bin/exec-suid --real -- /usr/bin/python -I

import os
import random
import subprocess
import scapy.all as scapy
from dojjail import Host, Network

flag = open("/flag").read()

os.open("/run/xtables.lock", os.O_CREAT)

def drop_rst_packets(sport):
subprocess.run(["/usr/sbin/iptables",
"-A", "OUTPUT",
"-p", "tcp",
"--tcp-flags", "RST", "RST",
"--sport", str(sport),
"-j", "DROP"],
stdin=subprocess.DEVNULL,
capture_output=True,
check=True)

class RawPacketHost(Host):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.seq = None

def entrypoint(self):
scapy.conf.ifaces.reload()
scapy.conf.route.resync()
drop_rst_packets(31337)
scapy.sniff(prn=self.handle_packet, iface="eth0")

def handle_packet(self, packet):
Expand All @@ -38,4 +55,6 @@ raw_packet_host = RawPacketHost("ip-10-0-0-2")
network = Network(hosts={user_host: "10.0.0.1", raw_packet_host: "10.0.0.2"}, subnet="10.0.0.0/24")
network.run()

user_host.interact()
user_host.exec(lambda: drop_rst_packets(31337))

user_host.interact()

0 comments on commit 7483084

Please sign in to comment.