Beispiel #1
0
        public static void OnHTTPReceive(AuthPacket packet, Client client)
        {
            packet.ReadString();

            var path = packet.ReadString();

            Manager.PatchMgr.Send(path, client);
        }
Beispiel #2
0
        public static void OnInformationRequest(AuthPacket packet, Client client)
        {
            var session = client.Session;
            if (!Manager.GetState())
            {
                AuthHandler.SendAuthComplete(true, AuthResult.ServerBusy, client);
                return;
            }

            var game = packet.ReadFourCC();
            var os = packet.ReadFourCC();
            var language = packet.ReadFourCC();

            Log.Message(LogType.Debug, "Program: {0}", game);
            Log.Message(LogType.Debug, "Platform: {0}", os);
            Log.Message(LogType.Debug, "Locale: {0}", language);

            var componentCount = packet.Read<int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build = packet.Read<int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Components.Any(c => c.Program == program && c.Platform == platform && c.Build == build))
                    continue;

                if (!DB.Auth.Components.Any(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, client);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, client);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, client);
                    return;
                }
            }

            var hasAccountName = packet.Read<bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read<int>(9) + 3;
                var accountName = packet.ReadString(accountLength);
                var account = DB.Auth.Accounts.SingleOrDefault(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    // Global base account.
                    session.Account.IP = session.GetClientInfo();
                    session.Account.Language = language;

                    // Assign the possible game accounts based on the game.
                    //session.GameAccounts.ForEach(ga => ga.OS = os);

                    // Save the last changes
                    DB.Auth.Update();

                    // Used for module identification.
                    client.Game = game;
                    client.OS = os;

                    AuthHandler.SendProofRequest(client);
                }
                else
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, client);
            }
        }
Beispiel #3
0
        public static void OnProofResponse(AuthPacket packet, Client client)
        {
            var session = client.Session;

            var moduleCount = packet.Read<byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read<int>(10);
                var state = packet.Read<PasswordModuleState>(8);

                switch (state)
                {
                    case PasswordModuleState.ClientChallenge:
                        if (session.GameAccount == null && session.GameAccounts.Count >= 1)
                        {
                            if (session.GameAccounts.Count > 1)
                            {
                                var region = packet.Read<Regions>(8);
                                var gameLength = packet.Read<byte>(8);
                                var game = packet.ReadString(gameLength);

                                session.GameAccount = session.GameAccounts.SingleOrDefault(ga => ga.Game + ga.Index == game && ga.Region == region);

                                var riskFingerprint = new AuthPacket(AuthServerMessage.ProofRequest);

                                riskFingerprint.Write(1, 3);

                                Manager.ModuleMgr.WriteRiskFingerprint(client, riskFingerprint);

                                client.SendPacket(riskFingerprint);

                                return;
                            }
                            else
                                session.GameAccount = session.GameAccounts[0];
                        }

                        if (!session.GameAccount.IsOnline)
                        {
                            if (session.GameAccount == null)
                                SendAuthComplete(true, AuthResult.NoGameAccount, client);
                            else
                                SendAuthComplete(false, AuthResult.GlobalSuccess, client);
                        }

                        break;
                    case PasswordModuleState.ClientProof:
                        // Wrong password module data size
                        if (dataSize != 0x121)
                            return;

                        var a = packet.Read(0x80);
                        var m1 = packet.Read(0x20);
                        var clientChallenge = packet.Read(0x80);

                        session.SecureRemotePassword.CalculateU(a);
                        session.SecureRemotePassword.CalculateClientM(a);

                        if (session.SecureRemotePassword.ClientM.Compare(m1))
                        {
                            session.SecureRemotePassword.CalculateServerM(m1);

                            // Assign valid game accounts for the account
                            if (session.Account.GameAccounts != null)
                                session.GameAccounts = session.Account.GameAccounts.Where(ga => ga.Game == client.Game && ga.Region == session.Account.Region).ToList();

                            SendProofValidation(client, clientChallenge);
                        }
                        else
                            SendAuthComplete(true, AuthResult.BadLoginInformation, client);

                        break;
                    default:
                        break;
                }
            }
        }
