cq_exe_strings.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. """Deep string analysis of cq.exe (launcher shell) to find how it spawns cq2.exe.
  2. cq.exe (1.6MB) reads env.json (gameid/token) and spawns cq2.exe.
  3. Hunt for:
  4. - CreateProcess command templates (e.g. "cq2.exe %s")
  5. - Quote/percent format strings near 'cq2' or 'exe'
  6. - Full command lines in adjacent data
  7. """
  8. import re
  9. import struct
  10. import sys
  11. from pathlib import Path
  12. EXE = Path(r"D:\ProgramFiles\996box\GameBoxDownload\1\cq.exe")
  13. data = EXE.read_bytes()
  14. print(f"cq.exe: {len(data)} bytes")
  15. # 1. All strings containing cq2
  16. print("=== strings containing 'cq2' ===")
  17. for m in re.finditer(rb"[\x20-\x7e]{4,200}", data):
  18. s = m.group()
  19. if b"cq2" in s.lower():
  20. print(f" @{m.index:#x}: {s.decode('ascii', errors='replace')}")
  21. print()
  22. # 2. Strings containing env.json (context of reading)
  23. print("=== strings near 'env.json' ===")
  24. for m in re.finditer(rb"env\.json", data):
  25. start = max(0, m.start() - 100)
  26. end = min(len(data), m.end() + 200)
  27. window = data[start:end]
  28. txt = window.decode("ascii", errors="replace")
  29. txt = "".join(c if 32 <= ord(c) < 127 else "·" for c in txt)
  30. print(f" @{m.start():#x}: {txt}")
  31. print()
  32. # 3. Format-string-like patterns (%s with exe/dll neighbors)
  33. print("=== printf-style templates mentioning exe ===")
  34. for m in re.finditer(rb"[\x20-\x7e]{6,120}", data):
  35. s = m.group().decode("ascii", errors="replace")
  36. if ("%s" in s or "%d" in s) and ("exe" in s.lower() or "game" in s.lower() or "open" in s.lower()):
  37. print(f" @{m.index:#x}: {s}")
  38. print()
  39. # 4. Command-line-ish: strings with quotes and .exe
  40. print("=== strings with .exe inside quotes ===")
  41. for m in re.finditer(rb'"[\x20-\x7e]{4,150}\.exe[\x20-\x7e]{0,100}"', data):
  42. print(f" @{m.index:#x}: {m.group().decode('ascii', errors='replace')}")
  43. print()
  44. # 5. URL-like strings (http/https)
  45. print("=== http(s) URLs ===")
  46. seen = set()
  47. for m in re.finditer(rb"https?://[\x21-\x7e]{6,100}", data):
  48. u = m.group().decode("ascii", errors="replace")
  49. if u not in seen:
  50. seen.add(u)
  51. print(f" {u}")