Exemplo n.º 1
0
        ///Authentication check
        private static void ProcessAuthenticate(Session MySession, List <byte> myPacket, bool CreateMasterSession)
        {
            if (!CreateMasterSession)
            {
                Logger.Info("Processing Authentication (Server Select)");
            }
            else
            {
                Logger.Info("Processing Authentication (Character Select)");
            }
            ///Opcode option? Just remove for now
            myPacket.RemoveRange(0, 1);

            ///Unknown also, supposedly can be 03 00 00 00 or  01 00 00 00
            myPacket.RemoveRange(0, 4);

            ///Game Code Length
            int GameCodeLength = myPacket[3] << 24 | myPacket[2] << 16 | myPacket[1] << 8 | myPacket[0];

            myPacket.RemoveRange(0, 4);

            ///Our Game Code String
            byte[] GameCodeArray = new byte[GameCodeLength];

            ///Copy The GameCode into other variable
            myPacket.CopyTo(0, GameCodeArray, 0, GameCodeLength);

            ///Remove GameCode from packet
            myPacket.RemoveRange(0, GameCodeLength);

            ///the actual gamecode
            string GameCode = Encoding.Default.GetString(GameCodeArray);

            if (GameCode == "EQOA")
            {
                ///Authenticate
                Logger.Info("Received EQOA Game Code, continuing...");

                ///Grab Character name
                ///Game Code Length
                int AccountNameLength = myPacket[3] << 24 | myPacket[2] << 16 | myPacket[1] << 8 | myPacket[0];
                myPacket.RemoveRange(0, 4);

                ///Our CharacterName Array
                byte[] AccountNameArray = new byte[AccountNameLength];

                ///Copy The characterName into other variable
                myPacket.CopyTo(0, AccountNameArray, 0, AccountNameLength);

                ///Remove characterName from packet
                myPacket.RemoveRange(0, AccountNameLength);

                ///the actual gamecode
                string AccountName = Encoding.Default.GetString(AccountNameArray);

                Logger.Info($"Received Account Name: {AccountName}");

                ///Username ends with 01, no known use, remove for now
                myPacket.RemoveRange(0, 1);

                //Decrypting password information goes here?

                string Password = "******";

                ///Remove encrypted password off packet
                myPacket.RemoveRange(0, 32);

                ///Uncomment once ready
                MySession.AccountID = AccountActions.VerifyPassword(AccountName, Password);

                ///Theoretically we want to verify account # is not 0 here, if it is, drop it.
                if (MySession.AccountID == 0)
                {
                    ///This work?
                    ///Just ignore the packet and let client resend.
                    ///Something noteable went wrong here most likely
                    return;
                }
            }

            else
            {
                ///If not EQOA.... drop?
                Logger.Err("Did not receive EQOA Game Code, not continuing...");
                ///Should we attempt to disconnect the session here?
            }
        }