decode_launch_resp.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. """Decode the FULL EnterGameClient response (session 753) from the SAZ —
  2. it may contain the launch URL that 996box passes to cq.exe."""
  3. import gzip
  4. import json
  5. from pathlib import Path
  6. import brotli
  7. def decode_response(path: Path) -> str:
  8. raw = path.read_bytes()
  9. idx = raw.find(b"\r\n\r\n")
  10. head = raw[:idx].decode("latin1")
  11. body = raw[idx + 4 :]
  12. enc = "br" if "Content-Encoding: br" in head else ("gzip" if "gzip" in head else "")
  13. chunked = "chunked" in head
  14. if chunked:
  15. out = b""
  16. rest = body
  17. while rest:
  18. le = rest.find(b"\r\n")
  19. if le < 0:
  20. break
  21. try:
  22. sz = int(rest[:le].split(b";")[0], 16)
  23. except ValueError:
  24. break
  25. if sz == 0:
  26. break
  27. out += rest[le + 2 : le + 2 + sz]
  28. rest = rest[le + 2 + sz + 2 :]
  29. body = out
  30. if enc == "br":
  31. body = brotli.decompress(body)
  32. elif enc == "gzip":
  33. body = gzip.decompress(body)
  34. return body.decode("utf-8", errors="replace")
  35. raw_dir = Path(r"C:\Users\ADMINI~1\AppData\Local\Temp\opencode\saz_dec\raw")
  36. txt = decode_response(raw_dir / "753_s.txt")
  37. print("=== EnterGameClient FULL response ===")
  38. try:
  39. data = json.loads(txt)
  40. # dump ALL keys recursively, looking for url/launch fields
  41. def walk(obj, path=""):
  42. if isinstance(obj, dict):
  43. for k, v in obj.items():
  44. p = f"{path}.{k}" if path else k
  45. if isinstance(v, (dict, list)):
  46. walk(v, p)
  47. else:
  48. kl = k.lower()
  49. if any(s in kl for s in ("url", "launch", "path", "exe", "start", "open")):
  50. print(f" *** {p} = {str(v)[:120]}")
  51. elif isinstance(v, str) and len(v) < 80:
  52. print(f" {p} = {v}")
  53. elif isinstance(obj, list):
  54. for i, item in enumerate(obj[:3]):
  55. walk(item, f"{path}[{i}]")
  56. walk(data)
  57. print()
  58. print("download_info keys:", list((data.get("data", {}).get("download_info") or {}).keys()))
  59. except json.JSONDecodeError:
  60. print(txt[:2000])