You can create, with scapy, FIN or RST packets that sniff easily in the bridge (usually br0) and process the corresponding RST or FIN packets.
Here is an example where RST is sent in the same direction of a data packet.
from scapy.all import *
import random
def sendRST(p):
flags = p.sprintf("%TCP.flags%")
if flags != "S":
ip = p[IP]
tcp = p[TCP]
if ip.len <= 40:
return
i = IP()
i.dst = ip.dst
i.src = ip.src
t = TCP()
t.flags = "R"
t.dport = tcp.dport
t.sport = tcp.sport
t.seq = tcp.seq
new_ack = tcp.seq + 1
print "RST sent to ",i.dst,":",t.dport
send(i/t)
while (1):
PKT = sniff (iface = "br0", filter = "tcp and src host x.x.x.x", count=1, prn=sendRST)
exit()
Check out the sniff options which are extremely powerful :)
Hope to help you.
source
share