Exemple #1
0
            public override void HandlePacket(LobbyClient client, ServerPacket packet)
            {
                var reader = packet.Reader;

                int versionHigh   = reader.ReadInt32();
                int versionMiddle = reader.ReadInt32();
                int versionLow    = reader.ReadInt32();
                int buildNo       = reader.ReadInt32();

                Log.Info($"Server Version: {versionHigh}.{versionMiddle}.{versionLow}.{buildNo}");

                byte unknown = reader.ReadByte();

                Log.Debug($"Unknown byte: {unknown}");

                uint puzzleSolution = 0;

                if (unknown > 0)
                {
                    byte[] encryptionKey = reader.ReadBytes(8);
                    client.SetEncryptionKey(encryptionKey);

                    uint[] uintEncryptionKey = new uint[2];
                    uintEncryptionKey[0] = BitConverter.ToUInt32(encryptionKey, 0);
                    uintEncryptionKey[1] = BitConverter.ToUInt32(encryptionKey, 4);

                    uint[] puzzleData = new uint[4];
                    puzzleData[3] = 0;
                    for (int i = 0; i < 3; i++)
                    {
                        puzzleData[i] = reader.ReadUInt32();
                    }

                    try
                    {
                        SolveLoginPuzzle(uintEncryptionKey, puzzleData, unknown);
                    }
                    catch (Exception)
                    {
                        Log.Error($"Failed to solve login puzzle: v[0]=0x{uintEncryptionKey[0]:X}, v[1]=0x{uintEncryptionKey[1]:X}, k[0]=0x{puzzleData[0]:X}, k[1]=0x{puzzleData[1]:X}, k[2]=0x{puzzleData[2]:X}");

                        client.OnPuzzleFailed(client, 10011);
                        client.Disconnect();
                        return;
                    }

                    puzzleSolution = puzzleData[3];
                }

                Log.Info($"Login puzzle solved: answer={puzzleSolution}");

                var askLogin = new GC2LS_ASK_LOGIN(puzzleSolution, client._username, 0);

                client.SendPacket(askLogin);
            }
Exemple #2
0
            public override void HandlePacket(LobbyClient client, ServerPacket packet)
            {
                var reader = packet.Reader;

                int  versionHigh = reader.ReadInt32(), versionMiddle = reader.ReadInt32(), versionLow = reader.ReadInt32(), buildNo = reader.ReadInt32();
                byte unknown        = reader.ReadByte();
                uint puzzleSolution = 0;

                if (unknown > 0)
                {
                    byte[] encryptionKey = reader.ReadBytes(8);
                    client.SetEncryptionKey(encryptionKey);

                    uint[] uintEncryptionKey = new uint[2];
                    uintEncryptionKey[0] = BitConverter.ToUInt32(encryptionKey, 0);
                    uintEncryptionKey[1] = BitConverter.ToUInt32(encryptionKey, 4);

                    uint[] puzzleData = new uint[4];
                    puzzleData[3] = 0;
                    for (int i = 0; i < 3; i++)
                    {
                        puzzleData[i] = reader.ReadUInt32();
                    }

                    try
                    {
                        SolveLoginPuzzle(uintEncryptionKey, puzzleData, unknown);
                    }
                    catch (Exception)
                    {
                        client.OnPuzzleFailed(client, 10011);
                        client.Disconnect();
                        return;
                    }
                    puzzleSolution = puzzleData[3];
                }
                var askLogin = new GC2LS_ASK_LOGIN(puzzleSolution, client.Username, 0);

                client.SendPacket(askLogin);
            }