docs: verified unit gating + camoufox turnstile
This commit is contained in:
@@ -1,156 +1,156 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""wr_one.py <email> [mailpass] — рега/вход Runtime одним аккаунтом + API-ключ.
|
||||
Код читается: gmail -> VPS wr_code2.py ; t-online -> VPS tcode2.py.
|
||||
Результат дописывается в C:/Users/User/tmp/wr_accounts.jsonl
|
||||
"""
|
||||
import json, os, re, subprocess, sys, time
|
||||
|
||||
sys.path.insert(0, r"C:/Users/User/tmp")
|
||||
import wr_reg
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE = "https://withruntime.com"
|
||||
OUT = r"C:\Users\User\tmp\wr_accounts.jsonl"
|
||||
VPS = "root@144.31.34.147"
|
||||
|
||||
|
||||
def log(*a):
|
||||
print(*a, flush=True)
|
||||
|
||||
|
||||
def ssh(cmd, timeout=180):
|
||||
r = subprocess.run(["ssh", "-o", "ConnectTimeout=15", "-o", "StrictHostKeyChecking=no", VPS, cmd],
|
||||
capture_output=True, text=True, timeout=timeout)
|
||||
return (r.stdout or "") + (("\nERR:" + r.stderr[-200:]) if r.stderr.strip() else "")
|
||||
|
||||
|
||||
def get_code(email, mailpass, min_ts, timeout=120):
|
||||
if email.lower().endswith("@gmail.com"):
|
||||
out = ssh("python3 /root/wr_code2.py '%s' %d %d" % (email, min_ts, timeout), timeout + 60)
|
||||
else:
|
||||
# tcode2.py <addr> <pw> code <min_uid> <timeout>; min_uid берём по времени -> используем UID 0 и фильтр по свежести
|
||||
out = ssh("python3 /root/ton_code.py '%s' '%s' withruntime %d %d" % (email, mailpass, max(0, min_ts - 60), timeout), timeout + 90)
|
||||
log(" code_raw:", out.strip()[:160])
|
||||
m = re.search(r"CODE=([0-9]{6})|\b([0-9]{6})\b", out)
|
||||
if m:
|
||||
return m.group(1) or m.group(2)
|
||||
return None
|
||||
|
||||
|
||||
def sign_in(pg, ctx, email):
|
||||
pg.goto(BASE + "/sign-in", wait_until="domcontentloaded")
|
||||
time.sleep(2.5)
|
||||
if "sign-in" not in pg.url:
|
||||
log(" already signed in:", pg.url)
|
||||
return True
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").click(no_wait_after=True, timeout=8000)
|
||||
except Exception:
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").evaluate("e=>e.click()")
|
||||
except Exception as e:
|
||||
log(" no email btn", str(e)[:80])
|
||||
time.sleep(2)
|
||||
el = pg.locator("input#cloud-email")
|
||||
el.click()
|
||||
el.type(email, delay=30)
|
||||
time.sleep(1.5)
|
||||
for i in range(40):
|
||||
b = pg.get_by_role("button", name=re.compile("Continue with email|Sending", re.I))
|
||||
if b.count():
|
||||
if not b.first.get_attribute("disabled") and "Sending" not in b.first.inner_text():
|
||||
break
|
||||
time.sleep(1)
|
||||
min_ts = int(time.time()) - 5
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").click(no_wait_after=True, timeout=10000)
|
||||
except Exception:
|
||||
pg.get_by_role("button", name="Continue with email").evaluate("e=>e.click()")
|
||||
log(" code requested")
|
||||
return "wait_code"
|
||||
|
||||
|
||||
def submit_code(pg, code):
|
||||
for i in range(15):
|
||||
if pg.locator("input#cloud-code").count():
|
||||
break
|
||||
time.sleep(1)
|
||||
if not pg.locator("input#cloud-code").count():
|
||||
log(" no code field:", re.sub(r"\s+", " ", pg.inner_text("body"))[:200])
|
||||
return False
|
||||
ce = pg.locator("input#cloud-code")
|
||||
ce.click()
|
||||
ce.type(code, delay=80)
|
||||
time.sleep(0.6)
|
||||
try:
|
||||
pg.get_by_role("button", name=re.compile("Continue|Sign in|Verify", re.I)).first.click(no_wait_after=True, timeout=8000)
|
||||
except Exception:
|
||||
pg.keyboard.press("Enter")
|
||||
for i in range(20):
|
||||
time.sleep(2)
|
||||
if "sign-in" not in pg.url:
|
||||
break
|
||||
body = pg.inner_text("body")
|
||||
if "sign-in" in pg.url or "Check your email" in body:
|
||||
log(" FAIL body:", re.sub(r"\s+", " ", body)[:220])
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def make_key(pg, label="farm"):
|
||||
js = """async (label) => {
|
||||
const r = await fetch('/api/account/keys', {method:'POST', headers:{'Content-Type':'application/json'},
|
||||
credentials:'include', body: JSON.stringify({action:'create', label:label, access:'full'})});
|
||||
return {s: r.status, t: await r.text()};
|
||||
}"""
|
||||
try:
|
||||
res = pg.evaluate(js, label)
|
||||
except Exception as e:
|
||||
return None, "evaluate: " + str(e)[:150]
|
||||
if res.get("s") != 200:
|
||||
return None, str(res)
|
||||
try:
|
||||
d = json.loads(res["t"])
|
||||
except Exception:
|
||||
return None, res["t"][:300]
|
||||
cred = d.get("credential") or {}
|
||||
key = cred.get("plaintext") or cred.get("key") or cred.get("secret") or d.get("key")
|
||||
return (key, None) if key else (None, json.dumps(d)[:400])
|
||||
|
||||
|
||||
def main():
|
||||
email = sys.argv[1]
|
||||
mailpass = sys.argv[2] if len(sys.argv) > 2 else ""
|
||||
min_ts = int(sys.argv[3]) if len(sys.argv) > 3 else int(time.time()) - 5
|
||||
with sync_playwright() as p:
|
||||
br, ctx, pg = wr_reg.connect(p)
|
||||
ctx.clear_cookies()
|
||||
st = sign_in(pg, ctx, email)
|
||||
if st is not True:
|
||||
code = get_code(email, mailpass, min_ts, 130)
|
||||
if not code:
|
||||
log("RESULT NO_CODE")
|
||||
return
|
||||
log(" code:", code)
|
||||
if not submit_code(pg, code):
|
||||
log("RESULT CODE_REJECTED")
|
||||
return
|
||||
log(" signed | url", pg.url[:70])
|
||||
try:
|
||||
c = ctx.request.get(BASE + "/api/account/console", timeout=30000).json()
|
||||
log(" trial:", json.dumps(c.get("trial"))[:200])
|
||||
except Exception as e:
|
||||
c = {}
|
||||
log(" console err", str(e)[:80])
|
||||
key, err = make_key(pg)
|
||||
if not key:
|
||||
log("RESULT KEY_FAIL", str(err)[:200])
|
||||
return
|
||||
rec = {"alias": email, "key": key, "ts": int(time.time()), "trial": (c or {}).get("trial")}
|
||||
with open(OUT, "a", encoding="utf-8") as f:
|
||||
f.write(json.dumps(rec) + "\n")
|
||||
log("RESULT OK", key[:20] + "...", "| trial:", json.dumps((c or {}).get("trial"))[:120])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# -*- coding: utf-8 -*-
|
||||
"""wr_one.py <email> [mailpass] — рега/вход Runtime одним аккаунтом + API-ключ.
|
||||
Код читается: gmail -> VPS wr_code2.py ; t-online -> VPS tcode2.py.
|
||||
Результат дописывается в C:/Users/User/tmp/wr_accounts.jsonl
|
||||
"""
|
||||
import json, os, re, subprocess, sys, time
|
||||
|
||||
sys.path.insert(0, r"C:/Users/User/tmp")
|
||||
import wr_reg
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE = "https://withruntime.com"
|
||||
OUT = r"C:\Users\User\tmp\wr_accounts.jsonl"
|
||||
VPS = "root@144.31.34.147"
|
||||
|
||||
|
||||
def log(*a):
|
||||
print(*a, flush=True)
|
||||
|
||||
|
||||
def ssh(cmd, timeout=180):
|
||||
r = subprocess.run(["ssh", "-o", "ConnectTimeout=15", "-o", "StrictHostKeyChecking=no", VPS, cmd],
|
||||
capture_output=True, text=True, timeout=timeout)
|
||||
return (r.stdout or "") + (("\nERR:" + r.stderr[-200:]) if r.stderr.strip() else "")
|
||||
|
||||
|
||||
def get_code(email, mailpass, min_ts, timeout=120):
|
||||
if email.lower().endswith("@gmail.com"):
|
||||
out = ssh("python3 /root/wr_code2.py '%s' %d %d" % (email, min_ts, timeout), timeout + 60)
|
||||
else:
|
||||
# tcode2.py <addr> <pw> code <min_uid> <timeout>; min_uid берём по времени -> используем UID 0 и фильтр по свежести
|
||||
out = ssh("python3 /root/ton_code.py '%s' '%s' withruntime %d %d" % (email, mailpass, max(0, min_ts - 60), timeout), timeout + 90)
|
||||
log(" code_raw:", out.strip()[:160])
|
||||
m = re.search(r"CODE=([0-9]{6})|\b([0-9]{6})\b", out)
|
||||
if m:
|
||||
return m.group(1) or m.group(2)
|
||||
return None
|
||||
|
||||
|
||||
def sign_in(pg, ctx, email):
|
||||
pg.goto(BASE + "/sign-in", wait_until="domcontentloaded")
|
||||
time.sleep(2.5)
|
||||
if "sign-in" not in pg.url:
|
||||
log(" already signed in:", pg.url)
|
||||
return True
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").click(no_wait_after=True, timeout=8000)
|
||||
except Exception:
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").evaluate("e=>e.click()")
|
||||
except Exception as e:
|
||||
log(" no email btn", str(e)[:80])
|
||||
time.sleep(2)
|
||||
el = pg.locator("input#cloud-email")
|
||||
el.click()
|
||||
el.type(email, delay=30)
|
||||
time.sleep(1.5)
|
||||
for i in range(40):
|
||||
b = pg.get_by_role("button", name=re.compile("Continue with email|Sending", re.I))
|
||||
if b.count():
|
||||
if not b.first.get_attribute("disabled") and "Sending" not in b.first.inner_text():
|
||||
break
|
||||
time.sleep(1)
|
||||
min_ts = int(time.time()) - 5
|
||||
try:
|
||||
pg.get_by_role("button", name="Continue with email").click(no_wait_after=True, timeout=10000)
|
||||
except Exception:
|
||||
pg.get_by_role("button", name="Continue with email").evaluate("e=>e.click()")
|
||||
log(" code requested")
|
||||
return "wait_code"
|
||||
|
||||
|
||||
def submit_code(pg, code):
|
||||
for i in range(15):
|
||||
if pg.locator("input#cloud-code").count():
|
||||
break
|
||||
time.sleep(1)
|
||||
if not pg.locator("input#cloud-code").count():
|
||||
log(" no code field:", re.sub(r"\s+", " ", pg.inner_text("body"))[:200])
|
||||
return False
|
||||
ce = pg.locator("input#cloud-code")
|
||||
ce.click()
|
||||
ce.type(code, delay=80)
|
||||
time.sleep(0.6)
|
||||
try:
|
||||
pg.get_by_role("button", name=re.compile("Continue|Sign in|Verify", re.I)).first.click(no_wait_after=True, timeout=8000)
|
||||
except Exception:
|
||||
pg.keyboard.press("Enter")
|
||||
for i in range(20):
|
||||
time.sleep(2)
|
||||
if "sign-in" not in pg.url:
|
||||
break
|
||||
body = pg.inner_text("body")
|
||||
if "sign-in" in pg.url or "Check your email" in body:
|
||||
log(" FAIL body:", re.sub(r"\s+", " ", body)[:220])
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def make_key(pg, label="farm"):
|
||||
js = """async (label) => {
|
||||
const r = await fetch('/api/account/keys', {method:'POST', headers:{'Content-Type':'application/json'},
|
||||
credentials:'include', body: JSON.stringify({action:'create', label:label, access:'full'})});
|
||||
return {s: r.status, t: await r.text()};
|
||||
}"""
|
||||
try:
|
||||
res = pg.evaluate(js, label)
|
||||
except Exception as e:
|
||||
return None, "evaluate: " + str(e)[:150]
|
||||
if res.get("s") != 200:
|
||||
return None, str(res)
|
||||
try:
|
||||
d = json.loads(res["t"])
|
||||
except Exception:
|
||||
return None, res["t"][:300]
|
||||
cred = d.get("credential") or {}
|
||||
key = cred.get("plaintext") or cred.get("key") or cred.get("secret") or d.get("key")
|
||||
return (key, None) if key else (None, json.dumps(d)[:400])
|
||||
|
||||
|
||||
def main():
|
||||
email = sys.argv[1]
|
||||
mailpass = sys.argv[2] if len(sys.argv) > 2 else ""
|
||||
min_ts = int(sys.argv[3]) if len(sys.argv) > 3 else int(time.time()) - 5
|
||||
with sync_playwright() as p:
|
||||
br, ctx, pg = wr_reg.connect(p)
|
||||
ctx.clear_cookies()
|
||||
st = sign_in(pg, ctx, email)
|
||||
if st is not True:
|
||||
code = get_code(email, mailpass, min_ts, 130)
|
||||
if not code:
|
||||
log("RESULT NO_CODE")
|
||||
return
|
||||
log(" code:", code)
|
||||
if not submit_code(pg, code):
|
||||
log("RESULT CODE_REJECTED")
|
||||
return
|
||||
log(" signed | url", pg.url[:70])
|
||||
try:
|
||||
c = ctx.request.get(BASE + "/api/account/console", timeout=30000).json()
|
||||
log(" trial:", json.dumps(c.get("trial"))[:200])
|
||||
except Exception as e:
|
||||
c = {}
|
||||
log(" console err", str(e)[:80])
|
||||
key, err = make_key(pg)
|
||||
if not key:
|
||||
log("RESULT KEY_FAIL", str(err)[:200])
|
||||
return
|
||||
rec = {"alias": email, "key": key, "ts": int(time.time()), "trial": (c or {}).get("trial")}
|
||||
with open(OUT, "a", encoding="utf-8") as f:
|
||||
f.write(json.dumps(rec) + "\n")
|
||||
log("RESULT OK", key[:20] + "...", "| trial:", json.dumps((c or {}).get("trial"))[:120])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user