reg: per-account proxy with 3 retries; proxy collector + numes filter; guide: egress/device-verification findings
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
Usage: python reg.py --start 0 --count 3 [--headless 1]
|
||||
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
|
||||
import pyotp
|
||||
|
||||
CHROME = os.environ.get("NUMES_CHROME", "C:/Program Files/Google/Chrome/Application/chrome.exe")
|
||||
ROOT = os.environ.get("NUMES_ROOT", os.path.dirname(os.path.abspath(__file__)))
|
||||
POOL = os.environ.get("NUMES_POOL", "gh_alive.jsonl")
|
||||
CHROME = "C:/Program Files/Google/Chrome/Application/chrome.exe"
|
||||
ROOT = "C:/Users/User/tmp/numes"
|
||||
POOL = "C:/Users/User/tmp/cometwork/gh_alive.jsonl"
|
||||
BANK = ROOT + "/bank.jsonl"
|
||||
FAIL = ROOT + "/fail.jsonl"
|
||||
DONE = ROOT + "/done.json"
|
||||
@@ -217,65 +217,127 @@ def warm_key(key):
|
||||
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():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--start", type=int, default=0)
|
||||
ap.add_argument("--count", type=int, default=2)
|
||||
ap.add_argument("--headless", type=int, default=0)
|
||||
ap.add_argument("--no-proxy", type=int, default=0)
|
||||
a = ap.parse_args()
|
||||
|
||||
os.makedirs(ROOT, exist_ok=True)
|
||||
accs = [x for x in pool() if x.get("login") and x.get("password")]
|
||||
done = set(load_json(DONE, []))
|
||||
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)}")
|
||||
|
||||
with sync_playwright() as p:
|
||||
ctx = p.chromium.launch_persistent_context(
|
||||
PROF,
|
||||
executable_path=CHROME,
|
||||
headless=bool(a.headless),
|
||||
args=["--disable-dev-shm-usage", "--disable-gpu", "--no-first-run", "--no-default-browser-check"],
|
||||
viewport={"width": 1280, "height": 900},
|
||||
)
|
||||
page = ctx.pages[0] if ctx.pages else ctx.new_page()
|
||||
for acc in todo:
|
||||
login = acc["login"]
|
||||
log("--- try", login)
|
||||
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:
|
||||
ctx.clear_cookies()
|
||||
ok, reason = do_login(page, acc)
|
||||
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()
|
||||
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(
|
||||
prof,
|
||||
executable_path=CHROME,
|
||||
headless=bool(a.headless),
|
||||
args=args,
|
||||
viewport={"width": 1280, "height": 900},
|
||||
)
|
||||
page = ctx.pages[0] if ctx.pages else ctx.new_page()
|
||||
try:
|
||||
ok, login, status = run_account(page, acc, px)
|
||||
finally:
|
||||
try:
|
||||
ctx.close()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
append(FAIL, {"login": login, "reason": "exc:" + str(e)[:200], "ts": int(time.time())})
|
||||
log("EXC", login, str(e)[:200])
|
||||
try:
|
||||
shot(page, "exc_" + re.sub(r"\W", "_", login))
|
||||
except Exception:
|
||||
pass
|
||||
done.add(login)
|
||||
finally:
|
||||
with open(DONE, "w", encoding="utf-8") as f:
|
||||
json.dump(sorted(done), f)
|
||||
ctx.close()
|
||||
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:
|
||||
json.dump(sorted(done), f)
|
||||
|
||||
|
||||
def save_key_file():
|
||||
|
||||
Reference in New Issue
Block a user