131 lines
5.1 KiB
Python
131 lines
5.1 KiB
Python
# Probe treg.to /auth/email/start across many mail domains.
|
|
# ACCEPTED(200)=domain passes blocklist; BLOCKED(403); RATE(429) -> retry via another proxy later.
|
|
# Turnstile tokens from local sidecar :8877 (real_page, free). Requests spread over proxy pool.
|
|
import json, random, sqlite3, string, sys, time, threading, queue
|
|
import requests
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
|
|
sys.path.insert(0, r"C:/Users/User/tmp/treg_test")
|
|
from treg_farm_v3 import HDRS
|
|
|
|
DOMAINS = [
|
|
# privacy (proven payer class)
|
|
"protonmail.com", "pm.me", "tutanota.com", "tutanota.de", "tuta.io",
|
|
"mailfence.com", "startmail.com", "disroot.org", "posteo.de", "mailbox.org",
|
|
"cock.li", "lavabit.com", "hushmail.com", "elude.in",
|
|
# majors (controls, mostly $0 or blocked)
|
|
"gmail.com", "outlook.com", "hotmail.com", "yahoo.com", "icloud.com",
|
|
"aol.com", "mail.com", "gmx.com", "zoho.com", "qq.com", "163.com", "126.com",
|
|
# PL
|
|
"wp.pl", "o2.pl", "tlen.pl", "interia.pl", "onet.pl", "op.pl", "vp.pl", "buziaczek.pl",
|
|
# UA/RU
|
|
"ukr.net", "meta.ua", "i.ua", "email.ua", "mail.ru", "inbox.ru", "list.ru", "bk.ru",
|
|
"yandex.ru", "yandex.com", "rambler.ru",
|
|
# CZ/SK
|
|
"seznam.cz", "email.cz", "centrum.cz", "post.cz", "azet.sk", "zoznam.sk",
|
|
# DE/AT/CH
|
|
"gmx.de", "gmx.at", "gmx.ch", "web.de", "aon.at", "bluewin.ch",
|
|
# baltics
|
|
"inbox.lv", "mail.lv", "one.lt", "delfi.lt", "hot.ee", "mail.ee",
|
|
# IT/FR/GR/HU/BG
|
|
"libero.it", "virgilio.it", "tiscali.it", "orange.fr", "laposte.net", "free.fr",
|
|
"in.gr", "freemail.hu", "citromail.hu", "abv.bg", "mail.bg",
|
|
# misc + disposable controls
|
|
"fastmail.com", "runbox.com", "yandex.by", "me.com", "live.com",
|
|
"guerrillamail.com", "mailinator.com", "tempmail.lol", "mail.tm", "voidash.bond",
|
|
]
|
|
|
|
DB = r"C:/Users/User/Desktop/proxy_bot/proxies.db"
|
|
STATE = r"C:/Users/User/tmp/treg_repo/probe_state.json"
|
|
lock = threading.Lock()
|
|
state = {}
|
|
try:
|
|
state = json.load(open(STATE, encoding="utf-8"))
|
|
except Exception:
|
|
state = {}
|
|
|
|
def load_proxies():
|
|
px = []
|
|
try:
|
|
con = sqlite3.connect(DB)
|
|
for (h,) in con.execute("select proxy from pool where alive=1"):
|
|
if not h.startswith("http"):
|
|
h = "http://" + h
|
|
px.append(h)
|
|
con.close()
|
|
except Exception as e:
|
|
print("proxydb err", e)
|
|
random.shuffle(px)
|
|
return px
|
|
|
|
PROXIES = load_proxies()
|
|
print("proxies loaded:", len(PROXIES), flush=True)
|
|
|
|
def sidecar_token(retry=2):
|
|
for _ in range(retry):
|
|
try:
|
|
r = requests.post("http://127.0.0.1:8877/solve", json={
|
|
"type": "turnstile",
|
|
"sitekey": "0x4AAAAAAFVJ1qUhtZ_qG-N7",
|
|
"url": "https://treg.to/", "real_page": True}, timeout=240)
|
|
d = r.json()
|
|
tok = d.get("token")
|
|
if tok:
|
|
return tok
|
|
except Exception:
|
|
pass
|
|
time.sleep(3)
|
|
return None
|
|
|
|
def probe(dom):
|
|
if state.get(dom, {}).get("verdict") in ("ACCEPTED", "BLOCKED"):
|
|
return dom, state[dom]["verdict"], "cached"
|
|
addr = "".join(random.choice(string.ascii_lowercase) for _ in range(9)) + str(random.randint(10, 99)) + "@" + dom
|
|
for attempt in range(3):
|
|
tok = sidecar_token()
|
|
if not tok:
|
|
return dom, "NOTOKEN", ""
|
|
sess = requests.Session()
|
|
sess.headers.update(HDRS)
|
|
px = random.choice(PROXIES) if PROXIES else None
|
|
try:
|
|
r = sess.post("https://treg.to/auth/email/start",
|
|
json={"email": addr, "captcha_token": tok},
|
|
proxies={"http": px, "https": px} if px else None, timeout=35)
|
|
st = r.status_code
|
|
except Exception as e:
|
|
st = 0
|
|
r = None
|
|
if st == 200:
|
|
v = "ACCEPTED"
|
|
elif st == 403:
|
|
v = "BLOCKED"
|
|
elif st == 429:
|
|
v = "RATE"
|
|
time.sleep(5)
|
|
continue
|
|
else:
|
|
v = f"HTTP{st}"
|
|
with lock:
|
|
state[dom] = {"verdict": v, "ts": time.strftime("%H:%M:%S"), "addr": addr, "proxy": px}
|
|
json.dump(state, open(STATE, "w", encoding="utf-8"))
|
|
print("%-20s %-9s via %s" % (dom, v, (px or "direct")[:38]), flush=True)
|
|
return dom, v, ""
|
|
with lock:
|
|
state[dom] = {"verdict": "RATE", "ts": time.strftime("%H:%M:%S")}
|
|
json.dump(state, open(STATE, "w", encoding="utf-8"))
|
|
return dom, "RATE", ""
|
|
|
|
todo = [d for d in DOMAINS if state.get(d, {}).get("verdict") not in ("ACCEPTED", "BLOCKED")]
|
|
print("to probe:", len(todo), flush=True)
|
|
# low concurrency: sidecar solves serially-ish, proxies rotate per request
|
|
with ThreadPoolExecutor(max_workers=3) as ex:
|
|
list(ex.map(probe, todo))
|
|
|
|
acc = [d for d, v in state.items() if v.get("verdict") == "ACCEPTED"]
|
|
blk = [d for d, v in state.items() if v.get("verdict") == "BLOCKED"]
|
|
print("=== SUMMARY ===", flush=True)
|
|
print("ACCEPTED(%d): %s" % (len(acc), acc), flush=True)
|
|
print("BLOCKED(%d): %s" % (len(blk), blk), flush=True)
|
|
print("OTHER: %s" % {d: v.get("verdict") for d, v in state.items() if v.get("verdict") not in ("ACCEPTED", "BLOCKED")}, flush=True)
|