Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- """This checks socks4 and socks5 and socks4 proxies using curl.
- It is necessary to make a proxies.txt file and put the urls in this form:
- sockstype://ip:port ex socks5://127.0.0.1:9050"""
- import subprocess as sub
- import time
- timeout = "5"
- debug = False
- check_hosts = [
- "ifconfig.me",
- "api.ipify.org",
- "bot.whatismyipaddress.com",
- "ipinfo.io/ip",
- "ipecho.net/plain"
- ]
- def log_good(string):
- with open("good_proxies.txt","a") as good_proxies:
- good_proxies.write(string)
- good_proxies.close()
- proxies = open("proxies.txt", "r").read().split("\n")
- total = len(proxies)
- for i, ip in enumerate(proxies):
- if not i=="":
- try:
- print(f"{i}/{total} Checking {ip}")
- sockstype, ip = ip.split("://")
- t1 = time.time()
- result = sub.check_output(["curl","-s","--connect-timeout",timeout,f"--{sockstype}",ip,check_hosts[0]])
- if debug == True:print(f"curl -s --connect-timeout {timeout} --{sockstype} {ip} {check_hosts[0]}")
- t2 = time.time()
- total_time = t2 - t1
- print(f"{ip} responded in {t2 - t1} seconds")
- log_good(f"{sockstype}://{ip} {round(total_time,1)}\n")
- except Exception as e:
- if debug == True:
- print(f"curl -s --connect-timeout {timeout} --{sockstype} {ip} {check_hosts[0]}")
- print(e)
- print("\n")
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement