-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
34 lines (27 loc) · 1.15 KB
/
main.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
import sys, requests, threading
from colorama import Fore, Style
def make_request(url, request_number):
try:
response = requests.get(url)
status_code = response.status_code
if status_code == 200:
print(f"{Fore.GREEN}[Success] {Fore.WHITE}Request to {url} completed with status code {status_code}{Style.RESET_ALL}")
else:
print(f"{Fore.YELLOW}[Failed] {Fore.WHITE}Request to {url} completed with status code {status_code}{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}[Failed] {Fore.WHITE}Failed to request {url}: {str(e)}{Style.RESET_ALL}")
if __name__ == "__main__":
if len(sys.argv) != 3:
print(f"{Fore.YELLOW}Usage: python main.py <target-url> <request-count>{Style.RESET_ALL}")
sys.exit(1)
domain = sys.argv[1]
num_requests = int(sys.argv[2])
urls = [domain for _ in range(num_requests)]
threads = []
for i, url in enumerate(urls, start=1):
thread = threading.Thread(target=make_request, args=(url, i))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
print(f"{Fore.CYAN}All requests completed.{Style.RESET_ALL}")