Beispiel #4
0
        public static void OnProofResponse(AuthPacket packet, Client client)
        {
            var session = client.Session;

            var moduleCount = packet.Read <byte>(3);

            for (int i = 0; i < moduleCount; i++)
            {
                var dataSize = packet.Read <int>(10);
                var state    = packet.Read <PasswordModuleState>(8);

                switch (state)
                {
                case PasswordModuleState.ClientChallenge:
                    if (session.GameAccount == null && session.GameAccounts.Count >= 1)
                    {
                        if (session.GameAccounts.Count > 1)
                        {
                            var region     = packet.Read <Regions>(8);
                            var gameLength = packet.Read <byte>(8);
                            var game       = packet.ReadString(gameLength);

                            session.GameAccount = session.GameAccounts.SingleOrDefault(ga => ga.Game + ga.Index == game && ga.Region == region);

                            var riskFingerprint = new AuthPacket(AuthServerMessage.ProofRequest);

                            riskFingerprint.Write(1, 3);

                            Manager.ModuleMgr.WriteRiskFingerprint(client, riskFingerprint);

                            client.SendPacket(riskFingerprint);

                            return;
                        }
                        else
                        {
                            session.GameAccount = session.GameAccounts[0];
                        }
                    }

                    if (session.GameAccount == null)
                    {
                        SendAuthComplete(true, AuthResult.NoGameAccount, client);
                    }
                    else if (!session.GameAccount.IsOnline)
                    {
                        SendAuthComplete(false, AuthResult.GlobalSuccess, client);

                        client.Session.GameAccount.IsOnline = true;
                    }

                    break;

                case PasswordModuleState.ClientProof:
                    // Wrong password module data size
                    if (dataSize != 0x121)
                    {
                        return;
                    }

                    var a  = packet.Read(0x80);
                    var m1 = packet.Read(0x20);
                    var clientChallenge = packet.Read(0x80);

                    session.SecureRemotePassword.CalculateU(a);
                    session.SecureRemotePassword.CalculateClientM(a);

                    if (session.SecureRemotePassword.ClientM.Compare(m1))
                    {
                        session.SecureRemotePassword.CalculateServerM(m1);

                        // Assign valid game accounts for the account
                        if (session.Account.GameAccounts != null)
                        {
                            session.GameAccounts = session.Account.GameAccounts.Where(ga => ga.Game == client.Game && ga.Region == session.Account.Region).ToList();
                        }

                        SendProofValidation(client, clientChallenge);
                    }
                    else
                    {
                        SendAuthComplete(true, AuthResult.BadLoginInformation, client);
                    }

                    break;

                default:
                    break;
                }
            }
        }
Beispiel #5
0
        public static void OnInformationRequest(AuthPacket packet, Client client)
        {
            var session = client.Session;

            if (!Manager.GetState())
            {
                AuthHandler.SendAuthComplete(true, AuthResult.ServerBusy, client);
                return;
            }

            var game     = packet.ReadFourCC();
            var os       = packet.ReadFourCC();
            var language = packet.ReadFourCC();

            Log.Message(LogType.Debug, "Program: {0}", game);
            Log.Message(LogType.Debug, "Platform: {0}", os);
            Log.Message(LogType.Debug, "Locale: {0}", language);

            var componentCount = packet.Read <int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program  = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build    = packet.Read <int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Any <Component>(c => c.Program == program && c.Platform == platform && c.Build == build))
                {
                    continue;
                }

                if (!DB.Auth.Any <Component>(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, client);
                    return;
                }

                if (!DB.Auth.Any <Component>(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, client);
                    return;
                }

                if (!DB.Auth.Any <Component>(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, client);
                    return;
                }
            }

            var hasAccountName = packet.Read <bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read <int>(9) + 3;
                var accountName   = packet.ReadString(accountLength);
                var account       = DB.Auth.Single <Account>(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    // Global base account.
                    session.Account.IP       = session.GetClientInfo();
                    session.Account.Language = language;

                    // Assign the possible game accounts based on the game.
                    //session.GameAccounts.ForEach(ga => ga.OS = os);

                    // Save the last changes
                    DB.Auth.Update(session.Account, "IP", session.Account.IP, "Language", session.Account.Language);

                    // Used for module identification.
                    client.Game = game;
                    client.OS   = os;

                    AuthHandler.SendProofRequest(client);
                }
                else
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, client);
                }
            }
        }
