220 lines
8.2 KiB
Python
220 lines
8.2 KiB
Python
"""Фарм Runtime только через email-канал (без Google OAuth).
|
|
|
|
python wr_email_farm.py 3 # 3 следующих gmail-алиаса
|
|
python wr_email_farm.py 3 20 # начать с +wr20
|
|
python wr_email_farm.py list.txt 5 # файл email:password построчно
|
|
|
|
Что делает на каждый ящик: свежий контекст Camoufox → /sign-in → Continue with email →
|
|
адрес → Turnstile проходит живьём → письмо читается на VPS → код (или ссылка) → /account →
|
|
POST /api/account/keys → живой GET /v1/usage. Результат в wr_email_accounts.jsonl.
|
|
|
|
Питфолы, проверенные на практике:
|
|
* gmail-алиас: письмо доходит, аккаунт создаётся, юнит чаще 0;
|
|
* t-online.de: их MTA письма Runtime не принимает вообще (0 попаданий в INBOX и Spam);
|
|
* VPN/датацентр/мобильный прокси: Runtime не отправляет письмо (их правило прямо это запрещает);
|
|
* параллельные прогоны на одном профиле Chrome роняют CDP (EPIPE) — только последовательно.
|
|
"""
|
|
import json
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
import urllib.request
|
|
|
|
from camoufox.sync_api import Camoufox
|
|
|
|
OUT = r"C:\Users\User\tmp\wr_email_accounts.jsonl"
|
|
FAIL = r"C:\Users\User\tmp\wr_email_fail.json"
|
|
VPS = "root@144.31.34.147"
|
|
GMAIL_BASE = os.environ.get("WR_GMAIL", "baradok609@gmail.com")
|
|
GMAIL_TAG = os.environ.get("WR_TAG", "wr")
|
|
PROXY = os.environ.get("WR_PROXY", "")
|
|
|
|
|
|
def log(*a):
|
|
print(*a, flush=True)
|
|
|
|
|
|
def ssh(cmd, timeout=220):
|
|
r = subprocess.run(["ssh", "-o", "ConnectTimeout=15", "-o", "StrictHostKeyChecking=no", VPS, cmd],
|
|
capture_output=True, text=True, timeout=timeout)
|
|
return (r.stdout or "") + (("ERR:" + r.stderr[-150:]) if r.stderr.strip() else "")
|
|
|
|
|
|
def read_pool(path):
|
|
rows = []
|
|
for line in open(path, encoding="utf-8", errors="ignore"):
|
|
line = line.strip()
|
|
if not line or line.startswith("#") or "@" not in line:
|
|
continue
|
|
if ":" in line:
|
|
em, pw = line.split(":", 1)
|
|
else:
|
|
em, pw = line, ""
|
|
rows.append((em.strip(), pw.strip()))
|
|
return rows
|
|
|
|
|
|
def pool_lookup(addr):
|
|
for path in (r"C:\Users\User\Desktop\avtoreg\working_mails.txt",):
|
|
if not os.path.exists(path):
|
|
continue
|
|
for em, pw in read_pool(path):
|
|
if em.lower() == addr.lower():
|
|
return pw
|
|
return ""
|
|
|
|
|
|
def fetch_mail(addr, tries=3):
|
|
for i in range(tries):
|
|
if addr.lower().endswith("@gmail.com"):
|
|
alias = addr.split("@")[0].split("+")[-1]
|
|
out = ssh("python3 /root/wr_link.py '%s'" % alias)
|
|
else:
|
|
pw = pool_lookup(addr)
|
|
out = ssh("python3 /root/ton_code.py '%s' '%s' withruntime 0 140" % (addr, pw), 200)
|
|
out_s = out.strip()[:320].replace("\n", " | ")
|
|
log(" mail try%d: %s" % (i + 1, out_s))
|
|
code = None
|
|
m = re.search(r"CODES \[(?:'|\")?(\d{6})", out) or re.search(r"CODE=(\d{6})", out) or re.search(r"\b(\d{6})\b", out)
|
|
if m:
|
|
code = m.group(1)
|
|
link = None
|
|
m = re.search(r"OPEN=(\S+)", out) or re.search(r"(https://withruntime\.com/\S+)", out)
|
|
if m:
|
|
link = m.group(1)
|
|
if code or link:
|
|
return code, link
|
|
time.sleep(10)
|
|
return None, None
|
|
|
|
|
|
def usage(key):
|
|
try:
|
|
req = urllib.request.Request("https://api.withruntime.com/v1/usage",
|
|
headers={"Authorization": "Bearer " + key})
|
|
d = json.loads(urllib.request.urlopen(req, timeout=25).read())
|
|
return {a["pool"]: a["left"] for a in d.get("allowances", [])}
|
|
except Exception as exc:
|
|
return {"err": str(exc)[:80]}
|
|
|
|
|
|
def run_one(browser, addr):
|
|
ctx = browser.new_context()
|
|
pg = ctx.new_page()
|
|
pg.set_default_timeout(45000)
|
|
try:
|
|
pg.goto("https://withruntime.com/sign-in", wait_until="domcontentloaded")
|
|
pg.wait_for_timeout(2500)
|
|
pg.get_by_text("Continue with email", exact=False).first.click()
|
|
pg.wait_for_timeout(1500)
|
|
el = pg.locator("input#cloud-email, input[type=email]").first
|
|
el.click()
|
|
el.type(addr, delay=55)
|
|
pg.wait_for_timeout(300)
|
|
pg.locator("button[type=submit]").first.click()
|
|
|
|
for _ in range(12):
|
|
pg.wait_for_timeout(2000)
|
|
if pg.locator("input#cloud-code").count():
|
|
break
|
|
if not pg.locator("input#cloud-code").count():
|
|
log(" no code field -> mail not sent")
|
|
return {"alias": addr, "status": "NO_FIELD"}
|
|
|
|
code, link = fetch_mail(addr)
|
|
signed = False
|
|
if code:
|
|
cel = pg.locator("input#cloud-code").first
|
|
cel.click()
|
|
cel.type(code, delay=90)
|
|
pg.wait_for_timeout(400)
|
|
pg.keyboard.press("Enter")
|
|
pg.wait_for_timeout(4500)
|
|
if not any(k in pg.url for k in ("/account", "/sandbox")):
|
|
try:
|
|
pg.locator("button[type=submit]").first.click()
|
|
except Exception:
|
|
pass
|
|
pg.wait_for_timeout(4000)
|
|
signed = any(k in pg.url for k in ("/account", "/sandbox"))
|
|
|
|
if not signed and link:
|
|
pg.goto(link, wait_until="domcontentloaded")
|
|
pg.wait_for_timeout(6000)
|
|
signed = any(k in pg.url for k in ("/account", "/sandbox"))
|
|
log(" url:", pg.url)
|
|
if not signed:
|
|
return {"alias": addr, "status": "NOT_SIGNED"}
|
|
|
|
res = pg.evaluate("""async () => {
|
|
const r = await fetch('/api/account/keys', {method:'POST', headers:{'Content-Type':'application/json'},
|
|
credentials:'include', body: JSON.stringify({action:'create', label:'email', access:'full'})});
|
|
return {s: r.status, t: (await r.text()).slice(0, 2000)};
|
|
}""")
|
|
key = None
|
|
try:
|
|
d = json.loads(res["t"])
|
|
c = d.get("credential") or {}
|
|
key = c.get("plaintext") or c.get("key") or d.get("key")
|
|
except Exception:
|
|
pass
|
|
if not key:
|
|
return {"alias": addr, "status": "NO_KEY", "raw": str(res)[:200]}
|
|
u = usage(key)
|
|
log(" unit:", u)
|
|
return {"alias": addr, "status": "OK", "key": key, "ts": int(time.time()), "usage": u}
|
|
except Exception as exc:
|
|
log(" err:", str(exc)[:200])
|
|
return {"alias": addr, "status": "ERR", "err": str(exc)[:200]}
|
|
finally:
|
|
try:
|
|
ctx.close()
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def main():
|
|
arg = sys.argv[1] if len(sys.argv) > 1 else "2"
|
|
count = int(sys.argv[2]) if len(sys.argv) > 2 else 1
|
|
if arg.endswith(".txt") and os.path.exists(arg):
|
|
todo = [e for e, _ in read_pool(arg)][:count]
|
|
else:
|
|
n = int(arg)
|
|
start = int(sys.argv[2]) if len(sys.argv) > 2 else 20
|
|
todo = ["%s+%s%d@gmail.com" % (GMAIL_BASE.split("@")[0], GMAIL_TAG, start + i) for i in range(n)]
|
|
|
|
fails = {}
|
|
if os.path.exists(FAIL):
|
|
try:
|
|
fails = json.load(open(FAIL, encoding="utf-8"))
|
|
except Exception:
|
|
fails = {}
|
|
todo = [a for a in todo if a not in fails]
|
|
log("queue:", todo)
|
|
|
|
cfg = {"headless": True, "humanize": True, "os": ["windows"], "geoip": False}
|
|
if PROXY:
|
|
cfg["proxy"] = {"server": PROXY}
|
|
cfg["geoip"] = True
|
|
|
|
done = 0
|
|
with Camoufox(**cfg) as browser:
|
|
for addr in todo:
|
|
log("== %s" % addr)
|
|
rec = run_one(browser, addr)
|
|
log(" ->", rec.get("status"), rec.get("usage", ""))
|
|
with open(OUT, "a", encoding="utf-8") as fh:
|
|
fh.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
|
if rec.get("status") != "OK":
|
|
fails[addr] = rec.get("status")
|
|
json.dump(fails, open(FAIL, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
|
|
else:
|
|
done += 1
|
|
time.sleep(6)
|
|
log("DONE ok=%d of %d" % (done, len(todo)))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |