Difference between revisions of "342 Protocol"

From RuneWiki
Jump to navigationJump to search
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{stub}}
 +
{{cleanup}}
 +
 
== Login Protocol ==
 
== Login Protocol ==
The Login Protocol for the 342 is very similar in structure to that of the 317 (and other versions). The login is comprised of four stages in which the client and server switch in regards to which one is reading and which one is writing.
+
The login is comprised of four stages in which the client and server switch in regards to which one is reading and which one is writing.
 
<br/>
 
<br/>
 
===Variables:===
 
===Variables:===
Line 6: Line 9:
 
====Name Hash====
 
====Name Hash====
 
A hash of the player name, thought to be used to select an appropriate login server. This has no use in current private servers.
 
A hash of the player name, thought to be used to select an appropriate login server. This has no use in current private servers.
<br/>
+
 
====Return Code====
 
The return code is a code used to identify which part of login the session is currently at.
 
=====Return Code Value: 0=====
 
Signifies that the session will exchange session keys in order to obtain encryption.
 
<br/>
 
=====Return Code Value: 1=====
 
Signifies that the session should re-attempt the login procedure.
 
<br/>
 
=====Return Code Value: 2=====
 
This is used to signify that the login process has successfully completed.
 
<br/>
 
=====Return Code Value: 3=====
 
Client displays message - "Invalid username or password".
 
<br/>
 
Used to let the player know that the account credentials they have entered are invalid.
 
<br/>
 
=====Return Code Value: 4=====
 
Client displays message - "Your account has been disabled".
 
<br/>
 
Used to tell the player that their account has been banned from the server.
 
<br/>
 
=====Return Code Value: 5=====
 
Client displays message - "Your account is already logged in".
 
<br/>
 
Used to let the player know that their account is already logged in.
 
<br/>
 
=====Return Code Value: 6=====
 
Client displays message - "RuneScape has been updated!".
 
<br/>
 
Used to let the player know that the game has been updated, and they should refresh the page in order to load the new client version.
 
<br/>
 
=====Return Code Value: 7=====
 
Client displays message - "This world is full".
 
<br/>
 
used to let the player know that the world they have selected is full.
 
<br/>
 
=====Return Code Value: 8=====
 
Client displays message - "Unable to connect, loginserver offline".
 
<br/>
 
Used to let the player know that the game server was unable to connect with a loginserver.
 
<br/>
 
=====Return Code Value: 9=====
 
Client displays message - "Login limit exceeded".
 
<br/>
 
Used to let the player know that there are too many current connections from their IP address to log in another account.
 
<br/>
 
=====Return Code Value: 10=====
 
Client displays message - "Unable to connect, bad session ID".
 
<br/>
 
Used to let the player know that the session ID the client provided to the server is bad.
 
<br/>
 
=====Return Code Value: 11=====
 
Client displays message - "Loginserver rejected session".
 
<br/>
 
Used to let the player know that the loginserver that was selected by the game server rejected the session.
 
<br/>
 
=====Return Code Value: 12=====
 
Client displays message - "You need a members account to sign into this world".
 
<br/>
 
Used to let the player know that the world they have selected is a members-only world, and the account they are using is not a member.
 
<br/>
 
=====Return Code Value: 13=====
 
Client displays message - "Could not complete login".
 
<br/>
 
Used to let the player know that the server was unable to complete the login request.
 
<br/>
 
=====Return Code Value: 14=====
 
Client displays message - "Server is being updated".
 
<br/>
 
Used to let the player know that the server is currently being updated, and they should wait for the update to complete.
 
<br/>
 
=====Return Code Value: 15=====
 
Unknown.
 
<br/>
 
=====Return Code Value: 16=====
 
Client displays message - "Login attempts exceeded".
 
<br/>
 
Used to let the player know that they have made too many logins with invalid username+password combinations, and they need to wait 5 minutes in order to try again.
 
<br/>
 
=====Return Code Value: 17=====
 
Client displays message - "You are standing in a members only area".
 
<br/>
 
Used to let the player know that they are attempting to log into a free-world and their character is located in a members-area.
 
<br/>
 
=====Return Code Value: 20=====
 
Client displays message - "Invalid loginserver requested".
 
<br/>
 
