Overwrite previous grok-keygen contents with the local registration/CPA protocol codebase (secrets and runtime data excluded).
84 lines
2.5 KiB
Python
84 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""直接测试 Grok 注册页,逐步打印每个步骤"""
|
|
from DrissionPage import Chromium
|
|
from DrissionPage.common import ChromiumOptions
|
|
import time
|
|
import os
|
|
|
|
# 配置
|
|
BROWSER_PATH = "/snap/bin/chromium"
|
|
EXT_PATH = os.path.expanduser("~/grok-reg-protocol-cpa/turnstilePatch")
|
|
URL = "https://accounts.x.ai/sign-up?redirect=grok-com"
|
|
|
|
opts = ChromiumOptions()
|
|
opts.set_browser_path(BROWSER_PATH)
|
|
if os.path.isdir(EXT_PATH):
|
|
try:
|
|
opts.add_extension(EXT_PATH)
|
|
print("[+] Turnstile patch loaded")
|
|
except Exception as e:
|
|
print(f"[!] Failed to load extension: {e}")
|
|
|
|
print("[*] Launching browser...")
|
|
b = Chromium(opts)
|
|
page = b.latest_tab
|
|
|
|
print(f"[*] Navigating to {URL}")
|
|
page.get(URL)
|
|
|
|
# 等待页面加载
|
|
for i in range(10):
|
|
time.sleep(1)
|
|
title = page.title
|
|
print(f"[{i+1}s] title={title}")
|
|
if "Attention" not in title and "Grok" in title:
|
|
print("[+] Page loaded successfully")
|
|
break
|
|
else:
|
|
print("[-] Page may be blocked by Cloudflare")
|
|
# 打印当前 HTML
|
|
html = page.html
|
|
print("HTML snippet:")
|
|
print(html[:1000])
|
|
b.quit()
|
|
exit(1)
|
|
|
|
# 查找输入框
|
|
print("\n[*] Looking for email input...")
|
|
selectors = [
|
|
('css:input[type="email"]', "email type"),
|
|
('css:input[name="email"]', "email name"),
|
|
('css:input[autocomplete="email"]', "email autocomplete"),
|
|
('css:input[placeholder*="email" i]', "email placeholder"),
|
|
('css:input[placeholder*="Email" i]', "Email placeholder"),
|
|
('css:input[inputmode="email"]', "email inputmode"),
|
|
('xpath://input[contains(@placeholder, "email") or contains(@placeholder, "Email")]', "xpath email"),
|
|
]
|
|
|
|
found = False
|
|
for sel, desc in selectors:
|
|
try:
|
|
ele = page.ele(sel, timeout=2)
|
|
if ele:
|
|
print(f"[+] Found input via {desc}: {sel}")
|
|
print(f" type={ele.attr('type')} name={ele.attr('name')} placeholder={ele.attr('placeholder')}")
|
|
found = True
|
|
break
|
|
except Exception as e:
|
|
print(f"[!] Error with {desc}: {e}")
|
|
|
|
if not found:
|
|
print("[-] No email input found with standard selectors")
|
|
# 打印所有 input
|
|
inputs = page.eles("css:input")
|
|
print(f"[*] Found {len(inputs)} input elements total")
|
|
for inp in inputs[:10]:
|
|
print(f" type={inp.attr('type')} name={inp.attr('name')} placeholder={inp.attr('placeholder')}")
|
|
|
|
# 打印部分 HTML
|
|
html = page.html
|
|
print("\nHTML snippet:")
|
|
print(html[:3000])
|
|
|
|
b.quit()
|