"""Decode BOTH 996box env.json files (main + cq/) and show live credentials. The main env.json format: The cq/env.json is plain JSON starting at first '{'. """ import base64 import json import sys from pathlib import Path if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace") SENSITIVE = ("sign", "key", "token", "password", "pwd") def show(obj: dict, title: str) -> None: print(f"=== {title} ===") for k, v in obj.items(): if any(s in k.lower() for s in SENSITIVE) and isinstance(v, str): print(f" {k}: ***REDACTED*** (len={len(v)})") else: sv = str(v) print(f" {k}: {sv[:100]}{'...' if len(sv) > 100 else ''}") print() def try_main() -> dict | None: p = Path(r"D:\ProgramFiles\996box\GameBoxDownload\1\env.json") if not p.exists(): return None text = p.read_bytes().decode("utf-8", errors="replace") idx = text.find("eyJ") if idx < 0: idx = text.find("MeyJ") if idx < 0: return None b64 = text[idx:].rstrip() try: padded = b64 + "=" * (-len(b64) % 4) dec = base64.urlsafe_b64decode(padded).decode("utf-8", errors="replace") # Use raw_decode to grab just the first JSON object (trailing data is junk) obj, _end = json.JSONDecoder().raw_decode(dec) if isinstance(obj, dict): return obj except Exception as e: print(f"main env decode error: {e}") return None def try_cq() -> dict | None: p = Path(r"D:\ProgramFiles\996box\GameBoxDownload\1\cq\env.json") if not p.exists(): return None text = p.read_bytes().decode("utf-8", errors="replace") idx = text.find("{") if idx < 0: return None try: obj, _end = json.JSONDecoder().raw_decode(text[idx:]) if isinstance(obj, dict): return obj except Exception as e: print(f"cq env decode error: {e}") return None def main() -> int: main_env = try_main() if main_env: show(main_env, "main env.json (base64-decoded)") else: print("main env.json: could not decode") cq_env = try_cq() if cq_env: show(cq_env, "cq/env.json (plain JSON)") else: print("cq/env.json: could not decode") return 0 if __name__ == "__main__": sys.exit(main())