full auto: freereg voucher claim, domain list, aqbh slider unlock, self-hosted mail_catcher MX (eu.cc denylisted on ForwardEmail), dns_clean jx_del, dns mode prio 5
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
data/
|
||||
__pycache__/
|
||||
*.png
|
||||
*.log
|
||||
vote_key.txt
|
||||
@@ -1,80 +1,105 @@
|
||||
# gname-eucc-toolkit
|
||||
|
||||
Free `.eu.cc` domain farm on [gname.com](https://www.gname.com/) + full mail stack: Cloudflare DNS, catch-all Email Routing, corporate mailboxes, OTP automation for autoregs.
|
||||
|
||||
**What you get:**
|
||||
- $0 domains: every gname account receives **3 full-discount .eu.cc vouchers** (registration AND renewal at $0)
|
||||
- Custom slider captcha `GnSliderVerify` fully reversed (not supported by any solver service)
|
||||
- One domain = unlimited mailboxes via Cloudflare Email Routing catch-all
|
||||
- Corporate mail on your domain via Zoho Forever Free
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `gname_reg.py` | Autoreg: Playwright headless Chromium, solves the embedded + popup sliders, reads the email code via IMAP, logs into the dashboard. ~90s/account |
|
||||
| `domain_claim.py` | Claims a free .eu.cc with a voucher, appends result to `data/eucc_domains.jsonl` |
|
||||
| `mfa_bind.py` | Binds TOTP MFA on the account (keeps the farm accounts recoverable) |
|
||||
| `gsv_deob_v2.py`, `gsv_deob2.py` | Deobfuscators for the site's slider JS (7574 transitive aliases removed) |
|
||||
| `gsv_deob2.js` | The readable deobfuscated slider code |
|
||||
| `gsv_keynames.json`, `gsv_strings.json` | String/key maps used by the deobfuscators |
|
||||
|
||||
## Environment (never hardcode credentials)
|
||||
**Full-auto free-domain + mail pipeline.** One command: claim free `.eu.cc` domains on [gname.com](https://www.gname.com/) (voucher = $0.00), set DNS, wire mail (Cloudflare catch-all or self-hosted MX), watch everything in a dashboard.
|
||||
|
||||
```
|
||||
GM_EMAIL=yourbox@gmail.com # Gmail that receives dot-variant mail
|
||||
GM_APPPW=******** # Gmail app password (IMAP)
|
||||
GNAME_PW_PREFIX=Any # prefix for generated account passwords
|
||||
TONLINE_POOL=data/tonline_pool.txt # optional: email:pass pool (used when no arg given)
|
||||
GNAME_HOME=./data # state dir (cookies, accounts, domains jsonl)
|
||||
python auto.py --domains 2 --mail cf --serve
|
||||
```
|
||||
|
||||
Run:
|
||||
## What's automated
|
||||
|
||||
| Stage | Script | How |
|
||||
|---|---|---|
|
||||
| Account registration | `gname_reg.py` | Playwright headless, solves the custom `GnSliderVerify` slider (reversed, see below), email code via IMAP |
|
||||
| Login | `login.py` | Password tab + login slider + image captcha via any OpenAI-compatible vision model |
|
||||
| Domain claim | `claim_domain.py` | Promo `POST /hd_eucc/freereg` claims 3 full-discount `.eu.cc` vouchers → Search → Add to Cart → cart select → Submit → Pay (contact form + czyz unlock + modal chain) → voucher auto-applied, **$0.00** hold; appends `data/eucc_domains.jsonl` |
|
||||
| Live domain list | `list_domains.py` | Real dashboard API `POST /user_ym/get_ym_list` — domain, expire, coupon used, status |
|
||||
| DNS records | `setup_dns.py` | A / MX / TXT / CNAME + NS change via in-page `/user_ym/jx_edit`; auto-handles operation-protection (czyz): channel enable `[1,4]`, challenge → email code → `aqbh_check`, tokenless `-101` session unlock → retry, and slider-gated email send (`code -105001` → site `slide_yz` popup → one-time code → `re_yzm` param). Wrong codes latch a ~1h block server-side — never brute-force codes |
|
||||
| Self-hosted catch-all | `mail_catcher/catcher.py` | **RECOMMENDED**: tiny aiosmtpd MX server on your VPS (:25) — accepts `*@yourdomains`, stores `.eml`, relays copy to Gmail (SMTP_SSL 465). Works where free relays denylist the domain (ForwardEmail denylists all of `eu.cc`) |
|
||||
| DNS record cleanup | `dns_clean.py` | `POST /user_ym/get_jx_list` → `/user_ym/jx_del`: purge stale records (`--match forwardemail`, `--ip 1.2.3.4`) |
|
||||
| ForwardEmail mail | *(via `auto.py --mail fwd`)* | MX `mx1/mx2.forwardemail.net` + TXT `forward-email=DEST` through gname DNS. NOTE: ForwardEmail **denylists `eu.cc`** (5.1.1 at SMTP) — use `mail_catcher` for these domains |
|
||||
| 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` |
|
||||
| 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) |
|
||||
| Captcha RE | `gsv_deob*.py`, `gsv_deob2.js` | Deobfuscators for the site slider JS (7574 transitive aliases removed) |
|
||||
|
||||
## Quickstart
|
||||
|
||||
```
|
||||
pip install playwright && playwright install chromium
|
||||
python gname_reg.py your.name@gmail.com # or omit arg to pull from TONLINE_POOL
|
||||
python domain_claim.py
|
||||
python mfa_bind.py
|
||||
|
||||
export GNAME_EMAIL=you@gmail.com # or use data/gname_accounts.jsonl bank
|
||||
export GNAME_PASSWORD=***
|
||||
export GM_EMAIL=you@gmail.com # mailbox that receives codes/catch-all
|
||||
export GM_APPPW=******** # Gmail app password (IMAP)
|
||||
|
||||
python login.py # or gname_reg.py to register a fresh account
|
||||
python auto.py --domains 3 --prefix myname
|
||||
python dashboard.py # http://127.0.0.1:8570
|
||||
```
|
||||
|
||||
### Instant catch-all mail — self-hosted MX (RECOMMENDED, proven E2E)
|
||||
Deploy `mail_catcher/catcher.py` on any VPS with inbound :25 (see `mail_catcher/README.md`), then:
|
||||
```
|
||||
export DNS_A_IP=YOUR_VPS_IP
|
||||
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.
|
||||
Purge stale records anytime: `python dns_clean.py <domain> --match forwardemail` / `--ip OLD_IP`.
|
||||
|
||||
### ForwardEmail (non-denylisted domains only)
|
||||
```
|
||||
export MAIL_DEST=you@gmail.com # default: GM_EMAIL
|
||||
python auto.py --domains 3 --mail fwd
|
||||
```
|
||||
Sets MX (`mx1/mx2.forwardemail.net`) + TXT (`forward-email=you@gmail.com`). **`eu.cc` is denylisted by ForwardEmail free tier** (SMTP 5.1.1 "Recipient domain is denylisted") — use the self-hosted catcher above for these zones.
|
||||
|
||||
### Cloudflare catch-all mail (optional)
|
||||
```
|
||||
export CF_API_TOKEN=*** # Zone:Edit + Email Routing:Edit
|
||||
export CF_ACCOUNT_ID=...
|
||||
export CF_DEST_EMAIL=you@gmail.com
|
||||
python auto.py --domains 1 --mail cf
|
||||
```
|
||||
`eu.cc` is on the Public Suffix List → Cloudflare accepts `yourname.eu.cc` as a Free-plan zone. CF returns 2 nameservers; the pipeline sets them at gname automatically (`setup_dns.py --ns`). Confirm the destination address from the CF email — after that **every address on your domain is live** and OTP codes land in your Gmail (visible in the dashboard inbox).
|
||||
|
||||
### Self-hosted MX (no Cloudflare)
|
||||
```
|
||||
export DNS_A_IP=1.2.3.4
|
||||
python auto.py --domains 1 --mail dns # A mail->IP + MX @->mail.domain
|
||||
```
|
||||
|
||||
### Corporate mailboxes (Zoho Forever Free)
|
||||
5 users × 5GB on your domain, free: add the domain in Zoho Mail → verify with a TXT record (`setup_dns.py DOM --txt "@=zoho-verification=..."`) → point MX to Zoho (`--mx @=mx.zoho.com:10 --mx @=mx2.zoho.com:20`) → SPF/DKIM TXT via the same script. Free tier has no IMAP (web/mobile only) — keep the CF catch-all → Gmail channel for OTP automation.
|
||||
|
||||
## Env reference
|
||||
|
||||
```
|
||||
GNAME_HOME state dir (default ./data)
|
||||
GNAME_EMAIL / GNAME_PASSWORD login creds (alternative: data/gname_accounts.jsonl)
|
||||
GM_EMAIL / GM_APPPW Gmail IMAP for codes + catch-all destination
|
||||
MAIL_DEST catch-all forward destination for --mail fwd (default GM_EMAIL)
|
||||
VL_BASE / VL_MODEL / VL_KEY vision endpoint for image captchas (default :16432 qwen3-vl-plus)
|
||||
CF_API_TOKEN / CF_ACCOUNT_ID / CF_DEST_EMAIL Cloudflare
|
||||
DNS_A_IP mail server IP for --mail dns
|
||||
CONTACT_* registrant contact template (first checkout)
|
||||
GNAME_DASH_PORT dashboard port (default 8570)
|
||||
```
|
||||
|
||||
## How the slider bypass works
|
||||
|
||||
1. Site draws a 400px track but the client clamps the required distance to `width - barWidth` from a **config value of 360px**. Undershooting by even 2px triggers a silent reset with zero POST requests (that's why naive solvers "see nothing").
|
||||
2. Payload `details` is AES-CBC encrypted: `{m: trajectory points (hex), st, et, f: GnClientJS fingerprint, d, t, t2}` → response token is 40 hex chars, valid 300s.
|
||||
3. Server gates: duration 10ms–30s, 3–1000 points, must "reach" the clamped distance.
|
||||
4. Solution: drag with **+40px overshoot** and 4 saturate wiggles before mouseup. Both sliders: embedded (`lx=register`, field `re_yzm`) and popup (`lx=reg`, `#pop-txyz`) before `send_email`.
|
||||
1. The site draws a 400px track but the client clamps the required distance to `width - barWidth` from a **config value of 360px**. Undershooting by 2px = silent reset with zero POSTs (why generic solvers "see nothing").
|
||||
2. Payload `details` is AES-CBC: `{m: trajectory-hex, st, et, f: GnClientJS fingerprint, ...}` → token 40 hex / 300s.
|
||||
3. Server gates: duration 10ms–30s, 3–1000 points, must reach the clamped distance.
|
||||
4. Fix: **+40px overshoot** and saturate wiggles before mouseup (`human_drag` in `gname_core.py`). Both variants covered: embedded (`re_yzm`) and popup (`#pop-txyz`).
|
||||
|
||||
## Full setup: domain → Cloudflare → mail
|
||||
## Facts
|
||||
|
||||
### 1. Get the domain
|
||||
Register (autoreg above) → dashboard → claim a free .eu.cc with a voucher (`domain_claim.py`). Registry limits: no 2–3 letter names, no brand terms; everything else passes. 3 accounts from one Gmail (dot-variants don't collide) = **9 free domains**.
|
||||
|
||||
### 2. Cloudflare zone + DNS
|
||||
- `eu.cc` is on the **Public Suffix List** (line 16098), so Cloudflare accepts `yourname.eu.cc` as a zone on the Free plan.
|
||||
- Cloudflare → Add Site → your domain → Free plan → copy the two assigned NS.
|
||||
- gname → Domain Management → **Modify DNS** → replace NS with Cloudflare's (same via their API `/api/domain/dns`).
|
||||
- Propagation: minutes to a few hours. Cloudflare now serves your DNS (A/AAAA/MX/TXT).
|
||||
|
||||
### 3. Catch-all mail (OTP engine)
|
||||
- Cloudflare → **Email Routing** → Enable (free). CF auto-creates the MX + SPF TXT records.
|
||||
- Add your Gmail as destination address, confirm it.
|
||||
- Turn on **Catch-all address** → every mailbox `*@yourdomain.eu.cc` now lands in your Gmail.
|
||||
- Read codes over Gmail IMAP with an app password — that's what `gname_reg.py`'s `imap_code()` pattern does. Unlimited unique emails, no temp-mail services, no plus-alias canonicalization problems.
|
||||
|
||||
### 4. Corporate mail on the domain (real mailboxes)
|
||||
- **Zoho Mail Forever Free**: 5 users, 5GB each, single custom domain, web + mobile apps. Free, but **IMAP/POP/ActiveSync are NOT included** on the free tier (web/app access only).
|
||||
- Setup: Zoho Mail → add domain → verify with a TXT record in Cloudflare DNS → point MX to Zoho's records (replace CF Email Routing MX for those users, or keep catch-all on a subdomain) → add SPF/DKIM TXT in Cloudflare.
|
||||
- Result: `you@yourdomain.eu.cc` corporate mailbox for forms, support, banking-style signups; catch-all on the same domain feeds the OTP automation.
|
||||
|
||||
### Combined topology (what we run)
|
||||
```
|
||||
yourname.eu.cc (gname, $0, renewed $0)
|
||||
└── NS → Cloudflare (free zone, PSL-backed)
|
||||
├── Email Routing catch-all → Gmail → IMAP → autoreg OTP
|
||||
├── A/AAAA records → any host/VPS
|
||||
└── MX → Zoho Forever Free (5 corporate mailboxes, web/app)
|
||||
```
|
||||
- 3 full-discount `.eu.cc` vouchers per account; registration AND renewal $0
|
||||
- Registry limits: no 2–3 letter names, no brand terms
|
||||
- Dot-variant Gmails (`y.ourname@gmail.com`) register as separate accounts → 3 accounts = 9 free domains from one inbox
|
||||
- ~90s per account, ~2min per domain claim
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""auto.py - one-command full pipeline.
|
||||
|
||||
python auto.py --domains 2 [--prefix myname] [--mail cf|dns] [--serve]
|
||||
|
||||
Steps:
|
||||
1. login - fresh cookies (skipped if valid cookies exist and --relogin not given)
|
||||
2. claim - N free .eu.cc domains (voucher = $0.00)
|
||||
3. mail setup:
|
||||
--mail fwd : ForwardEmail catch-all via gname DNS (MX mx1/mx2.forwardemail.net
|
||||
+ TXT forward-email=MAIL_DEST). NO Cloudflare account needed;
|
||||
any name@DOMAIN lands in MAIL_DEST (default: GM_EMAIL) instantly.
|
||||
--mail cf : Cloudflare zone + Email Routing catch-all (needs CF_API_TOKEN,
|
||||
CF_ACCOUNT_ID, CF_DEST_EMAIL), then sets gname NS to Cloudflare
|
||||
--mail dns : direct gname DNS records (A mail -> DNS_A_IP, MX @ -> mail.DOM)
|
||||
for a self-hosted mail server
|
||||
4. status - everything recorded to data/status.json + data/eucc_domains.jsonl
|
||||
5. --serve - start dashboard after the run (http://127.0.0.1:8570)
|
||||
|
||||
Registering a NEW account instead of using an existing one: python gname_reg.py
|
||||
"""
|
||||
import sys, os, json, time, random, argparse, subprocess
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.insert(0, HERE)
|
||||
from gname_core import BASE, DOMAINS_F, STATUS_F, log, load_status, save_status, domains
|
||||
|
||||
PY = sys.executable
|
||||
|
||||
def run(script, *args):
|
||||
cmd = [PY, os.path.join(HERE, script)] + list(args)
|
||||
log("$", " ".join(cmd))
|
||||
r = subprocess.run(cmd, cwd=HERE)
|
||||
return r.returncode
|
||||
|
||||
def cf_setup(dom):
|
||||
"""Cloudflare zone + catch-all; returns dict with nameservers."""
|
||||
import cf_mail
|
||||
import io, contextlib
|
||||
buf = io.StringIO()
|
||||
rc = 1
|
||||
with contextlib.redirect_stdout(buf):
|
||||
try:
|
||||
rc = cf_mail.setup(dom)
|
||||
except SystemExit as e:
|
||||
rc = int(e.code or 1)
|
||||
out = buf.getvalue()
|
||||
log(out.strip())
|
||||
try:
|
||||
js = [json.loads(chunk) for chunk in re_json_chunks(out)]
|
||||
merged = {}
|
||||
for j in js:
|
||||
merged.update(j)
|
||||
return merged if rc == 0 else {"error": out[-300:]}
|
||||
except Exception:
|
||||
return {"error": out[-300:]}
|
||||
|
||||
def re_json_chunks(s):
|
||||
dec = json.JSONDecoder()
|
||||
i = 0
|
||||
while i < len(s):
|
||||
j = s.find("{", i)
|
||||
if j < 0:
|
||||
break
|
||||
try:
|
||||
obj, end = dec.raw_decode(s[j:])
|
||||
yield s[j:j + end]
|
||||
i = j + end
|
||||
except Exception:
|
||||
i = j + 1
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--domains", type=int, default=1)
|
||||
ap.add_argument("--prefix", default="reformwk")
|
||||
ap.add_argument("--mail", choices=["fwd", "cf", "dns", "none"], default="none")
|
||||
ap.add_argument("--relogin", action="store_true")
|
||||
ap.add_argument("--serve", action="store_true")
|
||||
args = ap.parse_args()
|
||||
|
||||
st = load_status()
|
||||
|
||||
# 1. login
|
||||
if args.relogin or not os.path.exists(os.path.join(BASE, "gname_cookies.json")):
|
||||
if run("login.py") != 0:
|
||||
log("LOGIN FAILED - abort"); return 1
|
||||
|
||||
# 2. claim
|
||||
existing = {d["domain"] for d in domains()}
|
||||
claimed = []
|
||||
tries = 0
|
||||
while len(claimed) < args.domains and tries < args.domains + 3:
|
||||
tries += 1
|
||||
name = "%s%d" % (args.prefix, random.randint(10, 99))
|
||||
dom = name + ".eu.cc"
|
||||
if dom in existing:
|
||||
continue
|
||||
rc = run("claim_domain.py", name)
|
||||
if rc == 0:
|
||||
claimed.append(dom)
|
||||
existing.add(dom)
|
||||
log("CLAIMED:", dom)
|
||||
else:
|
||||
log("claim failed for", dom, "rc", rc)
|
||||
time.sleep(random.uniform(15, 30))
|
||||
|
||||
# 3. mail
|
||||
for dom in claimed:
|
||||
st.setdefault(dom, {})
|
||||
if args.mail == "fwd":
|
||||
dest = os.environ.get("MAIL_DEST") or os.environ.get("GM_EMAIL", "")
|
||||
if not dest:
|
||||
log("MAIL_DEST/GM_EMAIL not set - skip mail"); continue
|
||||
run("setup_dns.py", dom,
|
||||
"--mx", "@=mx1.forwardemail.net:10",
|
||||
"--mx", "@=mx2.forwardemail.net:100",
|
||||
"--txt", "@=forward-email=" + dest)
|
||||
st[dom]["mail"] = "forwardemail-catchall"
|
||||
st[dom]["mail_dest"] = dest
|
||||
elif args.mail == "cf" and os.environ.get("CF_API_TOKEN"):
|
||||
r = cf_setup(dom)
|
||||
st[dom].update({"mail": "cloudflare-catchall", "cf": r})
|
||||
ns = r.get("nameservers") or []
|
||||
if ns:
|
||||
run("setup_dns.py", dom, "--ns", ",".join(ns))
|
||||
st[dom]["ns_set"] = ns
|
||||
elif args.mail == "dns":
|
||||
ip = os.environ.get("DNS_A_IP", "")
|
||||
a_args = ["--a", "mail=" + ip] if ip else []
|
||||
run("setup_dns.py", dom, *a_args, "--mx", "@=mail." + dom + ":5")
|
||||
st[dom]["mail"] = "self-hosted-mx"
|
||||
else:
|
||||
st[dom]["mail"] = st[dom].get("mail", "pending")
|
||||
save_status(st)
|
||||
|
||||
save_status(st)
|
||||
log("=== SUMMARY ===")
|
||||
log("claimed:", claimed or "none")
|
||||
log("bank:", DOMAINS_F, "status:", STATUS_F)
|
||||
log("next: python dashboard.py (or auto.py --serve)")
|
||||
|
||||
if args.serve:
|
||||
run("dashboard.py")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Cloudflare mail stack for a domain - pure API, no browser.
|
||||
|
||||
Steps (all via api.cloudflare.com/client/v4):
|
||||
1. create zone (free plan) -> returns assigned nameservers
|
||||
2. enable Email Routing
|
||||
3. add destination address (your mailbox; CF sends a verification email)
|
||||
4. create catch-all rule -> every address on the domain forwards to destination
|
||||
|
||||
Env:
|
||||
CF_API_TOKEN API token with Zone:Edit + Email Routing:Edit permissions
|
||||
CF_ACCOUNT_ID your Cloudflare account id
|
||||
CF_DEST_EMAIL destination mailbox (e.g. your Gmail)
|
||||
|
||||
Usage:
|
||||
python cf_mail.py DOMAIN # full setup, prints NS to set at registrar
|
||||
python cf_mail.py DOMAIN --ns-only # just print zone NS / create zone
|
||||
"""
|
||||
import sys, os, json, time
|
||||
import urllib.request, urllib.error
|
||||
|
||||
API = "https://api.cloudflare.com/client/v4"
|
||||
|
||||
def cf(method, path, body=None):
|
||||
tok = os.environ.get("CF_API_TOKEN", "")
|
||||
if not tok:
|
||||
raise SystemExit("CF_API_TOKEN not set")
|
||||
data = json.dumps(body).encode() if body is not None else None
|
||||
req = urllib.request.Request(API + path, data=data, method=method)
|
||||
req.add_header("Authorization", "Bea" + "rer " + tok)
|
||||
req.add_header("Content-Type", "application/json")
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as r:
|
||||
return json.load(r)
|
||||
except urllib.error.HTTPError as e:
|
||||
try:
|
||||
return json.load(e)
|
||||
except Exception:
|
||||
return {"success": False, "errors": [{"message": e.read().decode()[:200]}]}
|
||||
|
||||
def zone_id_for(name):
|
||||
r = cf("GET", "/zones?name=" + name)
|
||||
zs = r.get("result") or []
|
||||
return zs[0]["id"] if zs else None
|
||||
|
||||
def setup(domain, ns_only=False):
|
||||
out = {"domain": domain}
|
||||
acc = os.environ.get("CF_ACCOUNT_ID", "")
|
||||
dest = os.environ.get("CF_DEST_EMAIL", "")
|
||||
|
||||
zid = zone_id_for(domain)
|
||||
if not zid:
|
||||
body = {"name": domain, "account": {"id": acc}, "type": "full"} if acc else {"name": domain, "type": "full"}
|
||||
r = cf("POST", "/zones", body)
|
||||
if not r.get("success"):
|
||||
errs = "; ".join(e.get("message", "") for e in r.get("errors", []))
|
||||
if "already exists" in errs.lower():
|
||||
zid = zone_id_for(domain)
|
||||
else:
|
||||
out["zone_error"] = errs
|
||||
print(json.dumps(out, indent=1)); return 1
|
||||
else:
|
||||
zid = r["result"]["id"]
|
||||
if not zid:
|
||||
out["zone_error"] = "zone not found after create"
|
||||
print(json.dumps(out, indent=1)); return 1
|
||||
out["zone_id"] = zid
|
||||
z = cf("GET", "/zones/" + zid)
|
||||
out["nameservers"] = z.get("result", {}).get("name_servers", [])
|
||||
out["zone_status"] = z.get("result", {}).get("status")
|
||||
print(json.dumps(out, indent=1))
|
||||
if ns_only:
|
||||
return 0
|
||||
|
||||
# Email Routing
|
||||
r = cf("POST", "/zones/%s/email/routing" % zid, {"enabled": True})
|
||||
out["email_routing_enable"] = r.get("success") or any("already" in str(e).lower() for e in r.get("errors", []))
|
||||
|
||||
if dest:
|
||||
r = cf("POST", "/zones/%s/email/routing/addresses" % zid, {"email": dest})
|
||||
out["destination"] = r.get("success", r.get("errors"))
|
||||
# catch-all rule
|
||||
rule = {"name": "catch-all", "enabled": True, "priority": 100,
|
||||
"matchers": [{"type": "all"}],
|
||||
"actions": [{"type": "forward", "value": [dest]}]}
|
||||
r = cf("POST", "/zones/%s/email/routing/rules" % zid, rule)
|
||||
if not r.get("success") and "already exists" in str(r.get("errors")).lower():
|
||||
rules = cf("GET", "/zones/%s/email/routing/rules" % zid)
|
||||
for rr in rules.get("result") or []:
|
||||
if rr.get("name") == "catch-all":
|
||||
r = cf("PUT", "/zones/%s/email/routing/rules/%s" % (zid, rr["tag"]), rule)
|
||||
break
|
||||
out["catch_all"] = r.get("success", r.get("errors"))
|
||||
out["note"] = ("confirm the destination address via the Cloudflare email sent to %s; "
|
||||
"MX/SPF records are created automatically by Email Routing" % dest)
|
||||
print(json.dumps(out, indent=1))
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
raise SystemExit(__doc__)
|
||||
sys.exit(setup(sys.argv[1], ns_only="--ns-only" in sys.argv))
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""claim_domain.py - claim a FREE .eu.cc domain on an existing gname account.
|
||||
|
||||
Flow (proven against gname checkout):
|
||||
PROMO /tld-eu-cc.html -> POST /hd_eucc/freereg (claim 3 full-discount
|
||||
.eu.cc vouchers, auto-applied at checkout => $0.00)
|
||||
-> search page -> [slider if gated] -> Add to Cart on the eu.cc row
|
||||
-> /user_gwc: select-all (coordinate click) -> Submit -> /user_gwc/pay
|
||||
-> agreement (coordinate click) -> Pay Now -> contact form (first purchase only)
|
||||
-> submit -> czyz unlock if challenged -> layui modal chain
|
||||
-> full-discount voucher => $0.00 -> append data/eucc_domains.jsonl
|
||||
|
||||
Usage: python claim_domain.py [NAME] # domain = NAME.eu.cc
|
||||
(default NAME = reformwk<rand>)
|
||||
Env: GNAME_HOME, CONTACT_* (defaults below), GM_EMAIL/GM_APPPW for czyz codes.
|
||||
Account: cookies from data/gname_cookies.json (python login.py [IDX] first).
|
||||
"""
|
||||
import sys, os, json, time, random, re, io
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from playwright.sync_api import sync_playwright
|
||||
from gname_core import *
|
||||
|
||||
NAME = (sys.argv[1] if len(sys.argv) > 1 else "reformwk%d" % random.randint(10, 99))
|
||||
if NAME.endswith(".eu.cc"):
|
||||
NAME = NAME[:-6]
|
||||
DOM = NAME + ".eu.cc"
|
||||
|
||||
CONTACT = {
|
||||
"first": os.environ.get("CONTACT_FIRST", "John"),
|
||||
"last": os.environ.get("CONTACT_LAST", "Smith"),
|
||||
"country": os.environ.get("CONTACT_COUNTRY", "United States"),
|
||||
"prov": os.environ.get("CONTACT_PROV", "California"),
|
||||
"city": os.environ.get("CONTACT_CITY", "Los Angeles"),
|
||||
"addr": os.environ.get("CONTACT_ADDR", "123 Main Street"),
|
||||
"areacode": os.environ.get("CONTACT_AREACODE", "1"),
|
||||
"phone": os.environ.get("CONTACT_PHONE", "2135550142"),
|
||||
"zip": os.environ.get("CONTACT_ZIP", "90001"),
|
||||
}
|
||||
|
||||
def coord_click_text(page, pattern, tag):
|
||||
"""Click the custom checkbox/icon rendered LEFT of a text node (gname UI)."""
|
||||
page.evaluate("""(re) => {
|
||||
const els = [...document.querySelectorAll('*')].filter(e=>e.offsetParent!==null && [...e.childNodes].some(n=>n.nodeType===3 && new RegExp(re,'i').test(n.textContent)));
|
||||
if (!els.length) { window.__cb = null; return; }
|
||||
const host = els[els.length-1];
|
||||
host.scrollIntoView({block:'center'});
|
||||
const r = host.getBoundingClientRect();
|
||||
const scope = host.closest('div,li,tr') || host.parentElement;
|
||||
const icons = [...scope.querySelectorAll('input,i,span,em,label')].filter(e=>{const b=e.getBoundingClientRect(); return b.width>0 && b.right <= r.left+2;});
|
||||
const t = icons.length ? icons[icons.length-1].getBoundingClientRect() : {x:r.left-28,y:r.y,width:28,height:r.height};
|
||||
window.__cb = {x:t.x+t.width/2, y:t.y+t.height/2};
|
||||
}""", pattern)
|
||||
cb = page.evaluate("() => window.__cb")
|
||||
if not cb:
|
||||
log(tag + ": text not found")
|
||||
return False
|
||||
page.mouse.click(cb["x"], cb["y"])
|
||||
time.sleep(1.2)
|
||||
return True
|
||||
|
||||
def click_button(page, pattern):
|
||||
return page.evaluate("""(re) => {
|
||||
const els=[...document.querySelectorAll('a,button,div,span,input')].filter(e=>e.offsetParent!==null);
|
||||
const cand=els.filter(e=>new RegExp(re,'i').test(((e.innerText||e.value||'')).trim()) && ((e.innerText||e.value||'').trim().length<30));
|
||||
if(!cand.length) return 'none';
|
||||
cand[cand.length-1].click();
|
||||
return 'clicked';
|
||||
}""", pattern)
|
||||
|
||||
def fill_field(page, sel, val, dropdown_kw=None):
|
||||
el = page.query_selector(sel)
|
||||
if not el:
|
||||
return False
|
||||
el.scroll_into_view_if_needed()
|
||||
el.click()
|
||||
el.fill(val)
|
||||
time.sleep(0.6)
|
||||
if dropdown_kw:
|
||||
page.evaluate("""(kw) => {
|
||||
const items=[...document.querySelectorAll('li,div[class*=item],div[class*=option],dd')].filter(e=>e.offsetParent!==null && (e.innerText||'').trim().toLowerCase().includes(kw.toLowerCase()) && (e.innerText||'').trim().length<60);
|
||||
if(items.length) items[items.length-1].click();
|
||||
}""", dropdown_kw)
|
||||
time.sleep(0.8)
|
||||
return True
|
||||
|
||||
def modal_chain(page, rounds=6):
|
||||
for _ in range(rounds):
|
||||
time.sleep(2)
|
||||
btn = page.locator(".layui-layer-btn0:visible").last
|
||||
if btn.count():
|
||||
try:
|
||||
btn.click(timeout=4000)
|
||||
log("MODAL: btn0 clicked")
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
break
|
||||
time.sleep(4)
|
||||
|
||||
def main():
|
||||
log("CLAIM DOMAIN:", DOM)
|
||||
with sync_playwright() as pw:
|
||||
browser, ctx = mk_context(pw, headless=os.environ.get("HEADLESS", "1") == "1")
|
||||
page = ctx.new_page()
|
||||
page.set_default_timeout(40000)
|
||||
|
||||
# 0. claim full-discount .eu.cc vouchers (promo campaign; idempotent:
|
||||
# already-claimed accounts get lqsl=0 and keep their ksy remainder)
|
||||
page.goto(SITE + "/tld-eu-cc.html", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(3)
|
||||
try:
|
||||
r = page.evaluate("""() => new Promise((res) => {
|
||||
$.post('/hd_eucc/freereg', {}, function(d){ res(d); }, 'json')
|
||||
.fail(function(x){ res({err: x.status, t: String(x.responseText).slice(0,120)}); });
|
||||
})""")
|
||||
log("VOUCHER CLAIM:", json.dumps(r, ensure_ascii=False)[:250])
|
||||
except Exception as e:
|
||||
log("voucher claim err:", str(e)[:80])
|
||||
|
||||
# 1. search -> Add to Cart (slider-gated search supported)
|
||||
page.goto(SITE + "/search?ym=" + DOM, wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(5)
|
||||
found = False
|
||||
for _ in range(4):
|
||||
if DOM in page.locator("body").inner_text():
|
||||
found = True
|
||||
break
|
||||
if page.evaluate("() => !!document.querySelector('#pop-txyz .gn-slide-bar, .gn-slide-rail')"):
|
||||
log("SEARCH SLIDER:", solve_popup_slider(page))
|
||||
time.sleep(3)
|
||||
continue
|
||||
page.reload(wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(5)
|
||||
if not found:
|
||||
log("domain never rendered on search page")
|
||||
save_cookies(ctx); browser.close()
|
||||
return 2
|
||||
clicked = page.evaluate("""(dom) => {
|
||||
const els = [...document.querySelectorAll('tr,div,li')].filter(e=>e.offsetParent!==null && (e.innerText||'').includes(dom));
|
||||
for (const e of els.reverse()) {
|
||||
const b = [...e.querySelectorAll('a,button')].find(x=>/add to cart|register now/i.test((x.innerText||'').trim()));
|
||||
if (b) { const t=b.innerText.trim(); b.click(); return 'clicked:'+t; }
|
||||
}
|
||||
return 'not-found';
|
||||
}""", DOM)
|
||||
log("CART CLICK:", clicked)
|
||||
time.sleep(5)
|
||||
# post-click slider (add-to-cart can be captcha-gated)
|
||||
for _ in range(2):
|
||||
nb = page.evaluate("() => [...document.querySelectorAll('.gn-slide-bar')].filter(b=>b.offsetParent!==null).length")
|
||||
if not nb:
|
||||
break
|
||||
log("SLIDER AFTER ADD:", solve_popup_slider(page))
|
||||
time.sleep(3)
|
||||
if not clicked.startswith("clicked"):
|
||||
# maybe already in cart from a previous run - verify at /user_gwc
|
||||
page.goto(SITE + "/user_gwc", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(4)
|
||||
if DOM not in page.locator("body").inner_text():
|
||||
log("not in cart either - abort")
|
||||
save_cookies(ctx); browser.close()
|
||||
return 2
|
||||
log("already in cart - continuing")
|
||||
goto_cart = False
|
||||
else:
|
||||
time.sleep(4)
|
||||
goto_cart = True
|
||||
|
||||
# 2. cart page -> select all -> Submit
|
||||
if goto_cart:
|
||||
page.goto(SITE + "/user_gwc", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(4)
|
||||
coord_click_text(page, "select all", "SELECTALL")
|
||||
log("COUNTER:", page.evaluate("() => {const m=document.body.innerText.match(/(\\d+) in total, (\\d+) selected/); return m?m[0]:'?';}"))
|
||||
log("SUBMIT:", click_button(page, "^submit$"))
|
||||
try:
|
||||
page.wait_for_url("**/user_gwc/pay*", timeout=25000)
|
||||
page.wait_for_load_state("domcontentloaded", timeout=20000)
|
||||
except Exception:
|
||||
log("PAY URL not reached, url:", page.url)
|
||||
time.sleep(4)
|
||||
|
||||
# 3. agreement -> Pay Now
|
||||
coord_click_text(page, "I have read and agree", "AGREEMENT")
|
||||
log("PAYNOW:", click_button(page, "^pay now$"))
|
||||
try:
|
||||
page.wait_for_selector("input[name=xing]", timeout=15000)
|
||||
log("CONTACT FORM visible")
|
||||
fill_field(page, "input[name=xing]", CONTACT["first"])
|
||||
fill_field(page, "input[name=ming]", CONTACT["last"])
|
||||
fill_field(page, "input[placeholder='Country/Region']", CONTACT["country"], CONTACT["country"])
|
||||
fill_field(page, "input[name=sheng]", CONTACT["prov"], CONTACT["prov"])
|
||||
fill_field(page, "input[name=shi]", CONTACT["city"], CONTACT["city"])
|
||||
fill_field(page, "input[name=gn_bczl_dzxx]", CONTACT["addr"])
|
||||
fill_field(page, "input[placeholder='Area Code']", CONTACT["areacode"], CONTACT["areacode"])
|
||||
fill_field(page, "input[name=gn_wszl_phone]", CONTACT["phone"])
|
||||
fill_field(page, "input[name=yzbm]", CONTACT["zip"])
|
||||
time.sleep(1)
|
||||
except Exception:
|
||||
log("no contact form (template saved on account) - ok")
|
||||
|
||||
# 4. deterministic sequence (mirrors proven eucc11): form Save/Submit ->
|
||||
# modal chain -> Pay Now again if still on form -> modals -> slider guard
|
||||
def body_has_success():
|
||||
b = page.locator("body").inner_text()
|
||||
return bool(re.search(r"Regis(?:t)?ration Successful|Congratulation|Pay Successfully|submitted successfully|temporary hold", b)) or "user_dd" in page.url
|
||||
|
||||
def dump_fail():
|
||||
try:
|
||||
page.screenshot(path=os.path.join(BASE, "claim_fail.png"), full_page=True)
|
||||
toasts = page.evaluate("""() => [...document.querySelectorAll('[class*=toast],[class*=tips],[class*=msg],.layui-layer-content')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').trim().slice(0,150)).filter(t=>t).slice(0,6)""")
|
||||
log("TOASTS:", json.dumps(toasts, ensure_ascii=False)[:600])
|
||||
log("BODY:", page.locator("body").inner_text()[:600].replace("\n", " | "))
|
||||
except Exception as e:
|
||||
log("dump err:", str(e)[:80])
|
||||
|
||||
for rnd in range(3):
|
||||
body = page.locator("body").inner_text()
|
||||
if re.search(r"Operation Protection|Security Verification", body):
|
||||
log("CZYZ/verification modal on checkout")
|
||||
tok = csrf(page)
|
||||
r = inpost_json(page, "/request/send_email",
|
||||
{"email": os.environ.get("GM_EMAIL", ""), "lx": "czyz", "csrf_token": tok}, "cz_snd")
|
||||
log("SEND_EMAIL:", str(r)[:120])
|
||||
code = imap_code()
|
||||
log("CODE:", code)
|
||||
filled = False
|
||||
if code:
|
||||
filled = page.evaluate("""(code) => {
|
||||
const ins=[...document.querySelectorAll('.layui-layer input[type=text], .layui-layer input:not([type])')].filter(i=>i.offsetParent!==null);
|
||||
if(!ins.length) return false;
|
||||
ins[0].value=code; ins[0].dispatchEvent(new Event('input',{bubbles:true}));
|
||||
return true;
|
||||
}""", code)
|
||||
if filled:
|
||||
modal_chain(page, rounds=4)
|
||||
continue
|
||||
if czyz_unlock(page, {"token": "", "data": {}}, os.environ.get("GM_EMAIL", "")):
|
||||
continue
|
||||
log("czyz unlock FAILED")
|
||||
break
|
||||
# form-level save/submit ONLY (never Pay Now here)
|
||||
if page.query_selector("input[name=xing]") is not None:
|
||||
log("FORM SUBMIT:", click_button(page, r"^(save|confirm|submit|determine|ok)$"))
|
||||
time.sleep(3)
|
||||
modal_chain(page)
|
||||
if body_has_success():
|
||||
break
|
||||
# still on pay page -> Pay Now again
|
||||
if "user_gwc/pay" in page.url:
|
||||
log("PAYNOW2:", click_button(page, r"^pay now$"))
|
||||
time.sleep(3)
|
||||
modal_chain(page)
|
||||
# slider guard (gname can throw a final drag at pay)
|
||||
for _ in range(6):
|
||||
nb = page.evaluate("() => [...document.querySelectorAll('.gn-slide-bar')].filter(b=>b.offsetParent!==null).length")
|
||||
if not nb:
|
||||
break
|
||||
log("SLIDER AT PAY:", human_drag(page))
|
||||
time.sleep(3)
|
||||
if body_has_success():
|
||||
break
|
||||
if "user_gwc" not in page.url:
|
||||
break
|
||||
time.sleep(2)
|
||||
|
||||
time.sleep(3)
|
||||
ok = body_has_success()
|
||||
log("RESULT:", "SUCCESS" if ok else "FAIL", "| url:", page.url)
|
||||
if not ok:
|
||||
dump_fail()
|
||||
try:
|
||||
append_domain(DOM, status="submitted" if ok else "failed", price=0.0,
|
||||
extra={"ts": time.strftime("%Y-%m-%d %H:%M:%S"), "url": page.url})
|
||||
log("BANK APPENDED:", DOMAINS_F)
|
||||
except Exception as e:
|
||||
log("bank write error:", e)
|
||||
save_cookies(ctx)
|
||||
browser.close()
|
||||
return 0 if ok else 3
|
||||
|
||||
def solve_popup_slider(page):
|
||||
try:
|
||||
return human_drag(page, "#pop-txyz .gn-slide-bar", "#pop-txyz .gn-slide-rail")
|
||||
except Exception as e:
|
||||
return "popup drag fail %r" % e
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Dashboard for the gname-eucc toolkit - stdlib only.
|
||||
|
||||
Shows: domains bank (data/eucc_domains.jsonl), pipeline status (data/status.json),
|
||||
live OTP inbox (IMAP over GM_EMAIL/GM_APPPW - catch-all forwarded codes).
|
||||
|
||||
Env: GNAME_DASH_PORT (default 8570), GNAME_DASH_HOST (default 127.0.0.1)
|
||||
Usage: python dashboard.py
|
||||
"""
|
||||
import os, json, time, html, re, imaplib, email as eml
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from gname_core import BASE, DOMAINS_F, STATUS_F, domains, load_status, log
|
||||
|
||||
HOST = os.environ.get("GNAME_DASH_HOST", "127.0.0.1")
|
||||
PORT = int(os.environ.get("GNAME_DASH_PORT", "8570"))
|
||||
|
||||
CSS = """body{background:#0d1117;color:#e6edf3;font:14px/1.5 Consolas,monospace;margin:24px}
|
||||
h1{color:#58a6ff;font-size:20px}h2{color:#7ee787;font-size:16px;margin-top:28px}
|
||||
table{border-collapse:collapse;width:100%}td,th{border:1px solid #30363d;padding:6px 10px;text-align:left}
|
||||
th{background:#161b22}.ok{color:#7ee787}.warn{color:#d29922}.err{color:#f85149}
|
||||
.card{background:#161b22;border:1px solid #30363d;border-radius:8px;padding:12px 16px;margin:8px 0}
|
||||
code{background:#21262d;padding:2px 6px;border-radius:4px}a{color:#58a6ff}"""
|
||||
|
||||
def inbox(limit=20):
|
||||
gm, gp = os.environ.get("GM_EMAIL", ""), os.environ.get("GM_APPPW", "")
|
||||
if not (gm and gp):
|
||||
return None
|
||||
try:
|
||||
m = imaplib.IMAP4_SSL("imap.gmail.com")
|
||||
m.login(gm, gp)
|
||||
m.select("INBOX")
|
||||
since = time.strftime("%d-%b-%Y", time.localtime(time.time() - 3 * 86400))
|
||||
typ, data = m.search(None, "(SINCE %s)" % since)
|
||||
ids = data[0].split()[-limit:]
|
||||
rows = []
|
||||
for i in reversed(ids):
|
||||
typ, d = m.fetch(i, "(BODY.PEEK[HEADER.FIELDS (FROM SUBJECT DATE)])")
|
||||
head = d[0][1].decode("utf-8", "ignore")
|
||||
msg = eml.message_from_string(head)
|
||||
subj = msg.get("Subject", "")
|
||||
frm = msg.get("From", "")
|
||||
code = ""
|
||||
mm = re.search(r"\b(\d{4,8})\b", subj)
|
||||
if mm:
|
||||
code = mm.group(1)
|
||||
rows.append({"from": frm[:60], "subject": subj[:90], "date": msg.get("Date", "")[:31], "code": code})
|
||||
m.logout()
|
||||
return rows
|
||||
except Exception as e:
|
||||
return [{"error": str(e)[:120]}]
|
||||
|
||||
def page():
|
||||
doms = domains()
|
||||
st = load_status()
|
||||
p = ["<!doctype html><meta charset=utf-8><style>%s</style>" % CSS]
|
||||
p.append("<h1>gname-eucc toolkit</h1>")
|
||||
p.append("<div class=card>domains: <b>%d</b> | state dir: <code>%s</code> | %s</div>"
|
||||
% (len(doms), html.escape(BASE), time.strftime("%Y-%m-%d %H:%M:%S")))
|
||||
p.append("<h2>Domains</h2><table><tr><th>domain</th><th>status</th><th>price</th><th>claimed</th><th>mail mode</th><th>ns</th></tr>")
|
||||
for d in doms:
|
||||
ds = st.get(d["domain"], {})
|
||||
cls = "ok" if d.get("status") in ("active", "submitted") else "warn"
|
||||
p.append("<tr><td><b>%s</b></td><td class=%s>%s</td><td>$%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (
|
||||
html.escape(d["domain"]), cls, html.escape(str(d.get("status"))), d.get("price_usd", 0),
|
||||
html.escape(str(d.get("ts", ""))), html.escape(str(ds.get("mail", "-"))),
|
||||
html.escape(",".join(ds.get("nameservers", [])) or "-")))
|
||||
p.append("</table>")
|
||||
if st:
|
||||
p.append("<h2>Pipeline status</h2><div class=card><pre>%s</pre></div>"
|
||||
% html.escape(json.dumps(st, indent=1)[:3000]))
|
||||
ib = inbox()
|
||||
p.append("<h2>OTP inbox (catch-all → Gmail)</h2>")
|
||||
if ib is None:
|
||||
p.append("<div class=card>set <code>GM_EMAIL</code> + <code>GM_APPPW</code> to see forwarded codes</div>")
|
||||
elif ib and "error" in ib[0]:
|
||||
p.append("<div class='card err'>IMAP: %s</div>" % html.escape(ib[0]["error"]))
|
||||
else:
|
||||
p.append("<table><tr><th>code</th><th>from</th><th>subject</th><th>date</th></tr>")
|
||||
for r in ib:
|
||||
p.append("<tr><td class=ok><b>%s</b></td><td>%s</td><td>%s</td><td>%s</td></tr>" % (
|
||||
html.escape(r.get("code", "")), html.escape(r.get("from", "")),
|
||||
html.escape(r.get("subject", "")), html.escape(r.get("date", ""))))
|
||||
p.append("</table>")
|
||||
p.append("<p><a href=/api/domains>/api/domains</a> <a href=/api/inbox>/api/inbox</a> <a href=/api/status>/api/status</a></p>")
|
||||
return "".join(p)
|
||||
|
||||
class H(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
u = urlparse(self.path)
|
||||
if u.path == "/api/domains":
|
||||
body = json.dumps(domains()).encode()
|
||||
elif u.path == "/api/status":
|
||||
body = json.dumps(load_status()).encode()
|
||||
elif u.path == "/api/inbox":
|
||||
body = json.dumps(inbox() or []).encode()
|
||||
else:
|
||||
body = page().encode("utf-8")
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json" if u.path.startswith("/api") else "text/html; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
log("dashboard on http://%s:%d" % (HOST, PORT))
|
||||
HTTPServer((HOST, PORT), H).serve_forever()
|
||||
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""dns_clean.py <domain> [--match SUBSTR ...] [--ip OLD_IP] — list DNS records and delete matches.
|
||||
|
||||
Proven endpoints: POST /user_ym/get_jx_list (records w/ ids), POST /user_ym/jx_del {ym, jxid}.
|
||||
Use to purge stale records (e.g. old forwardemail MX/TXT or duplicate A mail=<old-ip>).
|
||||
"""
|
||||
import sys, os, time, json
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from gname_core import SITE, log, mk_context, save_cookies, csrf, inpost_json, ensure_czyz_channel
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
|
||||
def main():
|
||||
dom = sys.argv[1]
|
||||
matches, only_ip = [], ""
|
||||
i = 2
|
||||
while i < len(sys.argv):
|
||||
if sys.argv[i] == "--match":
|
||||
matches.append(sys.argv[i + 1].lower()); i += 2
|
||||
elif sys.argv[i] == "--ip":
|
||||
only_ip = sys.argv[i + 1]; i += 2
|
||||
else:
|
||||
i += 1
|
||||
|
||||
with sync_playwright() as pw:
|
||||
browser, ctx = mk_context(pw)
|
||||
page = ctx.new_page()
|
||||
page.goto(SITE + "/user/iframe#/jie_info/ym=%s/dns=a.share-dns.com,b.share-dns.net" % dom,
|
||||
wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(10)
|
||||
ensure_czyz_channel(page)
|
||||
tok = csrf(page)
|
||||
r = inpost_json(page, "/user_ym/get_jx_list", {"ym": dom, "csrf_token": tok}, "list")
|
||||
data = (r or {}).get("data") or []
|
||||
for x in data:
|
||||
print("REC", x.get("id"), x.get("zjt"), x.get("lx"), str(x.get("jxz"))[:60],
|
||||
"prio", x.get("mx"), flush=True)
|
||||
doomed = []
|
||||
for rec in data:
|
||||
v = json.dumps(rec).lower()
|
||||
if matches and any(m in v for m in matches):
|
||||
doomed.append(rec)
|
||||
elif only_ip and rec.get("lx") == "A" and rec.get("jxz") == only_ip:
|
||||
doomed.append(rec)
|
||||
for rec in doomed:
|
||||
rr = inpost_json(page, "/user_ym/jx_del",
|
||||
{"ym": dom, "jxid": rec.get("id"), "id": rec.get("id"), "csrf_token": tok},
|
||||
"del")
|
||||
ok = isinstance(rr, dict) and rr.get("code") == 1
|
||||
print("DEL", rec.get("id"), rec.get("zjt"), rec.get("lx"), "->", "OK" if ok else str(rr)[:120], flush=True)
|
||||
time.sleep(1.5)
|
||||
save_cookies(ctx)
|
||||
browser.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
-241
@@ -1,241 +0,0 @@
|
||||
# Gname fill inline contact template -> agree -> Pay Now -> order (stage 11)
|
||||
import sys, os, json, time, random, re
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE = os.environ.get("GNAME_HOME", os.path.join(os.path.dirname(os.path.abspath(__file__)), "data"))
|
||||
COOKIES_F = os.path.join(BASE, "gname_cookies.json")
|
||||
BANK_F = os.path.join(BASE, "eucc_domains.jsonl")
|
||||
MODE = sys.argv[1] if len(sys.argv) > 1 else "fill" # fill = stop before PayNow; pay = full
|
||||
|
||||
C = {"first": "Sergiy", "last": "Melnyk", "country": "Ukraine", "prov": "Kyiv", "city": "Kyiv",
|
||||
"addr": "Khreshchatyk Street 22, apt 14", "areacode": "380", "phone": "992936096", "zip": "01001"}
|
||||
|
||||
with sync_playwright() as pw:
|
||||
try:
|
||||
browser = pw.chromium.launch(headless=True, args=["--disable-blink-features=AutomationControlled", "--no-sandbox"])
|
||||
except Exception:
|
||||
cand = [d for d in os.listdir(r"C:/Users/User/AppData/Local/ms-playwright") if d.startswith("chromium-1")]
|
||||
exe = os.path.join(r"C:/Users/User/AppData/Local/ms-playwright", sorted(cand)[-1], "chrome-win", "chrome.exe")
|
||||
browser = pw.chromium.launch(headless=True, executable_path=exe, args=["--disable-blink-features=AutomationControlled"])
|
||||
ctx = browser.new_context(viewport={"width": 1366, "height": 900}, locale="en-US", timezone_id="Europe/Kiev",
|
||||
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(COOKIES_F)))
|
||||
page = ctx.new_page()
|
||||
netlog = []
|
||||
def on_resp(r):
|
||||
u = r.url
|
||||
if "gname.com/request/" in u and not any(k in u for k in ("chaym", "login_status", "get_xygx", "get_cps", "get_yhq")):
|
||||
try:
|
||||
b = r.text()[:900]
|
||||
netlog.append({"url": u, "status": r.status, "body": b})
|
||||
print("NET", r.status, u.split("gname.com")[-1][:60], b[:300].replace("\n", " "), flush=True)
|
||||
except Exception:
|
||||
pass
|
||||
page.on("response", on_resp)
|
||||
|
||||
page.goto("https://www.gname.com/user_gwc", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(4)
|
||||
# select all
|
||||
page.evaluate("""() => {
|
||||
const els = [...document.querySelectorAll('*')].filter(e=>e.offsetParent!==null && [...e.childNodes].some(n=>n.nodeType===3 && /select all/i.test(n.textContent)));
|
||||
const host = els[els.length-1];
|
||||
const scope = host.closest('div,li,tr') || host.parentElement;
|
||||
const r = host.getBoundingClientRect();
|
||||
const icons = [...scope.querySelectorAll('input,i,span,em,label')].filter(e=>{const b=e.getBoundingClientRect(); return b.width>0 && b.right <= r.left+2;});
|
||||
const t = icons.length ? icons[icons.length-1].getBoundingClientRect() : {x:r.left-28,y:r.y,width:28,height:r.height};
|
||||
window.__selbox = {x:t.x+t.width/2, y:t.y+t.height/2};
|
||||
}""")
|
||||
sb = page.evaluate("() => window.__selbox")
|
||||
page.mouse.click(sb["x"], sb["y"])
|
||||
time.sleep(1.5)
|
||||
print("COUNTER:", page.evaluate("() => {const m=document.body.innerText.match(/(\\d+) in total, (\\d+) selected/); return m?m[0]:'?';}"), flush=True)
|
||||
page.evaluate("""() => {
|
||||
const els=[...document.querySelectorAll('a,button,input,div,span')].filter(e=>e.offsetParent!==null);
|
||||
const cand=els.filter(e=>/^submit$/i.test(((e.innerText||e.value||'')).trim()));
|
||||
cand[cand.length-1].click();
|
||||
}""")
|
||||
try:
|
||||
page.wait_for_url("**/user_gwc/pay*", timeout=25000)
|
||||
page.wait_for_load_state("domcontentloaded", timeout=20000)
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(4)
|
||||
print("URL PAY:", page.url, flush=True)
|
||||
|
||||
# agreement checkbox FIRST (coordinate click after scroll into view)
|
||||
page.evaluate("""() => {
|
||||
const els = [...document.querySelectorAll('*')].filter(e=>e.offsetParent!==null && [...e.childNodes].some(n=>n.nodeType===3 && /I have read and agree/i.test(n.textContent)));
|
||||
const host = els[els.length-1];
|
||||
host.scrollIntoView({block:'center'});
|
||||
const r = host.getBoundingClientRect();
|
||||
const scope = host.closest('div,li,tr') || host.parentElement;
|
||||
const icons = [...scope.querySelectorAll('input,i,span,em,label')].filter(e=>{const b=e.getBoundingClientRect(); return b.width>0 && b.right <= r.left+2;});
|
||||
const t = icons.length ? icons[icons.length-1].getBoundingClientRect() : {x:r.left-28,y:r.y,width:28,height:r.height};
|
||||
window.__agbox = {x:t.x+t.width/2, y:t.y+t.height/2};
|
||||
}""")
|
||||
time.sleep(1)
|
||||
ab = page.evaluate("() => window.__agbox")
|
||||
page.mouse.click(ab["x"], ab["y"])
|
||||
time.sleep(1)
|
||||
agchk = page.evaluate("""() => [...document.querySelectorAll('input[type=checkbox]')].filter(c=>c.checked).map(c=>c.name||'?')""")
|
||||
print("AGREED:", json.dumps(agchk), flush=True)
|
||||
|
||||
# click Pay Now — template form only renders after it (with agreement checked)
|
||||
page.evaluate("""() => {
|
||||
const els=[...document.querySelectorAll('a,button,div,span,input')].filter(e=>e.offsetParent!==null);
|
||||
const cand=els.filter(e=>/^pay now$/i.test(((e.innerText||e.value||'')).trim()));
|
||||
if (cand.length) cand[cand.length-1].click();
|
||||
}""")
|
||||
try:
|
||||
page.wait_for_selector("input[name=xing]", timeout=15000)
|
||||
print("FORM VISIBLE", flush=True)
|
||||
except Exception:
|
||||
print("FORM NOT APPEARED", flush=True)
|
||||
toast = page.evaluate("""() => {
|
||||
const ts=[...document.querySelectorAll('[class*=toast],[class*=tips],[class*=msg],.layui-layer-content')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').trim().slice(0,120));
|
||||
return ts.filter(t=>t).slice(0,5);
|
||||
}""")
|
||||
print("TOASTS:", json.dumps(toast, ensure_ascii=False), flush=True)
|
||||
time.sleep(1.5)
|
||||
|
||||
def fill_field(sel, val, click_dropdown_kw=None):
|
||||
try:
|
||||
el = page.query_selector(sel)
|
||||
if not el:
|
||||
print("MISS:", sel, flush=True)
|
||||
return False
|
||||
el.scroll_into_view_if_needed()
|
||||
el.click()
|
||||
el.fill(val)
|
||||
time.sleep(0.7)
|
||||
if click_dropdown_kw:
|
||||
# click suggestion containing kw
|
||||
r = page.evaluate("""(kw) => {
|
||||
const items=[...document.querySelectorAll('li,div[class*=item],div[class*=option],dd')].filter(e=>e.offsetParent!==null && (e.innerText||'').trim().toLowerCase().includes(kw.toLowerCase()) && (e.innerText||'').trim().length<60);
|
||||
if(!items.length) return 'noitems';
|
||||
items[items.length-1].click();
|
||||
return 'clicked:'+items[items.length-1].innerText.trim().slice(0,40);
|
||||
}""", click_dropdown_kw)
|
||||
print("DROPDOWN %s: %s" % (sel, r), flush=True)
|
||||
time.sleep(1)
|
||||
return True
|
||||
except Exception as e:
|
||||
print("FILL ERR %s: %s" % (sel, str(e)[:70]), flush=True)
|
||||
return False
|
||||
|
||||
fill_field("input[name=xing]", C["first"])
|
||||
fill_field("input[name=ming]", C["last"])
|
||||
fill_field("input[placeholder='Country/Region']", C["country"], click_dropdown_kw="Ukraine")
|
||||
fill_field("input[name=sheng]", C["prov"], click_dropdown_kw="Kyiv")
|
||||
fill_field("input[name=shi]", C["city"], click_dropdown_kw="Kyiv")
|
||||
fill_field("input[name=gn_bczl_dzxx]", C["addr"])
|
||||
fill_field("input[placeholder='Area Code']", C["areacode"], click_dropdown_kw="380")
|
||||
fill_field("input[name=gn_wszl_phone]", C["phone"])
|
||||
fill_field("input[name=yzbm]", C["zip"])
|
||||
# dump filled state
|
||||
vals = page.evaluate("""() => [...document.querySelectorAll('input[type=text]')].filter(i=>i.offsetParent!==null).map(i=>({n:i.name,ph:i.placeholder,v:i.value}))""")
|
||||
print("VALS:", json.dumps(vals, ensure_ascii=False), flush=True)
|
||||
page.screenshot(path=os.path.join(BASE, "eucc11_filled.png"), full_page=True)
|
||||
|
||||
# agreement already checked before Pay Now; just verify
|
||||
agchk = page.evaluate("""() => [...document.querySelectorAll('input[type=checkbox]')].filter(c=>c.checked).map(c=>c.name||'?')""")
|
||||
print("CHECKED:", json.dumps(agchk), flush=True)
|
||||
allbtns = page.evaluate("""() => [...document.querySelectorAll('a,button,div,span,input')].filter(e=>e.offsetParent!==null).map(e=>((e.innerText||e.value||'')).trim()).filter(t=>t && t.length<30 && /save|confirm|submit|ok|determine|pay|buy|order|next/i.test(t))""")
|
||||
print("BTNS NEAR:", json.dumps(sorted(set(allbtns))), flush=True)
|
||||
if MODE == "pay":
|
||||
# 1) form-level submit (Save/Confirm/Submit/Determine/OK), NOT Pay Now
|
||||
r1 = page.evaluate("""() => {
|
||||
const els=[...document.querySelectorAll('a,button,div,span,input')].filter(e=>e.offsetParent!==null);
|
||||
const cand=els.filter(e=>/^(save|confirm|submit|determine|ok)$/i.test(((e.innerText||e.value||'')).trim()));
|
||||
if(!cand.length) return 'none';
|
||||
cand[cand.length-1].click();
|
||||
return 'clicked:'+((cand[cand.length-1].innerText||cand[cand.length-1].value)||'').trim();
|
||||
}""")
|
||||
print("FORM SUBMIT:", r1, flush=True)
|
||||
time.sleep(4)
|
||||
# modal chain after Submit: Confirm -> Payment Confirm (layui popups). Click .layui-layer-btn0 (Confirm) each time.
|
||||
for mtry in range(4):
|
||||
vis = page.locator(".layui-layer:visible")
|
||||
n = vis.count()
|
||||
if n == 0:
|
||||
break
|
||||
txts = []
|
||||
for i in range(n):
|
||||
try:
|
||||
txts.append(vis.nth(i).inner_text()[:150].replace("\n", " | "))
|
||||
except Exception:
|
||||
pass
|
||||
print("LAYUI MODALS(%d): %s" % (n, " ;; ".join(txts)), flush=True)
|
||||
clicked = False
|
||||
try:
|
||||
btn = page.locator(".layui-layer-btn0:visible").last
|
||||
if btn.count():
|
||||
btn.click(timeout=4000)
|
||||
clicked = True
|
||||
except Exception as e:
|
||||
print("BTN0 ERR:", str(e)[:60], flush=True)
|
||||
print("LAYUI CONFIRM CLICK:", clicked, flush=True)
|
||||
time.sleep(4)
|
||||
# 2) slider if demanded
|
||||
try:
|
||||
nb = page.evaluate("() => [...document.querySelectorAll('.gn-slide-bar')].filter(b=>b.offsetParent!==null).length")
|
||||
except Exception:
|
||||
nb = 0
|
||||
print("SLIDER BARS:", nb, flush=True)
|
||||
# 3) Pay Now again if still on pay page
|
||||
try:
|
||||
still = "user_gwc/pay" in page.url and page.query_selector("input[name=xing]") is not None
|
||||
except Exception:
|
||||
still = False
|
||||
print("STILL ON FORM:", still, flush=True)
|
||||
r2 = page.evaluate("""() => {
|
||||
const els=[...document.querySelectorAll('a,button,div,span,input')].filter(e=>e.offsetParent!==null);
|
||||
const cand=els.filter(e=>/^pay now$/i.test(((e.innerText||e.value||'')).trim()));
|
||||
if(!cand.length) return 'none';
|
||||
cand[cand.length-1].click(); return 'clicked';
|
||||
}""")
|
||||
print("PAYNOW2:", r2, flush=True)
|
||||
time.sleep(3)
|
||||
# handle Warm Tips / confirm modal (real layui popups only)
|
||||
for mtry in range(3):
|
||||
vis = page.locator(".layui-layer:visible")
|
||||
n = vis.count()
|
||||
if n == 0:
|
||||
break
|
||||
txts = []
|
||||
for i in range(n):
|
||||
try:
|
||||
txts.append(vis.nth(i).inner_text()[:200].replace("\n", " | "))
|
||||
except Exception:
|
||||
pass
|
||||
print("MODAL%d:" % mtry, " ;; ".join(txts), flush=True)
|
||||
try:
|
||||
btn = page.locator(".layui-layer-btn0:visible").last
|
||||
if btn.count():
|
||||
btn.click(timeout=4000)
|
||||
print("MODAL CLICK: btn0", flush=True)
|
||||
except Exception as e:
|
||||
print("MODAL CLICK ERR:", str(e)[:60], flush=True)
|
||||
time.sleep(4)
|
||||
for _ in range(8):
|
||||
time.sleep(3)
|
||||
try:
|
||||
nb = page.evaluate("() => [...document.querySelectorAll('.gn-slide-bar')].filter(b=>b.offsetParent!==null).length")
|
||||
u = page.url
|
||||
except Exception:
|
||||
nb, u = 0, "?"
|
||||
if nb:
|
||||
print("SLIDER AT PAY2", flush=True)
|
||||
break
|
||||
if "user_gwc" not in u:
|
||||
break
|
||||
print("URL FINAL:", page.url, flush=True)
|
||||
try:
|
||||
bf = page.locator("body").inner_text()
|
||||
print("FINAL BODY:", bf[:1200].replace("\n", " | "), flush=True)
|
||||
except Exception:
|
||||
pass
|
||||
page.screenshot(path=os.path.join(BASE, "eucc11_result.png"), full_page=True)
|
||||
json.dump(netlog[-80:], open(os.path.join(BASE, "eucc_netlog11.json"), "w"), indent=1)
|
||||
json.dump(ctx.cookies(), open(COOKIES_F, "w"))
|
||||
browser.close()
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""gname_core - shared helpers for the gname-eucc toolkit.
|
||||
|
||||
Env:
|
||||
GNAME_HOME state dir (cookies, banks, status). default ./data
|
||||
GM_EMAIL gmail that receives forwarded mail (catch-all dest + OTP)
|
||||
GM_APPPW gmail app password (IMAP)
|
||||
GM_IMAP_HOST default imap.gmail.com
|
||||
VL_BASE OpenAI-compatible vision endpoint for image captchas
|
||||
default http://127.0.0.1:16432/v1
|
||||
VL_MODEL default qwen3-vl-plus
|
||||
VL_KEY optional bearer key for VL_BASE (or data/vote_key.txt)
|
||||
"""
|
||||
import os, sys, json, re, time, random, base64
|
||||
import imaplib
|
||||
import email as eml
|
||||
import email.utils
|
||||
import urllib.request as uq
|
||||
|
||||
BASE = os.environ.get("GNAME_HOME") or os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
|
||||
os.makedirs(BASE, exist_ok=True)
|
||||
COOKIES_F = os.path.join(BASE, "gname_cookies.json")
|
||||
DOMAINS_F = os.path.join(BASE, "eucc_domains.jsonl")
|
||||
STATUS_F = os.path.join(BASE, "status.json")
|
||||
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
||||
"(KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36")
|
||||
SITE = "https://www.gname.com"
|
||||
|
||||
# mail-reader globals (used by extracted imap_code)
|
||||
GM = os.environ.get("GM_EMAIL", "")
|
||||
GP = os.environ.get("GM_APPPW", "")
|
||||
IS_TONLINE = False
|
||||
EMAIL = ""
|
||||
TONLINE_PW = os.environ.get("TONLINE_PW", "")
|
||||
|
||||
def log(*a):
|
||||
print(*a, flush=True)
|
||||
|
||||
def load_status():
|
||||
try:
|
||||
return json.load(open(STATUS_F, encoding="utf-8"))
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
def save_status(st):
|
||||
tmp = STATUS_F + ".tmp"
|
||||
json.dump(st, open(tmp, "w", encoding="utf-8"), indent=1)
|
||||
os.replace(tmp, STATUS_F)
|
||||
|
||||
def append_domain(dom, status="submitted", price=0.0, extra=None):
|
||||
rec = {"domain": dom, "status": status, "price_usd": price,
|
||||
"ts": time.strftime("%Y-%m-%d %H:%M:%S")}
|
||||
if extra:
|
||||
rec.update(extra)
|
||||
seen = set()
|
||||
try:
|
||||
for l in open(DOMAINS_F, encoding="utf-8"):
|
||||
if l.strip():
|
||||
seen.add(json.loads(l)["domain"])
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if dom in seen:
|
||||
return
|
||||
with open(DOMAINS_F, "a", encoding="utf-8") as f:
|
||||
f.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
||||
|
||||
def domains():
|
||||
out = []
|
||||
try:
|
||||
for l in open(DOMAINS_F, encoding="utf-8"):
|
||||
if l.strip():
|
||||
out.append(json.loads(l))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
return out
|
||||
|
||||
def mk_context(pw, headless=True, cookies=True):
|
||||
"""browser + context (+ saved cookies) with light stealth."""
|
||||
try:
|
||||
browser = pw.chromium.launch(headless=headless,
|
||||
args=["--disable-blink-features=AutomationControlled", "--no-sandbox"])
|
||||
except Exception:
|
||||
cand = os.environ.get("PLAYWRIGHT_BROWSERS_PATH") or ""
|
||||
raise
|
||||
ctx = browser.new_context(viewport={"width": 1440, "height": 950}, locale="en-US",
|
||||
timezone_id="Europe/Kiev", user_agent=UA)
|
||||
ctx.add_init_script("Object.defineProperty(navigator,'webdriver',{get:()=>undefined});")
|
||||
if cookies and os.path.exists(COOKIES_F):
|
||||
try:
|
||||
ctx.add_cookies(json.load(open(COOKIES_F, encoding="utf-8")))
|
||||
except Exception as e:
|
||||
log("cookies load err:", str(e)[:100])
|
||||
return browser, ctx
|
||||
|
||||
def save_cookies(ctx):
|
||||
json.dump(ctx.cookies(), open(COOKIES_F, "w", encoding="utf-8"))
|
||||
log("COOKIES SAVED:", len(ctx.cookies()))
|
||||
|
||||
def csrf(page):
|
||||
return page.evaluate("() => (window.layui && layui.setter && layui.setter.token) || ''")
|
||||
|
||||
def inpost(page, url, data, tag, get=False, tries=20):
|
||||
"""$.post/$.get inside the page (keeps cookies/csrf/headers site-native)."""
|
||||
page.evaluate("""(o) => {
|
||||
window['__r_'+o.tag] = 'pending';
|
||||
var cb = function(res){ window['__r_'+o.tag] = JSON.stringify(res); };
|
||||
var er = function(x){ window['__r_'+o.tag] = 'HTTPERR:'+x.status+' '+String(x.responseText).slice(0,200); };
|
||||
if (o.get) { $.get(o.url, o.data, cb, 'json').fail(er); }
|
||||
else { $.post(o.url, o.data, cb, 'json').fail(er); }
|
||||
}""", {"tag": tag, "url": url, "data": data, "get": get})
|
||||
for _ in range(tries):
|
||||
time.sleep(1.5)
|
||||
r = page.evaluate("(t) => window['__r_'+t]", tag)
|
||||
if r != "pending":
|
||||
return r
|
||||
return "TIMEOUT"
|
||||
|
||||
def inpost_json(page, url, data, tag, get=False, tries=20):
|
||||
r = inpost(page, url, data, tag, get=get, tries=tries)
|
||||
try:
|
||||
return json.loads(r)
|
||||
except Exception:
|
||||
return {"_raw": r}
|
||||
|
||||
def vl_solve_image(page, selectors, out_png="cap.png", tries=3, field="input[name=re_yzm]"):
|
||||
"""Screenshot an image captcha, solve via VL_BASE vision model, fill field."""
|
||||
vl_base = os.environ.get("VL_BASE", "http://127.0.0.1:16432/v1").rstrip("/")
|
||||
model = os.environ.get("VL_MODEL", "qwen3-vl-plus")
|
||||
key = os.environ.get("VL_KEY", "")
|
||||
if not key:
|
||||
vk = os.path.join(BASE, "vote_key.txt")
|
||||
if os.path.exists(vk):
|
||||
key = open(vk, encoding="utf-8").read().strip()
|
||||
shot = os.path.join(BASE, out_png)
|
||||
for t in range(tries):
|
||||
done = False
|
||||
for sel in selectors:
|
||||
el = page.query_selector(sel)
|
||||
if el:
|
||||
el.screenshot(path=shot)
|
||||
done = True
|
||||
break
|
||||
if not done:
|
||||
box = page.evaluate("""(f) => { const i=document.querySelector(f); if(!i) return null;
|
||||
let n=i.parentElement, img=n?n.querySelector('img'):null;
|
||||
if(!img){ n=n?n.parentElement:null; img=n?n.querySelector('img'):null; }
|
||||
if(!img) return null; const r=img.getBoundingClientRect();
|
||||
return {x:r.x,y:r.y,width:r.width,height:r.height}; }""", field)
|
||||
if box:
|
||||
page.screenshot(path=shot, clip=box)
|
||||
done = True
|
||||
if not done:
|
||||
log("VL: no captcha img found")
|
||||
return None
|
||||
b64 = base64.b64encode(open(shot, "rb").read()).decode()
|
||||
payload = json.dumps({"model": model, "messages": [{"role": "user", "content": [
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64," + b64}},
|
||||
{"type": "text", "text": "What text/characters are shown in this captcha image? Reply with ONLY the characters, nothing else."}]}],
|
||||
"max_tokens": 20}).encode()
|
||||
hdrs = {"Content-Type": "application/json"}
|
||||
if key:
|
||||
hdrs["Authorization"] = "Bea" + "rer " + key
|
||||
try:
|
||||
resp = json.load(uq.urlopen(uq.Request(vl_base + "/chat/completions", data=payload, headers=hdrs), timeout=60))
|
||||
ans = resp["choices"][0]["message"]["content"].strip()
|
||||
code = re.sub(r"[^A-Za-z0-9]", "", ans)[:6]
|
||||
log("VL ANSWER:", ans[:40])
|
||||
if len(code) >= 3:
|
||||
page.fill(field, code)
|
||||
return code
|
||||
except Exception as e:
|
||||
log("VL ERR:", str(e)[:120])
|
||||
page.evaluate("""() => { const img=document.querySelector('img.yzm-img')||document.querySelector('img[src*=captcha]'); if(img) img.click(); }""")
|
||||
time.sleep(2)
|
||||
return None
|
||||
|
||||
def czyz_unlock(page, chal, fallback_email):
|
||||
"""Unlock gname operation protection (czyz) with an email code.
|
||||
chal = jx_edit response json {token, data:{yxyz:{name,title}}}."""
|
||||
tok = csrf(page)
|
||||
bhtoken = chal.get("token", "")
|
||||
yz = chal.get("data", {}).get("yxyz", {}) or {}
|
||||
yzname = yz.get("name") or "yzm"
|
||||
yzemail = yz.get("title") or fallback_email
|
||||
log("CZYZ challenge: field=%s email=%s" % (yzname, yzemail))
|
||||
r = inpost_json(page, "/request/send_email", {"email": yzemail, "lx": "czyz", "csrf_token": tok}, "cz_snd")
|
||||
log("SEND_EMAIL czyz:", str(r)[:150])
|
||||
code = imap_code(wait=300)
|
||||
log("CZYZ code:", code)
|
||||
if not code:
|
||||
return False
|
||||
body = {"csrf_token": tok, "token": bhtoken}
|
||||
body[yzname] = code
|
||||
r = inpost_json(page, "/user_zh/aqbh_check", body, "cz_aq")
|
||||
log("AQBH_CHECK:", str(r)[:250])
|
||||
ok = str(r).find('"code":1') >= 0 or str(r).find('"code":"1"') >= 0
|
||||
return ok
|
||||
|
||||
_AQBH_OK = False
|
||||
_AQBH_BLOCKED = False
|
||||
|
||||
def aqbh_session_unlock(page, email=None):
|
||||
"""Unlock operation-protection for the whole session when jx_edit returns
|
||||
code -101 'please set operation protection' with NO challenge token
|
||||
(proven flow from gname_eucc30.py): send_email lx=czyz -> IMAP code ->
|
||||
POST /user_zh/aqbh_check {token:'', eyzm: code}.
|
||||
Hardened: send rate-limit cooldown retry, min_ts mail filter (never reuse
|
||||
stale codes), 1h wrong-code lockout latch (server counts failed checks)."""
|
||||
global _AQBH_OK, _AQBH_BLOCKED
|
||||
if _AQBH_OK:
|
||||
return True
|
||||
if _AQBH_BLOCKED:
|
||||
return False
|
||||
tok = csrf(page)
|
||||
email = email or os.environ.get("GM_EMAIL", "")
|
||||
t_send = time.time() - 30
|
||||
sent = False
|
||||
for attempt in range(4):
|
||||
r = inpost_json(page, "/request/send_email", {"email": email, "lx": "czyz", "csrf_token": tok}, "aq_snd%d" % attempt)
|
||||
log("AQBH SEND_EMAIL:", str(r)[:150])
|
||||
if isinstance(r, dict) and r.get("code") == -105001:
|
||||
# slider gate: solve their own widget, one-time code rides as re_yzm
|
||||
lx = ((r.get("data") or {}).get("verify") or {}).get("lx") or "czyz"
|
||||
ok, drag, st, yz_code = solve_slide_yz(page, lx)
|
||||
log("AQBH SLIDE_YZ:", ok, drag, "cb_status:", st, "re_yzm_len:", len(str(yz_code)))
|
||||
if not ok or not yz_code:
|
||||
return False
|
||||
time.sleep(1)
|
||||
r = inpost_json(page, "/request/send_email",
|
||||
{"email": email, "lx": "czyz", "re_yzm": yz_code, "csrf_token": tok}, "aq_snd2")
|
||||
log("AQBH SEND_EMAIL retry:", str(r)[:150])
|
||||
if isinstance(r, dict) and r.get("code") == 1:
|
||||
sent = True
|
||||
break
|
||||
msg = str((r or {}).get("msg", "")) if isinstance(r, dict) else ""
|
||||
m2 = re.search(r"after\s+(\d+)\s+seconds", msg)
|
||||
if m2: # send rate-limit: wait out cooldown, no attempt burned
|
||||
wait_s = min(int(m2.group(1)) + 5, 90)
|
||||
log("AQBH SEND cooldown %ss" % wait_s)
|
||||
time.sleep(wait_s)
|
||||
continue
|
||||
return False
|
||||
if not sent:
|
||||
return False
|
||||
code = imap_code(wait=300, min_ts=t_send)
|
||||
log("AQBH code:", code)
|
||||
if not code:
|
||||
return False
|
||||
r = inpost_json(page, "/user_zh/aqbh_check", {"csrf_token": tok, "token": "", "eyzm": code}, "aq_sess")
|
||||
log("AQBH_CHECK session:", str(r)[:250])
|
||||
s = str(r)
|
||||
ok = '"code":1' in s or '"code":"1"' in s
|
||||
if ok:
|
||||
_AQBH_OK = True
|
||||
elif "tried wrong" in s or "restricted for 1 hour" in s:
|
||||
_AQBH_BLOCKED = True
|
||||
log("AQBH LOCKOUT: wrong-code limit hit, blocked ~1h - stop attempts")
|
||||
return ok
|
||||
|
||||
|
||||
def ensure_czyz_channel(page):
|
||||
tok = csrf(page)
|
||||
r = inpost_json(page, "/user_zh/get_czyz", {"csrf_token": tok}, "czyz", get=True)
|
||||
try:
|
||||
if r.get("data", {}).get("yx", {}).get("zt") != 1:
|
||||
inpost(page, "/user_zh/set_czyz", {"czyz[]": "1", "csrf_token": tok}, "setcz")
|
||||
time.sleep(1)
|
||||
except Exception:
|
||||
pass
|
||||
# channel 4 required for DNS edits (proven: gname_eucc32 set_czyz [1,4])
|
||||
try:
|
||||
d = r.get("data", {}) if isinstance(r, dict) else {}
|
||||
if str(d.get("mb", {}).get("zt", "")) != "4" and "4" not in str(d):
|
||||
inpost(page, "/user_zh/set_czyz", {"czyz[]": ["1", "4"], "csrf_token": tok}, "setcz14")
|
||||
time.sleep(1)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
# ---- extracted from gname_reg.py (proven implementations) ----
|
||||
def dot_variant(local="yourname", domain="gmail.com"):
|
||||
# random 1-2 dots inserted -> same Gmail inbox, unique for site
|
||||
idxs = sorted(random.sample(range(1, len(local)), random.choice([1, 2])))
|
||||
out = ""
|
||||
for i, ch in enumerate(local):
|
||||
if i in idxs:
|
||||
out += "."
|
||||
out += ch
|
||||
return out + "@" + domain
|
||||
|
||||
def canon(addr):
|
||||
addr = addr.lower().strip().strip("<>")
|
||||
lp, _, dm = addr.partition("@")
|
||||
lp = lp.split("+")[0].replace(".", "")
|
||||
return lp + "@" + dm
|
||||
|
||||
POOL_F = os.environ.get("TONLINE_POOL", os.path.join(BASE, "tonline_pool.txt"))
|
||||
USED_F = os.path.join(BASE, "tonline_used.txt")
|
||||
|
||||
def imap_code(wait=240, min_ts=0):
|
||||
t0 = time.time()
|
||||
while time.time() - t0 < wait:
|
||||
try:
|
||||
if IS_TONLINE:
|
||||
m = imaplib.IMAP4_SSL("secureimap.t-online.de", 993)
|
||||
m.login(EMAIL, TONLINE_PW)
|
||||
typ, cnt = m.select("INBOX")
|
||||
n = int(cnt[0]) if cnt and cnt[0] else 0
|
||||
ids = [str(i) for i in range(max(1, n - 29), n + 1)] if n else []
|
||||
else:
|
||||
m = imaplib.IMAP4_SSL("imap.gmail.com")
|
||||
m.login(GM, GP)
|
||||
m.select("INBOX")
|
||||
since = time.strftime("%d-%b-%Y", time.localtime(time.time() - 86400))
|
||||
typ, data = m.search(None, '(SINCE %s)' % since)
|
||||
ids = data[0].split()[-40:]
|
||||
for i in reversed(ids):
|
||||
typ, md = m.fetch(i, "(RFC822)")
|
||||
raw = md[0][1]
|
||||
msg = eml.message_from_bytes(raw)
|
||||
if min_ts:
|
||||
try:
|
||||
dt = email.utils.parsedate_to_datetime(msg.get("Date", ""))
|
||||
if dt.timestamp() < min_ts:
|
||||
continue # stale mail from an earlier run
|
||||
except Exception:
|
||||
pass
|
||||
to = (msg.get("To", "") + " " + msg.get("X-Gmail-Original-To", "") + " " + msg.get("Delivered-To", "")).lower()
|
||||
frm = (msg.get("From", "") or "").lower()
|
||||
addrs = re.findall(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+", to)
|
||||
if IS_TONLINE:
|
||||
hit = any(a.lower() == EMAIL.lower() for a in addrs) or not addrs
|
||||
elif EMAIL:
|
||||
hit = any(canon(a) == canon(EMAIL) for a in addrs)
|
||||
else:
|
||||
# no reg-email pinned: accept mail to our Gmail (dot variants canon-equal)
|
||||
hit = (not addrs) or any(canon(a) == canon(GM) for a in addrs) if GM else True
|
||||
if ("gname" in frm or "gname" in (msg.get("Subject", "") or "").lower()) and hit:
|
||||
body = ""
|
||||
if msg.is_multipart():
|
||||
for p in msg.walk():
|
||||
if p.get_content_type() == "text/plain":
|
||||
body = p.get_payload(decode=True).decode("utf-8", "ignore")
|
||||
break
|
||||
else:
|
||||
body = msg.get_payload(decode=True).decode("utf-8", "ignore")
|
||||
body_html = ""
|
||||
if msg.is_multipart():
|
||||
for p in msg.walk():
|
||||
if p.get_content_type() == "text/html":
|
||||
body_html = p.get_payload(decode=True).decode("utf-8", "ignore")
|
||||
if "Reason for failure" in body or "incorrect or has expired" in body:
|
||||
continue # skip aqbh failure-notice mails
|
||||
mm = (re.search(r"(?:verification code is|code is|code|验证码)\s*[::]?\s*(\d{4,8})", body, re.I)
|
||||
or re.search(r"(?:verification code is|code is|code|验证码)\s*[::]?\s*(\d{4,8})", body_html, re.I)
|
||||
or re.search(r"\b(\d{6})\b", body) or re.search(r"\b(\d{6})\b", body_html))
|
||||
m.logout()
|
||||
if mm:
|
||||
return mm.group(1)
|
||||
m.logout()
|
||||
except Exception as e:
|
||||
log("imap err:", e)
|
||||
time.sleep(6)
|
||||
return None
|
||||
|
||||
def human_drag(page, sel_bar=".gn-slide-bar", sel_rail=".gn-slide-rail"):
|
||||
rect = page.evaluate("""(sel) => {
|
||||
const bars = [...document.querySelectorAll(sel[0])].filter(b => b.offsetParent !== null && b.getBoundingClientRect().width > 10);
|
||||
const rails = [...document.querySelectorAll(sel[1])].filter(r => r.offsetParent !== null);
|
||||
if (!bars.length) return null;
|
||||
const b = bars[bars.length - 1].getBoundingClientRect();
|
||||
const r = (rails[rails.length - 1] || bars[bars.length - 1]).getBoundingClientRect();
|
||||
return {bx: b.x, by: b.y, bw: b.width, bh: b.height, rw: r.width};
|
||||
}""", [sel_bar, sel_rail])
|
||||
if not rect:
|
||||
return "no-visible-bar"
|
||||
dist = rect["rw"] - rect["bw"] + 40 # OVERSHOOT: widget clamps delta at config width; must saturate
|
||||
x0 = rect["bx"] + rect["bw"] / 2
|
||||
y0 = rect["by"] + rect["bh"] / 2
|
||||
page.mouse.move(x0 + random.uniform(-3, 3), y0 + random.uniform(-4, 4))
|
||||
time.sleep(random.uniform(0.08, 0.2))
|
||||
page.mouse.move(x0, y0)
|
||||
time.sleep(random.uniform(0.05, 0.12))
|
||||
page.mouse.down()
|
||||
time.sleep(random.uniform(0.1, 0.25))
|
||||
steps = random.randint(24, 32)
|
||||
for i in range(1, steps + 1):
|
||||
p = i / steps
|
||||
ease = 1 - (1 - p) ** 3
|
||||
x = x0 + dist * ease + random.uniform(-1.2, 1.2)
|
||||
y = y0 + random.uniform(-2.5, 2.5)
|
||||
page.mouse.move(x, y)
|
||||
time.sleep(random.uniform(0.014, 0.038))
|
||||
for _ in range(4): # saturate past the end so clamped delta reaches max
|
||||
page.mouse.move(x0 + dist + random.uniform(-2, 4), y0 + random.uniform(-2, 2))
|
||||
time.sleep(0.05)
|
||||
page.mouse.move(x0 + dist, y0)
|
||||
time.sleep(random.uniform(0.08, 0.18))
|
||||
page.mouse.up()
|
||||
st = ""
|
||||
for _ in range(10):
|
||||
time.sleep(0.6)
|
||||
st = page.evaluate("""() => {
|
||||
try {
|
||||
const a = window.GN_SLIDER_VERIFY ? window.GN_SLIDER_VERIFY.status : '';
|
||||
const b = window.GN_SLIDER_VERIFY_LOGIN ? window.GN_SLIDER_VERIFY_LOGIN.status : '';
|
||||
return a + '|' + b;
|
||||
} catch(e){ return 'err'; }
|
||||
}""")
|
||||
if "success" in st or "error" in st or "fail" in st:
|
||||
break
|
||||
bx_after = page.evaluate("""(sel) => { const bars=[...document.querySelectorAll(sel)].filter(b=>b.offsetParent!==null); return bars.length? Math.round(bars[bars.length-1].getBoundingClientRect().x) : -1; }""", sel_bar)
|
||||
return "dragged %.0fpx bar_after_x=%s widget_status=%s" % (dist, bx_after, st)
|
||||
|
||||
|
||||
def solve_slide_yz(page, lx="czyz"):
|
||||
"""Invoke the site's own slide_yz(lx, cb, cbClose) widget (common.js):
|
||||
opens #pop-txyz layer with GnSliderVerify, we drag it, callback sets flag.
|
||||
common.js is NOT loaded on every SPA route (e.g. jie_info) — hop to /user
|
||||
first if needed; all unlock/DNS calls are plain same-origin API posts.
|
||||
Returns (success, drag_result, callback_status)."""
|
||||
if page.evaluate("() => typeof slide_yz") != "function":
|
||||
for hop in ("/user_gwc", "/", "/tld-eu-cc.html"):
|
||||
try:
|
||||
page.goto(SITE + hop, wait_until="domcontentloaded", timeout=60000)
|
||||
except Exception:
|
||||
continue
|
||||
time.sleep(6)
|
||||
if page.evaluate("() => typeof slide_yz") == "function":
|
||||
break
|
||||
if page.evaluate("() => typeof slide_yz") != "function":
|
||||
return False, "slide_yz unavailable on any hop", 0, ""
|
||||
page.evaluate("""(lx) => {
|
||||
window.__SYZ = 0; window.__SYZ_CODE = '';
|
||||
try { slide_yz(lx, function(code){ window.__SYZ = 1; window.__SYZ_CODE = code || ''; },
|
||||
function(){ window.__SYZ = 2; }); }
|
||||
catch(e) { window.__SYZ = -1; }
|
||||
}""", lx)
|
||||
appeared = False
|
||||
for _ in range(16):
|
||||
time.sleep(1)
|
||||
if page.evaluate("""() => { const b=document.querySelector('#pop-txyz .gn-slide-bar');
|
||||
return !!(b && b.offsetParent !== null); }"""):
|
||||
appeared = True
|
||||
break
|
||||
st0 = page.evaluate("() => window.__SYZ")
|
||||
if st0 in (1, 2, -1):
|
||||
return (st0 == 1), "no-widget cb=%s" % st0, st0, page.evaluate("() => window.__SYZ_CODE")
|
||||
if not appeared:
|
||||
return False, "widget never appeared", page.evaluate("() => window.__SYZ"), ""
|
||||
drag = human_drag(page, "#pop-txyz .gn-slide-bar", "#pop-txyz .gn-slide-rail")
|
||||
for _ in range(12):
|
||||
time.sleep(1)
|
||||
st = page.evaluate("() => window.__SYZ")
|
||||
if st in (1, 2):
|
||||
return (st == 1), drag, st, page.evaluate("() => window.__SYZ_CODE")
|
||||
return False, drag, page.evaluate("() => window.__SYZ"), ""
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""list_domains.py - list LIVE domains on the logged-in gname account.
|
||||
|
||||
Uses the real dashboard API: POST /user_ym/get_ym_list (discovered via eucc.js).
|
||||
Usage: python login.py [IDX] && python list_domains.py [--json]
|
||||
Output: domain | expire | auto-renew | status (+ free-renewal availability)
|
||||
"""
|
||||
import sys, os, json, time
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from playwright.sync_api import sync_playwright
|
||||
from gname_core import SITE, mk_context, log, inpost_json, csrf
|
||||
|
||||
def main():
|
||||
as_json = "--json" in sys.argv
|
||||
with sync_playwright() as pw:
|
||||
browser, ctx = mk_context(pw)
|
||||
page = ctx.new_page()
|
||||
page.set_default_timeout(30000)
|
||||
page.goto(SITE + "/user/iframe#/index", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(6)
|
||||
tok = csrf(page)
|
||||
r = inpost_json(page, "/user_ym/get_ym_list", {"page": 1, "limit": 50, "csrf_token": tok}, "ymlist")
|
||||
browser.close()
|
||||
code = (r or {}).get("code")
|
||||
data = (r or {}).get("data") or []
|
||||
if code != 1:
|
||||
log("API ERR:", json.dumps(r, ensure_ascii=False)[:300])
|
||||
return 1
|
||||
out = []
|
||||
for d in data:
|
||||
out.append({
|
||||
"domain": d.get("ym"),
|
||||
"expire": d.get("dqsj"),
|
||||
"autorenew": d.get("sfxufei"),
|
||||
"status": d.get("ztstr") or d.get("zt"),
|
||||
"coupon_used": d.get("yhqid"),
|
||||
})
|
||||
if as_json:
|
||||
print(json.dumps(out, ensure_ascii=False, indent=1))
|
||||
else:
|
||||
log("DOMAINS ON ACCOUNT:", len(out))
|
||||
for o in out:
|
||||
log(" -", o["domain"], "| exp:", o["expire"], "| autorenew:", o["autorenew"],
|
||||
"| coupon:", o["coupon_used"] or "-")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,79 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Gname login + cookie save.
|
||||
|
||||
Credentials: env GNAME_EMAIL / GNAME_PASSWORD, or bank file
|
||||
data/gname_accounts.jsonl (line index as argv[1]).
|
||||
|
||||
Usage: python login.py [bank_index]
|
||||
"""
|
||||
import sys, os, re, json, time
|
||||
from playwright.sync_api import sync_playwright
|
||||
from gname_core import (BASE, COOKIES_F, SITE, UA, log, mk_context,
|
||||
save_cookies, human_drag, vl_solve_image)
|
||||
|
||||
def pick_creds():
|
||||
idx = int(sys.argv[1]) if len(sys.argv) > 1 else None
|
||||
if idx is not None:
|
||||
bank_f = os.path.join(BASE, "gname_accounts.jsonl")
|
||||
bank = [json.loads(l) for l in open(bank_f, encoding="utf-8") if l.strip()]
|
||||
acc = bank[idx]
|
||||
return acc["email"], acc["password"]
|
||||
e, p = os.environ.get("GNAME_EMAIL", ""), os.environ.get("GNAME_PASSWORD", "")
|
||||
if not (e and p):
|
||||
bank_f = os.path.join(BASE, "gname_accounts.jsonl")
|
||||
if os.path.exists(bank_f):
|
||||
acc = json.loads(open(bank_f, encoding="utf-8").readline())
|
||||
return acc["email"], acc["password"]
|
||||
raise SystemExit("set GNAME_EMAIL/GNAME_PASSWORD or provide data/gname_accounts.jsonl")
|
||||
return e, p
|
||||
|
||||
def main():
|
||||
email, password = pick_creds()
|
||||
log("LOGIN AS:", email)
|
||||
with sync_playwright() as pw:
|
||||
browser, ctx = mk_context(pw, cookies=False)
|
||||
page = ctx.new_page()
|
||||
page.goto(SITE + "/login", wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(3)
|
||||
# Password tab (default is email-code / QR)
|
||||
page.evaluate("""() => {
|
||||
const els = [...document.querySelectorAll('a,span,div,li,button')]
|
||||
.filter(e=>e.offsetParent!==null && (e.innerText||'').trim()==='Password');
|
||||
if (els.length) els[0].click();
|
||||
}""")
|
||||
time.sleep(2)
|
||||
filled = page.evaluate("""(creds) => {
|
||||
const set = (el, v) => { el.value = v; el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true})); };
|
||||
const vis = [...document.querySelectorAll('input')].filter(i=>i.offsetParent!==null);
|
||||
let em = vis.find(i=>['lg_yx','re_yx'].includes(i.name)) || vis.find(i=>/mail/i.test(i.placeholder));
|
||||
let pw = vis.find(i=>i.type==='password');
|
||||
if (!em || !pw) return 'no-fields';
|
||||
set(em, creds[0]); set(pw, creds[1]);
|
||||
return 'ok';
|
||||
}""", [email, password])
|
||||
log("FILLED:", filled)
|
||||
time.sleep(1)
|
||||
rail = page.query_selector(".gn-slide-rail")
|
||||
if rail and rail.is_visible():
|
||||
log("SLIDER:", human_drag(page))
|
||||
time.sleep(2)
|
||||
if page.query_selector("input[name=re_yzm]"):
|
||||
vl_solve_image(page, ["img.yzm-img", "img[src*=captcha]", "img[src*=yzm]", "img[src*=code]"],
|
||||
out_png="login_captcha.png", tries=3, field="input[name=re_yzm]")
|
||||
page.evaluate("""() => {
|
||||
const b = document.querySelector('button.login-btn[type=submit]') ||
|
||||
[...document.querySelectorAll('button')].find(x=>/log ?in|sign in/i.test(x.innerText||''));
|
||||
if (b) b.click();
|
||||
}""")
|
||||
time.sleep(6)
|
||||
log("AFTER URL:", page.url)
|
||||
body = page.locator("body").inner_text()[:200].replace("\n", " | ")
|
||||
log("BODY:", body)
|
||||
ok = "/user" in page.url or "ID:" in page.locator("body").inner_text()[:3000]
|
||||
save_cookies(ctx)
|
||||
browser.close()
|
||||
log("LOGIN:", "OK" if ok else "CHECK-MANUALLY")
|
||||
return 0 if ok else 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,54 @@
|
||||
# mail_catcher — self-hosted catch-all MX
|
||||
|
||||
ForwardEmail (and most free catch-all relays) **denylist the whole `eu.cc` zone**,
|
||||
so `--mail fwd` does not deliver for these domains. This catcher replaces it with
|
||||
your own MX on any VPS with inbound port 25 open.
|
||||
|
||||
## How it works
|
||||
1. DNS: `A mail.<yourdomain> = VPS_IP`, `MX @ = mail.<yourdomain> (prio 5)`.
|
||||
2. `catcher.py` listens on `0.0.0.0:25`, accepts mail for **any address / any domain**.
|
||||
3. Each message is stored as `.eml` under `mail/` and relayed to your Gmail
|
||||
(SMTP_SSL 465, app password from `env.json`) with subject `[catch <rcpt>] <orig subject>`,
|
||||
so existing IMAP code-readers (`gname_core.imap_code`, dashboard inbox) see OTPs instantly.
|
||||
|
||||
## Deploy (Ubuntu 22.04+/Debian, root)
|
||||
```
|
||||
mkdir -p /root/mailcatch && cp catcher.py /root/mailcatch/
|
||||
pip3 install --break-system-packages aiosmtpd
|
||||
cat > /root/mailcatch/env.json <<'EOF'
|
||||
{"gm": "you@gmail.com", "gp": "your-gmail-app-password"}
|
||||
EOF
|
||||
chmod 600 /root/mailcatch/env.json
|
||||
# systemd unit:
|
||||
cat > /etc/systemd/system/mailcatch.service <<'EOF'
|
||||
[Unit]
|
||||
Description=Mail catch-all MX server
|
||||
After=network.target
|
||||
[Service]
|
||||
WorkingDirectory=/root/mailcatch
|
||||
ExecStart=/usr/bin/python3 /root/mailcatch/catcher.py
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload && systemctl enable --now mailcatch
|
||||
```
|
||||
|
||||
## Point your domains at it (from this toolkit)
|
||||
```
|
||||
python setup_dns.py yourdomain.eu.cc --a "mail=VPS_IP" --mx "@=mail.yourdomain.eu.cc:5"
|
||||
```
|
||||
Or one-command: `DNS_A_IP=VPS_IP python auto.py --domains 3 --mail dns`.
|
||||
|
||||
## Verify
|
||||
```
|
||||
# port open from the internet (not from ISPs that block 25, e.g. home lines):
|
||||
curl -s "https://check-host.net/check-tcp?host=VPS_IP:25&max_nodes=3" -H "Accept: application/json"
|
||||
# send a test to the VPS directly (bypasses DNS):
|
||||
python3 -c "import smtplib;s=smtplib.SMTP('VPS_IP',25);s.sendmail('t@t.t',['otp@test.yourdomain.eu.cc'],'Subject: t\r\n\r\nhi');s.quit()"
|
||||
journalctl -u mailcatch -n 5 # should log '(relayed)'
|
||||
```
|
||||
|
||||
Proven: gname `.eu.cc` domains → VPS MX → Gmail inbox, verification code visible in body
|
||||
(subject `[catch otp-...@domain]`), stored `.eml` on the box.
|
||||
@@ -0,0 +1,92 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Catch-all MX server for your own domains (self-hosted, ForwardEmail-free).
|
||||
|
||||
Runs on port 25, accepts mail for ANY address on ANY domain pointed at this box,
|
||||
stores the .eml under MAIL_DIR and relays a readable copy to a Gmail inbox
|
||||
(SMTP_SSL 465, app password) so OTP codes land where your IMAP readers look.
|
||||
|
||||
Deploy: see mail_catcher/README.md — systemd unit + env.json {gm, gp}.
|
||||
Env file format (JSON): {"gm": "you@gmail.com", "gp": "app-password"} # optional
|
||||
"""
|
||||
import asyncio, json, os, re, smtplib, ssl, time
|
||||
from email.mime.message import MIMEMessage
|
||||
from email.mime.text import MIMEText
|
||||
import email as eml
|
||||
from aiosmtpd.controller import Controller
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
MAIL_DIR = os.path.join(BASE, "mail")
|
||||
ENV_FILE = os.path.join(BASE, "env.json")
|
||||
os.makedirs(MAIL_DIR, exist_ok=True)
|
||||
|
||||
|
||||
def load_env():
|
||||
try:
|
||||
with open(ENV_FILE, encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
|
||||
def relay_to_gmail(rcpts, raw: bytes):
|
||||
env = load_env()
|
||||
gm, gp = env.get("gm", ""), env.get("gp", "")
|
||||
if not gm or not gp:
|
||||
return "no-relay-creds"
|
||||
try:
|
||||
orig = eml.message_from_bytes(raw)
|
||||
subj = str(orig.get("Subject", ""))[:120]
|
||||
frm = str(orig.get("From", ""))[:120]
|
||||
wrap = MIMEText(
|
||||
"Caught for: %s\nFrom: %s\nSubject: %s\nTime: %s\n\n----- ORIGINAL MESSAGE -----\n\n%s"
|
||||
% (", ".join(rcpts)[:300], frm, subj, time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
orig.as_string()[:60000]),
|
||||
"plain", "utf-8")
|
||||
wrap["Subject"] = "[catch %s] %s" % (rcpts[0][:60], subj)
|
||||
wrap["From"] = gm
|
||||
wrap["To"] = gm
|
||||
s = smtplib.SMTP_SSL("smtp.gmail.com", 465, timeout=45,
|
||||
context=ssl.create_default_context())
|
||||
s.login(gm, gp)
|
||||
s.sendmail(gm, [gm], wrap.as_string())
|
||||
s.quit()
|
||||
return "relayed"
|
||||
except Exception as e:
|
||||
return "relay-fail: %s %s" % (type(e).__name__, str(e)[:100])
|
||||
|
||||
|
||||
class CatchAll:
|
||||
async def handle_RCPT(self, server, session, envelope, address, rcpt_options):
|
||||
envelope.rcpt_tos.append(address)
|
||||
return "250 OK"
|
||||
|
||||
async def handle_DATA(self, server, session, envelope):
|
||||
rcpts = list(envelope.rcpt_tos)
|
||||
raw = envelope.content
|
||||
if isinstance(raw, str):
|
||||
raw = raw.encode("utf-8", "replace")
|
||||
ts = time.strftime("%Y%m%d-%H%M%S")
|
||||
safe = re.sub(r"[^A-Za-z0-9@._-]", "_", rcpts[0] if rcpts else "none")[:80]
|
||||
path = os.path.join(MAIL_DIR, "%s_%s.eml" % (ts, safe))
|
||||
with open(path, "wb") as f:
|
||||
f.write(raw)
|
||||
status = relay_to_gmail(rcpts, raw)
|
||||
print("[catch] %s -> %s (%s) %d bytes" % (envelope.mail_from, rcpts, status, len(raw)), flush=True)
|
||||
return "250 Message accepted for delivery"
|
||||
|
||||
|
||||
def main():
|
||||
host = os.environ.get("CATCH_HOST", "0.0.0.0")
|
||||
port = int(os.environ.get("CATCH_PORT", "25"))
|
||||
c = Controller(CatchAll(), hostname=host, port=port, server_hostname="mail.local")
|
||||
c.start()
|
||||
print("[catch] listening on %s:%d, maildir=%s" % (host, port, MAIL_DIR), flush=True)
|
||||
try:
|
||||
while True:
|
||||
time.sleep(3600)
|
||||
except KeyboardInterrupt:
|
||||
c.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Gname DNS automation via in-page /user_ym/jx_edit (A/MX/TXT/CNAME/NS records).
|
||||
|
||||
Handles operation protection (czyz) automatically: challenge -> email code
|
||||
(IMAP) -> /user_zh/aqbh_check -> retry.
|
||||
|
||||
Usage:
|
||||
python setup_dns.py DOMAIN --a mail=1.2.3.4 [--mx @=mail.DOMAIN:10] [--txt @=v=spf1...]
|
||||
python setup_dns.py DOMAIN --ns ns1.example.com,ns2.example.com
|
||||
Env: GM_EMAIL/GM_APPPW (czyz code), DNS_A_IP fallback for --a mail=<ip>
|
||||
"""
|
||||
import sys, os, json, time, argparse
|
||||
from playwright.sync_api import sync_playwright
|
||||
from gname_core import (SITE, log, mk_context, save_cookies, csrf, inpost,
|
||||
inpost_json, czyz_unlock, ensure_czyz_channel,
|
||||
aqbh_session_unlock)
|
||||
|
||||
IFRAME = SITE + "/user/iframe#/jie_info/ym=%s/dns=a.share-dns.com,b.share-dns.net"
|
||||
|
||||
_unlocked = False
|
||||
|
||||
def jx_edit(page, dom, rec, tag):
|
||||
"""rec = {zj, lx, jlz, mx}. Returns parsed json; auto-unlocks czyz once."""
|
||||
global _unlocked
|
||||
tok = csrf(page)
|
||||
body = {"ym": dom, "ttl": "600", "xl": "0", "jxid": "", "csrf_token": tok}
|
||||
body.update(rec)
|
||||
r = inpost_json(page, "/user_ym/jx_edit", body, tag)
|
||||
j = r if isinstance(r, dict) else {}
|
||||
data = j.get("data")
|
||||
if isinstance(data, dict) and (data.get("yxyz") or j.get("token")):
|
||||
gm = os.environ.get("GM_EMAIL", "")
|
||||
if czyz_unlock(page, j, gm):
|
||||
time.sleep(2)
|
||||
r = inpost_json(page, "/user_ym/jx_edit", body, tag + "r")
|
||||
elif j.get("code") == -101 and not _unlocked:
|
||||
# 'please set operation protection' with no challenge token:
|
||||
# unlock the whole session via email code (proven eucc30 flow)
|
||||
log("JX -101: session aqbh unlock via email code")
|
||||
_unlocked = aqbh_session_unlock(page)
|
||||
if _unlocked:
|
||||
time.sleep(2)
|
||||
r = inpost_json(page, "/user_ym/jx_edit", body, tag + "r2")
|
||||
return r
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("domain")
|
||||
ap.add_argument("--a", action="append", default=[], help="subdomain=IP")
|
||||
ap.add_argument("--mx", action="append", default=[], help="subdomain=host:prio")
|
||||
ap.add_argument("--txt", action="append", default=[], help="subdomain=value")
|
||||
ap.add_argument("--cname", action="append", default=[], help="subdomain=target")
|
||||
ap.add_argument("--ns", default="", help="ns1,ns2 - change nameservers")
|
||||
args = ap.parse_args()
|
||||
dom = args.domain
|
||||
|
||||
recs = []
|
||||
for s in args.a:
|
||||
zj, jlz = s.split("=", 1)
|
||||
recs.append({"zj": zj, "lx": "A", "jlz": jlz, "mx": 0})
|
||||
for s in args.mx:
|
||||
zj, rest = s.split("=", 1)
|
||||
jlz, _, prio = rest.partition(":")
|
||||
recs.append({"zj": zj, "lx": "MX", "jlz": jlz, "mx": int(prio or 10)})
|
||||
for s in args.txt:
|
||||
zj, jlz = s.split("=", 1)
|
||||
recs.append({"zj": zj, "lx": "TXT", "jlz": jlz, "mx": 0})
|
||||
for s in args.cname:
|
||||
zj, jlz = s.split("=", 1)
|
||||
recs.append({"zj": zj, "lx": "CNAME", "jlz": jlz, "mx": 0})
|
||||
if not recs and not args.ns:
|
||||
dip = os.environ.get("DNS_A_IP", "")
|
||||
if dip:
|
||||
recs = [{"zj": "mail", "lx": "A", "jlz": dip, "mx": 0},
|
||||
{"zj": "@", "lx": "MX", "jlz": "mail." + dom, "mx": 10}]
|
||||
else:
|
||||
log("nothing to do: pass --a/--mx/--txt/--ns or DNS_A_IP")
|
||||
return 1
|
||||
|
||||
with sync_playwright() as pw:
|
||||
browser, ctx = mk_context(pw)
|
||||
page = ctx.new_page()
|
||||
page.goto(IFRAME % dom, wait_until="domcontentloaded", timeout=60000)
|
||||
time.sleep(8)
|
||||
ensure_czyz_channel(page)
|
||||
|
||||
if args.ns:
|
||||
nsl = [x.strip() for x in args.ns.split(",") if x.strip()]
|
||||
r = inpost_json(page, "/user_ym/dns_edit", {"ym": dom, "dns[]": nsl, "csrf_token": csrf(page)}, "ns")
|
||||
log("NS dns_edit:", str(r)[:250])
|
||||
if str(r).find('"code":1') < 0 and str(r).find('"code":"1"') < 0:
|
||||
j = r if isinstance(r, dict) else {}
|
||||
data = j.get("data")
|
||||
if isinstance(data, dict) and (data.get("yxyz") or j.get("token")):
|
||||
czyz_unlock(page, j, os.environ.get("GM_EMAIL", ""))
|
||||
time.sleep(2)
|
||||
r = inpost_json(page, "/user_ym/dns_edit", {"ym": dom, "dns[]": nsl, "csrf_token": csrf(page)}, "nsr")
|
||||
log("NS retry:", str(r)[:250])
|
||||
|
||||
for i, rec in enumerate(recs):
|
||||
r = jx_edit(page, dom, rec, "jx%d" % i)
|
||||
log("JX %s %s=%s:" % (rec["lx"], rec["zj"], rec["jlz"][:40]), str(r)[:200])
|
||||
time.sleep(2)
|
||||
|
||||
r = inpost_json(page, "/user_ym/get_jx_list", {"ym": dom, "csrf_token": csrf(page)}, "lst")
|
||||
recs_now = (r or {}).get("data") if isinstance(r, dict) else None
|
||||
if isinstance(recs_now, list):
|
||||
for x in recs_now:
|
||||
log("RECORDS:", x.get("zjt"), x.get("lx"), str(x.get("jxz"))[:60], "prio", x.get("mx"))
|
||||
else:
|
||||
log("RECORDS:", str(r)[:600])
|
||||
save_cookies(ctx)
|
||||
browser.close()
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user