Used to let the player know that the loginserver that was requested by the game server is invalid.
 
<br/>
 
=====Return Code Value: 21=====
 
Client displays message - "You have only just left another world".
 
<br/>
 
Used to let the player know that they have just left another world, and they must wait to enter another.
 
<br/>
 
=====Return Code Value: 22=====
 
Client displays message - "Malformed login packet".
 
<br/>
 
Used to let the player know that the login-packet that the client sent to the server was malformed.
 
<br/>
 
 
====Server Session Key====
 
====Server Session Key====
 
The server-session-key is one of two ciphers used to encrypt the game protocol, using the ISAAC algorithms.
 
The server-session-key is one of two ciphers used to encrypt the game protocol, using the ISAAC algorithms.
Line 126: Line 30:
 
====Connect Status====
 
====Connect Status====
 
The status of the connection.
 
The status of the connection.
=====Connect Status Value: 16=====
+
{|border=2
Signifies that the connection is new.
+
! Value
<br/>
+
! Status
=====Connect Status Value: 18=====
+
|-
Signifies that the session is reconnecting a previously lost connection.
+
| 16
<br/>
+
| Signifies that the connection is new.
 +
|-
 +
| 18
 +
| Signifies that the session is reconnecting a previously lost connection.
 +
|-
 +
|}
 +
 
 
====Size====
 
====Size====
 
The size of the unencrypted login packet, used to determine how many bytes need to be read from the stream by the server.
 
The size of the unencrypted login packet, used to determine how many bytes need to be read from the stream by the server.
Line 137: Line 47:
 
====Client Version====
 
====Client Version====
 
The memory-version of the game client.
 
The memory-version of the game client.
<br/>
+
{|border=2
=====Client Version Value: 0=====
+
! Value
Signifies that the client is a low-memory client.
+
! Status
<br/>
+
|-
=====Client Version Value: 1=====
+
| 0
Signifies that the client is a high-memory client.
+
| Signifies the client is a low-memory client.
 +
|-
 +
| 1
 +
| Signifies that the client is a high-memory client.
 +
|-
 +
|}
 +
 
 
====CRC Values====
 
====CRC Values====
Unknown.
+
9 4-byte values, Each containing the CRC of their respective cache files. Used by the server to verify client is up to date.
 
<br/>
 
<br/>
 +
 
====Player Status====
 
====Player Status====
 
The in-game player status - player, player moderator, or administrator.
 
The in-game player status - player, player moderator, or administrator.
 
<br/>
 
<br/>
=====Player Status Value: 0=====
+
{|border=2
Signifies that this player is a normal player.
+
! Value
<br/>
+
! Status
=====Player Status Value: 1=====
+
|-
Signifies that this player is a player moderator.
+
| 0
<br/>
+
| Signifies that this player is a normal player.
=====Player Status Value: 2=====
+
|-
Signifies that this player is an administrator.
+
| 1
<br/>
+
| Signifies that this player is a player moderator.
 +
|-
 +
| 2
 +
| Signifies that this player is an administrator.
 +
|-
 +
|}
 +
 
 
====Flagged====
 
====Flagged====
 
If set to 1, information about mouse movements etc. are sent to the server. Suspected bot accounts are flagged.
 
If set to 1, information about mouse movements etc. are sent to the server. Suspected bot accounts are flagged.
 
<br/>
 
<br/>
 +
====Response Codes====
 +
At the beginning and end of the login procedure, we send different values to the client to allow or deny a login. The various values show different messages on the login box on the client or do something internally.
 
<br/>
 
