Files
autoreg-skills-max/skills/lobehub-pool/scripts/lobehub_autoreg.py

118 lines
4.2 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
LobeHub Self-Hosted Mass Auto-Registration
Target: http://[REDACTED-IP]:3210 (Better Auth)
Strategy: 49 reforrm.me users × 5 subaddresses (+001..+005) = 245 accounts
Rate-limit: 3 registers per batch, 30s cooldown
Output: lobehub_new_accounts.json
"""
import requests
import json
import time
import sys
import os
from datetime import datetime
SERVER = "http://[REDACTED-IP]:3210"
REGISTER_URL = f"{SERVER}/api/auth/sign-up/email"
LOGIN_URL = f"{SERVER}/api/auth/sign-in/email"
# Load reforrm.me users
reform_users_path = r"C:\Users\User\Desktop\reforrm_workspace_users.txt"
users = []
with open(reform_users_path) as f:
for line in f:
line = line.strip()
if "@reforrm.me" in line and "ACTIVE" in line:
email = line.split("@reforrm.me")[0].strip() + "@reforrm.me"
users.append(email)
print(f"[INFO] Loaded {len(users)} active reforrm.me users")
# Generate subaddresses: user+001@reforrm.me, user+002@reforrm.me, etc.
SUBADDR_COUNT = 5 # 49 * 5 = 245
BATCH_SIZE = 3
BATCH_DELAY = 30 # seconds between batches
ERROR_DELAY = 5
PASSWORD = "[REDACTED]"
NAME_PREFIX = "LhUser"
all_accounts = []
existing = len(users) * SUBADDR_COUNT
for i, user in enumerate(users):
base_email = user.split("@")[0]
domain = "reforrm.me"
for sub in range(1, SUBADDR_COUNT + 1):
email = f"{base_email}+{sub:03d}@{domain}"
name = f"{NAME_PREFIX}{i*SUBADDR_COUNT + sub}"
batch_num = (len(all_accounts)) // BATCH_SIZE + 1
try:
print(f"[{len(all_accounts)+1}/{existing}] Registering {email} ...", end=" ")
sys.stdout.flush()
r = requests.post(
REGISTER_URL,
json={"email": email, "password": PASSWORD, "name": name},
headers={"Content-Type": "application/json"},
timeout=15
)
if r.status_code == 200:
data = r.json()
token = [REDACTED]"token", "")
user_id = data.get("user", {}).get("id", "")
print(f"OK token={token[:12]}... user_id={user_id}")
all_accounts.append({
"email": email,
"password": PASSWORD,
"token": token,
"user_id": user_id,
"name": name,
"configured": False,
"created_at": datetime.now().isoformat()
})
elif r.status_code == 429:
print(f"RATE-LIMITED (429) — long wait 60s")
time.sleep(60)
r = requests.post(REGISTER_URL,
json={"email": email, "password": PASSWORD, "name": name},
headers={"Content-Type": "application/json"}, timeout=15)
if r.status_code == 200:
data = r.json()
token = [REDACTED]"token", "")
user_id = data.get("user", {}).get("id", "")
print(f"OK (retry) token={token[:12]}...")
all_accounts.append({
"email": email, "password": PASSWORD, "token": token,
"user_id": user_id, "name": name, "configured": False,
"created_at": datetime.now().isoformat()
})
else:
print(f"FAIL (retry): {r.status_code} {r.text[:200]}")
else:
print(f"FAIL: {r.status_code} {r.text[:200]}")
except Exception as e:
print(f"ERROR: {e}")
time.sleep(ERROR_DELAY)
if len(all_accounts) > 0 and len(all_accounts) % BATCH_SIZE == 0:
print(f" [BATCH {batch_num}] Cooldown {BATCH_DELAY}s...")
time.sleep(BATCH_DELAY)
time.sleep(1.5)
output_path = r"C:\Users\User\AppData\Local\hermes\lobehub_new_accounts.json"
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, "w") as f:
json.dump(all_accounts, f, indent=2)
print(f"\n{'='*60}")
print(f"[DONE] Registered {len(all_accounts)} new accounts")
print(f"[FILE] {output_path}")
print(f"{'='*60}")