Skip to main content
The SFS2X username/password fields are vestigial; the password is always sent empty. Real authentication rides in ~50 fields on a custom SFSObject payload, most of them device fingerprints, three of them opaque MD5-based “integrity” tokens.

Device ID

Persisted to PlayerPrefs["DEVICE_ID"]; on iOS additionally mirrored to the Keychain (survives uninstall). The assets/deviceId.txt file present in the install package contains a single byte, "1"; no code reads it anywhere; it does not appear to be the device id source. Unchanged in 1.0.364.

SFS zone login

A stock SFS2X LoginRequest (action=1, system controller), but every call site passes an empty password. Real auth material is entirely inside the parameters SFSObject: All three integrity fields (SecurityCode/OneCode/CoreV) are ordinary client-side MD5 constructions with a hardcoded salt, fully reproducible in Go, no native dependency. Native binaries & security found no evidence the server treats them as a hard gate versus a fingerprint for offline analysis, but a Go client should send them anyway (they cost nothing to compute). Checked against the 2026-10-04 capture, the SecurityCode and OneCode/CoreV formulas reproduce the real iOS app’s values exactly.

Token lifecycle

Everything in this section comes from the 1.0.364 C# (AccountCredentialManager, AppStartupLoading, LoginState, LoginMessage) and is static-analysis-only unless a line says otherwise. goclient implements little of it: it keeps no refresh token, so it can’t refresh itself the way the real client does.

Storage

at and rt come only from getserverlist.php responses. No Lua code sets them.

A GSL call on every cold start

CheckResVersionState clears the cached server IP, port, and connection type (keeping zone and gameUid), so StartConnect never finds a cached server and always runs GetServerList. The client then:
  1. Picks the serverList entry matching the response’s lastLoggedServer, falling back to serverList[0]. goclient first picks the entry carrying the session’s gameUid, then falls back the same way.
  2. Stores the new at/rt and clears loginKey.
  3. Connects and logs in with the stored at.

Choosing the GSL opt

So a returning client refreshes its token on its own once at.time is 30 days old, and right after an E011 clears at. The form fields and their order are on Gate-server RSA+AES handshake. goclient sends opt=login, opt=fix, or opt=new on the guest and email paths. It sends opt=refresh for a session config that holds a refresh token (see Refreshing the access token) and through the manual -cs-rt flag. Its game-server lookup sends no opt field (see Looking up the game server).

GSL result codes

The client accepts a GSL response only when code == 0 and serverList is non-empty. goclient decodes code but doesn’t branch on it.

Login rejection codes

A rejected Login arrives as SFS2X ec=28 with a reason string in ep[0] (see Live validation against production). LoginState.OnLoginResponse and the Lua LoginErrorCode table map them: None of the numeric codes is a credential problem, and none is worth retrying. The E1xx codes (E101-E117) are client-local loading and network codes; the server never sends them. goclient reports E011 as session.ErrTokenRejected, the numeric codes above as session.ErrAccountBlocked, E005 as session.ErrLoginMaintenanceOrIdentity, E015/E016 (the season’s server window) as session.ErrSeasonWindow, and every other rejection as ErrAuthRejected. A blocked account, role, device or IP exits with code 4, because neither a fresh capture nor a token refresh can fix it. E015/E016 exit with code 1: they are a server state, not a credential problem, so the next run may get in. E005 still exits with code 2, like the other rejections; whether it should is still undecided (see Client 1.0.370). The real client’s recovery from E011 needs the refresh token: clear at, run GSL opt=refresh with rt, store the new pair, and log in again. goclient does the same for a session config that holds a refresh token, such as an own-device one (see Refreshing the access token). A config captured from the real app has no refresh token, so its recovery is a fresh capture, see Recovering from a rotated token.

Reading a ban

