119 lines
4.8 KiB
Python
119 lines
4.8 KiB
Python
"""Grok reg — live residential proxies + t-online.de IMAP + Playwright."""
|
|
import imaplib, email, re, json, random, time, sys
|
|
from pathlib import Path
|
|
from urllib.parse import urlparse
|
|
from playwright.sync_api import sync_playwright, TimeoutError as PwTimeout
|
|
|
|
EMAILS_FILE = "C:/Users/User/Desktop/_PROJECTS/GPT-AUTOREG/emails.txt"
|
|
PROXY_FILE = "C:/Users/User/tmp/bpproxy_live.json"
|
|
OUTPUT = "accounts/grok_accounts.json"
|
|
|
|
def load_proxies():
|
|
with open(PROXY_FILE) as f:
|
|
return json.load(f)
|
|
|
|
def parse_proxy(url):
|
|
p = urlparse(url)
|
|
return {"server": f"http://{p.hostname}:{p.port}", "username": p.username, "password": p.password}
|
|
|
|
def load_emails():
|
|
emails = []
|
|
with open(EMAILS_FILE, "r") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if not line or line.startswith("#") or line.startswith("---"):
|
|
continue
|
|
if ":" in line:
|
|
user, pw = line.split(":", 1)
|
|
emails.append((user.strip(), pw.strip()))
|
|
return emails
|
|
|
|
def get_code_tonline(addr, pw, timeout=120):
|
|
deadline = time.time() + timeout
|
|
while time.time() < deadline:
|
|
try:
|
|
mail = imaplib.IMAP4_SSL("secureimap.t-online.de", 993)
|
|
mail.login(addr, pw)
|
|
mail.select("inbox")
|
|
_, msgs = mail.search(None, "UNSEEN")
|
|
if not msgs[0]:
|
|
_, msgs = mail.search(None, "ALL")
|
|
for num in msgs[0].split()[-10:]:
|
|
_, data = mail.fetch(num, "(RFC822)")
|
|
for part in data:
|
|
if not isinstance(part, tuple): continue
|
|
msg = email.message_from_bytes(part[1])
|
|
body = ""
|
|
if msg.is_multipart():
|
|
for p in msg.walk():
|
|
if p.get_content_type() in ("text/plain", "text/html"):
|
|
pl = p.get_payload(decode=True)
|
|
if pl: body += pl.decode(errors="ignore")
|
|
else:
|
|
pl = msg.get_payload(decode=True)
|
|
if pl: body = pl.decode(errors="ignore")
|
|
codes = re.findall(r"\b(\d{6,8})\b", body)
|
|
if codes and codes[0] != "000000":
|
|
mail.logout()
|
|
return codes[0]
|
|
mail.logout()
|
|
except Exception as e:
|
|
print(f" [IMAP] {e}")
|
|
time.sleep(5)
|
|
return None
|
|
|
|
def register_one(email_addr, email_pw, proxy_url):
|
|
pw = "".join(random.choices("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*", k=16))
|
|
proxy_cfg = parse_proxy(proxy_url)
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, proxy=proxy_cfg)
|
|
page = browser.new_page()
|
|
try:
|
|
page.goto("https://accounts.x.ai/sign-up?redirect=grok-com", wait_until="networkidle", timeout=60000)
|
|
body = page.inner_text("body")[:500]
|
|
if "not available in your region" in body.lower():
|
|
return None
|
|
page.wait_for_selector("input[type=email]", state="visible", timeout=20000)
|
|
page.locator("input[type=email]").first.fill(email_addr)
|
|
time.sleep(1)
|
|
page.locator("button:has-text('Continue')").first.click()
|
|
time.sleep(3)
|
|
pw_input = page.locator("input[type=password]").first
|
|
if pw_input.is_visible():
|
|
pw_input.fill(pw)
|
|
time.sleep(0.5)
|
|
page.locator("button:has-text('Continue')").first.click()
|
|
time.sleep(3)
|
|
page.wait_for_selector("input[type=text]:not([readonly])", state="visible", timeout=20000)
|
|
code = get_code_tonline(email_addr, email_pw, timeout=120)
|
|
if not code: return None
|
|
page.locator("input[type=text]:not([readonly])").first.fill(code)
|
|
time.sleep(0.5)
|
|
page.locator("button:has-text('Verify')").first.click()
|
|
time.sleep(5)
|
|
if "grok.com" in page.url:
|
|
return {"email": email_addr, "password": pw, "site": "grok", "status": "active"}
|
|
finally:
|
|
browser.close()
|
|
|
|
def main():
|
|
count = int(sys.argv[1]) if len(sys.argv) > 1 else 1
|
|
proxies = load_proxies()
|
|
emails = load_emails()
|
|
ok = []
|
|
for i in range(min(count, len(emails))):
|
|
addr, epw = emails[i]
|
|
proxy_url = proxies[i % len(proxies)]
|
|
r = register_one(addr, epw, proxy_url)
|
|
if r: ok.append(r)
|
|
if i < count - 1: time.sleep(random.randint(10, 20))
|
|
if ok:
|
|
out = Path(OUTPUT)
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
existing = json.loads(out.read_text()) if out.exists() else []
|
|
existing.extend(ok)
|
|
out.write_text(json.dumps(existing, indent=2))
|
|
|
|
if __name__ == "__main__":
|
|
main() |