Actions

Classic/177/Login

From RuneWiki

The login process is as described:

1) Client establishes connection to TCP port 43594

2) Server initiates communication by sending a 4-byte random seed

3) Client replies with a payload depending on the action: Connecting, reconnecting, or registering

4) Server replies to that payload with a response code

Opcode Encryption

This system has no name or a known real-world counterpart. I’ll do my best to break it down.

Terminology:

  1. Key, this is the offset to add or subtract the opcode from.
  2. Friend, the specific offset each opcode applies.
  3. Spooky Threat, named after the copyright warning, an additional offset that makes the friend offset vary more.
  4. Encryption Array, a list of the friend values for any opcode for the other side.

There is an initial “key” that it starts at 3141592 for both sides. Opcodes are added or subtracted to, so the real value is uncovered. Both sides must use an agreed upon Spooky Threat and friend values for every opcode or the stream will get out of sync.

Example implementation

RSA Encryption

Passwords are RSA-encrypted using a 128-bit key. Passwords can be up to 21-characters in length.

Because of the key size, only 16 bytes (128 bits / 8 bits per byte) can be encrypted at once. The client breaks the password up into 3 blocks of 7 characters. The string is padded to 21 characters no matter what and gets filled in with spaces (ASCII 32) if necessary.

Each block starts with 4 bytes of random numbers followed by an additional 4 zeroes. Only the last 8 bytes are relevant. Combine the last 8-bytes from each of the 3 blocks to get a password string, then trim the spaces off.

https://github.com/Pazaz/RSC-177-Server/blob/485e294845dc0ffd0db7b9ba1e14e89ff3b71a90/engine/Login.js#L50