Example #1
0
        public static void SendAuthComplete(bool failed, AuthResult result, AuthSession session)
        {
            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                complete.Write(0, 3);
                complete.Write(0x80005000, 32); // Ping request, ~10 secs

                var hasOptionalData = true;

                complete.Write(hasOptionalData, 1);

                if (hasOptionalData)
                {
                    var hasConnectionInfo = true;

                    complete.Write(hasConnectionInfo, 1);

                    if (hasConnectionInfo)
                    {
                        complete.Write(25000000, 32);
                        complete.Write(1000, 32);
                    }
                }

                complete.Write(false, 1);

                complete.WriteString("", 8, false); // FirstName not implemented
                complete.WriteString("", 8, false); // LastName not implemented

                complete.Write(session.Account.Id, 32);

                complete.Write(0, 8);
                complete.Write(0, 64);
                complete.Write(0, 8);

                complete.WriteString(session.Account.Email, 5, false, -1);

                complete.Write(0, 64);
                complete.Write(0, 32);

                complete.Write(0, 8);
            }

            session.Send(complete);
        }
        public void Write(AuthPacket packet)
        {
            packet.WriteString(Account.GivenName, 8, false);
            packet.WriteString(Account.Surname, 8, false);

            packet.Write(Account.Id, 32);
            packet.Write((byte)Account.Region, 8);
            packet.Write((ulong)Account.Flags, 64);

            packet.Write((byte)GameAccount.Region, 8);
            packet.WriteString(GameAccount.AccountId + "#" + GameAccount.Index, 5, false, -1);
            packet.Write((ulong)GameAccount.Flags, 64);

            packet.Write(Account.LoginFailures, 32);
            packet.Write(0, 8);
        }
Example #3
0
        public static void SendProofValidation(Client client, byte[] clientChallenge)
        {
            var passwordModule            = client.Modules.SingleOrDefault(m => m.Name == "Password");
            var selectedGameAccountModule = client.Modules.SingleOrDefault(m => m.Name == "SelectGameAccount");

            var proofValidation = new AuthPacket(AuthServerMessage.ProofRequest);

            var moduleCount = 2;

            proofValidation.Write(moduleCount, 3);

            /// Password module
            Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, passwordModule, 161);

            // State
            proofValidation.Flush();
            proofValidation.Write(PasswordModuleState.ValidateProof, 8);

            // Data
            proofValidation.Write(client.Session.SecureRemotePassword.ServerM);
            proofValidation.Write(client.Session.SecureRemotePassword.S2);

            /// SelectGameAccount module
            if (client.Session.GameAccounts.Count > 1)
            {
                var gameAccountBuffer = new AuthPacket();

                gameAccountBuffer.Write(0, 8);
                gameAccountBuffer.Write(client.Session.GameAccounts.Count, 8);

                client.Session.GameAccounts.ForEach(ga =>
                {
                    gameAccountBuffer.Write(ga.Region, 8);
                    gameAccountBuffer.WriteString(ga.Game + ga.Index, 8, false);
                });

                gameAccountBuffer.Finish();

                Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, selectedGameAccountModule, gameAccountBuffer.Data.Length);

                // Data
                proofValidation.Write(gameAccountBuffer.Data);
            }
            else
            {
                Manager.ModuleMgr.WriteRiskFingerprint(client, proofValidation);
            }

            client.SendPacket(proofValidation);
        }
Example #4
0
        public static void OnListSubscribeRequest(AuthPacket packet, Client client)
        {
            Log.Message(LogType.Debug, "Received ListSubscribeRequest.");

            // Battlenet::Client::WoWRealm::ListSubscribeResponse
            var listSubscribeResponse = new AuthPacket(AuthServerMessage.ListSubscribeResponse, AuthChannel.WoWRealm);

            listSubscribeResponse.Write(0, 1);
            listSubscribeResponse.Write(0, 7);

            var realmCounter = 0;

            // Battlenet::Client::WoWRealm::ListUpdate
            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var listUpdate = new AuthPacket(AuthServerMessage.ListUpdate, AuthChannel.WoWRealm);

                listUpdate.Write(true, 1);
                listUpdate.Write(realm.Value.Category, 32);          // RealmCategory
                listUpdate.Write(0, 32);                             // RealmPopulation, float written as uint32
                listUpdate.Write(realm.Value.State, 8);              // RealmState
                listUpdate.Write(realm.Value.Id, 19);                // RealmId
                listUpdate.Write(0x80000000 + realm.Value.Type, 32); // RealmType
                listUpdate.WriteString(realm.Value.Name, 10, false); // RealmName
                listUpdate.Write(false, 1);                          // Battlenet::VersionString, not used for now
                listUpdate.Write(realm.Value.Flags, 8);              // RealmInfoFlags
                listUpdate.Write(0, 8);
                listUpdate.Write(0, 12);
                listUpdate.Write(0, 8);
                listUpdate.Write(++realmCounter, 32);

                listUpdate.Finish();

                // Write ListUpdate data to ListSubscribeResponse
                listSubscribeResponse.Write(listUpdate.Data);
            }

            // Battlenet::Client::WoWRealm::ListComplete
            var listComplete = new AuthPacket(AuthServerMessage.ListComplete, AuthChannel.WoWRealm);

            listComplete.Finish();

            // Write ListComplete data to ListSubscribeResponse end
            listSubscribeResponse.Write(listComplete.Data);


            client.SendPacket(listSubscribeResponse);
        }