A ban’s ep[0] is one string with its details separated by ; inside it, for example 4;-9223372036847575810;13;703;<roleName>. It is not five array elements. This layout comes from C485’s report in discussion #53, which cites UIAccountBanView.lua:155-176. It hasn’t been re-checked against this project’s 1.0.364 decompile, and no ban has been seen live here. The dialog names a reason only for 705 (Data Error), 706 (Exploitation of Glitches), 727 (Violation of Speech Rules), and 602 (character deletion). Any other code, such as the 703 in #53, displays as “Data Error”, so the dialog doesn’t tell you the real reason. Don’t read the ban time’s other digits as a duration: the client ignores them. goclient logs the code, whether a ban is permanent, and its reason, then exits with code 4. It reads the sign from the text, so it never parses the number.

The ShuMei risk ban is a different surface

The ep[0] ban above is the account-level ERROR_BANID, returned as a Login rejection. A separate, ShuMei-driven ban arrives after a successful login as a server push: push.shumei.exception.level in game (or login.push.shumei.exception.level on the account-selection screen) carries creat_account_rick_level, which the client turns into the account-ban popup when it’s 1 or 2. It targets the device behind the account, not a specific role, and it never appears in ep[0]. See How ShuMei drives account bans.

Following a serverInfo redirect

When the Login response carries serverInfo, the real client saves the new ip, port, zone, and uid, clears its network config, runs the normal Login-response handler, and reconnects. The cached IP is now set, so the reconnect goes straight to ConnectGame: no GSL call, and the same at. serverInfo.uid replaces gameUid. goclient follows redirects too (confirmed live) and now does the same as the real client: it redials with the same at and adopts serverInfo.zone and serverInfo.uid. Earlier versions called GSL opt=fix before redialing. Under the iOS identity that call could only swap a working token for an Android-bound one, because that GSL request claimed platform=Android. With -cs-ios, or on a reconnect a session config’s iosMode, check-version, every GSL call (opt=refresh, the guest/email getserverlist, the own-device opt=login trade, and the game-server lookup), and the Login claim iOS. Otherwise they stay Android.

Looking up the game server

A session config’s ip and port are optional. The game server’s address comes from GSL getserverlist.php, as it does for the real client on every cold start, so you don’t have to copy it from a capture. The client clears its cached server before it connects (ClearServerNetworkInfo in CheckResVersionState.OnEnter), so it asks GSL every time. Since the 1.0.370 fixes, goclient’s session-config reconnect does the same:
  • Before every Login: one lookup, unless the run just refreshed its tokens (the refresh was its GSL call) or the address was typed on the command line. With no address saved, this lookup is the only way to find the server, and the run stops if it fails.
  • It fails open: with an address saved, a lookup that fails in any way, GSL 211/212 included, keeps the configured address and token and changes nothing else.
  • What it takes from the reply: the entry that carries the session’s gameUid (an entry that names another role is refused), its address, and any access or refresh token the reply carries, as the client’s SaveGameLoginToken stores them. A -cs-at typed on the command line is kept. A reply that rotates the refresh token is saved to the session config before the Login, so a Login that fails afterwards can’t lose it.
  • When the listed server doesn’t answer: every gateway refuses the connection, or the Login gets no reply. The Login is retried at the configured address, if one is saved, still with the token the lookup handed back.
  • When a server refuses a handed-back token (E011): it answered, so its address stays, and the Login is retried there with the token the lookup replaced: the configured one, or the one this run’s refresh issued. The session config keeps that token, not the refused one. This holds after every lookup, the one after an address stops answering included.
  • When the address doesn’t answer and no lookup has worked yet (the pre-Login one failed, or none was made): goclient looks the server up once and, if GSL names a different address, retries there. A rejected Login, such as E011, never triggers a lookup.
goclient saves the address it connected to back into the session config. On the first run after the 1.0.370 fixes, GSL’s gateway host names will likely replace the captured IPs. The lookup sends no opt field, the request the real app makes on a cold start while it holds a fresh at and an rt. It sends the session’s device, zone and gameUid, and platform=iOS for a session the iOS app issued. Before the 1.0.370 fixes, the lookup ran only with no address saved or after the address stopped answering, and it took only the address from the reply and kept the session’s at. The live checks below ran on that version. Confirmed live on 2026-10-10 against a session captured from the iOS app, with the Android check-version reply’s gate host and RSA key:
  • opt=fix, which the table above gives a client with no rt, was rejected with code 212. It returned no server list and no tokens, and the session’s at kept working.
  • No opt returned code 0 and one entry: State#783, zone APS783, port 10783, the three lastwar-game-tcp-* gateway hostnames, and the session’s gameUid. It returned no at or rt.
  • With no address in the session config, goclient looked the server up, logged in, and saved the gateway list and port.
  • With the pre-August address (the captured gateway IPs on port 17783), the first gateway timed out and the second reset the connection. goclient looked the server up once, retried at the hostnames on 10783, logged in, and saved the new address.
