This commit is contained in:
rooba 2022-03-29 18:00:00 +00:00
parent ad25300c37
commit 473fef9372
8 changed files with 84359 additions and 20044 deletions

17
README.md Normal file

@ -0,0 +1,17 @@
# Dependancies
- UVLoop
- python-socks
- ssl
Most of these libraries do not support windows
Solely for checking if a proxy is alive, checks ~1200 proxies a minute with 100 workers, cpu load and memory being negligable
UVLoop isn't necessary, but does give far greater performance
Theoretically you could run thousands of workers, you would just need to increase the maximum file descriptors allowed
Drop the `CHECK_TIMEOUT` if you would like to increase time, this would likely ensure that the less responsive proxies are verified
1000 Workers uses roughly 5% cpu on a dual core, completes checking 10000 proxies in roughly 4 minutes.

@ -1,7 +0,0 @@
# Dependancies
- UVLoop
- python-socks
- ssl
Most of these libraries do not support windows

24438
dead_proxies.txt Normal file

File diff suppressed because it is too large Load Diff

9980
proxies_to_check.txt Normal file

File diff suppressed because it is too large Load Diff

49504
proxy_log.log Normal file

File diff suppressed because it is too large Load Diff

183
test.py

@ -1,30 +1,47 @@
from asyncio import Queue, get_running_loop, new_event_loop, sleep
from ipaddress import IPv4Address
from asyncio import Queue, get_running_loop, new_event_loop, gather, Event
from ipaddress import AddressValueError, IPv4Address
from logging import basicConfig, log
from re import compile
from ssl import (CERT_NONE, PROTOCOL_TLS_CLIENT, SSLContext, TLSVersion,
_create_unverified_context)
from python_socks.async_.asyncio import ProxyType
from python_socks.async_.asyncio.v2 import Proxy
from uvloop import install
from python_socks.async_.asyncio.v2._stream import AsyncioSocketStream
try:
from uvloop import install
install()
except ImportError:
print("Unable to find uvloop, defaulting to normal event loop")
CHECK_PORT = 80
try:
from ssl import (CERT_NONE, PROTOCOL_TLS_CLIENT, _create_unverified_context)
except ImportError:
print("Unable to find ssl, we will not be able to make any connections using 443 unless ssl is installed")
CHECK_PORT = 80
CHECK_ADDR: str | IPv4Address = IPv4Address("198.204.232.125")
CHECK_HOST_NAME: str = "tcp.ac"
CHECK_TIMEOUT: float = 10.0
WORKERS = 1000
CHECK_PROXIES = "./proxies_to_check.txt"
CHECKING_LOG = "./proxy_log.log"
VALID_PROXIES = "./valid_proxies.txt"
basicConfig(filename=CHECKING_LOG, filemode="w+", level=1)
DEAD_PROXIES = "./dead_proxies.txt"
CHECKING_LOG = "./proxy_log.log"
LOG_FMT = "%(asctime)s:%(levelname)s:%(levelno)s:%(lineno)d - %(message)s"
basicConfig(filename=CHECKING_LOG, filemode="w+", level=1, format=LOG_FMT, datefmt='[%D %H:%M:%S]', )
install()
loop = new_event_loop()
PROXIES = []
TASKS = []
PROXY_QUEUE = Queue(40)
PROXIES = set()
PROXY_QUEUE = Queue(WORKERS)
LIVE_PROXIES = set()
UNRESPONSIVE = set()
CLOSING = Event()
proxy_re = compile(
r"(?=^(?:(?P<protocol>socks[4-5]):\/\/)?(?:(?P<username>[^:]+):(?P<password>[^@]+)@)?(?P<ipaddr>[^:]+):(?P<port>[^$]+)$)"
@ -36,16 +53,11 @@ with open(CHECK_PROXIES, "r") as f:
if not match:
continue
# protocol = None
# if match.group("protocol") == "socks4":
# protocol = ProxyType.SOCKS4
# elif match.group("protocol") == "socks5":
# protocol = ProxyType.SOCKS5
# TODO: Pretty sure could identify by port used but just check all anyways for now
PROXIES.append((ProxyType.HTTP, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
PROXIES.append((ProxyType.SOCKS4, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
PROXIES.append((ProxyType.SOCKS5, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
PROXIES.add((ProxyType.HTTP, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
PROXIES.add((ProxyType.SOCKS4, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
PROXIES.add((ProxyType.SOCKS5, match.group("ipaddr"), match.group("port"), match.groupdict().get("username", None), match.groupdict().get("password", None),))
REQUEST_PAGE = f"""GET /ip HTTP/1.1
@ -59,84 +71,101 @@ Upgrade-Insecure-Requests: 0
Cache-Control: max-age=0""".encode("utf8")
def save_proxies():
with open(VALID_PROXIES, "w+") as f:
f.writelines(LIVE_PROXIES)
with open(DEAD_PROXIES, "w+") as f:
f.writelines(UNRESPONSIVE)
async def proxy_check():
_loop = get_running_loop()
while _loop.is_running():
while _loop.is_running() and not CLOSING.is_set():
page_requested = False
skip_read = False
protocol, ipaddr, port, username, password = await PROXY_QUEUE.get()
proxy = Proxy.create(protocol, ipaddr, port, username, password, loop=_loop)
try:
proxy = Proxy.create(protocol, ipaddr, port, username, password, loop=_loop)
if isinstance(CHECK_ADDR, IPv4Address):
check_addr = str(CHECK_ADDR)
elif isinstance(CHECK_ADDR, str):
IPv4Address(CHECK_ADDR)
check_addr = CHECK_ADDR
except AddressValueError:
print(f"CHECK_ADDRESS should be either an IPv4Address, or a string of the form x.x.x.x")
exit(1)
ctx = None
if CHECK_PORT == 443:
ctx = _create_unverified_context(PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False
ctx.verify_mode = CERT_NONE
ctx.hostname_checks_common_name = False
ctx.get_ca_certs(False)
try:
_stream: AsyncioSocketStream | None = None
try:
if isinstance(CHECK_ADDR, IPv4Address):
ipaddr = str(CHECK_ADDR)
elif isinstance(CHECK_ADDR, str):
ipaddr = CHECK_ADDR
ctx = _create_unverified_context(PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False
ctx.verify_mode = CERT_NONE
ctx.hostname_checks_common_name = False
ctx.get_ca_certs(False)
ctx = None if CHECK_PORT == 80 else ctx
_stream = await proxy.connect(str(CHECK_ADDR), CHECK_PORT, timeout=10.0, dest_ssl=ctx)
log(10, f"proxy connected: {protocol.name.lower()}://{ipaddr}:{port}")
_stream = await proxy.connect(check_addr, CHECK_PORT, timeout=CHECK_TIMEOUT, dest_ssl=ctx) # type: ignore
# await _stream.start_tls("tcp.ac", ctx)
LIVE_PROXIES.add(f"{protocol.name.lower()}://{ipaddr}:{port}")
log(10, f"proxy connected: {protocol.name.lower()}://{ipaddr}:{port}")
except Exception as e:
UNRESPONSIVE.add(f"{protocol.name.lower()}://{ipaddr}:{port}")
log(10, f"Connect Failed : {protocol.name.lower()}://{ipaddr}:{port}")
skip_read = True
continue
else:
if not _stream:
log(10, f"Connect Failed : {protocol.name.lower()}://{ipaddr}:{port}")
continue
try:
skip_read = True
try:
if _stream:
await _stream.close()
continue
except Exception as e:
log(20, f"Exception in writing to file: {type(e)} | {e}")
continue
while reading and not skip_read:
if skip_read:
break
try:
if not page_requested:
await _stream.write_all(REQUEST_PAGE)
page_requested = True
resp = await _stream.reader.readline()
if len(resp):
log(10, "We have connected")
else:
reading = False
except Exception as e:
log(10, f"Exception on sock_sendall(): {type(e)} | {e}")
break
except Exception as e:
log(10, f"Error when closing stream | {type(e)} - {e}")
finally:
continue
reading = True
while reading and _stream:
try:
if not page_requested:
await _stream.write_all(REQUEST_PAGE)
page_requested = True
resp = await _stream.reader.readline()
except Exception as e:
log(10, f"Exception when interacting with stream | {type(e)} - {e}")
reading = False
finally:
PROXY_QUEUE.task_done()
async def begin():
_loop = get_running_loop()
for _ in range(40):
for _ in range(WORKERS):
TASKS.append(_loop.create_task(proxy_check()))
for proxy in PROXIES:
await PROXY_QUEUE.put(proxy)
await PROXY_QUEUE.join()
CLOSING.set()
loop.run_until_complete(begin())
loop.run_forever()
await gather(*TASKS)
save_proxies()
loop.stop()
try:
loop.run_until_complete(begin())
except KeyboardInterrupt:
print("KeyboardInterrupt Received, closing event loop early.")
save_proxies()
finally:
loop.close()

19960
valid.log

File diff suppressed because it is too large Load Diff

314
valid_proxies.txt Normal file

@ -0,0 +1,314 @@
socks5://72.221.232.155:4145
socks4://72.195.34.59:4145
socks5://218.64.85.211:7300
socks4://80.81.232.145:5678
socks5://174.77.111.197:4145
socks4://174.64.199.79:4145
socks5://111.61.4.43:1080
socks4://1.53.137.84:4145
socks4://62.4.51.9:5678
socks4://47.243.71.40:20840
socks4://180.250.54.165:4145
socks4://98.170.57.231:4145
socks4://216.105.130.241:39593
socks4://174.77.111.197:4145
socks4://46.23.141.142:5678
socks4://180.250.54.161:4145
socks4://173.249.33.122:35299
socks4://89.132.207.82:4145
socks4://98.162.96.41:4145
socks4://119.28.26.16:45004
socks4://210.56.245.94:4145
socks5://125.141.139.112:5566
socks4://65.21.153.73:4006
socks5://144.217.7.124:35403
socks5://98.188.47.150:4145
socks4://174.75.211.222:4145
socks4://163.172.189.73:21930
socks4://182.75.30.6:5678
socks4://103.153.148.98:1080
socks4://106.242.5.206:4145
socks4://190.53.44.10:5678
socks5://184.178.172.14:4145
socks4://103.233.103.237:4153
socks4://78.131.57.211:4153
socks4://169.239.221.89:1080
socks4://43.251.116.66:8888
socks4://116.118.98.23:5678
socks4://202.137.114.3:5678
socks5://72.195.34.59:4145
socks5://51.83.140.70:8181
socks5://107.152.44.198:9300
socks5://176.31.69.143:2002
socks4://103.5.63.214:40544
socks4://190.14.224.244:3629
socks5://62.210.93.129:55618
socks4://189.201.191.67:4145
socks4://86.100.63.127:4145
socks4://80.191.250.162:7070
socks5://180.167.161.166:7302
socks4://138.197.193.107:9050
socks4://95.43.125.120:4153
socks5://179.60.146.51:443
socks4://170.78.92.45:5678
socks4://72.221.172.203:4145
socks4://72.221.232.155:4145
socks5://119.28.26.16:45004
socks4://197.149.90.178:5678
socks4://41.174.132.82:5678
socks4://103.76.190.37:31756
socks4://103.4.94.178:41350
socks5://112.54.33.47:7302
socks4://68.71.249.153:48606
socks5://68.71.249.153:48606
socks4://45.179.165.1:5678
socks4://136.243.106.188:10081
socks4://103.200.135.226:4145
socks4://92.51.78.66:4153
socks4://190.61.85.238:4153
socks4://45.170.46.49:3629
socks4://170.78.92.37:5678
socks5://45.81.130.66:8888
socks4://200.58.74.104:5678
socks4://150.109.148.234:1234
socks4://200.6.175.10:59341
socks4://187.94.211.60:2580
socks4://69.61.200.104:36181
socks4://43.224.10.26:6667
socks5://162.144.105.150:44316
socks4://103.83.36.1:5678
socks4://5.188.147.26:3629
socks4://72.195.114.184:4145
socks5://98.188.47.132:4145
socks5://173.212.248.58:5224
socks4://98.162.96.52:4145
socks4://185.69.71.141:5678
socks4://47.103.15.171:10705
socks4://24.249.199.12:4145
socks4://84.241.42.74:4153
socks4://121.122.34.93:30001
socks4://161.82.252.36:4153
socks5://45.81.129.214:8888
socks5://98.162.96.41:4145
socks4://144.217.7.124:35403
socks4://185.171.55.218:4153
socks4://79.133.202.7:1088
socks4://43.250.127.98:4153
socks4://200.70.19.82:4153
socks5://112.105.12.67:1111
socks5://72.206.181.103:4145
socks5://72.221.172.203:4145
socks5://128.199.142.101:27125
socks4://72.210.252.137:4145
socks4://41.71.63.22:5678
socks4://179.191.18.59:5678
socks4://170.84.205.17:4153
socks4://45.224.197.137:4145
socks4://24.249.199.4:4145
socks4://180.93.32.190:5678
socks4://200.118.122.6:4153
socks4://103.31.45.173:4153
socks5://45.81.129.247:8888
socks4://103.237.77.158:5678
socks4://54.39.87.232:39721
socks4://94.158.152.248:46846
socks4://208.102.51.6:58208
socks5://143.248.55.62:5566
socks4://137.184.48.109:59097
socks4://114.109.172.105:4145
socks5://61.132.47.18:54191
socks4://81.91.144.46:5678
socks4://190.144.224.182:44550
socks5://72.49.49.11:31034
socks5://178.75.4.83:1080
socks5://91.142.172.7:5678
socks4://213.14.31.122:35314
socks4://180.178.108.107:5678
socks4://165.22.223.82:6939
socks4://46.218.2.102:1088
socks4://185.161.186.83:54321
socks4://91.239.182.222:4153
socks4://72.195.34.42:4145
socks4://115.127.23.165:35294
socks5://72.210.208.101:4145
socks5://98.170.57.231:4145
socks5://47.102.110.19:7890
socks4://85.72.32.44:44550
socks4://103.143.196.44:1080
socks4://95.70.220.173:4153
socks4://43.228.112.98:5678
socks4://159.65.159.172:4003
socks4://180.232.77.210:4145
socks4://213.234.0.242:30941
socks4://144.202.97.15:19050
socks4://180.94.64.114:5678
socks5://98.175.31.195:4145
socks4://80.80.164.164:10801
socks4://50.84.203.105:5678
socks4://182.48.82.160:4153
socks4://103.97.111.179:5678
socks4://24.37.245.42:51056
socks4://212.220.13.98:4153
socks4://196.251.41.33:5678
socks4://104.238.97.215:11845
socks4://178.253.244.61:1080
socks5://137.184.48.109:59097
socks4://91.105.152.168:4145
socks4://165.154.63.122:23780
socks5://62.182.156.123:1080
socks4://72.195.34.41:4145
socks4://72.195.34.58:4145
socks4://46.8.247.3:38279
socks4://88.135.42.27:4153
socks5://207.228.63.2:52305
socks4://46.36.105.58:4153
socks4://27.123.1.1:4153
socks4://124.109.44.126:4145
socks5://184.181.217.210:4145
socks5://72.206.181.123:4145
socks4://89.212.90.179:4145
socks4://112.222.61.180:4145
socks4://117.28.254.143:4145
socks5://72.195.114.169:4145
socks5://96.9.92.227:33427
socks4://186.167.20.242:5678
socks4://46.109.118.225:4145
socks4://45.172.176.1:59341
socks4://189.3.54.50:4145
socks4://77.104.75.97:5678
socks4://181.14.198.178:3629
socks4://45.163.196.76:31318
socks4://123.49.53.170:5678
socks4://98.188.47.150:4145
socks5://173.212.220.213:20934
socks4://181.209.111.226:1080
socks4://128.199.96.113:28545
socks4://193.151.197.122:3629
socks4://92.222.206.151:20217
socks4://45.172.225.13:4153
socks5://174.64.199.79:4145
socks5://114.96.80.92:20005
socks5://160.153.254.240:19938
socks4://47.242.235.25:29050
socks4://36.94.82.147:4145
socks4://103.90.231.93:14574
socks4://89.133.95.177:4145
socks4://182.93.80.3:8291
socks4://41.204.236.44:5678
socks4://200.3.173.140:5678
socks4://36.89.156.211:4145
socks4://51.15.152.89:61250
socks4://91.226.51.200:4145
socks4://201.140.99.140:1080
socks4://142.93.162.127:52178
socks4://46.214.93.157:5678
socks4://59.152.102.181:4153
socks4://98.162.25.23:4145
socks4://103.53.110.45:10801
socks4://58.97.194.206:5678
socks4://103.146.30.11:4145
socks4://188.95.20.138:5678
socks4://103.164.223.35:5678
socks4://177.129.63.142:4153
socks4://184.181.217.210:4145
socks4://78.88.229.195:4145
socks5://125.141.133.49:5566
socks4://186.157.240.69:5678
socks4://109.173.96.85:3629
socks4://115.91.83.42:4145
socks4://109.87.172.133:5678
socks4://186.211.6.137:4145
socks4://201.220.128.92:3000
socks4://143.255.178.1:4153
socks4://183.177.127.42:5678
socks4://89.186.17.82:3737
socks5://47.103.15.171:10705
socks5://79.137.34.27:47949
socks4://72.210.208.101:4145
socks4://103.82.233.2:1089
socks4://185.196.176.77:4145
socks4://202.57.46.140:4145
socks4://144.126.142.41:18352
socks4://77.65.131.188:4145
socks4://103.81.64.74:1080
socks4://103.152.89.210:4153
socks4://154.79.248.156:5678
socks5://173.212.248.58:7625
socks5://24.249.199.4:4145
socks4://98.175.31.195:4145
socks5://137.184.192.145:34694
socks4://36.67.88.77:4153
socks4://98.188.47.132:4145
socks4://195.181.37.137:1122
socks5://173.212.220.213:20933
socks4://92.42.8.23:4153
socks4://43.241.132.66:4153
socks4://202.145.11.217:5678
socks4://103.68.35.162:4145
socks4://45.234.67.62:5678
socks4://1.186.40.157:39651
socks4://72.195.114.169:4145
socks5://193.36.119.67:58341
socks4://103.200.135.228:4145
socks5://174.75.211.222:4145
socks4://185.98.1.59:4153
socks4://110.77.145.159:4145
socks5://45.76.188.101:15648
socks4://94.139.150.45:4145
socks4://96.9.88.94:4153
socks5://172.247.149.164:808
socks4://131.196.180.1:4153
socks4://192.169.250.203:43652
socks4://154.79.242.178:10801
socks4://160.119.214.134:5678
socks4://131.0.246.113:4153
socks5://66.42.224.229:41679
socks4://67.22.223.9:39593
socks4://200.29.176.174:4145
socks5://202.149.89.69:7999
socks4://45.81.130.66:8888
socks5://98.162.25.23:4145
socks4://203.76.112.68:5678
socks4://72.217.216.239:4145
socks4://103.84.39.82:3629
socks4://143.255.140.28:5678
socks4://185.132.90.169:6789
socks4://200.70.19.92:4153
socks4://197.82.166.158:1080
socks4://103.251.214.167:6667
socks5://192.169.244.80:11514
socks4://46.188.53.61:3629
socks4://107.152.32.226:50626
socks4://182.53.197.156:43574
socks4://186.64.81.4:5678
socks5://54.39.87.232:39721
socks5://158.69.64.142:9200
socks4://47.206.214.4:54321
socks5://72.195.34.41:4145
socks4://103.17.90.6:5678
socks4://122.144.129.9:20086
socks5://128.168.80.100:1080
socks4://51.15.201.113:31579
socks5://72.217.216.239:4145
socks4://179.49.116.50:8587
socks4://91.83.42.1:44550
socks4://196.43.106.38:5678
socks4://177.52.26.234:4145
socks5://24.249.199.12:4145
socks4://112.78.144.62:4145
socks4://5.178.217.227:31019
socks4://45.81.130.84:8888
socks4://65.186.60.165:5678
socks4://43.154.54.110:10808
socks5://72.195.114.184:4145
socks4://138.255.220.2:5678
socks5://72.210.252.137:4145
socks4://109.167.134.253:44788
socks5://43.249.11.61:8888
socks5://159.65.159.172:4003
socks4://46.28.75.50:443
socks5://218.78.54.149:8902
socks4://72.49.49.11:31034
socks4://131.196.13.229:5678
socks4://201.206.141.102:6969
socks4://62.122.201.246:50129