<br/>
 +
{| border=2
 +
! Value
 +
! Response
 +
|-
 +
| -1
 +
| Waits for 2000ms and tries again while counting failures.
 +
|-
 +
| 0
 +
| Exchanges session keys, player name, password, etc.
 +
|-
 +
| 1
 +
| Waits for 2000ms and tries again.
 +
|-
 +
| 2
 +
| Client made a successful login.
 +
|-
 +
| 3
 +
| "Invalid username or password."
 +
|-
 +
| 4
 +
| "Your account has been disabled. Please check your message-center for details."
 +
|-
 +
| 5
 +
| "Your account is already logged in. Try again in 60 secs..."
 +
|-
 +
| 6
 +
| "RuneScape has been updated! Please reload this page."
 +
|-
 +
| 7
 +
| "This world is full. Please use a different world."
 +
|-
 +
| 8
 +
| "Unable to connect. Login server offline."
 +
|-
 +
| 9
 +
| "Login limit exceeded. Too many connections from your address."
 +
|-
 +
| 10
 +
| "Unable to connect. Bad session id."
 +
|-
 +
| 11
 +
| "Login server rejected session. Please try again."
 +
|-
 +
| 12
 +
| "You need a members account to login to this world. Please subscribe, or use a different world."
 +
|-
 +
| 13
 +
| "Could not complete login. Please try using a different world."
 +
|-
 +
| 14
 +
| "The server is being updated. Please wait 1 minute and try again."
 +
|-
 +
| 15
 +
| See the [[#Regarding response code 15|notes below]].
 +
|-
 +
| 16
 +
| "Login attempts exceeded. Please wait 1 minute and try again."
 +
|-
 +
| 17
 +
| "You are standing in a members-only area. To play on this world move to a free area first."
 +
|-
 +
| 20
 +
| "Invalid loginserver requested. Please try using a different world."
 +
|-
 +
| 21
 +
| "You have only just left another world. Your profile will be transferred in: (number) seconds."
 +
|-
 +
| None of the above
 +
| "Unexpected server response. Please try using a different world."
 +
|-
 +
|}
 +
 +
==== Regarding response code 15 ====
 +
On the server, players are not unregistered for quite some time. This can be best witnessed when the client forcefully closes the connection while in combat. If you're quick enough before the player dies or kills the NPC, login attempts during that time return that the account is already logged in. This probably explains why the message says "try again in 60 seconds", and they just reused the response when the player is truly logged in.
 +
 +
Going along with this "players aren't offline yet" idea, when the client experiences some lag and performs a reconnect, it byte 18 as it's "connection type" to the server.
 +
 +
The server most likely saves this as a boolean (reconnect = var == 18;). When the login is entirely validated, meaning the password's are okay and the server isn't full, it can either send back the normal response, 2, or 15.
 +
 +
But why 15? If you look at the client code, you'll see that the chat messages aren't cleared. If you've ever had a shitty connection you've noticed that your chat stays there upon a reconnect, and this is exactly why.
 +
<!-- thanks to Jim for this contribution-->
 +
There are some minor annoyances with implementing response 15, since you can't send the rights byte (or the flagged byte, I forget which).
 +
 
===Login Process:===
 
===Login Process:===
 
====Stage 1: Client -> Server====
 
====Stage 1: Client -> Server====
 
{| border=2
 
{| border=2
 
|-
 
|-
! Type
+
! Data Type
 
! Value
 
! Value
 
|-
 
|-
Line 177: Line 185:
 
|}
 
|}
 
<br/>
 
<br/>
 +
 
====Stage 2: Server -> Client====
 
====Stage 2: Server -> Client====
 
{| border=2
 
{| border=2
 
|-
 
|-
! Type
+
! Data Type
 
! Value
 
! Value
 
|-
 
|-
Line 208: Line 217:
 
|-
 
|-
 
| byte
 
| byte
| "return code"
+
| "response code"
 
|-
 
|-
| long
+
| [[QWord|long]]
 
| "server session key"
 
| "server session key"
 
|-
 
|-
 
|}
 
|}
 
<br/>
 
<br/>
 +
 
====Stage 3: Client -> Server====
 
====Stage 3: Client -> Server====
 
{| border=2
 
{| border=2
 
|-
 
|-
| Type
+
! Data Type
| Value
+
! Value
|-
 
| byte
 
| 10
 
|-
 
| int
 
| "datafileversion"[0]
 
|-
 
| int
 
| "datafileversion"[1]
 
|-
 
|-
 
| int
 
| "datafileversion"[2]
 
|-
 
| int
 
| "datafileversion"[3]
 
|-
 
| int
 
| "user id"
 
|-
 
| string
 
| "username"
 
|-
 
| string
 
| "password"
 
|-
 
| long
 
| "client session key"
 
|-
 
| long
 
| "server session key"
 
 
|-
 
|-
 
| byte
 
| byte
Line 261: Line 240:
 
| 255
 
| 255
 
|-
 
|-
| short
+
| [[Word|short]]
 
| 342
 
| 342
 
|-
 
|-
Line 267: Line 246:
 
| "client version"
 
| "client version"
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[0]
 
| "crc values"[0]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[1]
 
| "crc values"[1]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[2]
 
| "crc values"[2]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[3]
 
| "crc values"[3]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[4]
 
| "crc values"[4]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[5]
 
| "crc values"[5]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[6]
 
| "crc values"[6]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[7]
 
| "crc values"[7]
 
|-
 
|-
| int
+
| [[DWord|int]]
 
| "crc values"[8]
 
| "crc values"[8]
 +
|-
 +
| byte
 +
| 10
 +
|-
 +
| [[DWord|int]]
 +
| "datafileversion"[0]
 +
|-
 +
| [[DWord|int]]
 +
| "datafileversion"[1]
 +
|-
 +
|-
 +
| [[DWord|int]]
 +
| "datafileversion"[2]
 +
|-
 +
| [[DWord|int]]
 +
| "datafileversion"[3]
 +
|-
 +
| [[DWord|int]]
 +
| "user id"
 +
|-
 +
| [[RSString|RSString]]
 +
| "username"
 +
|-
 +
| [[RSString|RSString]]
 +
| "password"
 +
|-
 +
| [[QWord|long]]
 +
| "client session key"
 +
|-
 +
| [[QWord|long]]
 +
| "server session key"
 
|-
 
|-
 
|}
 
|}
 
<br/>
 
<br/>
 +
 
====Stage 4: Server -> Client====
 
====Stage 4: Server -> Client====
 
{| border=2
 
{| border=2
 
|-
 
|-
| Type
+
! Data Type
| Value
+
! Value
 
|-
 
|-
 
| byte
 
| byte
| "return code"
+
| "response code"
 
|-
 
|-
 
| byte
 
| byte
Line 316: Line 327:
 
==Game Protocol==
 
==Game Protocol==
 
(needs to be documented)
 
(needs to be documented)
 +
 +
===Server -> Client Packets===
 +
 +
{| border=2
 +
|-
 +
! Opcode
 +
! Type
 +
! Length (bytes)
 +
! Name
 +
! Description
 +
|-
 +
| 98
 +
| VARIABLE_BYTE
 +
| N/A
 +
| [[342:Send message|Send message]]
 +
| Sends a server message (e.g. 'Welcome to RuneScape') or trade/duel request.
 +
|-
 +
| 99
 +
| VARIABLE_SHORT
 +
| N/A
 +
| [[342:Update players|Update players]]
 +
| Sends the player update block.
 +
|-
 +
| 128
 +
| FIXED
 +
| 0
 +
| [[342:Logout|Logout]]
 +
| Disconnects the client from the server.
 +
|-
 +
|}
 +
 +
===Client -> Server Packets===
 +
 +
{| border=2
 +
|-
 +
! Opcode
 +
! Type
 +
! Length (bytes)
 +
! Name
 +
! Description
 +
|-
 +
|}

Latest revision as of 22:33, 11 October 2009

Stub

This article is a stub. You can help RuneWiki by expanding it.

Cleanup

This article requires cleaning up to adhere to our quality standards. You can help RuneWiki by improving it.


Login Protocol

The login is comprised of four stages in which the client and server switch in regards to which one is reading and which one is writing.

Variables:

The login process has a lot of variable data, compiled here is a list of the variables and their different values.

Name Hash

A hash of the player name, thought to be used to select an appropriate login server. This has no use in current private servers.

Server Session Key

The server-session-key is one of two ciphers used to encrypt the game protocol, using the ISAAC algorithms.

"Data File Version"

Unknown, quoted from a Winterlove private server.

User ID

The ID of the user.

Username

The username of the player, used to identify their account.

Password

The password of the player account, used so only they can log into their account.

Client Session Key

The client-session-key is one of two ciphers used to encrypt the game protocol, using the ISAAC algorithms.

Connect Status

The status of the connection.

Value Status
16 Signifies that the connection is new.
18 Signifies that the session is reconnecting a previously lost connection.

Size

The size of the unencrypted login packet, used to determine how many bytes need to be read from the stream by the server.

Client Version

The memory-version of the game client.

Value Status
0 Signifies the client is a low-memory client.
1 Signifies that the client is a high-memory client.

CRC Values

9 4-byte values, Each containing the CRC of their respective cache files. Used by the server to verify client is up to date.

Player Status

The in-game player status - player, player moderator, or administrator.

Value Status
0 Signifies that this player is a normal player.
1 Signifies that this player is a player moderator.
2 Signifies that this player is an administrator.

Flagged

If set to 1, information about mouse movements etc. are sent to the server. Suspected bot accounts are flagged.

Response Codes

At the beginning and end of the login procedure, we send different values to the client to allow or deny a login. The various values show different messages on the login box on the client or do something internally.

Value Response
-1 Waits for 2000ms and tries again while counting failures.
0 Exchanges session keys, player name, password, etc.
1 Waits for 2000ms and tries again.
2 Client made a successful login.
3 "Invalid username or password."
4 "Your account has been disabled. Please check your message-center for details."
5 "Your account is already logged in. Try again in 60 secs..."
6 "RuneScape has been updated! Please reload this page."
7 "This world is full. Please use a different world."
8 "Unable to connect. Login server offline."
9 "Login limit exceeded. Too many connections from your address."
10 "Unable to connect. Bad session id."
11 "Login server rejected session. Please try again."
12 "You need a members account to login to this world. Please subscribe, or use a different world."
13 "Could not complete login. Please try using a different world."
14 "The server is being updated. Please wait 1 minute and try again."
15 See the notes below.
16 "Login attempts exceeded. Please wait 1 minute and try again."
17 "You are standing in a members-only area. To play on this world move to a free area first."
20 "Invalid loginserver requested. Please try using a different world."
21 "You have only just left another world. Your profile will be transferred in: (number) seconds."
None of the above "Unexpected server response. Please try using a different world."

Regarding response code 15

On the server, players are not unregistered for quite some time. This can be best witnessed when the client forcefully closes the connection while in combat. If you're quick enough before the player dies or kills the NPC, login attempts during that time return that the account is already logged in. This probably explains why the message says "try again in 60 seconds", and they just reused the response when the player is truly logged in.

Going along with this "players aren't offline yet" idea, when the client experiences some lag and performs a reconnect, it byte 18 as it's "connection type" to the server.

The server most likely saves this as a boolean (reconnect = var == 18;). When the login is entirely validated, meaning the password's are okay and the server isn't full, it can either send back the normal response, 2, or 15.

But why 15? If you look at the client code, you'll see that the chat messages aren't cleared. If you've ever had a shitty connection you've noticed that your chat stays there upon a reconnect, and this is exactly why. There are some minor annoyances with implementing response 15, since you can't send the rights byte (or the flagged byte, I forget which).

Login Process:

Stage 1: Client -> Server

Data Type Value
ubyte 14
ubyte "name hash"


Stage 2: Server -> Client

Data Type Value
byte 0
byte 0
byte 0
byte 0
byte 0
byte 0
byte 0
byte 0
byte "response code"
long "server session key"


Stage 3: Client -> Server

Data Type Value
byte "connect status"
byte "size"
byte 255
short 342
byte "client version"
int "crc values"[0]
int "crc values"[1]
int "crc values"[2]
int "crc values"[3]
int "crc values"[4]
int "crc values"[5]
int "crc values"[6]
int "crc values"[7]
int "crc values"[8]
byte 10
int "datafileversion"[0]
int "datafileversion"[1]
int "datafileversion"[2]
int "datafileversion"[3]
int "user id"
RSString "username"
RSString "password"
long "client session key"
long "server session key"


Stage 4: Server -> Client

Data Type Value
byte "response code"
byte "player status"
byte "flagged"


Game Protocol

(needs to be documented)

Server -> Client Packets

Opcode Type Length (bytes) Name Description
98 VARIABLE_BYTE N/A Send message Sends a server message (e.g. 'Welcome to RuneScape') or trade/duel request.
99 VARIABLE_SHORT N/A Update players Sends the player update block.
128 FIXED 0 Logout Disconnects the client from the server.

Client -> Server Packets

Opcode Type Length (bytes) Name Description