npetrovski / l2js-client

JavaScript client for Lineage 2
MIT License
105 stars 35 forks source link

C4 Support? #4

Closed w3nder closed 3 years ago

npetrovski commented 3 years ago

Hi @W3nder. I don't have anything (documents) I can offer you right now, but I will have a look and will come back to you.

npetrovski commented 3 years ago

@W3nder I managed to re-write the project to work with C4 and the server you mentioned. The authentication works fine, but when connect to the Game server, and after I send "ProtocolVersion" (= 656), the server does not respond (I expect to receive CryptInit).

[11/14/2020, 1:56:44 PM] DEBUG MMOConnection Connecting [ '83.166.99.220:2106' ]
[11/14/2020, 1:56:44 PM] INFO MMOConnection Connected [ '83.166.99.220:2106' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Receive [ 'Init' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Sending  [ 'AuthGameGuard' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Sending  [ 'RequestAuthLogin' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Receive [ 'LoginOk' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Sending  [ 'RequestServerList' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Receive [ 'ServerList' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Sending  [ 'RequestServerLogin' ]
[11/14/2020, 1:56:44 PM] DEBUG LoginClient Receive [ 'PlayOk' ]
[11/14/2020, 1:56:44 PM] DEBUG MMOConnection Connecting [ '83.166.99.220:7777' ]
[11/14/2020, 1:56:44 PM] INFO MMOConnection Disconnected [ '83.166.99.220:2106' ]
[11/14/2020, 1:56:45 PM] INFO MMOConnection Connected [ '83.166.99.220:7777' ]
[11/14/2020, 1:56:45 PM] DEBUG GameClient Sending  [ 'ProtocolVersion' ]

<--- I DO NOT RECEIVE ANYTHING HERE

Could you please let me know what ProtocolVersion you send to this server - is it 656 value or something else? (a hex-dump of the ProtocolVersion packet you send will help a lot)

After I make CryptInit works, I will push a new GIT branch for C4 (version 0x785a)

npetrovski commented 3 years ago

Thanks - will merge this change in branch "C4-0x785a" - you can switch to this branch and test on your side as well. This "magicHex" is apparently something, related to this specific server, and most probably will not work in other C4 servers, although, I will merge this as well.

Regarding :

[15/11/2020 23:46:38] ERROR Die RangeError: Offset is outside the bounds of the DataView
      switch (opcode) {
        case 0x00:
          rpk = new Die(); // CryptInit????

that's perfectly normal, this protocol version (656) has a bit different opcodes for the packets. All C4-related packets will be pushed indeed to "C4-0x785a"

npetrovski commented 3 years ago

Good news. GameCrypt class was entirely rewritten, and now it follows the 656 protocol flow (just XOR with a key). The C4 Login and Game encryption is now completed - I managed to successfully login and select a character :

[11/16/2020, 9:50:20 PM] DEBUG MMOConnection Connecting [ '83.166.99.220:2106' ]
[11/16/2020, 9:50:20 PM] INFO MMOConnection Connected [ '83.166.99.220:2106' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Receive [ 'Init' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Sending  [ 'AuthGameGuard' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Receive [ 'GGAuth' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Sending  [ 'RequestAuthLogin' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Receive [ 'LoginOk' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Sending  [ 'RequestServerList' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Receive [ 'ServerList' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Sending  [ 'RequestServerLogin' ]
[11/16/2020, 9:50:20 PM] DEBUG LoginClient Receive [ 'PlayOk' ]
[11/16/2020, 9:50:20 PM] DEBUG MMOConnection Connecting [ '83.166.99.220:7777' ]
[11/16/2020, 9:50:20 PM] INFO MMOConnection Disconnected [ '83.166.99.220:2106' ]
[11/16/2020, 9:50:21 PM] INFO MMOConnection Connected [ '83.166.99.220:7777' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'ProtocolVersion' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Receive [ 'CryptInit' ]
[11/16/2020, 9:50:21 PM] DEBUG CryptInit XOR key [ 21229 ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'AuthLogin' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Receive [ 'CharSelectionInfo' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'CharacterSelect' ]
[11/16/2020, 9:50:21 PM] DEBUG GamePacketHandler Unknown game packet received. [0xf8 0x2] len=3
[11/16/2020, 9:50:21 PM] DEBUG GameClient Receive [ 'CharSelected' ]
[11/16/2020, 9:50:21 PM] DEBUG CharSelected Char selected [ 'SomeRandomTrash' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'RequestManorList' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'RequestKeyMapping' ]
[11/16/2020, 9:50:21 PM] DEBUG GameClient Sending  [ 'EnterWorld' ]

Although, it seems the whole protocol has many differences and lots of the packet handlers have to be re-written - something if you wish, you can work on.

npetrovski commented 3 years ago

Yeah. As I said there are lots of changes related to the packet handlers, including some configurations like GameServerPacket paper-doll constants and their usage. When I have the time I will go over those packets and fix those problems. In the meanwhile, if you manage to fix some of those issues - let me know,

w3nder commented 3 years ago

There are 40 minutes that the character is logged in without taking even one disconnect.

I am comparing here the package is not far from being the same as the main version.

Now that I'm connected to the game, I'm going to start fixing the packages ..

As soon as I finish, I send a PR or come back here to tell you how I did it to succeed.

Thank you again..