Ejemplo n.º 1
0
        /// <summary>
        /// Create a message object from the specified buffer.
        /// </summary>
        /// <param name="aBuf">The buffer containing the message.</param>
        /// <param name="aIndex">The index where the message is starting in the buffer.</param>
        /// <param name="aLength">The length of the message.</param>
        internal MsgAccount(Byte[] aBuf, int aIndex, int aLength)
            : base(aBuf, aIndex, aLength)
        {
            RivestCipher5 cipher = new RivestCipher5(COServer.Server.RC5_SEED);

            Byte[] pwd_data = new Byte[MAX_NAME_SIZE];
            Buffer.BlockCopy(mBuf, 20, pwd_data, 0, MAX_NAME_SIZE);
            cipher.Decrypt(ref pwd_data, MAX_NAME_SIZE);

            __Account  = Program.Encoding.GetString(mBuf, 4, MAX_NAME_SIZE).TrimEnd('\0');
            __Password = Program.Encoding.GetString(pwd_data, 0, MAX_NAME_SIZE).TrimEnd('\0');
            __Server   = Program.Encoding.GetString(mBuf, 36, MAX_NAME_SIZE).TrimEnd('\0');
        }
        /// <summary>
        /// Packet Type: 1086. This packet is accepted by the Account Server as the first packet from the client. It
        /// contains login information specified by the client, information such as the player's account name, encrypted
        /// password, and requested message server. The packet should be handled by decrypting the password, checking it
        /// with the database, and transferring the client to the message server (or rejecting access). The packet
        /// will decrypt the password automatically.
        /// </summary>
        /// <param name="packet">The received packet.</param>
        /// <param name="seed">The seed used for Rivest Cipher 5.</param>
        public MsgAccount(byte[] packet, int seed)
            : base(packet)
        {
            // Initialize Decryption Algorithms:
            var rivestCipher    = new RivestCipher5(seed);
            var netdragonCipher = new NetDragonPasswordCipher(Account);

            byte[] encrypted = ReadArray(16, 132);

            // Decrypt Password:
            rivestCipher.Decrypt(encrypted);
            netdragonCipher.Decrypt(encrypted);

            fixed(byte *decrypted = encrypted)
            Password = new string((sbyte *)decrypted);
        }