Example #5
0
        public static void OnListSubscribeRequest(AuthPacket packet, Client client)
        {
            Log.Debug("Received ListSubscribeRequest.");

            // Battlenet::Client::WoWRealm::ListSubscribeResponse
            var listSubscribeResponse = new AuthPacket(AuthServerMessage.ListSubscribeResponse, AuthChannel.WoWRealm);

            listSubscribeResponse.Write(0, 1);
            listSubscribeResponse.Write(0, 7);

            var realmCounter = 0;

            // Battlenet::Client::WoWRealm::ListUpdate
            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var listUpdate = new AuthPacket(AuthServerMessage.ListUpdate, AuthChannel.WoWRealm);

                listUpdate.Write(true, 1);
                listUpdate.Write(realm.Value.Category, 32);          // RealmCategory
                listUpdate.Write(0, 32);                             // RealmPopulation, float written as uint32
                listUpdate.Write(realm.Value.State, 8);              // RealmState
                listUpdate.Write(realm.Value.Id, 19);                // RealmId
                listUpdate.Write(0x80000000 + realm.Value.Type, 32); // RealmType
                listUpdate.WriteString(realm.Value.Name, 10, false); // RealmName
                listUpdate.Write(false, 1);                          // Battlenet::VersionString, not used for now
                listUpdate.Write(realm.Value.Flags, 8);              // RealmInfoFlags
                listUpdate.Write(0, 8);
                listUpdate.Write(0, 12);
                listUpdate.Write(0, 8);
                listUpdate.Write(++realmCounter, 32);

                listUpdate.Finish();

                // Write ListUpdate data to ListSubscribeResponse
                listSubscribeResponse.Write(listUpdate.Data);
            }

            // Battlenet::Client::WoWRealm::ListComplete
            var listComplete = new AuthPacket(AuthServerMessage.ListComplete, AuthChannel.WoWRealm);

            listComplete.Finish();

            // Write ListComplete data to ListSubscribeResponse end
            listSubscribeResponse.Write(listComplete.Data);

            client.SendPacket(listSubscribeResponse);
        }
Example #6
0
        public static void OnRealmUpdate(AuthPacket packet, AuthSession session)
        {
            Log.Message(LogType.Debug, "Received realm update.");

            var complete = new AuthPacket(AuthServerMessage.Complete, AuthChannel.WoW);

            complete.Flush();
            complete.Write(0, 8);

            var realmCounter = 0;

            foreach (var realm in Manager.Realms.RealmList)
            {
                var realmlist = new AuthPacket(AuthServerMessage.RealmUpdate, AuthChannel.WoW);

                realmlist.Write(true, 1);
                realmlist.Write(1, 32);
                realmlist.Write(0f, 32);
                realmlist.Write(realm.Value.Flags, 8);
                realmlist.Write(realm.Value.Id, 19);
                realmlist.Write(0x80000000 + realm.Value.Type, 32);
                realmlist.WriteString(realm.Value.Name, 10, false);
                realmlist.Write(false, 1);
                realmlist.Write(realm.Value.Status, 8);
                realmlist.Write(0, 12);
                realmlist.Write(0, 8);
                realmlist.Write(0, 32);
                realmlist.Write(++realmCounter, 8);

                // End
                realmlist.Flush();
                realmlist.Write(new byte[] { 0x43, 0x02 });
                realmlist.Finish();

                complete.Write(realmlist.Data);
            }

            session.Send(complete);
        }
