-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_http.py
42 lines (36 loc) · 1.55 KB
/
check_http.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
import requests
import sys
import warnings
from colorama import init, Fore, Style
# Suppress InsecureRequestWarning
warnings.filterwarnings("ignore", message="Unverified HTTPS request")
# Initialize colorama
init(autoreset=True)
def check_subdomains(subdomain_file):
with open(subdomain_file, 'r') as f:
subdomains = f.read().splitlines()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
for subdomain in subdomains:
try:
response = requests.get(f"https://{subdomain}", timeout=10, headers=headers, verify=False)
if response.status_code == 200:
print(Fore.GREEN + "[200] - " + subdomain)
elif response.status_code == 403:
print(Fore.RED + "[403] - " + subdomain)
elif response.status_code == 404:
print(Fore.WHITE + "[404] - " + subdomain)
else:
print(Fore.WHITE + f"[{response.status_code}] - {subdomain}")
except requests.exceptions.Timeout:
print(Fore.BLUE + "[TIMEOUT] - " + subdomain)
except requests.exceptions.ConnectionError:
print(Fore.WHITE + "[CONNECTION ERROR] - " + subdomain)
except Exception as e:
print(Fore.WHITE + f"[ERROR] - {subdomain}: {str(e)}")
if __name__ == "__main__":
if len(sys.argv) != 3 or sys.argv[1] != '-l':
print("Usage: python3 check_http.py -l <subdomains_file>")
sys.exit(1)
check_subdomains(sys.argv[2])