Beispiel #1
0
        public void HandleLogonChallenge(ClientLogonChallengePacket packet, WoWClient sender)
        {
            Account account = Provider.FindAccount(packet.Identity);

            if (account == null)
            {
                // reply with Server Logon Challenge
                sender.Writer.Write((byte)0x0);     // cmd, always 0
                sender.Writer.Write((byte)0x0);     // instant dc?
                sender.Writer.Write((byte)AuthenticationResult.UnkAccount);
            }
            else if (account.Banned)
            {
                sender.Writer.Write((byte)0x0);     // cmd, always 0
                sender.Writer.Write((byte)0x0);     // instant dc?
                sender.Writer.Write((byte)AuthenticationResult.Banned);
            }
            else if (packet.Build != 5875)      // only accept 1.12.1
            {
                sender.Writer.Write((byte)0x0); // cmd, always 0
                sender.Writer.Write((byte)0x0); // instant dc?
                sender.Writer.Write((byte)AuthenticationResult.WrongBuild);
            }
            else
            {
                // do SRP6 calculation and send back the server logon challenge, asking client for proof

                /*
                 *  uint8   cmd;
                 *  uint8   error;
                 *  uint8   unk2;
                 *  uint8   B[32]; -- server's public value
                 *  uint8   g_len; -- always 1
                 *  uint8   g;     -- 7
                 *  uint8   N_len; -- always 32
                 *  uint8   N[32]; -- always 0894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7 ;; joining the cool emu club
                 *  uint8   s[32]; -- Salt, a random value
                 *  uint8   unk3[16];
                 *  uint8   unk4;
                 */

                SRP6 srp = new SRP6(account.Identity, account.Password);
                sender.SRP = srp;

                sender.Writer.Write((byte)0x0);
                sender.Writer.Write((byte)AuthenticationResult.Succes);
                sender.Writer.Write((byte)0x0);
                sender.Writer.Write(srp.B.ToFixedByteArray().Pad(32));
                sender.Writer.Write((byte)0x1); // todo: implement flexible generator
                sender.Writer.Write((byte)0x7);
                sender.Writer.Write((byte)32);  // todo: implement flexible mod
                sender.Writer.Write(srp.Modulus.ToFixedByteArray().Pad(32));
                sender.Writer.Write(srp.Salt.ToFixedByteArray().Pad(32));
                sender.Writer.Write(new byte[16]);
                sender.Writer.Write((byte)0x0);

                sender.Writer.Flush();
            }
        }