Example #7
0
        public static void SendProofValidation(Client client, byte[] clientChallenge)
        {
            var passwordModule = client.Modules.SingleOrDefault(m => m.Name == "Password");
            var selectedGameAccountModule = client.Modules.SingleOrDefault(m => m.Name == "SelectGameAccount");

            var proofValidation = new AuthPacket(AuthServerMessage.ProofRequest);

            var moduleCount = 2;

            proofValidation.Write(moduleCount, 3);

            /// Password module
            Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, passwordModule, 161);

            // State
            proofValidation.Flush();
            proofValidation.Write(PasswordModuleState.ValidateProof, 8);

            // Data
            proofValidation.Write(client.Session.SecureRemotePassword.ServerM);
            proofValidation.Write(client.Session.SecureRemotePassword.S2);

            /// SelectGameAccount module
            if (client.Session.GameAccounts.Count > 1)
            {
                var gameAccountBuffer = new AuthPacket();

                gameAccountBuffer.Write(0, 8);
                gameAccountBuffer.Write(client.Session.GameAccounts.Count, 8);

                client.Session.GameAccounts.ForEach(ga =>
                {
                    gameAccountBuffer.Write(ga.Region, 8);
                    gameAccountBuffer.WriteString(ga.Game + ga.Index, 8, false);
                });

                gameAccountBuffer.Finish();

                Manager.ModuleMgr.WriteModuleHeader(client, proofValidation, selectedGameAccountModule, gameAccountBuffer.Data.Length);

                // Data
                proofValidation.Write(gameAccountBuffer.Data);
            }
            else
                Manager.ModuleMgr.WriteRiskFingerprint(client, proofValidation);

            client.SendPacket(proofValidation);
        }
Example #8
0
        public static void SendAuthComplete(bool failed, AuthResult result, Client client)
        {
            client.Session.GameAccount.IsOnline = true;

            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                // No modules supported here.
                complete.Write(0, 3);

                var pingTimeout = 0x80005000;
                var hasRegulatorRules = true;

                complete.Write(pingTimeout, 32);
                complete.Write(hasRegulatorRules, 1);

                if (hasRegulatorRules)
                {
                    var hasRegulatorInfo = true;

                    complete.Write(hasRegulatorInfo, 1);

                    if (hasRegulatorInfo)
                    {
                        var threshold = 25000000;
                        var rate = 1000;

                        complete.Write(threshold, 32);
                        complete.Write(rate, 32);
                    }
                }

                var haslogonInfo = true;
                var account = client.Session.Account;
                var gameAccount = client.Session.GameAccount;

                complete.Write(!haslogonInfo, 1);

                complete.WriteString(account.GivenName, 8, false);
                complete.WriteString(account.Surname, 8, false);

                complete.Write(account.Id, 32);
                complete.Write((byte)account.Region, 8);
                complete.Write((ulong)account.Flags, 64);

                complete.Write((byte)gameAccount.Region, 8);
                complete.WriteString(gameAccount.AccountId + "#" + gameAccount.Index, 5, false, -1);
                complete.Write((ulong)gameAccount.Flags, 64);

                complete.Write(account.LoginFailures, 32);
                complete.Write(0, 8);
            }

            client.SendPacket(complete);
        }
        public static async Task SendProofValidation(AuthSession session, byte[] clientChallenge)
        {
            var proofRequest = new ProofRequest { AccountRegion = session.Account.Region };

            proofRequest.Modules.Add(new PasswordModule
            {
                Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "Password" && m.System == session.Platform),
                State = PasswordModuleState.ValidateProof,
                AccountRegion = proofRequest.AccountRegion,
                SecureRemotePassword = session.SecureRemotePassword, 
                Size = 161
            });

            /// SelectGameAccount module
            if (session.GameAccounts?.Count > 1)
            {
                var gameAccountBuffer = new AuthPacket();

                gameAccountBuffer.Write(0, 8);
                gameAccountBuffer.Write(session.GameAccounts.Count, 8);

                session.GameAccounts.ForEach(ga =>
                {
                    gameAccountBuffer.Write(ga.Region, 8);
                    gameAccountBuffer.WriteString(ga.Game + ga.Index, 8, false);
                });

                gameAccountBuffer.Finish();

                proofRequest.Modules.Add(new SelectGameAccountModule
                {
                    Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "SelectGameAccount" && m.System == session.Platform),
                    AccountRegion = proofRequest.AccountRegion,
                    GameAccountData = gameAccountBuffer.Data,
                    Size = (uint)gameAccountBuffer.Data.Length
                });
            }
            else
                proofRequest.Modules.Add(new RiskFingerprintModule
                {
                    Data = Manager.ModuleMgr.Modules.SingleOrDefault(m => m.Name == "RiskFingerprint" && m.System == session.Platform)
                });

            await session.Send(proofRequest);
        }
