Ejemplo n.º 1
0
        public void HandleAuthSession(ref IPacketReader packet, ref IWorldManager manager)
        {
            Common.Cryptography.Authenticator.ClientBuild = packet.ReadUInt16();

            packet.Position = 14;
            string login    = packet.ReadString();
            string username = login.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)[0];

            Account account = new Account(username.ToUpper());

            account.Load <Character>();
            manager.Account = account;

            PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_AUTH_RESPONSE], "SMSG_AUTH_RESPONSE");

            writer.WriteUInt8(0x0C); // AUTH_OK
            manager.Send(writer);
        }
Ejemplo n.º 2
0
        public void HandleMovementStatus(ref IPacketReader packet, ref IWorldManager manager)
        {
            if (manager.Account.ActiveCharacter.IsTeleporting)
            {
                return;
            }

            uint opcode = packet.Opcode;
            long pos    = packet.Position;

            var   character = manager.Account.ActiveCharacter;
            ulong Flags     = packet.ReadUInt64();

            packet.ReadUInt16();
            character.Location.Update(packet, true);

            //packet.Position = pos;
            //PacketWriter writer = new PacketWriter(opcode, Sandbox.Instance.Opcodes[opcode].ToString());
            //writer.Write(packet.ReadToEnd());
            //manager.Send(writer);
        }
Ejemplo n.º 3
0
        public static byte[] LogonChallenge(IPacketReader packet)
        {
            packet.Position = 11;
            ClientBuild     = packet.ReadUInt16();

            packet.Position = 33;                                  // Skip to username
            BUsername       = packet.ReadBytes(packet.ReadByte()); // Read username
            string username = Encoding.ASCII.GetString(BUsername);

            byte[] x;
            using (SHA1 sha = new SHA1CryptoServiceProvider())
            {
                byte[] user = Encoding.ASCII.GetBytes(username.ToUpper() + ":" + Password.ToUpper());
                byte[] res  = Salt.Concat(sha.ComputeHash(user, 0, user.Length)).ToArray();
                x = sha.ComputeHash(res, 0, res.Length).Reverse().ToArray();
            }

            byte[] b = new byte[20];
            new Random().NextBytes(b);
            RB = b.Reverse().ToArray();

            G = new BigInteger(new byte[] { 7 });
            V = G.ModPow(new BigInteger(x), new BigInteger(RN));

            K = new BigInteger(new byte[] { 3 });
            BigInteger temp = (K * V) + G.ModPow(new BigInteger(RB), new BigInteger(RN));

            B = temp % new BigInteger(RN);

            int size = ClientBuild < 5428 ? 118 : 119;

            byte[] result = new byte[size];
            Array.Copy(B.GetBytes(32).Reverse().ToArray(), 0, result, 3, 32);
            result[35] = 1;
            result[36] = 7;
            result[37] = 32;
            Array.Copy(N, 0, result, 38, N.Length);
            Array.Copy(Salt, 0, result, 70, Salt.Length);
            return(result);
        }
Ejemplo n.º 4
0
        public static byte[] LogonChallenge(IPacketReader packet)
        {
            packet.Position = 11;
            uint build = packet.ReadUInt16();

            packet.Position = 33;                                  //Skip to username
            BUsername       = packet.ReadBytes(packet.ReadByte()); //Read username
            string username = Encoding.ASCII.GetString(BUsername);

            byte[] x;
            using (SHA1 sha = new SHA1CryptoServiceProvider())
            {
                byte[] user = Encoding.ASCII.GetBytes(username.ToUpper() + ":" + Password.ToUpper());
                byte[] res  = Salt.Concat(sha.ComputeHash(user, 0, user.Length)).ToArray();
                x = sha.ComputeHash(res, 0, res.Length).Reverse().ToArray();
            }

            byte[] b = new byte[20];
            new Random().NextBytes(b);
            RB = b.Reverse().ToArray();

            G = new BigInteger(new byte[] { 7 });
            V = G.ModPow(new BigInteger(x), new BigInteger(RN));

            K = new BigInteger(new byte[] { 3 });
            BigInteger temp = (K * V) + G.ModPow(new BigInteger(RB), new BigInteger(RN));

            B = temp % new BigInteger(RN);

            IEnumerable <byte> result = new byte[3]; //Opcode, 0, Success

            result = result.Concat(B.GetBytes(32).Reverse());
            result = result.Concat(new byte[] { 1, 7, 32 }); //1, G, 32
            result = result.Concat(N);
            result = result.Concat(Salt);
            result = result.Concat(new byte[(build < 5875 ? 16 : 17)]); //unknown, Security Flag (version?)
            return(result.ToArray());
        }
Ejemplo n.º 5
0
        public static byte[] LogonChallenge(IPacketReader packet)
        {
            packet.Position = 11;
            ClientBuild     = packet.ReadUInt16();

            packet.Position = 33;                                  // Skip to username
            BUsername       = packet.ReadBytes(packet.ReadByte()); // Read username

            byte[] credshash;
            using (SHA1 sha = new SHA1CryptoServiceProvider())
            {
                string username    = Encoding.ASCII.GetString(BUsername);
                byte[] credentials = Encoding.ASCII.GetBytes(username.ToUpper() + ":" + Password.ToUpper());
                byte[] tmp         = Salt.Concat(sha.ComputeHash(credentials)).ToArray();
                credshash = sha.ComputeHash(tmp).Reverse().ToArray();
            }

            RB = new byte[20];
            new Random().NextBytes(RB);

            G = new BigInteger(new byte[] { 7 });
            V = G.ModPow(new BigInteger(credshash), new BigInteger(RN));

            K = new BigInteger(new byte[] { 3 });
            B = ((K * V) + G.ModPow(new BigInteger(RB), new BigInteger(RN))) % new BigInteger(RN);

            // create packet data
            byte[] result = new byte[GetLogonChallengeSize()];
            Array.Copy(B.GetBytes(32).Reverse().ToArray(), 0, result, 3, 32);
            result[35] = 1;
            result[36] = 7;
            result[37] = 32;
            Array.Copy(N, 0, result, 38, N.Length);
            Array.Copy(Salt, 0, result, 70, Salt.Length);
            return(result);
        }