Пример #1
0
        public Character(InPacket packet)
        {
            GUID = packet.ReadUInt64();
            Name = packet.ReadCString();
            Race = (Race)packet.ReadByte();
            Class = (Class)packet.ReadByte();
            Gender = (Gender)packet.ReadByte();
            Bytes = packet.ReadBytes(5);
            Level = packet.ReadByte();
            ZoneId = packet.ReadUInt32();
            MapId = packet.ReadUInt32();
            X = packet.ReadSingle();
            Y = packet.ReadSingle();
            Z = packet.ReadSingle();
            GuildId = packet.ReadUInt32();
            Flags = packet.ReadUInt32();
            packet.ReadUInt32();	// customize (rename, etc)
            packet.ReadByte();		// first login
            PetInfoId = packet.ReadUInt32();
            PetLevel = packet.ReadUInt32();
            PetFamilyId = packet.ReadUInt32();

            // read items
            for (int i = 0; i < Items.Length - 1; ++i)
                Items[i] = new Item(packet);

            // read bags
            for (int i = 0; i < 4; ++i)
            {
                packet.ReadUInt32();
                packet.ReadByte();
                packet.ReadUInt32();
            }
        }
Пример #2
0
        protected void HandleServerAuthChallenge(InPacket packet)
        {
            uint one  = packet.ReadUInt32();
            uint seed = packet.ReadUInt32();

            BigInteger seed1 = packet.ReadBytes(16).ToBigInteger();
            BigInteger seed2 = packet.ReadBytes(16).ToBigInteger();

            var rand = System.Security.Cryptography.RandomNumberGenerator.Create();

            byte[] bytes = new byte[4];
            rand.GetBytes(bytes);
            BigInteger ourSeed = bytes.ToBigInteger();

            uint zero = 0;

            byte[] authResponse = HashAlgorithm.SHA1.Hash
                                  (
                Encoding.ASCII.GetBytes(Game.Username.ToUpper()),
                BitConverter.GetBytes(zero),
                BitConverter.GetBytes((uint)ourSeed),
                BitConverter.GetBytes(seed),
                Game.Key.ToCleanByteArray()
                                  );

            OutPacket response = new OutPacket(WorldCommand.ClientAuthSession);

            response.Write((uint)12340);        // client build
            response.Write(zero);
            response.Write(Game.Username.ToUpper().ToCString());
            response.Write(zero);
            response.Write((uint)ourSeed);
            response.Write(zero);
            response.Write(zero);
            response.Write(zero);
            response.Write((ulong)zero);
            response.Write(authResponse);
            response.Write(zero);            // length of addon data

            Send(response);

            // TODO: don't fully initialize here, auth may fail
            // instead, initialize in HandleServerAuthResponse when auth succeeds
            // will require special logic in network code to correctly decrypt/parse packet header
            authenticationCrypto.Initialize(Game.Key.ToCleanByteArray());
        }
Пример #3
0
        void HandleServerAuthChallenge(InPacket packet)
        {
            uint one = packet.ReadUInt32();
            uint seed = packet.ReadUInt32();

            BigInteger seed1 = packet.ReadBytes(16).ToBigInteger();
            BigInteger seed2 = packet.ReadBytes(16).ToBigInteger();

            var rand = System.Security.Cryptography.RandomNumberGenerator.Create();
            byte[] bytes = new byte[4];
            rand.GetBytes(bytes);
            BigInteger ourSeed = bytes.ToBigInteger();

            uint zero = 0;

            byte[] authResponse = HashAlgorithm.SHA1.Hash
            (
                Encoding.ASCII.GetBytes(Game.Username.ToUpper()),
                BitConverter.GetBytes(zero),
                BitConverter.GetBytes((uint)ourSeed),
                BitConverter.GetBytes(seed),
                Game.Key.ToCleanByteArray()
            );

            OutPacket response = new OutPacket(WorldCommand.ClientAuthSession);
            response.Write((uint)12340);        // client build
            response.Write(zero);
            response.Write(Game.Username.ToUpper().ToCString());
            response.Write(zero);
            response.Write((uint)ourSeed);
            response.Write(zero);
            response.Write(zero);
            response.Write(zero);
            response.Write((ulong)zero);
            response.Write(authResponse);
            response.Write(zero);            // length of addon data

            Send(response);

            // TODO: don't fully initialize here, auth may fail
            // instead, initialize in HandleServerAuthResponse when auth succeeds
            // will require special logic in network code to correctly decrypt/parse packet header
            AuthenticationCrypto.Initialize(Game.Key.ToCleanByteArray());
        }