Add donor-state classifier and measured account gates (2026-11-13)

This commit is contained in:
2026-11-13 22:30:24 +02:00
parent 131cda56cd
commit 776b8d8799
2 changed files with 169 additions and 0 deletions
+28
View File
@@ -82,8 +82,36 @@ The script skips logins already listed in `WS_USED`.
```
wavespeed/ws_autoreg.py registration pipeline (GitHub OAuth + Turnstile + key creation)
wavespeed/ws_keycheck.py key validation: catalogue, chat completion, media generation
wavespeed/ws_classify.py donor pre-flight: ready / flagged / nosession (no captcha spent)
```
## Account-state gates (measured 2026-11-13)
Mass-registered GitHub accounts are not interchangeable: before spending a Turnstile solve,
classify the donor. `wavespeed/ws_classify.py` does exactly this — one login + one authorize
fetch per account (~5-8 s, no captcha), verdicts `ready` / `flagged` / `nosession`.
Three states observed on the same egress:
| state | signal | share |
|---|---|---|
| `ready` | authorize page renders (200 with `authenticity_token` + `authorize`) | ~17% of day-old accounts |
| `flagged` | `200` on `/dashboard` with flash *"This account is flagged, and therefore cannot authorize a third party application"* | ~8% |
| `nosession` | authorize redirects to `/login?client_id=...` | ~75% |
- Fresh accounts (registered the same day at scale) are `flagged` almost immediately —
GitHub refuses third-party authorization client-side, nothing in the flow can fix it.
- Month-old pools die on 2FA: `/sessions/two-factor/app` rejects the stored TOTP secret
(the post to `/sessions/two-factor` returns the same page, session never establishes).
- A burned residential IP shows `nosession` for every account: logins pass but the session
does not survive the next request. This is the GitHub-side per-IP login budget, not a
credential problem.
- On the `ready` subset the trial grant is far better than the earlier 4-6% estimate:
a 2/2 run and a 17% ready-rate means the practical cost is ~6 accounts per `$1`,
not ~20.
Recommended order: classify → run the pipeline only on `ready` → keep one GH lane at a time.
## Notes / pitfalls
- `verified-device` on the GitHub login means the account needs an e-mail code — use
+141
View File
@@ -0,0 +1,141 @@
# -*- coding: utf-8 -*-
"""Pre-flight classifier for GitHub accounts used as WaveSpeed OAuth donors.
WaveSpeed is GitHub-OAuth only, so an account that GitHub refuses to authorize is
worthless no matter how many times you retry. Two failure modes dominate and are
invisible until the full (captcha-paid) pipeline runs:
* ``flagged`` — "This account is flagged, and therefore cannot authorize
a third party application". Freshly mass-registered accounts hit this almost
immediately; nothing can be done client-side.
* ``nosession`` — /login lands without an authenticated session (password
changed, device verification required, or the egress IP already burned its
GitHub login budget). The authorize URL then redirects to /login.
Only ``ready`` accounts deserve a Turnstile solve. Classifying costs one login and
one page fetch per account (~5-8 s) and no captcha money.
Usage:
python ws_classify.py <pool.json> <limit> [skip]
# appends ready accounts to pool_ready.json, verdicts to classify.log
Pool format: JSON list (or JSONL) of {login, password, totp, email, email_pw}.
"""
import json
import os
import sys
import time
import requests
HOME = os.path.dirname(os.path.abspath(__file__))
OUT = os.path.join(HOME, "pool_ready.json")
SEEN = os.path.join(HOME, "classify_seen.txt")
LOG = os.path.join(HOME, "classify.log")
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36")
CLIENT_ID = os.environ.get("WS_GH_CLIENT_ID", "Ov23liO4t6o6MsNlCsE9")
AUTH = ("https://github.com/login/oauth/authorize?client_id=%s"
"&redirect_uri=https%%3A%%2F%%2Fwavespeed.ai%%2Fcenter%%2Fdefault%%2Fgithub%%2Fcallback"
"&response_type=code" % CLIENT_ID)
def log(msg):
print(msg, flush=True)
with open(LOG, "a", encoding="utf-8") as f:
f.write(time.strftime("%H:%M:%S ") + msg + "\n")
def gh_login(acc):
"""Direct (residential) login. Returns (session, verdict)."""
s = requests.Session()
s.headers.update({"User-Agent": UA, "Accept-Language": "en-US,en;q=0.9"})
r = s.get("https://github.com/login", timeout=45)
import re
m = re.search(r'name="authenticity_token" value="([^"]+)"', r.text)
if not m:
return None, "no-csrf"
r = s.post("https://github.com/session",
data={"authenticity_token": m.group(1), "login": acc["login"],
"password": acc["password"], "commit": "Sign in", "return_to": ""},
timeout=45, allow_redirects=True)
if "verified-device" in r.url:
return None, "verified-device"
if "two-factor" in r.url:
if not acc.get("totp"):
return None, "2fa-no-secret"
try:
import pyotp
except ImportError:
return None, "2fa-no-pyotp"
m2 = re.search(r'name="authenticity_token" value="([^"]+)"', r.text)
r = s.post("https://github.com/sessions/two-factor",
data={"authenticity_token": m2.group(1) if m2 else "",
"otp": pyotp.TOTP(acc["totp"]).now()},
timeout=45, allow_redirects=True)
if "two-factor" in r.url:
return None, "2fa-fail"
if "github.com/login" in r.url:
return None, "login-fail"
return s, "ok"
def classify(acc):
s, verdict = gh_login(acc)
if not s:
return "login:" + verdict
try:
r = s.get(AUTH, timeout=45, allow_redirects=True)
body = r.text.lower()
if "cannot authorize a third party application" in body:
return "flagged"
if "login/oauth/authorize" in r.url and "authorize" in body:
return "ready"
if "/login" in r.url:
return "nosession"
return "other:" + r.url[:60]
except Exception as e: # noqa: BLE001
return "authz-err:" + repr(e)[:60]
def load_pool(path):
txt = open(path, encoding="utf-8", errors="replace").read().strip()
if txt.startswith("["):
return json.loads(txt)
out = []
for line in txt.splitlines():
line = line.strip()
if line:
try:
out.append(json.loads(line))
except Exception: # noqa: BLE001
pass
return out
def main():
if len(sys.argv) < 2:
print(__doc__)
return
pool = load_pool(sys.argv[1])
limit = int(sys.argv[2]) if len(sys.argv) > 2 else 50
skip = int(sys.argv[3]) if len(sys.argv) > 3 else 0
done = set(open(SEEN).read().split()) if os.path.exists(SEEN) else set()
todo = [a for a in pool if a.get("login") and a["login"] not in done]
log("pool=%d done=%d todo=%d" % (len(pool), len(done), len(todo)))
good = 0
for acc in todo[skip:skip + limit]:
verdict = classify(acc)
if verdict == "ready":
good += 1
with open(OUT, "a", encoding="utf-8") as f:
f.write(json.dumps(acc, ensure_ascii=False) + "\n")
with open(SEEN, "a") as f:
f.write(acc["login"] + "\n")
log("%s -> %s" % (acc["login"], verdict))
log("DONE ready=%d of %d" % (good, limit))
if __name__ == "__main__":
main()