Skip to content

Commit 8a24e92

Browse files
authored
Update check_http.py
1 parent e48902c commit 8a24e92

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

check_http.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import requests
22
import sys
3+
from colorama import Fore, Style, init
4+
5+
# Initialize colorama for colorized output
6+
init(autoreset=True)
37

48
# Function to check the status code of each subdomain
59
def check_subdomains(file_path):
@@ -11,18 +15,26 @@ def check_subdomains(file_path):
1115
subdomain = subdomain.strip() # Removing newline characters
1216
if subdomain: # If the line is not empty
1317
try:
14-
# Adding timeout and disabling SSL verification
1518
response = requests.get(f"http://{subdomain}", timeout=5, verify=False)
16-
print(f"[{response.status_code}] - {subdomain}")
17-
except requests.exceptions.SSLError as ssl_err:
18-
print(f"[SSL ERROR] - {subdomain} ({ssl_err})")
19-
except requests.exceptions.Timeout as timeout_err:
20-
print(f"[TIMEOUT] - {subdomain} ({timeout_err})")
21-
except requests.exceptions.RequestException as e:
22-
print(f"[ERROR] - {subdomain} ({e})")
19+
status_code = response.status_code
20+
21+
if status_code == 200:
22+
print(f"{Fore.GREEN}[{status_code}] - {subdomain}")
23+
elif status_code == 403:
24+
print(f"{Fore.RED}[{status_code}] - {subdomain}")
25+
elif status_code == 404:
26+
print(f"{Fore.WHITE}[{status_code}] - {subdomain}")
27+
else:
28+
print(f"{Fore.WHITE}[{status_code}] - {subdomain}")
29+
30+
except requests.exceptions.Timeout:
31+
print(f"{Fore.WHITE}[TIMEOUT] - {subdomain}")
32+
except requests.exceptions.RequestException:
33+
print(f"{Fore.WHITE}[CONNECTION ERROR] - {subdomain}")
34+
2335
except FileNotFoundError:
2436
print(f"File '{file_path}' not found.")
25-
37+
2638
if __name__ == "__main__":
2739
if len(sys.argv) != 3:
2840
print("Usage: python check_http.py -l <subdomains.txt>")

0 commit comments

Comments
 (0)