Device ID
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 SFS2XLoginRequest (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:
- Picks the
serverListentry matching the response’slastLoggedServer, falling back toserverList[0].goclientfirst picks the entry carrying the session’sgameUid, then falls back the same way. - Stores the new
at/rtand clearsloginKey. - Connects and logs in with the stored
at.
Choosing the GSL opt
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 whencode == 0 and serverList is non-empty.
goclient decodes code but doesn’t branch on it.
Login rejection codes
A rejectedLogin 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’sep[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
Theep[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’sip 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/212included, 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’sSaveGameLoginTokenstores them. A-cs-attyped on the command line is kept. A reply that rotates the refresh token is saved to the session config before theLogin, so aLoginthat fails afterwards can’t lose it. - When the listed server doesn’t answer: every gateway refuses the connection, or the
Logingets no reply. TheLoginis 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 theLoginis 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-
Loginone failed, or none was made):goclientlooks the server up once and, if GSL names a different address, retries there. A rejectedLogin, such asE011, 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 nort, was rejected with code212. It returned no server list and no tokens, and the session’satkept working.- No
optreturned code0and one entry:State#783, zoneAPS783, port10783, the threelastwar-game-tcp-*gateway hostnames, and the session’sgameUid. It returned noatorrt. - With no address in the session config,
goclientlooked 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.goclientlooked the server up once, retried at the hostnames on10783, logged in, and saved the new address.
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, thenloginKey, then GSL opt=login. goclient ran that flow on 2026-10-04 with a fresh, Go-generated device (confirmed live):
- The existing
-emailand-code-pipeflow bound the new device to the real account.push.account.login.newreturned the account’sgameUidand aloginKey. TheLASTWAR_STATE_DIRenvironment variable kept that device’s state files apart from the existing ones. - The experimental
-own-device-session <path>flag traded theloginKeyfor the device’s ownat/rtpair through GSLopt=login. The response namedlastLoggedServer783 and a one-entryserverListforAPS783, whoseipheld three gateway hostnames on port 10783 (see SFS2X wire protocol).at.timeandrt.timeboth equaled the moment of issue. The flag writes these into a session config, includingrefreshToken,accessTokenTime, andrefreshTokenTime, which later runs refresh with (see Refreshing the access token). - A base-zone
Loginwith that token andgoclient’s Android identity (1.0.364/1892,un=gameUid,shumeiBoxIdempty) was rejected withec=28,ep=[E005]. - On 2026-10-13 the same token, nine days old, logged in once the
Logincarried a filled Androidtaanalytics blob (confirmed live). Theinitpush 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.
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
Loginwas accepted with{}for months, and on 2026-10-13 a fresh guest was accepted with the filled blob too (confirmed live). The-emailbinding ran with it the same night (see Setting up a device of its own in one run); theloginKeyfast path (opt=login,unempty) 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:
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
Loginwas accepted and itsinitarrived. Email verification and theloginKeytrade then wrote a config withiosModetrue and1.0.344/786. - A
Loginwith that config was accepted withshumeiBoxIdempty and loaded the account’s buildings. It sent the filled iOSta:#os=iOS,#bundle_id=com.lastwar.ios,lw_platform=AppStore, the build andlw_zone, withlw_device_id,lw_shumei_idandlw_airKeyblank (blank before the 1.0.370 follow-up; the iOStanow fills them).ta={}wasn’t tried. - One
opt=refreshwith the config’s refresh token, a few minutes after the bind, returned code0, the currentatwith its originalat.time, and nort. 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:
accountArrcarries nologinKey. TheloginKeyis the account’s, at the push’s top level. EachaccountArrentry is a role: the server’sid,zone,name,ip, andport, the role’sgameUid,gameUserName,gameUserLevel, andpower, and also the deviceuuidthe role was created on and the server’s internal database and cache hosts.goclientlogs only the server and role fields.- A quick second code request sent no email. A second
account.login.send.verify.codeabout 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 witherrorCode=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 GSLopt=newreturned for it, gotec=28,ep=[E011]. Bind again from a freshLASTWAR_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
Logintakes the role’s one live connection, so the devices don’t play at the same time.
Refreshing the access token
A session config with arefreshToken, 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 noaccessToken, or itsaccessTokenTimeis 30 days old (gsl.ChooseOpt),goclientsends GSLopt=refreshwith 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 theLoginuses them, so a rotatedrtsurvives aLoginthat fails. A GSL code 211 or 212 means the device’s credentials are gone and exits 2, except before theLoginwhile 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.
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 whoseaccessTokenthe server never issued gotE011. The refresh succeeded, and the secondLoginloaded 160 buildings.- Stale
at.time: withaccessTokenTimeset 31 days back, the refresh ran before theLogin, which was accepted. - No access token: a config holding only
refreshTokenrefreshed and logged in. - What
opt=refreshreturned: each time, the device’s currentatwith its originalat.time, and nort. Eight days after issue, a refresh doesn’t rotate either token.
Open questions
These need live observation; Findings & further work tracks them.- Does
opt=refreshrotateatorrtonceatis 30 days old? Eight days after issue it returned the currentatand nort(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, orairKeyonopt=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 bareinit (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):
-
change.user.parseidandcheck.device.change {_id}, both from C#. The server answeredcheck.device.changewithr:false; the C# reads the result and ignores it. -
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. -
login.ext {info, add}.infois a JSON device description: device name and model, OS version, network type, GPU, and CPU. Wheninitcarriesadd {a, b, data, enc}, the C# decryptsdatawith a hardcoded AES key, executes it as Lua, and returns the result asadd: a server-pushed, executable integrity challenge. It’s documented here as a protocol fact only; reproducing it is out of scope. In the capture,initcarriedaddand the server answeredlogin.extwith{success:true}. -
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.
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 plusreal_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
OnUnDelayPassDayexactly at the boundary andOnPassDay5 to 15 s later, with random jitter, when 61 DataCenter managers re-fetch their daily state.OnPassWeekfires 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 appliesreal_timezone_offsetonly wheninitcarries the key. The Lua falls back to0(UTC) when the key is absent, which would put its boundary at 00:00 UTC whiletomorrowstays at 02:00 UTC. The 2026-10-04 capture shows the key in theLoginresponse; whetherinitcarries it too hasn’t been checked. Anchoring ontomorrow(day zero =tomorrow - 86400s) 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
Withclient_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 thechatToken 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).