reg: per-account proxy with 3 retries; proxy collector + numes filter; guide: egress/device-verification findings

This commit is contained in:
2026-11-13 23:38:26 +02:00
parent ac8afc2def
commit b51723bc4e
4 changed files with 270 additions and 49 deletions
+23
View File
@@ -59,6 +59,29 @@ python reg.py --count 12 # 12 аккаунтов за прогон
Практика: ~80% аккаунтов из чистого пула дают ключ, 50 секунд на аккаунт, Практика: ~80% аккаунтов из чистого пула дают ключ, 50 секунд на аккаунт,
Chrome живёт 12-15 аккаунтов — гоняйте пачками по 12. Chrome живёт 12-15 аккаунтов — гоняйте пачками по 12.
### Прокси и egress (важно)
`reg.py` умеет гонять каждый аккаунт через свой прокси:
```bash
export NUMES_PROXY_FILE=/path/proxies.txt # host:port, по одному на аккаунт
python reg.py --count 12 # 3 попытки с ротацией прокси на аккаунт
python reg.py --count 12 --no-proxy 1 # принудительно прямой IP
```
Что выяснено на живых прогонах:
- **Свежий egress ломает GitHub OAuth.** Аккаунты, созданные с одного IP-семейства, при входе
с датацентр-прокси получают `gh_device_verification` (проверка устройства) — 4 аккаунта на
31 проверенном прокси дали 0 ключей. Часть прокси MITM-ит TLS → `ERR_CERT_AUTHORITY_INVALID`.
- **curl-проба прокси завышает пул.** `HEAD https://site/` через прокси отвечает 200/302, а
настоящая страница в Chrome уходит в `ERR_TIMED_OUT`. Фильтровать только прогоном страницы.
- Сетевые ошибки (`ERR_*`, `net::`, `Timeout`) не помечаются в `done.json` — аккаунт остаётся
пригодным для следующей попытки.
Практический вывод: регистрация идёт с того IP, где живёт пул; прокси выгоднее тратить на
другие цели, а не на OAuth-флоу.
## 3. Шим на прод-хосте ## 3. Шим на прод-хосте
```bash ```bash
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env python3
"""Collect live HTTP(S) proxies for browser waves: fetch public lists, probe via https."""
import concurrent.futures as cf
import json
import os
import re
import subprocess
import sys
OUT = os.environ.get("PX_OUT", "C:/Users/User/tmp/numes/proxies_http.txt")
LIMIT = int(os.environ.get("PX_LIMIT", "600"))
SOURCES = [
"https://api.proxyscrape.com/v4/free-proxy-list/get?request=display_proxies&protocol=http&proxy_format=ipport&format=text&timeout=8000",
"https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/http.txt",
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt",
"https://raw.githubusercontent.com/proxifly/free-proxy-list/main/proxies/protocols/http/data.txt",
]
def fetch(url):
try:
r = subprocess.run(["curl", "-sL", "-m", "40", url], capture_output=True,
text=True, timeout=60, errors="replace")
return r.stdout or ""
except Exception:
return ""
def parse(txt):
out = set()
for m in re.finditer(r"(\d{1,3}(?:\.\d{1,3}){3}):(\d{2,5})", txt):
out.add("%s:%s" % (m.group(1), m.group(2)))
return out
def probe(hp, timeout=12):
url = "https://api.ipify.org"
try:
r = subprocess.run(["curl", "-s", "-m", str(timeout), "-x", "http://" + hp, url],
capture_output=True, text=True, timeout=timeout + 6)
ip = (r.stdout or "").strip()
if ip and len(ip) < 20 and ip.count(".") == 3:
return hp, ip
except Exception:
pass
return hp, ""
def main():
cands = set()
for u in SOURCES:
t = fetch(u)
got = parse(t)
print("%-70s %d" % (u.split("/")[2], len(got)))
cands |= got
# свой relay на прод-хосте тоже годится как egress
cands = list(cands)[:LIMIT * 4]
print("candidates:", len(cands))
live = []
with cf.ThreadPoolExecutor(max_workers=120) as ex:
for hp, ip in ex.map(probe, cands):
if ip:
live.append((hp, ip))
# dedupe by egress ip: один egress = одна полоса
seen, uniq = set(), []
for hp, ip in live:
if ip in seen:
continue
seen.add(ip)
uniq.append(hp)
with open(OUT, "w", encoding="utf-8") as f:
for hp in uniq:
f.write(hp + "\n")
print("live:", len(live), "unique egress:", len(uniq), "->", OUT)
if __name__ == "__main__":
main()
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Keep only proxies that actually open numes.ai over HTTPS (CONNECT), dedupe by egress."""
import concurrent.futures as cf
import os
import subprocess
import sys
IN = os.environ.get("PX_IN", "C:/Users/User/tmp/numes/proxies_http.txt")
OUT = os.environ.get("PX_OUT2", "C:/Users/User/tmp/numes/proxies_numes.txt")
TARGET = "https://numes.ai/"
OK = {"200", "301", "302", "303", "307", "403"}
def ip_of(px, timeout=12):
try:
r = subprocess.run(["curl", "-s", "-m", str(timeout), "-x", "http://" + px,
"https://api.ipify.org"], capture_output=True, text=True,
timeout=timeout + 6)
ip = (r.stdout or "").strip()
return ip if ip and len(ip) < 20 and ip.count(".") == 3 else ""
except Exception:
return ""
def hit(px, timeout=18):
try:
r = subprocess.run(["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}",
"-m", str(timeout), "--http1.1", "-x", "http://" + px, TARGET],
capture_output=True, text=True, timeout=timeout + 8)
return (r.stdout or "").strip()
except Exception:
return "000"
def main():
px = [l.strip() for l in open(IN, encoding="utf-8") if l.strip()]
print("in:", len(px))
good = []
with cf.ThreadPoolExecutor(max_workers=60) as ex:
codes = list(ex.map(hit, px))
pass1 = [p for p, c in zip(px, codes) if c in OK]
print("numes-reachable:", len(pass1))
with cf.ThreadPoolExecutor(max_workers=40) as ex:
ips = list(ex.map(ip_of, pass1))
seen, out = set(), []
for p, ip in zip(pass1, ips):
if not ip or ip in seen:
continue
seen.add(ip)
out.append(p)
with open(OUT, "w", encoding="utf-8") as f:
f.write("\n".join(out) + ("\n" if out else ""))
print("unique egress:", len(out), "->", OUT)
if __name__ == "__main__":
main()
+100 -38
View File
@@ -4,14 +4,14 @@
Usage: python reg.py --start 0 --count 3 [--headless 1] Usage: python reg.py --start 0 --count 3 [--headless 1]
State: done.json (logins tried), bank.jsonl (keys ok), fail.jsonl (reasons) State: done.json (logins tried), bank.jsonl (keys ok), fail.jsonl (reasons)
""" """
import argparse, json, os, re, sys, time, traceback import argparse, json, os, re, subprocess, sys, time, traceback
from playwright.sync_api import sync_playwright from playwright.sync_api import sync_playwright
import pyotp import pyotp
CHROME = os.environ.get("NUMES_CHROME", "C:/Program Files/Google/Chrome/Application/chrome.exe") CHROME = "C:/Program Files/Google/Chrome/Application/chrome.exe"
ROOT = os.environ.get("NUMES_ROOT", os.path.dirname(os.path.abspath(__file__))) ROOT = "C:/Users/User/tmp/numes"
POOL = os.environ.get("NUMES_POOL", "gh_alive.jsonl") POOL = "C:/Users/User/tmp/cometwork/gh_alive.jsonl"
BANK = ROOT + "/bank.jsonl" BANK = ROOT + "/bank.jsonl"
FAIL = ROOT + "/fail.jsonl" FAIL = ROOT + "/fail.jsonl"
DONE = ROOT + "/done.json" DONE = ROOT + "/done.json"
@@ -217,65 +217,127 @@ def warm_key(key):
return None, str(e)[:120] return None, str(e)[:120]
def proxy_list():
f = os.environ.get("NUMES_PROXY_FILE", "")
if not f or not os.path.exists(f):
return []
out = []
with open(f, encoding="utf-8", errors="replace") as fh:
for line in fh:
line = line.strip()
if line and not line.startswith("#") and ":" in line:
out.append(line)
return out
def egress(px, timeout=15):
if not px:
return ""
try:
r = subprocess.run(
["curl", "-s", "-m", str(timeout), "-x", "http://" + px, "https://api.ipify.org"],
capture_output=True, text=True, timeout=timeout + 8)
ip = (r.stdout or "").strip()
return ip if ip and len(ip) < 20 else ""
except Exception:
return ""
def run_account(page, acc, px):
login = acc["login"]
log("--- try", login, "px", px or "direct")
try:
ctx = page.context
ctx.clear_cookies()
ok, reason = do_login(page, acc)
if not ok:
append(FAIL, {"login": login, "reason": reason, "px": px, "ts": int(time.time())})
log("FAIL", login, reason)
shot(page, "fail_" + re.sub(r"\W", "_", login))
return False, login, "resp"
key, kerr = create_key(page, acc)
if not key:
append(FAIL, {"login": login, "reason": "key:" + kerr, "px": px, "ts": int(time.time())})
log("KEYFAIL", login, kerr[:120])
shot(page, "keyfail_" + re.sub(r"\W", "_", login))
return False, login, "resp"
code, cost = warm_key(key)
append(BANK, {"gh": login, "email": acc.get("email"), "key": key,
"http": code, "cost": cost, "px": px, "egress": egress(px),
"ts": int(time.time())})
log("OK", login, "http", code, "cost", cost, "keylen", len(key), "px", px or "direct")
save_key_file()
return True, login, "ok"
except Exception as e:
me = str(e)
status = "netfail" if any(k in me for k in ("ERR_", "net::", "Timeout", "timeout", "ECONN")) else "fail"
append(FAIL, {"login": login, "reason": "exc:" + me[:200], "px": px, "status": status,
"ts": int(time.time())})
log("EXC", login, me[:200], status)
try:
shot(page, "exc_" + re.sub(r"\W", "_", login))
except Exception:
pass
return False, login, status
def main(): def main():
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser()
ap.add_argument("--start", type=int, default=0) ap.add_argument("--start", type=int, default=0)
ap.add_argument("--count", type=int, default=2) ap.add_argument("--count", type=int, default=2)
ap.add_argument("--headless", type=int, default=0) ap.add_argument("--headless", type=int, default=0)
ap.add_argument("--no-proxy", type=int, default=0)
a = ap.parse_args() a = ap.parse_args()
os.makedirs(ROOT, exist_ok=True) os.makedirs(ROOT, exist_ok=True)
accs = [x for x in pool() if x.get("login") and x.get("password")] accs = [x for x in pool() if x.get("login") and x.get("password")]
done = set(load_json(DONE, [])) done = set(load_json(DONE, []))
todo = [x for x in accs if x["login"] not in done][a.start:a.start + a.count] todo = [x for x in accs if x["login"] not in done][a.start:a.start + a.count]
log(f"wave start: pool={len(accs)} done={len(done)} todo={len(todo)}") px_all = [] if a.no_proxy else proxy_list()
log(f"wave start: pool={len(accs)} done={len(done)} todo={len(todo)} proxies={len(px_all)}")
for idx, acc in enumerate(todo):
if acc["login"] in done:
continue
status = "fail"
for attempt in range(3):
px = px_all[(a.start + idx + attempt) % len(px_all)] if px_all else None
prof = "%s_%d" % (PROF, (a.start + idx + attempt) % 120)
try:
with sync_playwright() as p: with sync_playwright() as p:
args = ["--disable-dev-shm-usage", "--disable-gpu", "--no-first-run",
"--no-default-browser-check"]
if px:
args.append("--proxy-server=http://" + px)
ctx = p.chromium.launch_persistent_context( ctx = p.chromium.launch_persistent_context(
PROF, prof,
executable_path=CHROME, executable_path=CHROME,
headless=bool(a.headless), headless=bool(a.headless),
args=["--disable-dev-shm-usage", "--disable-gpu", "--no-first-run", "--no-default-browser-check"], args=args,
viewport={"width": 1280, "height": 900}, viewport={"width": 1280, "height": 900},
) )
page = ctx.pages[0] if ctx.pages else ctx.new_page() page = ctx.pages[0] if ctx.pages else ctx.new_page()
for acc in todo:
login = acc["login"]
log("--- try", login)
try: try:
ctx.clear_cookies() ok, login, status = run_account(page, acc, px)
ok, reason = do_login(page, acc) finally:
if not ok:
append(FAIL, {"login": login, "reason": reason, "ts": int(time.time())})
log("FAIL", login, reason)
shot(page, "fail_" + re.sub(r"\W", "_", login))
done.add(login)
continue
key, kerr = create_key(page, acc)
if not key:
append(FAIL, {"login": login, "reason": "key:" + kerr, "ts": int(time.time())})
log("KEYFAIL", login, kerr[:120])
shot(page, "keyfail_" + re.sub(r"\W", "_", login))
done.add(login)
continue
code, cost = warm_key(key)
append(BANK, {"gh": login, "email": acc.get("email"), "key": key,
"http": code, "cost": cost, "ts": int(time.time())})
log("OK", login, "http", code, "cost", cost, "keylen", len(key))
done.add(login)
save_key_file()
except Exception as e:
append(FAIL, {"login": login, "reason": "exc:" + str(e)[:200], "ts": int(time.time())})
log("EXC", login, str(e)[:200])
try: try:
shot(page, "exc_" + re.sub(r"\W", "_", login)) ctx.close()
except Exception: except Exception:
pass pass
done.add(login) except Exception as e:
finally: me = str(e)
status = "netfail" if any(k in me for k in ("ERR_", "net::", "Timeout", "ECONN")) else "fail"
log("LAUNCH_FAIL", acc["login"], me[:160], status)
append(FAIL, {"login": acc["login"], "reason": "launch:" + me[:200],
"px": px, "status": status, "ts": int(time.time())})
if status != "netfail":
break
if status != "netfail":
done.add(acc["login"])
else:
log("SKIP(done untouched)", acc["login"])
with open(DONE, "w", encoding="utf-8") as f: with open(DONE, "w", encoding="utf-8") as f:
json.dump(sorted(done), f) json.dump(sorted(done), f)
ctx.close()
def save_key_file(): def save_key_file():