mfa_bind.py: real MFA+protection binder (proven -100/-101 2-state flow, vk21 E2E); auto.py: mfa_bind before DNS writes; gname_core: aqbh send-cooldown + freshness anchor; README: 4/4 domains proven
This commit is contained in:
@@ -23,7 +23,7 @@ python auto.py --domains 2 --mail cf --serve
|
|||||||
| Cloudflare mail | `cf_mail.py` | Pure API: create zone → enable Email Routing → destination address → **catch-all rule** (every `*@yourdomain` forwards to your Gmail). MX/SPF auto-created by CF |
|
| Cloudflare mail | `cf_mail.py` | Pure API: create zone → enable Email Routing → destination address → **catch-all rule** (every `*@yourdomain` forwards to your Gmail). MX/SPF auto-created by CF |
|
||||||
| Orchestration | `auto.py` | login → claim N → mail setup → NS switch → `data/status.json` |
|
| Orchestration | `auto.py` | login → claim N → mail setup → NS switch → `data/status.json` |
|
||||||
| Dashboard | `dashboard.py` | stdlib HTTP (:8570): domains, pipeline status, live OTP inbox (codes parsed from subjects) |
|
| Dashboard | `dashboard.py` | stdlib HTTP (:8570): domains, pipeline status, live OTP inbox (codes parsed from subjects) |
|
||||||
| MFA bind | `mfa_bind.py` | TOTP on the account (keeps farm accounts recoverable) |
|
| MFA bind + protection | `mfa_bind.py` | Proven 2-state fix: `-100 remove protection` → aqbh email unlock; `-101 set protection` → MFA bind (`set_aqlb` secret+totp) + `set_czyz [1,4]`. Run BEFORE `setup_dns.py` on fresh accounts |
|
||||||
| Captcha RE | `gsv_deob*.py`, `gsv_deob2.js` | Deobfuscators for the site slider JS (7574 transitive aliases removed) |
|
| Captcha RE | `gsv_deob*.py`, `gsv_deob2.js` | Deobfuscators for the site slider JS (7574 transitive aliases removed) |
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
@@ -47,7 +47,7 @@ Deploy `mail_catcher/catcher.py` on any VPS with inbound :25 (see `mail_catcher/
|
|||||||
export DNS_A_IP=YOUR_VPS_IP
|
export DNS_A_IP=YOUR_VPS_IP
|
||||||
python auto.py --domains 3 --mail dns # A mail->IP + MX @->mail.domain (prio 5)
|
python auto.py --domains 3 --mail dns # A mail->IP + MX @->mail.domain (prio 5)
|
||||||
```
|
```
|
||||||
Proven chain: external sender → public MX `mail.<domain>.eu.cc` → VPS :25 catcher → `.eml` stored + relayed to Gmail (`[catch otp-...@domain]` subject, verification code in body — `imap_code`/dashboard read it). Works for 3/3 live domains.
|
Proven chain: external sender → public MX `mail.<domain>.eu.cc` → VPS :25 catcher → `.eml` stored + relayed to Gmail (`[catch otp-...@domain]` subject, verification code in body — `imap_code`/dashboard read it). Works for **4/4 live domains** (incl. `reformvk21.eu.cc` via `mfa_bind.py` → `setup_dns.py`: A/MX/SPF `code:1`, public DNS confirmed via Google resolver, external SMTP → catcher → Gmail FOUND).
|
||||||
Proven outbound chain: client → VPS `:587` (auth LOGIN, TLS) → Gmail relay fallback → recipient inbox with `From: you@yourdomain` (marker test found in INBOX). Proven OTP loop: `/next` → mail to issued address → `/latest?wait=90` → `CODE VALID: True` (see `mail_catcher/README.md`).
|
Proven outbound chain: client → VPS `:587` (auth LOGIN, TLS) → Gmail relay fallback → recipient inbox with `From: you@yourdomain` (marker test found in INBOX). Proven OTP loop: `/next` → mail to issued address → `/latest?wait=90` → `CODE VALID: True` (see `mail_catcher/README.md`).
|
||||||
Purge stale records anytime: `python dns_clean.py <domain> --match forwardemail` / `--ip OLD_IP`.
|
Purge stale records anytime: `python dns_clean.py <domain> --match forwardemail` / `--ip OLD_IP`.
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ def main():
|
|||||||
st[dom]["ns_set"] = ns
|
st[dom]["ns_set"] = ns
|
||||||
elif args.mail == "dns":
|
elif args.mail == "dns":
|
||||||
ip = os.environ.get("DNS_A_IP", "")
|
ip = os.environ.get("DNS_A_IP", "")
|
||||||
|
if os.environ.get("GNAME_UID"):
|
||||||
|
# ensure operation protection is SET (MFA + czyz[1,4]);
|
||||||
|
# without it jx_edit writes fail with -101 on fresh accounts
|
||||||
|
st[dom]["mfa_bind_rc"] = run("mfa_bind.py", "--uid", os.environ["GNAME_UID"])
|
||||||
a_args = ["--a", "mail=" + ip] if ip else []
|
a_args = ["--a", "mail=" + ip] if ip else []
|
||||||
t_args = ["--txt", "@=v=spf1 ip4:" + ip + " ~all"] if ip else []
|
t_args = ["--txt", "@=v=spf1 ip4:" + ip + " ~all"] if ip else []
|
||||||
run("setup_dns.py", dom, *a_args, "--mx", "@=mail." + dom + ":5", *t_args)
|
run("setup_dns.py", dom, *a_args, "--mx", "@=mail." + dom + ":5", *t_args)
|
||||||
|
|||||||
+22
-5
@@ -214,6 +214,7 @@ def aqbh_session_unlock(page, email=None):
|
|||||||
tok = csrf(page)
|
tok = csrf(page)
|
||||||
email = email or os.environ.get("GM_EMAIL", "")
|
email = email or os.environ.get("GM_EMAIL", "")
|
||||||
t_send = time.time() - 30
|
t_send = time.time() - 30
|
||||||
|
t_sent_ok = t_send
|
||||||
sent = False
|
sent = False
|
||||||
for attempt in range(4):
|
for attempt in range(4):
|
||||||
r = inpost_json(page, "/request/send_email", {"email": email, "lx": "czyz", "csrf_token": tok}, "aq_snd%d" % attempt)
|
r = inpost_json(page, "/request/send_email", {"email": email, "lx": "czyz", "csrf_token": tok}, "aq_snd%d" % attempt)
|
||||||
@@ -231,6 +232,7 @@ def aqbh_session_unlock(page, email=None):
|
|||||||
log("AQBH SEND_EMAIL retry:", str(r)[:150])
|
log("AQBH SEND_EMAIL retry:", str(r)[:150])
|
||||||
if isinstance(r, dict) and r.get("code") == 1:
|
if isinstance(r, dict) and r.get("code") == 1:
|
||||||
sent = True
|
sent = True
|
||||||
|
t_sent_ok = time.time() # freshness anchor AFTER cooldown/slider waits
|
||||||
break
|
break
|
||||||
msg = str((r or {}).get("msg", "")) if isinstance(r, dict) else ""
|
msg = str((r or {}).get("msg", "")) if isinstance(r, dict) else ""
|
||||||
m2 = re.search(r"after\s+(\d+)\s+seconds", msg)
|
m2 = re.search(r"after\s+(\d+)\s+seconds", msg)
|
||||||
@@ -242,19 +244,34 @@ def aqbh_session_unlock(page, email=None):
|
|||||||
return False
|
return False
|
||||||
if not sent:
|
if not sent:
|
||||||
return False
|
return False
|
||||||
code = imap_code(wait=300, min_ts=t_send)
|
min_ts = t_sent_ok - 20
|
||||||
|
ok = False
|
||||||
|
for chk in range(3):
|
||||||
|
code = imap_code(wait=240, min_ts=min_ts)
|
||||||
log("AQBH code:", code)
|
log("AQBH code:", code)
|
||||||
if not code:
|
if not code:
|
||||||
return False
|
break
|
||||||
r = inpost_json(page, "/user_zh/aqbh_check", {"csrf_token": tok, "token": "", "eyzm": code}, "aq_sess")
|
r = inpost_json(page, "/user_zh/aqbh_check", {"csrf_token": tok, "token": "", "eyzm": code}, "aq_sess%d" % chk)
|
||||||
log("AQBH_CHECK session:", str(r)[:250])
|
log("AQBH_CHECK session:", str(r)[:250])
|
||||||
s = str(r)
|
s = str(r)
|
||||||
|
if isinstance(r, dict):
|
||||||
|
ok = str(r.get("code")) == "1"
|
||||||
|
else:
|
||||||
ok = '"code":1' in s or '"code":"1"' in s
|
ok = '"code":1' in s or '"code":"1"' in s
|
||||||
if ok:
|
if ok:
|
||||||
_AQBH_OK = True
|
break
|
||||||
elif "tried wrong" in s or "restricted for 1 hour" in s:
|
if "tried wrong" in s or "restricted for 1 hour" in s:
|
||||||
_AQBH_BLOCKED = True
|
_AQBH_BLOCKED = True
|
||||||
log("AQBH LOCKOUT: wrong-code limit hit, blocked ~1h - stop attempts")
|
log("AQBH LOCKOUT: wrong-code limit hit, blocked ~1h - stop attempts")
|
||||||
|
break
|
||||||
|
if "incorrect or has expired" in s:
|
||||||
|
# mail lag: the code we read may predate the newest send — re-read fresh
|
||||||
|
min_ts = time.time() - 5
|
||||||
|
time.sleep(12)
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
if ok:
|
||||||
|
_AQBH_OK = True
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+114
-24
@@ -1,26 +1,116 @@
|
|||||||
import os, json, time, re
|
#!/usr/bin/env python3
|
||||||
|
"""mfa_bind.py — bind TOTP MFA + enable operation-protection channels on a gname account.
|
||||||
|
|
||||||
|
WHY: gname DNS/domain writes fail in two opposite states:
|
||||||
|
-100 "Please remove operation protection" -> session must pass aqbh email-code unlock FIRST
|
||||||
|
-101 "please set operation protection" -> protection channels must be SET (czyz [1,4])
|
||||||
|
Proven sequence (2026-10-16, uid 510198 / reformvk21.eu.cc):
|
||||||
|
1. login -> GET secret from #/safeModify/lx=4/type=0/txt= (input[name=secret] or img src secret=)
|
||||||
|
2. if writes return -100: aqbh_session_unlock (email code via IMAP; GM_EMAIL/GM_APPPW env)
|
||||||
|
3. POST /user_zh/set_aqlb {secret, code=totp(secret)} -> MFA bound
|
||||||
|
4. POST /user_zh/set_czyz czyz[]=1&czyz[]=4 -> email+MFA channels ON
|
||||||
|
5. now /user_ym/jx_edit writes succeed (setup_dns.py)
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python mfa_bind.py [--uid 510198] [--bank path/to/gname_accounts.jsonl] [--out mfa.json]
|
||||||
|
Env: GM_EMAIL, GM_APPPW (gmail app-password) for the -100 email-code unlock.
|
||||||
|
Secrets stay local: writes mfa_secret to --out (default gname_mfa.json, gitignored).
|
||||||
|
"""
|
||||||
|
import argparse, base64, hashlib, hmac, json, os, re, struct, sys, time
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
from playwright.sync_api import sync_playwright
|
from playwright.sync_api import sync_playwright
|
||||||
BASE = os.environ.get("GNAME_HOME", os.path.join(os.path.dirname(os.path.abspath(__file__)), "data"))
|
import gname_core as G
|
||||||
with sync_playwright() as pw:
|
from gname_core import mk_context, save_cookies, csrf, inpost_json, inpost, aqbh_session_unlock
|
||||||
b = pw.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
||||||
ctx = b.new_context(viewport={"width":1440,"height":950}, locale="en-US",
|
SITE = G.SITE
|
||||||
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36")
|
|
||||||
ctx.add_cookies(json.load(open(BASE+"/gname_cookies.json")))
|
|
||||||
|
def totp(secret, period=30, digits=6):
|
||||||
|
key = base64.b32decode(secret.upper().replace(" ", ""), casefold=True)
|
||||||
|
ctr = int(time.time()) // period
|
||||||
|
h = hmac.new(key, struct.pack(">Q", ctr), hashlib.sha1).digest()
|
||||||
|
o = h[-1] & 0x0F
|
||||||
|
return str((struct.unpack(">I", h[o:o + 4])[0] & 0x7FFFFFFF) % (10 ** digits)).zfill(digits)
|
||||||
|
|
||||||
|
|
||||||
|
def get_secret(page):
|
||||||
|
return page.evaluate("""() => {
|
||||||
|
let s = (document.querySelector('input[name=secret]')||{}).value || '';
|
||||||
|
if (!s) { const img=[...document.querySelectorAll('img')].map(i=>i.src).find(x=>x.includes('secret=')); if(img) s=new URL(img).searchParams.get('secret'); }
|
||||||
|
return s;
|
||||||
|
}""")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument("--uid", default=os.environ.get("GNAME_UID", ""))
|
||||||
|
ap.add_argument("--bank", default=os.environ.get("GNAME_BANK", "gname_accounts.jsonl"))
|
||||||
|
ap.add_argument("--out", default="gname_mfa.json")
|
||||||
|
a = ap.parse_args()
|
||||||
|
|
||||||
|
acc = None
|
||||||
|
for line in open(a.bank, encoding="utf-8"):
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
d = json.loads(line)
|
||||||
|
if a.uid and str(d.get("uid")) == str(a.uid):
|
||||||
|
acc = d
|
||||||
|
elif not a.uid:
|
||||||
|
acc = d # first without --uid
|
||||||
|
if acc:
|
||||||
|
break
|
||||||
|
if not acc:
|
||||||
|
print("FATAL: uid not found in bank"); sys.exit(2)
|
||||||
|
G.EMAIL = acc["email"]
|
||||||
|
|
||||||
|
with sync_playwright() as pw:
|
||||||
|
browser, ctx = mk_context(pw, cookies=True)
|
||||||
page = ctx.new_page()
|
page = ctx.new_page()
|
||||||
page.goto("https://www.gname.com/user/iframe#/safeModify/lx=4/type=0/txt=", wait_until="domcontentloaded", timeout=60000)
|
page.goto(SITE + "/user", wait_until="domcontentloaded", timeout=60000)
|
||||||
time.sleep(9)
|
time.sleep(4)
|
||||||
body = page.evaluate("() => document.body.innerText.split(String.fromCharCode(10)).filter(l=>l.trim()).join(' | ').slice(0,1400)")
|
tok = csrf(page)
|
||||||
print("BODY:", body, flush=True)
|
r = inpost_json(page, "/user_ym/get_ym_list", {"page": 1, "limit": 50, "csrf_token": tok}, "idcheck")
|
||||||
fields = page.evaluate("""() => [...document.querySelectorAll('input,select')].map(e=>e.tagName+':'+(e.type||'')+':'+(e.name||'')+':'+(e.placeholder||'')+':'+(e.offsetParent?'vis':'hid'))""")
|
d = (r or {}).get("data") or {}
|
||||||
print("FIELDS:", json.dumps(fields[:20]), flush=True)
|
lst = d.get("data") if isinstance(d, dict) else d
|
||||||
imgs = page.evaluate("""() => [...document.querySelectorAll('img')].filter(i=>i.offsetParent!==null).map(i=>({src:(i.src||'').slice(0,120), w:i.width, h:i.height}))""")
|
print("ACCOUNT DOMAINS:", [x.get("ym") for x in (lst or [])], flush=True)
|
||||||
print("IMGS:", json.dumps(imgs[:8]), flush=True)
|
|
||||||
scripts = page.evaluate("""() => [...document.querySelectorAll('script')].filter(s=>!s.src && s.textContent.length>800).map(s=>s.textContent)""")
|
page.goto(SITE + "/user/iframe#/safeModify/lx=4/type=0/txt=", wait_until="domcontentloaded", timeout=60000)
|
||||||
for i,s in enumerate(scripts):
|
time.sleep(8)
|
||||||
eps = sorted(set(re.findall(r'["\']/[a-z_0-9/]{4,50}["\']', s)))
|
sec = get_secret(page)
|
||||||
eps = [e for e in eps if any(k in e for k in ('user_zh','request','mfa','aqbh','user_'))]
|
print("SECRET len:", len(sec or ""), flush=True)
|
||||||
if eps: print("script %d (%db) EPS:" % (i, len(s)), eps[:20], flush=True)
|
if not sec:
|
||||||
open(BASE+"/mfa_inline_%d.js"%i,"w",encoding="utf-8").write(s)
|
print("FATAL: no secret (page may require aqbh unlock first)"); save_cookies(ctx); browser.close(); sys.exit(5)
|
||||||
page.screenshot(path=BASE+"/mfa_page.png", full_page=True)
|
|
||||||
json.dump(ctx.cookies(), open(BASE+"/gname_cookies.json","w"))
|
bound = False
|
||||||
b.close()
|
for rnd in range(3):
|
||||||
|
r = inpost_json(page, "/user_zh/set_aqlb",
|
||||||
|
{"secret": sec, "code": totp(sec), "csrf_token": csrf(page)}, "bind%d" % rnd)
|
||||||
|
print("SET_AQLB try%d:" % rnd, str(r)[:200], flush=True)
|
||||||
|
s = str(r)
|
||||||
|
if isinstance(r, dict) and str(r.get("code")) == "1":
|
||||||
|
bound = True; break
|
||||||
|
if "remove operation protection" in s:
|
||||||
|
if not aqbh_session_unlock(page, email=os.environ.get("GM_EMAIL")):
|
||||||
|
time.sleep(20); continue
|
||||||
|
r2 = inpost_json(page, "/user_zh/set_aqlb",
|
||||||
|
{"secret": sec, "code": totp(sec), "csrf_token": csrf(page)}, "bindB%d" % rnd)
|
||||||
|
print("SET_AQLB after unlock:", str(r2)[:200], flush=True)
|
||||||
|
if isinstance(r2, dict) and str(r2.get("code")) == "1":
|
||||||
|
bound = True; break
|
||||||
|
time.sleep(2); continue
|
||||||
|
break
|
||||||
|
|
||||||
|
r = inpost(page, "/user_zh/set_czyz", {"czyz[]": ["1", "4"], "csrf_token": csrf(page)}, "cz")
|
||||||
|
print("SET_CZYZ[1,4]:", str(r)[:200], flush=True)
|
||||||
|
json.dump({"uid": str(acc.get("uid", "")), "mfa_secret": sec, "bound": bound, "ts": int(time.time())},
|
||||||
|
open(a.out, "w"))
|
||||||
|
save_cookies(ctx)
|
||||||
|
browser.close()
|
||||||
|
print("MFA_BIND DONE bound=%s czyz=%s" % (bound, str(r)[:60]), flush=True)
|
||||||
|
sys.exit(0 if bound else 3)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user