Login Protocol
The login protocol begins after INIT_LOGIN. The server accepts two variable-short client packets with the same payload layout; the reconnect flag does not change how the payload is parsed.
| Client packet | ID | Payload size |
|---|---|---|
LOGIN |
16 | Variable short |
RECONNECT |
18 | Variable short |
The payload fields are consumed in this order:
| Field | Encoding | Notes |
|---|---|---|
| Client version | 4-byte integer | — |
| Instance ID | 8-byte integer | — |
| Flags | 1 byte | See the flag bit positions below |
| Settings | JStr |
Applet settings string |
| New display name | JStr2, conditional |
Present when the NEW_DISPLAY_NAME flag is set |
| RSA block | 2-byte length and ciphertext | See the RSA/XTEA decoding guide |
The flag bit positions are zero-based:
| Flag | Bit position |
|---|---|
MEMBER |
1 |
JAGEX_DOMAIN |
3 |
NEW_DISPLAY_NAME |
4 |
The decrypted login payload contains four 4-byte ISAAC seed values, a 24-byte machine ID, a 2-byte affiliate ID, credentials, and a password. Credentials depend on the type selected during init:
| Init credentials type | Credential encoding |
|---|---|
| 1 or 2 | Base-37 display name |
| 3 | JStr2 email |
The password uses its packed wire representation. The server derives the nonce from the low 32 bits of seed values 2 and 3 and rejects a mismatch with the nonce returned by INIT_LOGIN.
The server removes the read timeout and starts authentication. Server reply packet types are:
| Server packet | ID | Payload size | Payload |
|---|---|---|---|
LOGIN_OK |
0 | Variable-any | Display name, staff level, membership days, cookie, flags, and account-related values |
INVALID_CREDENTIALS |
8 | 0 | Empty payload |
PICK_NEW_DISPLAY_NAME |
10 | Variable-any | Empty in the current helper |
ERROR |
2 | Variable-any | Error message as JStr |
The LOGIN_OK payload fields appear in this order:
| Order | Field | Encoding / notes |
|---|---|---|
| 1 | Display name | Base-37 long |
| 2 | Staff level | Ordinal (1 byte) |
| 3 | Reserved | Zero byte |
| 4 | Membership days | 2 bytes |
| 5 | Cookie | JStr |
| 6 | Reply flags | 1 byte |
| 7 | Random data | Optional |
| 8 | Display name | JStr |
| 9 | Unread-message count | 1 byte |
Reply flags is a one-byte bitfield with zero-based bit positions:
| Flag | Bit position | Meaning |
|---|---|---|
READ_RANDOM_DATA |
1 | Random data follows the flags byte when this bit is set; it is omitted when clear. |
CHAT_RESTRICTED |
3 | The account is chat-restricted. |
The current success path uses the defaults: empty cookie, no random data, and no chat-restricted flag.
On successful authentication, the server writes LOGIN_OK and switches to the game-specific, ISAAC-ciphered game protocol.