uncensoredlabs.dev autoreg: Turnstile signup via SOCKS5 egress, API key farm
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env python3
|
||||
"""uncensoredlabs.dev account farm.
|
||||
|
||||
Signup без почты/пароля: Turnstile(action=signup) -> access-key -> API-ключ ul_...
|
||||
Один аккаунт = один профиль Chrome. Прокси — SOCKS5, один аккаунт на egress.
|
||||
|
||||
Usage:
|
||||
python uc_labs_autoreg.py --count 5
|
||||
python uc_labs_autoreg.py --count 3 --proxies socks.txt
|
||||
UL_PROXIES='socks5://127.0.0.1:1088' python uc_labs_autoreg.py --count 1
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
SITE = "https://uncensoredlabs.dev"
|
||||
SITEKEY = "0x4AAAAAAFvIxFn7-3_j5sez" # из window.__data лендинга / HTML /signup
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def find_chrome():
|
||||
env = os.environ.get("CHROME_EXE")
|
||||
if env and os.path.exists(env):
|
||||
return env
|
||||
local = os.environ.get("LOCALAPPDATA", "")
|
||||
for c in (
|
||||
r"C:/Program Files/Google/Chrome/Application/chrome.exe",
|
||||
r"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
||||
os.path.join(local, "Google/Chrome/Application/chrome.exe") if local else "",
|
||||
):
|
||||
if c and os.path.exists(c):
|
||||
return c
|
||||
return None
|
||||
|
||||
|
||||
def log(*a):
|
||||
s = " ".join(str(x) for x in a)
|
||||
try:
|
||||
print(s, flush=True)
|
||||
except Exception:
|
||||
print(s.encode("ascii", "replace").decode(), flush=True)
|
||||
|
||||
|
||||
def parse_proxy(url):
|
||||
"""'socks5://user:pass@host:port' -> playwright proxy dict."""
|
||||
if "://" not in url:
|
||||
url = "http://" + url
|
||||
u = urllib.parse.urlparse(url)
|
||||
d = {"server": f"{u.scheme}://{u.hostname}:{u.port}"}
|
||||
if u.username:
|
||||
d["username"] = urllib.parse.unquote(u.username)
|
||||
if u.password:
|
||||
d["password"] = urllib.parse.unquote(u.password)
|
||||
return d
|
||||
|
||||
|
||||
def load_proxies(path=None):
|
||||
env = os.environ.get("UL_PROXIES", "").strip()
|
||||
if env:
|
||||
return [x.strip() for x in env.split(",") if x.strip()]
|
||||
if path and os.path.exists(path):
|
||||
out = []
|
||||
for line in open(path, encoding="utf-8", errors="replace"):
|
||||
line = line.strip()
|
||||
if line and not line.startswith("#"):
|
||||
out.append(line)
|
||||
return out
|
||||
return []
|
||||
|
||||
|
||||
def egress_ip(proxy_url):
|
||||
try:
|
||||
import requests
|
||||
if proxy_url.startswith("socks"):
|
||||
return requests.get("https://api.ipify.org", timeout=15,
|
||||
proxies={"http": proxy_url, "https": proxy_url}).text.strip()
|
||||
return requests.get("https://api.ipify.org", timeout=15,
|
||||
proxies={"http": proxy_url, "https": proxy_url}).text.strip()
|
||||
except Exception:
|
||||
return "?"
|
||||
|
||||
|
||||
def farm_one(p, idx, proxy_url, out_path, exe, profiles_dir):
|
||||
prof = os.path.join(profiles_dir, f"p{idx}")
|
||||
ctx = p.chromium.launch_persistent_context(
|
||||
prof,
|
||||
executable_path=exe,
|
||||
headless=False,
|
||||
proxy=parse_proxy(proxy_url) if proxy_url else None,
|
||||
ignore_default_args=["--enable-automation"],
|
||||
args=["--disable-blink-features=AutomationControlled", "--no-first-run",
|
||||
"--no-default-browser-check", "--window-size=1100,820"],
|
||||
viewport={"width": 1100, "height": 800},
|
||||
)
|
||||
try:
|
||||
page = ctx.pages[0] if ctx.pages else ctx.new_page()
|
||||
page.set_default_timeout(30000)
|
||||
# commit: domcontentloaded может не наступить, если прокси режет часть ресурсов
|
||||
page.goto(SITE + "/signup", wait_until="commit", timeout=45000)
|
||||
time.sleep(9)
|
||||
|
||||
tok = ""
|
||||
for _ in range(12):
|
||||
try:
|
||||
tok = page.evaluate("() => {try { return (window.turnstile && window.turnstile.getResponse && window.turnstile.getResponse()) || ''; } catch(e) { return ''; }}")
|
||||
except Exception:
|
||||
tok = ""
|
||||
if tok:
|
||||
break
|
||||
time.sleep(2)
|
||||
|
||||
if not tok:
|
||||
page.evaluate("""(sk) => {
|
||||
window.__t = ''; window.__te = '';
|
||||
let d = document.getElementById('ulk');
|
||||
if (!d) { d = document.createElement('div'); d.id = 'ulk';
|
||||
d.style.cssText = 'position:fixed;right:0;bottom:0;z-index:99999'; document.body.appendChild(d); }
|
||||
const go = () => { try { window.turnstile.render('#ulk', {sitekey: sk, action: 'signup',
|
||||
callback: t => { window.__t = t; }, 'error-callback': e => { window.__te = String(e); } }); }
|
||||
catch(e) { window.__te = e.message; } };
|
||||
if (window.turnstile) go(); else { const s = document.createElement('script');
|
||||
s.src = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit&onload=__on';
|
||||
window.__on = go; document.head.appendChild(s); }
|
||||
return 'ok'; }""", SITEKEY)
|
||||
for _ in range(15):
|
||||
time.sleep(2)
|
||||
r = page.evaluate("() => ({t: window.__t||'', e: window.__te||''})")
|
||||
if r.get("t"):
|
||||
tok = r["t"]
|
||||
break
|
||||
if r.get("e"):
|
||||
log(idx, "turnstile error:", r["e"])
|
||||
break
|
||||
if not tok:
|
||||
log(idx, "no turnstile token")
|
||||
return None
|
||||
|
||||
signup = page.evaluate("""async (tk) => {
|
||||
const r = await fetch('/api/auth/sign-up/access-key', {
|
||||
method: 'POST', credentials: 'include',
|
||||
headers: {'Content-Type': 'application/json', 'X-Turnstile-Token': tk},
|
||||
body: JSON.stringify({accepted: true})});
|
||||
return r.status + ' ' + (await r.text()).slice(0, 300); }""", tok)
|
||||
log(idx, "signup:", signup[:110])
|
||||
if not signup.startswith("200"):
|
||||
return None
|
||||
|
||||
acc = ""
|
||||
try:
|
||||
acc = json.loads(signup.split(" ", 1)[1]).get("key", "")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
keyres = page.evaluate("""async () => {
|
||||
const r = await fetch('/api/account/keys', {
|
||||
method: 'POST', credentials: 'include',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({name: 'k' + Date.now()})});
|
||||
return r.status + ' ' + (await r.text()).slice(0, 600); }""")
|
||||
secret = ""
|
||||
if keyres.startswith("201"):
|
||||
try:
|
||||
secret = json.loads(keyres.split(" ", 1)[1]).get("secret", "")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
me = page.evaluate("""async () => {
|
||||
const r = await fetch('/api/account/me', {credentials: 'include'});
|
||||
return r.status + ' ' + (await r.text()).slice(0, 500); }""")
|
||||
bal = ""
|
||||
try:
|
||||
bal = json.loads(me.split(" ", 1)[1]).get("wallet", {}).get("balance_nano", "")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cookies = {c["name"]: c["value"] for c in ctx.cookies()}
|
||||
rec = {
|
||||
"idx": idx,
|
||||
"acc_number": acc,
|
||||
"secret": secret,
|
||||
"balance_nano": bal,
|
||||
"ip": egress_ip(proxy_url) if proxy_url else "direct",
|
||||
"proxy": (proxy_url.split("@")[-1] if proxy_url else ""),
|
||||
"session": cookies.get("__Secure-better-auth.session_token", ""),
|
||||
"ts": time.strftime("%Y-%m-%dT%H:%M:%S"),
|
||||
}
|
||||
with open(out_path, "a", encoding="utf-8") as f:
|
||||
f.write(json.dumps(rec) + "\n")
|
||||
log(idx, "OK", (secret[:14] + "...") if secret else "NO KEY", "balance", bal)
|
||||
return rec
|
||||
finally:
|
||||
try:
|
||||
ctx.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="uncensoredlabs.dev autoreg")
|
||||
ap.add_argument("--count", type=int, default=1, help="сколько аккаунтов")
|
||||
ap.add_argument("--start", type=int, default=1, help="стартовый индекс профиля")
|
||||
ap.add_argument("--proxies", help="файл со списком прокси (SOCKS5)")
|
||||
ap.add_argument("--out", default=os.path.join(HERE, "bank.jsonl"), help="куда писать результат")
|
||||
ap.add_argument("--profiles", default=os.path.join(HERE, "profiles"), help="каталог профилей Chrome")
|
||||
args = ap.parse_args()
|
||||
|
||||
exe = find_chrome()
|
||||
if not exe:
|
||||
log("Chrome не найден: задайте CHROME_EXE")
|
||||
return 2
|
||||
os.makedirs(args.profiles, exist_ok=True)
|
||||
proxies = load_proxies(args.proxies)
|
||||
if args.count > 1 and not proxies:
|
||||
log("внимание: без прокси лимит 5 аккаунтов на IP в 24ч")
|
||||
|
||||
p = sync_playwright().start()
|
||||
good = 0
|
||||
for i in range(args.count):
|
||||
purl = proxies[i % len(proxies)] if proxies else ""
|
||||
try:
|
||||
r = farm_one(p, args.start + i, purl, args.out, exe, args.profiles)
|
||||
if r and r.get("secret"):
|
||||
good += 1
|
||||
except Exception as e:
|
||||
log(args.start + i, "ERR", str(e)[:140])
|
||||
time.sleep(2)
|
||||
p.stop()
|
||||
log(f"готово: {good} из {args.count}, bank={args.out}")
|
||||
return 0 if good else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user