"""纯算探针:在线 DFP bootstrap 注册新设备 -> 打 /f/a/p 看能否拿回新鲜 a_y_q_z。 不依赖任何抓包快照。profile 本地生成,did/egid 在线注册,payload 本地构造。 """ from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from core.device_profile import DeviceProfileGenerator, save_device_profile # noqa: E402 from core.sms_login import login_api_params # noqa: E402 from core import fap_request # noqa: E402 from tools.new_device import run_online_bootstrap # noqa: E402 def main() -> int: profile = DeviceProfileGenerator(seed=20260727).new_profile() print(f"[profile] did={profile.did} odid={profile.o_did} rdid={profile.rdid} egid={profile.egid}") print("[bootstrap] 在线 DFP 注册(unified_fetch/check_repair/gdfp_report)...") try: result = run_online_bootstrap(profile, timeout=30) ident = result.get("identity", {}) print(f"[bootstrap] ok identity did={ident.get('did')} egid={ident.get('egid')}") except Exception as exc: # noqa: BLE001 print(f"[bootstrap] 失败: {exc.__class__.__name__}: {exc}") print("[bootstrap] 继续用本地画像打 /f/a/p(did 可能未注册)") device_info = login_api_params(profile) print(f"[fap] device_info keys: {sorted(device_info.keys())}") payload = fap_request.build_default_payload(device_info) print(f"[fap] payload: {payload}") resp = fap_request.call_fap(payload, timeout=30) print(f"[fap] status={resp.status_code} ok={resp.ok} error={resp.error}") print(f"[fap] text[:600]: {(resp.text or '')[:600]}") ticket = fap_request.extract_a_y_q_z(resp.data) print(f"[fap] a_y_q_z = {ticket}") print("[DONE]" + (" PASS: 拿到新鲜 a_y_q_z -> passport 纯算可行" if ticket else " FAIL: 未拿到 a_y_q_z")) return 0 if ticket else 1 if __name__ == "__main__": raise SystemExit(main())