Skip to main content
Everything documented elsewhere in this dossier translated into a build order. Bootstrap first, core loop second, everything else is additive.

Phase 1: Bootstrap (nothing else works without this)

  1. GET getlsu3dversion.php, extract resMsg (RSA pubkey) and the answering host. An updateType of 2 means the server no longer accepts the build you claim (Startup, version-check & hot-update).
  2. Implement the GSL RSA-PKCS1v15 + AES-256-ECB-PKCS7 envelope (Gate-server RSA+AES handshake), Go has no stdlib ECB mode, write the trivial 16-byte-block loop.
  3. POST getserverlist.php, check code (0 is success), parse serverList[], pick the entry matching the last-logged server (else the first), and persist at/at.time/rt/rt.time. The token lifecycle covers how the real client picks opt and refreshes.
  4. Open a plain TCP socket to the zone’s gateway. serverList[].ip is a |-delimited list; the real client races every entry and keeps the first to answer its ping (SFS2X wire protocol). Implement the packet envelope, the length-derived XOR “encryption,” zlib compression, and the SFSObject codec (SFS2X wire protocol).
  5. Send SFS Login with the ~50-field parameter object (Identity, login & session), including the SecurityCode/OneCode/CoreV MD5 constructions.
  6. Wait for the bare init push; live, it arrives on its own, with no init.before or init.after. Capture chatToken if chat is needed later.
  7. Start a 4-second PingPongRequest heartbeat.
Live validation against production has a side-by-side table of what the real client does on the wire and which of goclient’s simplifications the server accepts.

Phase 2: Core loop

Build the command dispatch table directly from the extracted cmd-data catalog (see Command reference for the row schema and how to regenerate it, don’t hand-transcribe the ~3,178 rows by hand). Implement, in order: City/Building → Military/Army (the base-building + troop loop) → World Map (needed for march/PVE) → Alliance + Chat + Mail (high command-count payoff) → Hero → Shop/Economy.

Phase 3: Defer

Season (754 cmds) and Activity (900 cmds) are recurring/time-limited live-ops content, 54% of the entire protocol surface by command count, and it churns every patch. Implement only if a specific feature is explicitly wanted; treating either as a monolith is not advisable given how fragmented each sub-feature’s schema is.

Crypto primitives checklist


Running the Go client

The roadmap above was actually built, the repository root is a from-scratch Go reimplementation of this protocol, live-tested against production (see Live validation against production for the full writeup of what’s confirmed against live production servers). It’s fully working and live-confirmed for GSL crypto, SFS2X packet framing (including Zstandard decompression), the SFSObject codec, brand-new-guest-account login, email-verification account binding, resource collection across 14 confirmed building types (Farmland, Iron Mine, Gold Mine, Smelter, Material Workshop, Training Base, Oil Well, Drone Parts Workshop, Component Factory, Tactical Institute, and the four Season 6 Spore Factory tiers; the 1.0.364 Crystal Factory and the Season 6 week-card building are wired in but unconfirmed, see the building-type table), and a growing set of account-level automations, none of which are building-uuid-scoped: the “Armed Truck”/“Overlord” idle rewards (lw.pve.idle.reward), greeting city visitors (visitor.operate), bulk-helping alliance members (al.help.all), claiming all alliance gifts (alliance.reward.allreceive), claiming all mail (chat.get.system.mails + mail.reward.batch), donating to the alliance’s currently-recommended tech (science.data.refresh + al.science.donate), and both once-a-day VIP claims (vip.add.login.score, vip.get.every.day.reward), see Live validation against production for the full writeup of each. Reconnecting into an established real account’s live game state was proven working end-to-end when first captured; that capture used the ta analytics blob’s real device/anti-fraud sub-fields, which a later security fix replaced with empty-string placeholders, and reconnect is now re-confirmed still working with those placeholders (an unattended cron reconnected and collected real resources over multiple days, August 2026). What remains open is the minimal required ta content. An Android from-scratch login is live-confirmed. -cs-ios sends the iOS identity from the first GSL call; a third party reports an iOS own-device bind through it working (discussion #56), and it hasn’t been reproduced here. See Live validation against production.
Not yet general-purpose. The reconnect path needs a session config: one captured from a real client login, or, since 2026-10-13, one -own-device-session writes for a device of its own (see below). -cs-ios on a guest or email login sends the iOS identity from the first GSL call through account.login.new. A third party reports an iOS own-device bind, its Login and one token refresh working (discussion #56); it hasn’t been reproduced here. An own-device config refreshes its access token on its own (see Refreshing the access token), but a captured config has no refresh token, so when the server invalidates its access token (ec=28, ep=[E011], as on 2026-08-16 and 2026-10-02), the fix is a fresh capture, see Recovering from a rotated token.
This section walks through going from a clean checkout to a working -collect run.
1

Build

2

Set up a session config (recommended)

Reconnecting into an established account needs several values that can only come from a real client’s own login (device ID, access token, …). The ShuMei fingerprint is optional: a captured session reconnects with shumeiBoxId empty (confirmed live, 2026-10-04) — see ShuMei device fingerprint. Rather than typing them on the command line every time, put them in a JSON file:
~/.lastwar_goclient_session.json is auto-loaded on every run if present, no flag needed. To use a different file, pass -config /path/to/file.json. Individual -cs-* flags still override whatever the config file says, for one-off tests.
Where these values come from: capture a real login (e.g. tcpdump while the real app logs in, since the SFS2X game socket is plain TCP with no TLS) and let pcap -session-out write this file from the captured Login, see Recovering from a rotated token. Capturing and decoding traffic also covers the manual pipeline. The game server’s ip (a |-delimited list of the zone’s gateways, tried in order) and port are optional: without them, goclient looks the role’s server up with GSL getserverlist, and it looks again if a saved address stops answering, see Looking up the game server. The access token is not single-use, but it is bound to the platform identity (iosMode) and the build (appVersion/versionCode, optional, defaulting to built-in values) it was issued under, and it will eventually need refreshing from a fresh capture.
This file contains live credentials for a real account, keep it out of version control. It’s already outside the repo, in your home directory, and chmod 600’d above; don’t move it into this repo or commit it anywhere.
3

Run a collection pass

Other ways to run it

Device identity also persists across runs in ~/.lastwar_goclient_* (deviceId, username, gameUid, loginKey) independent of the session config, so repeated guest/email-flow runs present a consistent device to the server. Delete those files to start fully fresh. Set LASTWAR_STATE_DIR to keep them in another directory instead, so several device identities can coexist on one machine.
Since 2026-10-13 a Login with the resulting config works, and it refreshes its own tokens. Run it like any session config, LASTWAR_STATE_DIR=~/.lastwar_own_device ./lastwar-client -config ~/own_device_session.json. On 2026-10-13 a token captured from the real app kept working alongside own devices (confirmed live). Each Login takes the role’s one live connection, so two devices don’t play at the same time. See Identity, login & session.

Flags reference

The definitive, always-current flag list lives in the code itself, run ./lastwar-client -h, or read the flag definitions directly in main.go. A duplicated table here has already drifted out of sync with the real flags more than once; the root README.md’s Usage section covers the common cases with a live-tested example for each. The optional-feature flags are -list-features, -run <feature> and -run-anyway; the duel gating behind -run-anyway is on Alliance Duel.

Project layout

See the README.md’s “Project layout” section at the repository root for the current package map (internal/{sfs,crypto,gsl,session,game,auth,app} plus the cmd/lastwar-client entry point), keeping a second copy here is exactly what caused it to drift out of sync.