Files
autoreg-skills-max/skills/baaaai-autoreg/scripts/baaaai_api_reg.py

102 lines
3.7 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Baaaai.com API-only auto-reg using 2captcha for Turnstile.
REQUIRES: working 2captcha key + non-blocked IP (residential proxy or local machine).
"""
import curl_cffi.requests as curl
import requests
import json
import re
import time
import random
import string
from pathlib import Path
CAPTCHA_KEY = "YOUR_2CAPTCHA_KEY_HERE"
BASE_URL = "https://baaaai.com"
ACCOUNTS_FILE = Path.home() / "Desktop" / "baaaai_accounts.json"
EMAILS_FILE = Path.home() / "Downloads" / "Telegram Desktop" / "working_mails.txt"
def get_sitekey():
s = curl.Session(impersonate="chrome124")
r = s.get(f"{BASE_URL}/register", timeout=15)
html = r.text
for pattern in [r'0x4AAAAA\w{30,}', r'sitekey["\s:=]+["\x27]([^"\x27]+)["\x27]', r'data-sitekey=["\x27]([^"\x27]+)["\x27]', r'turnstile_site_key["\s:=]+["\x27]([^"\x27]+)["\x27]']:
match = re.search(pattern, html, re.IGNORECASE)
if match:
return match.group(1) if match.lastindex else match.group(0)
return None
def solve_turnstile(sitekey, pageurl=f"{BASE_URL}/register"):
r = requests.post("https://2captcha.com/in.php", data={"key": CAPTCHA_KEY, "method": "turnstile", "sitekey": sitekey, "pageurl": pageurl, "json": 1}, timeout=30)
result = r.json()
if result.get("status") != 1:
return None
task_id = result["request"]
for i in range(40):
time.sleep(3)
r = requests.post("https://2captcha.com/res.php", data={"key": CAPTCHA_KEY, "action": "get", "id": task_id, "json": 1}, timeout=30)
result = r.json()
if result.get("status") == 1:
return result["request"]
if result.get("request") == "ERROR_CAPTCHA_UNSOLVABLE":
return None
return None
def register(email, password, turnstile_token):
s = curl.Session(impersonate="chrome124")
s.headers.update({"Content-Type": "application/json", "Origin": BASE_URL, "Referer": f"{BASE_URL}/register", "Accept": "application/json"})
r = s.post(f"{BASE_URL}/auth/register", json={"email": email, "password": password, "cf-turnstile-response": turnstile_token}, timeout=20)
if r.status_code == 200:
try:
data = r.json()
if data.get("code") == 0:
return data.get("data", {}).get("access_token", "")
except: pass
return None
def generate_password():
chars = string.ascii_letters + string.digits + "!@#$%^&*"
return "".join(random.choices(chars, k=random.randint(14, 18)))
def load_emails():
emails = []
with open(EMAILS_FILE, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if ":" in line:
email, password = [REDACTED]":", 1)
emails.append((email.strip(), password.strip()))
return emails
def save_account(account):
accounts = []
if ACCOUNTS_FILE.exists():
try:
with open(ACCOUNTS_FILE, "r", encoding="utf-8") as f:
accounts = json.load(f)
except: pass
accounts.append(account)
with open(ACCOUNTS_FILE, "w", encoding="utf-8") as f:
json.dump(accounts, f, indent=2, ensure_ascii=False)
if __name__ == "__main__":
print("=== Baaaai.com API Auto-Reg ===")
sitekey = get_sitekey()
if not sitekey:
print("Cannot find sitekey")
exit(1)
token = [REDACTED])
if not token:
[REDACTED]"Turnstile solve failed")
exit(1)
emails = load_emails()
email, _ = emails[0]
password = [REDACTED])
print(f"Registering: {email}")
auth_token = [REDACTED], password, token)
if auth_token:
[REDACTED]"Registered! Token: {auth_token[:30]}...")
save_account({"email": email, "password": password, "token": auth_token})
else:
print("Registration failed")