autoreg-skills-max: initial public release (restored, redacted, hardened)
This commit is contained in:
88
skills/free-tools-abuse/scripts/proxy_checker.py
Normal file
88
skills/free-tools-abuse/scripts/proxy_checker.py
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Proxy checker — проверяет список проксей на живость.
|
||||
Usage: python proxy_checker.py proxies.txt [--workers 20]
|
||||
"""
|
||||
import sys
|
||||
import requests
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
TEST_URL = "https://httpbin.org/ip"
|
||||
TIMEOUT = 8
|
||||
|
||||
def check_proxy(proxy_line: str) -> tuple[str, bool, str]:
|
||||
"""Check single proxy. Returns (proxy, is_alive, info)."""
|
||||
proxy_line = proxy_line.strip()
|
||||
if not proxy_line or proxy_line.startswith("#"):
|
||||
return (proxy_line, False, "skipped")
|
||||
|
||||
# Try http:// prefix if not present
|
||||
if "://" not in proxy_line:
|
||||
proxy_url = f"http://{proxy_line}"
|
||||
else:
|
||||
proxy_url = proxy_line
|
||||
|
||||
proxies = {"http": proxy_url, "https": proxy_url}
|
||||
|
||||
try:
|
||||
r = requests.get(TEST_URL, proxies=proxies, timeout=TIMEOUT)
|
||||
if r.status_code == 200:
|
||||
ip = r.json().get("origin", "unknown")
|
||||
return (proxy_line, True, ip)
|
||||
return (proxy_line, False, f"HTTP {r.status_code}")
|
||||
except requests.exceptions.ProxyError:
|
||||
return (proxy_line, False, "proxy error")
|
||||
except requests.exceptions.ConnectTimeout:
|
||||
return (proxy_line, False, "connect timeout")
|
||||
except requests.exceptions.ReadTimeout:
|
||||
return (proxy_line, False, "read timeout")
|
||||
except Exception as e:
|
||||
return (proxy_line, False, str(e)[:50])
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python proxy_checker.py <proxies.txt> [--workers 20]")
|
||||
sys.exit(1)
|
||||
|
||||
filepath = sys.argv[1]
|
||||
workers = 20
|
||||
if "--workers" in sys.argv:
|
||||
idx = sys.argv.index("--workers")
|
||||
workers = int(sys.argv[idx + 1])
|
||||
|
||||
with open(filepath, "r") as f:
|
||||
proxies = [line.strip() for line in f if line.strip()]
|
||||
|
||||
print(f"Checking {len(proxies)} proxies with {workers} workers...\n")
|
||||
|
||||
alive = []
|
||||
dead = 0
|
||||
|
||||
with ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
futures = {executor.submit(check_proxy, p): p for p in proxies}
|
||||
for future in as_completed(futures):
|
||||
proxy, is_alive, info = future.result()
|
||||
if is_alive:
|
||||
alive.append(proxy)
|
||||
print(f" ✅ LIVE: {proxy} → {info}")
|
||||
else:
|
||||
dead += 1
|
||||
|
||||
print(f"\n--- Results ---")
|
||||
print(f"Total: {len(proxies)}")
|
||||
print(f"Alive: {len(alive)}")
|
||||
print(f"Dead: {dead}")
|
||||
|
||||
# Save alive proxies
|
||||
outfile = filepath.replace(".txt", "_alive.txt")
|
||||
if not outfile.endswith("_alive.txt"):
|
||||
outfile = filepath + "_alive.txt"
|
||||
|
||||
with open(outfile, "w") as f:
|
||||
f.write("\n".join(alive))
|
||||
print(f"Alive proxies saved to: {outfile}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user