52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
"""纯算探针:DFP bootstrap -> 尝试多种组合拉取 weapon 插件清单 (/a/q)。
|
||
|
||
不依赖任何抓包快照。试 (did/egid) × (有无 cookie) × (先 /m/k 后 /a/q)。
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
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 # noqa: E402
|
||
from core import weapon_plugin_loader as wpl # noqa: E402
|
||
from tools.new_device import run_online_bootstrap # noqa: E402
|
||
|
||
|
||
def _try_aq(label, profile, **kw):
|
||
dec, plugin_map, resp = wpl.fetch_plugin_manifest(profile, timeout=30, **kw)
|
||
status = getattr(resp, "status_code", "?")
|
||
print(f"[aq:{label}] http={status} dec={ (dec or '')[:160] } plugin_keys={list(plugin_map.keys()) if isinstance(plugin_map,dict) else plugin_map}")
|
||
return plugin_map
|
||
|
||
|
||
def main() -> int:
|
||
profile = DeviceProfileGenerator(seed=20260727).new_profile()
|
||
print(f"[profile] did={profile.did} egid={profile.egid}")
|
||
try:
|
||
run_online_bootstrap(profile, timeout=30)
|
||
print(f"[bootstrap] ok did={profile.did} egid={profile.egid}")
|
||
except Exception as exc: # noqa: BLE001
|
||
print(f"[bootstrap] fail: {exc}")
|
||
|
||
_try_aq("did+cookie", profile, device_id=profile.did, include_cookie=True)
|
||
_try_aq("egid+cookie", profile, device_id=profile.egid, include_cookie=True)
|
||
_try_aq("did+nocookie", profile, device_id=profile.did, include_cookie=False)
|
||
|
||
print("[policy] POST /m/k first (p1) ...")
|
||
pdec, pinner, presp = wpl.fetch_policy(profile, timeout=30, device_id=profile.did)
|
||
print(f"[policy] http={getattr(presp,'status_code','?')} dec={ (pdec or '')[:300] }")
|
||
if isinstance(pinner, dict):
|
||
print(f"[policy] inner keys: {list(pinner.keys())}")
|
||
|
||
_try_aq("did+cookie(after m/k)", profile, device_id=profile.did, include_cookie=True)
|
||
return 0
|
||
|
||
|
||
if __name__ == "__main__":
|
||
raise SystemExit(main())
|