probe_enter_game.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """Side-effect-free probe: OPTIONS preflight on EnterGameClient host variants.
  2. The captures show the web client always sends an OPTIONS preflight before
  3. cross-site POSTs. OPTIONS has no business side effect, so it's safe for
  4. probing which host actually serves the endpoint:
  5. - pc-api.996hezi.com (current SDK host)
  6. - api.996hezi.com (getTodayOpen's real host)
  7. Path variants from the app.asar JS map (/pcApi/v1/homeapi/gameindex/...)
  8. and the SDK's current path.
  9. """
  10. import asyncio
  11. import sys
  12. from pathlib import Path
  13. _HERE = Path(__file__).resolve().parent
  14. sys.path.insert(0, str(_HERE.parent / "src"))
  15. import httpx
  16. CANDIDATES = [
  17. ("https://pc-api.996hezi.com", "/v1/homeapi/gameindex/EnterGameClient", "SDK current (lowercase g)"),
  18. ("https://pc-api.996hezi.com", "/v1/homeapi/Gameindex/EnterGameClient", "capture style (capital G)"),
  19. ("https://api.996hezi.com", "/v1/homeapi/gameindex/EnterGameClient", "api host, lowercase"),
  20. ("https://api.996hezi.com", "/v1/homeapi/Gameindex/EnterGameClient", "api host, capital"),
  21. ]
  22. HEADERS = {
  23. "Origin": "https://pc.hzwlan.com",
  24. "Referer": "https://pc.hzwlan.com/",
  25. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) 996Box/5.1.1 Chrome/108.0.5359.215 Electron/",
  26. "Access-Control-Request-Method": "POST",
  27. }
  28. async def main() -> int:
  29. async with httpx.AsyncClient(timeout=10, verify=False) as c:
  30. for host, path, note in CANDIDATES:
  31. url = host + path
  32. try:
  33. r = await c.options(url, headers=HEADERS)
  34. # CORS preflight: 204/200 = endpoint routed (allowed);
  35. # 404 = no such route on this host
  36. allow = r.headers.get("access-control-allow-methods", "")
  37. print(f" [{r.status_code}] {url:<68} allow={allow[:30]!r:<34} ({note})")
  38. except Exception as e:
  39. print(f" [ERR ] {url:<68} {type(e).__name__}: {str(e)[:40]} ({note})")
  40. return 0
  41. if __name__ == "__main__":
  42. sys.exit(asyncio.run(main()))