• You will be disconnected and reconnected again.

Whitepaper: Game introspection for analytical data

MoistNut

Administrator
Staff member
Frosties Admin
Alliance Leader (R4)
Whiteout Survival
MoistBanananana [NUT]
This system turns a phone's encrypted game traffic into a live, searchable picture of the game world, without touching the client or the servers.

Summary​


Three parts do the work:

  • Capture. A WireGuard tunnel and an intercepting proxy record the phone's traffic.
  • Spool. Raw messages go into an append-only log. It is the source of truth.
  • Go service. It decodes the spool into Postgres, publishes live events, and serves a dashboard and bots.

Because every derived row can be rebuilt from the spool, decoders can improve without losing history.

1. Design goals​


  • Passive. It only reads traffic already sent to the device.
  • Lossless first. Raw bytes are stored before they are understood, so a decoding bug means a replay, not lost data.
  • Restart-safe. The service can crash or redeploy mid-stream without duplicating or dropping data.
  • Multi-account. Every packet is tied to the account, alliance and game state that produced it.

2. System overview​


block-beta
    columns 7
    t["<b>Everything downstream is rebuilt from one append-only spool</b>"]:7
    phone["<b>Phone</b><br/>Game client<br/>WireGuard profile"] space capture["<b>Capture node</b><br/>mitmproxy, WireGuard<br/>TLS decrypted here"] space spool["<b>Spool</b><br/>Append-only JSONL<br/>Source of truth"] space:2
    space:7
    space:2 consumers["<b>Consumers</b><br/>Dashboard, bots, MCP<br/>Grafana (optional)"] space go["<b>Go service</b><br/>Tail, decode, ingest<br/>Events, REST, MCP"] space pg["<b>Postgres</b><br/>Packets + derived<br/>Row-level security"]
    phone --> capture
    capture --> spool
    spool -- "tails and replays" --> go
    go --> consumers
    go --> pg
    classDef main fill:#dbe9ff,stroke:#2f6fd0,stroke-width:3px
    classDef note fill:none,stroke:none
    class spool main
    class t note

Each stage depends only on the one before it. The highlighted spool is what everything after it can be rebuilt from.

3. Capture​


3.1 WireGuard​


The phone imports a standard WireGuard profile and all its traffic goes to the capture node. It needs no rooting and no proxy setting, and the tunnel survives switching between Wi-Fi and cellular.

Keep the tunnel subnet and MTU clear of the home LAN, or the phone connects but sends nothing. Keys live in a cluster secret, and a script rotates them and reissues the phone profile as a file and QR code.

3.2 mitmproxy and TLS​


On the capture node, mitmproxy runs in WireGuard mode. It ends the tunnel in user space, so no kernel routing setup is needed. It also acts as a local certificate authority: the phone trusts that CA, the proxy decrypts the client's session, opens its own session to the real server, and relays between them.

block-beta
    columns 5
    t["<b>The proxy sits between two TLS sessions and keeps a plaintext copy</b>"]:5
    phone["<b>Phone</b><br/>Trusts the proxy CA<br/>Routes via WireGuard"] space proxy["<b>mitmproxy</b><br/>Decrypts, re-encrypts<br/>Local certificate authority"] space server["<b>Game server</b><br/>Sees an ordinary client<br/>Nothing is sent to it"]
    space:5
    space:2 addon["<b>Capture add-on</b><br/>Appends each message<br/>to the spool as JSON"] space:2
    phone <-- "TLS session 1<br/>proxy CA cert" <--> proxy
    proxy <-- "TLS session 2<br/>real server cert" <--> server
    proxy -- "plaintext copy" --> addon
    classDef main fill:#dbe9ff,stroke:#2f6fd0,stroke-width:3px
    classDef note fill:none,stroke:none
    class proxy main
    class t note

This works only on a device you control and have set up to trust the CA. Clients that pin certificates would defeat it. Keep proxy logging at warning level, because higher levels print the tunnel's private key.

3.3 Capture add-on​


The game keeps long-lived TCP connections that carry binary messages. A small add-on appends one JSON line per message to a spool file: connection, direction, timestamp and the bytes as text. It does no parsing, so it cannot lose data to a decoder bug.

4. The spool​


The spool is plain files on a persistent volume. Everything downstream is a pure function of it, so a new decoder can be tested by replaying real history.

