-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocks Proxy Finder.py
More file actions
64 lines (53 loc) · 2.08 KB
/
Socks Proxy Finder.py
File metadata and controls
64 lines (53 loc) · 2.08 KB
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
import argparse
import socks
import socket
import time
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor, as_completed
def check_proxy(proxy):
try:
# Remove 'socks5://' from the proxy string
proxy = proxy.replace('socks5://', '')
# Split the proxy into host and port
host, port = proxy.split(':')
port = int(port)
# Create a socket to connect through the proxy
socks.set_default_proxy(socks.SOCKS5, host, port)
socket.socket = socks.socksocket
# Measure the connection time
start_time = time.time()
sock = socket.socket()
sock.settimeout(5) # seconds
sock.connect(("cows.info.gf", 90))
sock.close()
end_time = time.time()
# Calculate response time in milliseconds
response_time = (end_time - start_time) * 1000
return f"{proxy} - {int(response_time)}ms"
except Exception:
return None
def main():
parser = argparse.ArgumentParser(description='SOCKS Proxy Checker')
parser.add_argument('-l', '--list', required=True, help='File containing list of proxies')
parser.add_argument('--threads', type=int, default=10, help='Number of threads to use for checking proxies')
args = parser.parse_args()
# Read the list of proxies from the file
with open(args.list, 'r') as file:
proxies = file.read().splitlines()
results = []
# Use ThreadPoolExecutor to manage multithreading
with ThreadPoolExecutor(max_workers=args.threads) as executor:
futures = {executor.submit(check_proxy, proxy): proxy for proxy in proxies}
for future in tqdm(as_completed(futures), total=len(futures), desc="Checking proxies", unit="proxy"):
result = future.result()
if result:
results.append(result)
# Print all the working proxies with their response times
if results:
print("\nWorking proxies:")
for result in results:
print(result)
else:
print("\nNo working proxies found.")
if __name__ == '__main__':
main()