Beispiel #6
0
        public static void OnInformationRequest(AuthPacket packet, AuthSession session)
        {
            Log.Message(LogType.Debug, "Program: {0}", packet.ReadFourCC());
            Log.Message(LogType.Debug, "Platform: {0}", packet.ReadFourCC());
            Log.Message(LogType.Debug, "Locale: {0}", packet.ReadFourCC());

            var componentCount = packet.Read <int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program  = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build    = packet.Read <int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Components.Any(c => c.Program == program && c.Platform == platform && c.Build == build))
                {
                    continue;
                }

                if (!DB.Auth.Components.Any(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, session);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, session);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, session);
                    return;
                }
            }

            var hasAccountName = packet.Read <bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read <int>(9) + 3;
                var accountName   = packet.ReadString(accountLength);
                var account       = DB.Auth.Accounts.First(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    AuthHandler.SendProofRequest(session);
                }
                else
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, session);
                }
            }
        }
Beispiel #7
0
        public static void OnInformationRequest(AuthPacket packet, AuthSession session)
        {
            if (!Manager.GetState())
            {
                AuthHandler.SendAuthComplete(true, AuthResult.ServerBusy, session);
                return;
            }

            Log.Message(LogType.Debug, "Program: {0}", packet.ReadFourCC());

            var os = packet.ReadFourCC();
            var language = packet.ReadFourCC();

            Log.Message(LogType.Debug, "Platform: {0}", os);
            Log.Message(LogType.Debug, "Locale: {0}", language);

            var componentCount = packet.Read<int>(6);

            for (int i = 0; i < componentCount; i++)
            {
                var program = packet.ReadFourCC();
                var platform = packet.ReadFourCC();
                var build = packet.Read<int>(32);

                Log.Message(LogType.Debug, "Program: {0}", program);
                Log.Message(LogType.Debug, "Platform: {0}", platform);
                Log.Message(LogType.Debug, "Locale: {0}", build);

                if (DB.Auth.Components.Any(c => c.Program == program && c.Platform == platform && c.Build == build))
                    continue;

                if (!DB.Auth.Components.Any(c => c.Program == program))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidProgram, session);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Platform == platform))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidPlatform, session);
                    return;
                }

                if (!DB.Auth.Components.Any(c => c.Build == build))
                {
                    AuthHandler.SendAuthComplete(true, AuthResult.InvalidGameVersion, session);
                    return;
                }
            }

            var hasAccountName = packet.Read<bool>(1);

            if (hasAccountName)
            {
                var accountLength = packet.Read<int>(9) + 3;
                var accountName = packet.ReadString(accountLength);
                var account = DB.Auth.Accounts.SingleOrDefault(a => a.Email == accountName);

                // First account lookup on database
                if ((session.Account = account) != null)
                {
                    session.Account.IP = session.GetClientIP();
                    session.Account.OS = os;
                    session.Account.Language = language;

                    DB.Auth.Update(session.Account, "IP", session.Account.IP, "OS", session.Account.OS, "Language", session.Account.Language);

                    AuthHandler.SendProofRequest(session);
                }
                else
                    AuthHandler.SendAuthComplete(true, AuthResult.BadLoginInformation, session);
            }
        }