The Go service reads it with a follower that:

  • merges files in capture-time order;
  • saves its read position about once a second and stops on a line boundary at shutdown;
  • after a crash, skips past the last packet it stored, so nothing is inserted twice.

5. Decoding​


block-beta
    columns 3
    t["<b>Raw bytes become typed, account-scoped rows in five steps</b>"]:3
    raw["<b>1. Raw message</b>"] d1["Direction, connection, timestamp and bytes, read from the spool"]:2
    space:3
    framing["<b>2. Framing</b>"] d2["Split into messages; pair replies with the requests that caused them"]:2
    space:3
    bodies["<b>3. Compact bodies</b>"] d3["Unpack zero-run words, length-prefixed blobs and embedded msgpack"]:2
    space:3
    records["<b>4. Typed records</b>"] d4["Map fields to meaning, only where evidence from the game confirms it"]:2
    space:3
    rows["<b>5. Stamped rows</b>"] d5["Attach account, alliance and state; write Postgres and publish events"]:2
    raw --> framing
    framing --> bodies
    bodies --> records
    records --> rows
    classDef main fill:#dbe9ff,stroke:#2f6fd0,stroke-width:3px
    classDef note fill:none,stroke:none
    class records main
    class t,d1,d2,d3,d4,d5 note

There is no public specification. Every field is established from evidence: match a decoded value to something visible in the game, then check it across the whole capture. Understood fields are decoded; unknown ones stay raw and are marked unknown, never guessed.

DomainRecovered
World mapCities, resource tiles, camps, banners, fortresses, the central castle, with owners
MovementMarches and rallies: who, where, when, with what troops
SocialRosters, ranks, profiles, name history, all chat channels
CombatBattle and scout reports, event fights, damage boards
EventsCalendar, leaderboards, sign-ups, scheduled hunts
PersonalInventory, heroes, mail rewards, shields

Scoping. A capture can hold several accounts, states and alliances that share tags. Each connection's owner comes from its login, and every packet is stamped with account, alliance and state. Queries scope by account and state by default, so one account's data never leaks into another's view. A registry merges every source that names a player or alliance into one current record, where the newest observation wins.

6. The Go service​


One binary ingests, stores, serves and embeds the dashboard.

  • Storage. Postgres holds raw and decoded packets plus derived tables. Some analyses (marches, camps, map freshness) are computed at query time, so improving one needs no migration. Search and stats also stay in Postgres: trigram indexes for fuzzy names, full-text for chat.
  • Live updates. Ingest publishes typed events. The web layer streams them to the dashboard, which refetches only what each event affects. Bots get a separate WebSocket that sends notifications only (structure changes, rallies, fights, scheduled events) and read details through MCP. A late subscriber gets the latest notification again.
  • Interfaces. Each read endpoint is registered once and becomes both a REST route and an MCP tool, so the dashboard and bots agree. MCP views are compact and paged. The dashboard is a React app with virtualised tables and a GPU-rendered map.
  • Privacy. MCP runs as a restricted Postgres role, and row-level security hides direct messages from it. A new endpoint cannot leak them by mistake. Raw SQL access is loopback-only, and public access sits behind an identity-aware proxy.

7. Reliability and rebuilds​


ConcernApproach
Crash between savesSkip ahead from the last stored packet
Replies after a restartPending requests are restored, so replies keep their labels
Decoder fixed or newFull replay, or an online rebuild
Rebuild cut-overOne atomic table swap, refused if the rebuild has fewer connections

An online rebuild re-reads the spool into a staging schema while the live service keeps running. When it catches up, the live follower pauses, the rebuild reads the remainder, and the tables swap in one transaction. The result matched a clean replay byte for byte.

8. Deployment​


Everything runs in one Kubernetes namespace: the Go service, tuned Postgres, the capture pod with its UDP port, and the spool volume. A script builds, pushes and deploys, and can trigger a rebuild. Other scripts generate and rotate tunnel keys.

9. Limitations​


  • Coverage. It sees only what the game sends the captured device. Some boards refresh only when someone opens the screen.
  • Decoding is incomplete. Some fields are unknown, and some inferences, such as whether an object was removed, are probabilistic.
  • Fragile to change. Pinned clients or a game update can break capture or decoding.
  • Responsible use. Capture only devices and accounts you own or may observe, and respect the game's terms. Direct messages are stored for identity only and kept out of every automated interface.
 
Back
Top