-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxyinspect.py
74 lines (63 loc) · 3.92 KB
/
proxyinspect.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
import requests
from colorama import Fore, Style
def ascii_art():
print("""
██████╗ ██████╗ ██████╗ ██╗ ██╗██╗ ██╗ ██╗███╗ ██╗███████╗██████╗ ███████╗ ██████╗████████╗ ██████╗ ██████╗
██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝╚██╗ ██╔╝ ██║████╗ ██║██╔════╝██╔══██╗██╔════╝██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗
██████╔╝██████╔╝██║ ██║ ╚███╔╝ ╚████╔╝ ██║██╔██╗ ██║███████╗██████╔╝█████╗ ██║ ██║ ██║ ██║██████╔╝
██╔═══╝ ██╔══██╗██║ ██║ ██╔██╗ ╚██╔╝ ██║██║╚██╗██║╚════██║██╔═══╝ ██╔══╝ ██║ ██║ ██║ ██║██╔══██╗
██║ ██║ ██║╚██████╔╝██╔╝ ██╗ ██║ ██║██║ ╚████║███████║██║ ███████╗╚██████╗ ██║ ╚██████╔╝██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
""")
def check_proxy(proxy):
proxies = {
'http': proxy,
'https': proxy
}
try:
response = requests.get('https://httpbin.org/ip', proxies=proxies, timeout=10)
if response.status_code == 200:
return True
except requests.RequestException:
pass
return False
def is_proxy_anonymous(proxy):
proxies = {
'http': proxy,
'https': proxy
}
try:
response = requests.get('https://httpbin.org/ip', proxies=proxies, timeout=10)
if response.status_code == 200:
client_ip = response.json().get('origin', '')
if not client_ip.startswith(proxy.split(':')[0]):
return True
except requests.RequestException:
pass
return False
def main():
filename = 'proxies.txt'
with open(filename, 'r') as file:
proxies = [line.strip() for line in file]
total_proxies = len(proxies)
valid_proxies = []
print(f"Total proxies: {total_proxies}")
for proxy in proxies:
print(f"Testing proxy {proxy} from list {filename}...")
if check_proxy(proxy):
if is_proxy_anonymous(proxy):
valid_proxies.append(proxy)
print(f"{Fore.GREEN}Proxy Valid and Anonymous{Style.RESET_ALL}")
else:
print(f"{Fore.YELLOW}Proxy Valid but Not Anonymous{Style.RESET_ALL}")
else:
print(f"{Fore.RED}Proxy Invalid{Style.RESET_ALL}")
print(f"\nTotal valid and anonymous proxies: {len(valid_proxies)}")
print("Valid and anonymous proxies list:")
for proxy in valid_proxies:
print(proxy)
if __name__ == "__main__":
ascii_art()
print("DISCLAIMER:\nThe accuracy of this tool depends on the restrictions of the proxy you are testing.\nMany public proxies use IP Rotation, Rate Limiting and Server Load Limiting which sometimes prevents the successfull connection to them.")
start = input("\nPress Enter to start checking proxies...")
main()