An iOS session no longer asks the Android check-version for these. It makes one check-version as the iOS build, as the iOS app does, and the lookup and the session’s own refresh use that reply’s gate host and RSA key. Confirmed live on 2026-10-19 with an equivalent build of this path: a copy of the scheduled runs’ captured iOS session, with no address, sent one iOS check-version and a platform=iOS lookup sealed with that reply’s key, then logged in and loaded 159 buildings. The scheduled runs’ captured session has no rt, so no iOS refresh was tried here. A third party reports one opt=refresh with an iOS own-device config’s refresh token returning code 0 and an access token (discussion #56); it hasn’t been reproduced here. If that check-version fails, the run still dials a configured address, but it can’t look the server up or refresh its token.

A device of its own

A Go client that copies the real app’s tokens shares them with the app, so either side’s refresh may invalidate the other’s. The real client’s role-switch flow shows how a device gets a pair of its own: email verification, then loginKey, then GSL opt=login. goclient ran that flow on 2026-10-04 with a fresh, Go-generated device (confirmed live):
  1. The existing -email and -code-pipe flow bound the new device to the real account. push.account.login.new returned the account’s gameUid and a loginKey. The LASTWAR_STATE_DIR environment variable kept that device’s state files apart from the existing ones.
  2. The experimental -own-device-session <path> flag traded the loginKey for the device’s own at/rt pair through GSL opt=login. The response named lastLoggedServer 783 and a one-entry serverList for APS783, whose ip held three gateway hostnames on port 10783 (see SFS2X wire protocol). at.time and rt.time both equaled the moment of issue. The flag writes these into a session config, including refreshToken, accessTokenTime, and refreshTokenTime, which later runs refresh with (see Refreshing the access token).
  3. A base-zone Login with that token and goclient’s Android identity (1.0.364/1892, un = gameUid, shumeiBoxId empty) was rejected with ec=28, ep=[E005].
  4. On 2026-10-13 the same token, nine days old, logged in once the Login carried a filled Android ta analytics blob (confirmed live). The init push loaded 160 buildings. Minutes later the account’s email got a “New Device Alert for Last War ID” naming an Android device in the United States, with a Sign Out of This Device button. So the account keeps a device list, and the server counts the Go client’s device as one of them.
The gate was ta. goclient filled ta only for iOS and sent {} on Android. C485 found from real Android captures that an Android Login with {} gets E005 and one with the platform markers filled in doesn’t (discussion #22). On 2026-10-13 one build sent the same token twice, changing only ta: The deviceId, account, and server were the same in both runs, so the 2026-10-04 suspects don’t block this Login: the Go-generated deviceId’s shape, the Android identity itself, and, nine days after binding, trust in the device. ta’s lw_device_id, lw_shumei_id, and lw_airKey stayed blank, as they were for iOS then (blank before the 1.0.370 follow-up; the iOS ta now fills them, Android’s still doesn’t). A missing shumeiBoxId isn’t the cause either, since the accepted Login sent none. What the test settles and what it doesn’t:
  • Established accounts only. A guest Login was accepted with {} for months, and on 2026-10-13 a fresh guest was accepted with the filled blob too (confirmed live). The -email binding ran with it the same night (see Setting up a device of its own in one run); the loginKey fast path (opt=login, un empty) hasn’t.
  • Which keys matter is open. Both A/B tests, C485’s and this one, compared {} with the whole blob. The platform markers (#os, #bundle_id, lw_platform) are the likely gate, but the build and zone keys changed with them.

Setting up a device of its own in one run

-email together with -own-device-session binds a fresh device and writes its session config in one run:
The run logs in as a guest, verifies the email, and logs the account’s roles: each role’s server, zone, gameUid, level, and power. Then it trades the account’s loginKey for the device’s own at/rt through GSL opt=login and writes the session config. A device that already holds a loginKey skips the email and trades it. -cs-ios on that command, or on a plain -email login, uses the iOS identity for the whole run: check-version, GSL platform=iOS, the guest Login (com.lastwar.ios and the iOS psh), and account.login.new pf=AppStore. The written session config has iosMode true and the iOS build (1.0.370/918 since the 1.0.370 fixes; 1.0.344/786 before). Without -cs-ios the same run stays Android. A third party ran this iOS bind against production on 2026-10-28 and reported it working (discussion #56), on one established account in one run. It hasn’t been reproduced here. Per that report:
  • The bind: the fresh device’s iOS guest Login was accepted and its init arrived. Email verification and the loginKey trade then wrote a config with iosMode true and 1.0.344/786.
  • A Login with that config was accepted with shumeiBoxId empty and loaded the account’s buildings. It sent the filled iOS ta: #os = iOS, #bundle_id = com.lastwar.ios, lw_platform = AppStore, the build and lw_zone, with lw_device_id, lw_shumei_id and lw_airKey blank (blank before the 1.0.370 follow-up; the iOS ta now fills them). ta = {} wasn’t tried.
  • One opt=refresh with the config’s refresh token, a few minutes after the bind, returned code 0, the current at with its original at.time, and no rt. The Android pair returned the same eight days after issue (see Refreshing the access token), so on iOS too an early refresh rotates neither token.
-server picks the role to bind, by its server number (783) or zone (APS783), from the roles the run logs; a value that names no server number is refused before the code is requested. Without it, the role push.account.login.new names at its top level is bound. A server the account has no role on, or two roles on one server, fails after verification without saving the binding. By then the code is spent, so bind again from a fresh LASTWAR_STATE_DIR with a server from the logged list. If GSL’s opt=login reply doesn’t list the picked role, the trade fails rather than writing another role’s server into the config. Binding a role other than the top-level one is static analysis only: the real account has one role, so it was never tried live. The role picker binds every role with the account’s top-level loginKey and the picked entry’s gameUid (AccountManager.lua:207-215, 1.0.370), so goclient does too. It keeps the bound role’s zone in .lastwar_goclient_zone and sends it as the GSL zone (UIRoleLoginView.lua:110-120). Confirmed live on 2026-10-13: one run bound a fresh device to the real account’s role on 783 and wrote its config, and a Login with that config loaded 160 buildings. What the same night showed:
  • accountArr carries no loginKey. The loginKey is the account’s, at the push’s top level. Each accountArr entry is a role: the server’s id, zone, name, ip, and port, the role’s gameUid, gameUserName, gameUserLevel, and power, and also the device uuid the role was created on and the server’s internal database and cache hosts. goclient logs only the server and role fields.
  • A quick second code request sent no email. A second account.login.send.verify.code about two minutes after the first was acknowledged, but no email came. Twelve minutes later one did. A code that already completed a binding was refused with errorCode=208193.
  • A failed bind leaves a guest behind. After a bind that failed at the code, the same device’s next guest Login, with the access token GSL opt=new returned for it, got ec=28, ep=[E011]. Bind again from a fresh LASTWAR_STATE_DIR; the run warns when the device already logged in as a guest.
  • Own devices keep working tokens, alongside a token captured from the real app. After a second device was bound and logged in, the first device’s config still logged in. On 2026-10-13 three more devices were bound to the account (one of them never saved its binding locally), and own devices logged in nine times between 00:13 and 02:16 PDT. The scheduled 03:00 PDT run, which uses a token captured from the real iOS app, still logged in afterwards (confirmed live, one run). Each Login takes the role’s one live connection, so the devices don’t play at the same time.

Refreshing the access token

A session config with a refreshToken, such as one -own-device-session writes, renews its own access token the way the real client does (csharp-native §2.3):
  • Before the Login, when the config has no accessToken, or its accessTokenTime is 30 days old (gsl.ChooseOpt), goclient sends GSL opt=refresh with the refresh token.
  • After an E011, it refreshes once and logs in again. A token rejected again right after a refresh exits 2 with a message to bind the device again. A refresh that fails for another reason, such as the network or another GSL code, exits 1, and the next run tries again.
  • Every refresh is saved at once. The new at, rt, and their times go into the session config before the Login uses them, so a rotated rt survives a Login that fails. A GSL code 211 or 212 means the device’s credentials are gone and exits 2, except before the Login while an old access token is still on hand: then the run logs an error saying to bind the device again and carries on with the old token for as long as it works.
The refresh sends the session’s device, zone, and gameUid, and platform=iOS under iosMode. A config captured from the real app has no refresh token, so its E011 still needs a fresh capture (see Recovering from a rotated token). The refresh token belongs to the config’s deviceId. A run whose -cs-deviceid names another device doesn’t use it. One that names the config’s own device does, and when that run saves a redirect or a looked-up address back to the config, the refresh token and its time stay in it. Before, any -cs-deviceid dropped the token, and that save-back deleted it from the config. Confirmed live on 2026-10-13 with the own device’s eight-day-old pair:
  • E011, then refresh: a config whose accessToken the server never issued got E011. The refresh succeeded, and the second Login loaded 160 buildings.
  • Stale at.time: with accessTokenTime set 31 days back, the refresh ran before the Login, which was accepted.
  • No access token: a config holding only refreshToken refreshed and logged in.
  • What opt=refresh returned: each time, the device’s current at with its original at.time, and no rt. Eight days after issue, a refresh doesn’t rotate either token.

Open questions

These need live observation; Findings & further work tracks them.
  • Does opt=refresh rotate at or rt once at is 30 days old? Eight days after issue it returned the current at and no rt (2026-10-13). The client stores whatever arrives non-empty.
  • Does the real app’s own 30-day refresh invalidate the tokens of a device of its own? Own devices and a captured token coexisted on 2026-10-13, but no real-app refresh happened in that window.
  • Does the server check platform, uuid, or airKey on opt=refresh? The client always sends the values the token was issued under.

Post-login sequence

In the 2026-10-04 capture of the real iOS app, the server pushed one bare init (about 287 KB, 247 top-level keys) about 200 ms after Login. No init.before, init.after, or push.init.build arrived. A Go client doesn’t send init itself; it just waits for it, see Live validation against production. Around and after init, the real client sends, in order (observed in the capture, with the C# and Lua sources noted):
  1. change.user.parseid and check.device.change {_id}, both from C#. The server answered check.device.change with r:false; the C# reads the result and ignores it.
  2. About 45 requests from Lua’s RequestOtherLoginMsg, nearly all reads: VIP, news, shop, alliance, world, and season info. The capture holds about 224 extension requests in the first 5 s.
  3. login.ext {info, add}. info is a JSON device description: device name and model, OS version, network type, GPU, and CPU. When init carries add {a, b, data, enc}, the C# decrypts data with a hardcoded AES key, executes it as Lua, and returns the result as add: a server-pushed, executable integrity challenge. It’s documented here as a protocol fact only; reproducing it is out of scope. In the capture, init carried add and the server answered login.ext with {success:true}.
  4. Nine mail.delete.batch {type: "auto", uids} calls about 4.7 s in. The real client auto-deletes mail older than 30 days once a day, see Alliance, chat & mail.
The server also pushes push.shumei.id {shumeiId} about 0.5 s after Login (observed live). The client caches that value and reports it as ta.lw_shumei_id in its next Login. Since the 1.0.370 follow-up goclient keeps it in the session config’s shumeiId: pcap -session-out records it (the last push.shumei.id after the Login, else the captured ta’s lw_shumei_id), a run saves each one a push brings as it arrives, as the client does in the push handler, so a run that then fails or is kicked keeps it, and the iOS Login sends it as ta lw_shumei_id. It belongs to the config’s deviceId: a run under another one neither sends nor saves it (static-analysis-only). shumeiId is the server’s own device identifier and is distinct from both shumeiBoxId and the push.shumei.exception.level risk push; the client also folds it into the analytics super properties (lw_shumei_id, Assembly-CSharp:58829,58940). login.init is an active pull that the real client never sent in the capture. The C# sends dataConfigMd5 with it only when non-empty. As far as the 1.0.364 Lua shows, none of these requests is a prerequisite for server-side state: production, idle rewards, visitors, and mail are all server-time-based, and daily VIP state arrives in init (static-analysis-only).

init fields worth reading

No gateway list, session hint, or token expiry appears anywhere in init.

Server day and daily reset

The server day starts at 00:00 server time, which is UTC plus real_timezone_offset. With the live offset of -7200 s, that’s 02:00 UTC every day, and init.tomorrow is 02:00 UTC of the next day (observed in the 2026-10-04 capture). The rest of this section is from the 1.0.364 Lua and C#, static-analysis-only:
  • Day zero is now - (now + real_timezone_offset * 1000) mod 86,400,000, all in ms (UITimeManager:GetTodayZero). Weeks start on Monday at the same boundary: Monday 02:00 UTC, live.
  • All server-day math uses UTC plus a fixed offset, so daylight saving time never moves the boundary.
  • There’s no “new day” push. The client fires OnUnDelayPassDay exactly at the boundary and OnPassDay 5 to 15 s later, with random jitter, when 61 DataCenter managers re-fetch their daily state. OnPassWeek fires 4 s after Monday’s boundary.
  • “Already claimed today” checks compare timestamps with IsSameDayForServer, not with 24-hour timers.
  • The C# always sets its next reset from init.tomorrow, but applies real_timezone_offset only when init carries the key. The Lua falls back to 0 (UTC) when the key is absent, which would put its boundary at 00:00 UTC while tomorrow stays at 02:00 UTC. The 2026-10-04 capture shows the key in the Login response; whether init carries it too hasn’t been checked. Anchoring on tomorrow (day zero = tomorrow - 86400 s) works either way.

Visitor type numbering

Two different numberings are both called “visitor type” (static-analysis-only): What visitor.operate {uid, operate} does depends on the behaviour type, so look it up through the entry’s eventId, not its type. For a MERCHANT (events 1001 and 1002), operate: 1 buys the offered item with resources and operate: 0 declines. A SystemGift visitor opens a gift-pack window first. Visitors with event ids 6001, 8001, 12001, and the S0-boss and ProtectCover visitors have client-made uids (eventId + 100000000) and never reach the server. Across 326 accepts on the real account over three months, every visitor’s behaviour type was 2, 3, or 10 (confirmed live).

Guest identity is sufficient

No OAuth is required to play: account.login.new with type=1 and only deviceId/airKey/pf is the full “no external provider” path. Social binding (Google Sign-In type=2, Apple Game Center type=4, Play Games type=5) requires obtaining a provider token yourself, out of scope for a headless client, and optional. Per the 1.0.364 Lua, account.login.new sends pf as "AppStore" on iOS and "market_global" on Android; goclient always sends market_global.

New-device account selection

With client_config switch 21 on and no stored gameUid, the 1.0.364 C# first connects to the loginServer {ip, port, ws_ip, ws_port} that the GSL response names, not to a game zone. The server then pushes login.push.shumei.exception.level, whose creat_account_rick_level == 1 hides the account picker’s New game button (AccountSelectState.OnPushShumeiExceptLevel, Assembly-CSharp:8915-8929; gated on switch 36, ENABLE_SHUMEI_CREATE_ACCOUNT_RISK_BAN). It’s the login-server half of the ShuMei risk ban, see How ShuMei drives account bans (static-analysis-only).

A second, optional channel: chat

Real-time chat text runs over a separate WebSocket (JSON frames, not SFSObject), authenticated with the chatToken from the init push. Server discovery is its own HTTP bootstrap, signed with an MD5 formula keyed on a fixed app id 100017: /server/links on the lastwar-chat-* hosts, or chat_server_links.php behind a DataConfig switch (see Alliance, chat & mail). Every outbound message is signed: MD5(uid + json(sortedParams) + sendTime + connectionSign). This channel is optional, skip it entirely if the Go client doesn’t need real-time chat; “share to chat” and moderation commands still work over the plain SFS socket regardless (see Alliance, chat & mail).