Example #10
0
        public static void SendAuthComplete(bool failed, AuthResult result, Client client)
        {
            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                // No modules supported here.
                complete.Write(0, 3);

                var pingTimeout       = 0x80005000;
                var hasRegulatorRules = true;

                complete.Write(pingTimeout, 32);
                complete.Write(hasRegulatorRules, 1);

                if (hasRegulatorRules)
                {
                    var hasRegulatorInfo = true;

                    complete.Write(hasRegulatorInfo, 1);

                    if (hasRegulatorInfo)
                    {
                        var threshold = 25000000;
                        var rate      = 1000;

                        complete.Write(threshold, 32);
                        complete.Write(rate, 32);
                    }
                }

                var haslogonInfo = true;
                var account      = client.Session.Account;
                var gameAccount  = client.Session.GameAccount;

                complete.Write(!haslogonInfo, 1);

                complete.WriteString(account.GivenName, 8, false);
                complete.WriteString(account.Surname, 8, false);

                complete.Write(account.Id, 32);
                complete.Write((byte)account.Region, 8);
                complete.Write((ulong)account.Flags, 64);

                complete.Write((byte)gameAccount.Region, 8);
                complete.WriteString(gameAccount.AccountId + "#" + gameAccount.Index, 5, false, -1);
                complete.Write((ulong)gameAccount.Flags, 64);

                complete.Write(account.LoginFailures, 32);
                complete.Write(0, 8);
            }

            client.SendPacket(complete);
        }
Example #11
0
        public static void SendAuthComplete(bool failed, AuthResult result, AuthSession session)
        {
            var complete = new AuthPacket(AuthServerMessage.Complete);

            complete.Write(failed, 1);

            if (failed)
            {
                complete.Write(false, 1);       // false - disable optional modules
                complete.Write(1, 2);           // 1 - enable AuthResults
                complete.Write(result, 16);     // AuthResults (Error codes)
                complete.Write(0x80000000, 32); // Unknown
            }
            else
            {
                complete.Write(0, 3);
                complete.Write(0x80005000, 32); // Ping request, ~10 secs

                var hasOptionalData = true;

                complete.Write(hasOptionalData, 1);

                if (hasOptionalData)
                {
                    var hasConnectionInfo = true;

                    complete.Write(hasConnectionInfo, 1);

                    if (hasConnectionInfo)
                    {
                        complete.Write(25000000, 32);
                        complete.Write(1000, 32);
                    }
                }

                complete.Write(false, 1);

                complete.WriteString("", 8, false); // FirstName not implemented
                complete.WriteString("", 8, false); // LastName not implemented

                complete.Write(session.Account.Id, 32);

                complete.Write(0, 8);
                complete.Write(0, 64);
                complete.Write(0, 8);

                complete.WriteString(session.Account.Email, 5, false, -1);

                complete.Write(0, 64);
                complete.Write(0, 32);

                complete.Write(0, 8);
            }

            session.Send(complete);
        }
Example #12
0
        public static void OnRealmUpdate(AuthPacket packet, Client client)
        {
            Log.Message(LogType.Debug, "Received realm update.");

            var complete = new AuthPacket(AuthServerMessage.RealmComplete, AuthChannel.WoW);

            complete.Flush();
            complete.Write(0, 8);

            var realmCounter = 0;

            foreach (var realm in Manager.RealmMgr.RealmList)
            {
                var realmlist = new AuthPacket(AuthServerMessage.RealmUpdate, AuthChannel.WoW);

                realmlist.Write(true, 1);
                realmlist.Write(1, 32);
                realmlist.Write(0f, 32);
                realmlist.Write(realm.Value.Flags, 8);
                realmlist.Write(realm.Value.Id, 19);
                realmlist.Write(0x80000000 + realm.Value.Type, 32);
                realmlist.WriteString(realm.Value.Name, 10, false);
                realmlist.Write(false, 1);
                realmlist.Write(realm.Value.Status, 8);
                realmlist.Write(0, 12);
                realmlist.Write(0, 8);
                realmlist.Write(0, 32);
                realmlist.Write(++realmCounter, 8);

                // End
                realmlist.Write(new byte[] { 0x43, 0x02 });
                realmlist.Finish();

                complete.Write(realmlist.Data);
            }

            client.SendPacket(complete);
        }