public static async void HandleVerifyWebCredentialsRequest(VerifyWebCredentialsRequest verifyWebCredentials, BnetSession session) { var logonResult = new LogonResult(); if (verifyWebCredentials.WebCredentials.ToStringUtf8() == session.LoginTicket) { logonResult.AccountId = new EntityId { High = 0x100000000000000, Low = session.Account.Id }; session.Account.GameAccounts.ForEach(ga => { logonResult.GameAccountId.Add(new EntityId { // TODO: Build the right High value. High = 0x200000200576F57, Low = ga.Id }); }); logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString()); } else logonResult.ErrorCode = (uint)BnetErrorCode.Denied; await session.Send(logonResult, BnetServiceHash.AuthenticationListenerService, 5); }
public static async void HandleVerifyWebCredentialsRequest(VerifyWebCredentialsRequest verifyWebCredentials, BnetSession session) { var logonResult = new LogonResult(); if (verifyWebCredentials.WebCredentials.ToStringUtf8() == session.LoginTicket) { logonResult.AccountId = new EntityId { High = 0x100000000000000, Low = session.Account.Id }; session.Account.GameAccounts.ForEach(ga => { logonResult.GameAccountId.Add(new EntityId { // TODO: Build the right High value. High = 0x200000200576F57, Low = ga.Id }); }); logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString()); } else { logonResult.ErrorCode = (uint)BnetErrorCode.Denied; } await session.Send(logonResult, BnetServiceHash.AuthenticationListenerService, 5); }
public void VerifyWebCredentials(string token) { if (base.m_rpcConnection != null) { VerifyWebCredentialsRequest message = new VerifyWebCredentialsRequest(); byte[] bytes = Encoding.UTF8.GetBytes(token); message.SetWebCredentials(bytes); base.m_rpcConnection.BeginAuth(); base.m_rpcConnection.QueueRequest(this.AuthClientService.Id, 7, message, null, 0); } }
public void VerifyWebCredentials(string token) { if (this.m_rpcConnection == null) { return; } VerifyWebCredentialsRequest verifyWebCredentialsRequest = new VerifyWebCredentialsRequest(); verifyWebCredentialsRequest.SetWebCredentials(Encoding.UTF8.GetBytes(token)); this.m_rpcConnection.BeginAuth(); this.m_rpcConnection.QueueRequest(this.AuthClientService.Id, 7, verifyWebCredentialsRequest, null, 0); }
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream) { switch (methodId) { case 1: { LogonRequest request = new LogonRequest(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleLogon(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.Logon(bgs.protocol.authentication.v1.LogonRequest: {1}) returned bgs.protocol.NoData: {2} status {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 2: { ModuleNotification request = new ModuleNotification(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleModuleNotify(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleNotify(bgs.protocol.authentication.v1.ModuleNotification: {1}) returned bgs.protocol.NoData: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 3: { ModuleMessageRequest request = new ModuleMessageRequest(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleModuleMessage(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 4: { EntityId request = new EntityId(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleSelectGameAccount_DEPRECATED(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount_DEPRECATED(bgs.protocol.EntityId: {1}) returned bgs.protocol.NoData: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 5: { GenerateSSOTokenRequest request = new GenerateSSOTokenRequest(); request.MergeFrom(stream); GenerateSSOTokenResponse response = new GenerateSSOTokenResponse(); BattlenetRpcErrorCode status = HandleGenerateSSOToken(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateSSOToken(bgs.protocol.authentication.v1.GenerateSSOTokenRequest: {1}) returned bgs.protocol.authentication.v1.GenerateSSOTokenResponse: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 6: { SelectGameAccountRequest request = new SelectGameAccountRequest(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleSelectGameAccount(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount(bgs.protocol.authentication.v1.SelectGameAccountRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 7: { VerifyWebCredentialsRequest request = new VerifyWebCredentialsRequest(); request.MergeFrom(stream); NoData response = new NoData(); BattlenetRpcErrorCode status = HandleVerifyWebCredentials(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.VerifyWebCredentials(bgs.protocol.authentication.v1.VerifyWebCredentialsRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } case 8: { GenerateWebCredentialsRequest request = new GenerateWebCredentialsRequest(); request.MergeFrom(stream); GenerateWebCredentialsResponse response = new GenerateWebCredentialsResponse(); BattlenetRpcErrorCode status = HandleGenerateWebCredentials(request, response); Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateWebCredentials(bgs.protocol.authentication.v1.GenerateWebCredentialsRequest: {1}) returned bgs.protocol.authentication.v1.GenerateWebCredentialsResponse: {2} status: {3}.", GetCallerInfo(), request.ToString(), response.ToString(), status); if (status == 0) { SendResponse(token, response); } else { SendResponse(token, status); } break; } default: Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId); SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod); break; } }
BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest request, NoData response) { return(_session.HandleVerifyWebCredentials(request)); }
BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest verifyWebCredentialsRequest) { if (verifyWebCredentialsRequest.WebCredentials.IsEmpty) { return(BattlenetRpcErrorCode.Denied); } PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetAccountInfo); stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8()); SQLResult result = DB.Login.Query(stmt); if (result.IsEmpty()) { return(BattlenetRpcErrorCode.Denied); } accountInfo = new AccountInfo(result); if (accountInfo.LoginTicketExpiry < Time.UnixTime) { return(BattlenetRpcErrorCode.TimedOut); } stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetCharacterCountsByAccountId); stmt.AddValue(0, accountInfo.Id); SQLResult characterCountsResult = DB.Login.Query(stmt); if (!characterCountsResult.IsEmpty()) { do { var realmId = new RealmId(characterCountsResult.Read <byte>(3), characterCountsResult.Read <byte>(4), characterCountsResult.Read <uint>(2)); accountInfo.GameAccounts[characterCountsResult.Read <uint>(0)].CharacterCounts[realmId.GetAddress()] = characterCountsResult.Read <byte>(1); } while (characterCountsResult.NextRow()); } stmt = DB.Login.GetPreparedStatement(LoginStatements.SelBnetLastPlayerCharacters); stmt.AddValue(0, accountInfo.Id); SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt); if (!lastPlayerCharactersResult.IsEmpty()) { do { var realmId = new RealmId(lastPlayerCharactersResult.Read <byte>(1), lastPlayerCharactersResult.Read <byte>(2), lastPlayerCharactersResult.Read <uint>(3)); LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo(); lastPlayedCharacter.RealmId = realmId; lastPlayedCharacter.CharacterName = lastPlayerCharactersResult.Read <string>(4); lastPlayedCharacter.CharacterGUID = lastPlayerCharactersResult.Read <ulong>(5); lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read <uint>(6); accountInfo.GameAccounts[lastPlayerCharactersResult.Read <uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter; } while (lastPlayerCharactersResult.NextRow()); } string ip_address = GetRemoteIpEndPoint().ToString(); // If the IP is 'locked', check that the player comes indeed from the correct IP address if (accountInfo.IsLockedToIP) { Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to IP: {accountInfo.LastIP} is logging in from IP: {ip_address}"); if (accountInfo.LastIP != ip_address) { return(BattlenetRpcErrorCode.RiskAccountLocked); } } else { Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to ip"); if (accountInfo.LockCountry.IsEmpty() || accountInfo.LockCountry == "00") { Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is not locked to country"); } else if (!accountInfo.LockCountry.IsEmpty() && !ipCountry.IsEmpty()) { Log.outDebug(LogFilter.Session, $"Session.HandleVerifyWebCredentials: Account: {accountInfo.Login} is locked to Country: {accountInfo.LockCountry} player Country: {ipCountry}"); if (ipCountry != accountInfo.LockCountry) { return(BattlenetRpcErrorCode.RiskAccountLocked); } } } // If the account is banned, reject the logon attempt if (accountInfo.IsBanned) { if (accountInfo.IsPermanenetlyBanned) { Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Banned account {accountInfo.Login} tried to login!"); return(BattlenetRpcErrorCode.GameAccountBanned); } else { Log.outDebug(LogFilter.Session, $"{GetClientInfo()} Session.HandleVerifyWebCredentials: Temporarily banned account {accountInfo.Login} tried to login!"); return(BattlenetRpcErrorCode.GameAccountSuspended); } } LogonResult logonResult = new LogonResult(); logonResult.ErrorCode = 0; logonResult.AccountId = new EntityId(); logonResult.AccountId.Low = accountInfo.Id; logonResult.AccountId.High = 0x100000000000000; foreach (var pair in accountInfo.GameAccounts) { EntityId gameAccountId = new EntityId(); gameAccountId.Low = pair.Value.Id; gameAccountId.High = 0x200000200576F57; logonResult.GameAccountId.Add(gameAccountId); } if (!ipCountry.IsEmpty()) { logonResult.GeoipCountry = ipCountry; } logonResult.SessionKey = ByteString.CopyFrom(new byte[64].GenerateRandomKey(64)); authed = true; SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult); return(BattlenetRpcErrorCode.Ok); }
public static void HandleVerifyWebCredentialsRequest(AuthSession session, VerifyWebCredentialsRequest verifyWebCredentialsRequest) { if (AuthenticationServerService.smethod_0(verifyWebCredentialsRequest.WebCredentials.ToStringUtf8(), Module.smethod_35 <string>(135873738u))) { goto IL_40; } goto IL_12A; uint arg_FE_0; while (true) { IL_F9: uint num; switch ((num = (arg_FE_0 ^ 2914461396u)) % 8u) { case 0u: { LogonResult logonResult; logonResult.AccountId = new EntityId { High = 72057594037927936uL, Low = 400392402uL }; logonResult.GameAccountId.Add(new EntityId { High = 144115196671520599uL, Low = 53248613uL }); arg_FE_0 = (num * 1282423581u ^ 3250166064u); continue; } case 2u: { LogonResult logonResult; session.Send(logonResult, 1898188341u, 5u); arg_FE_0 = (num * 2722318603u ^ 3294505385u); continue; } case 3u: return; case 4u: { LogonResult logonResult; logonResult.SessionKey = ByteString.CopyFromUtf8(new byte[0].GenerateRandomKey(64).ToHexString()); arg_FE_0 = (num * 3298850102u ^ 2641972478u); continue; } case 5u: goto IL_12A; case 6u: goto IL_40; case 7u: { LogonResult logonResult = new LogonResult(); logonResult.ErrorCode = 0u; arg_FE_0 = (num * 3066472018u ^ 3234139154u); continue; } } break; } return; IL_40: arg_FE_0 = 2502728195u; goto IL_F9; IL_12A: session.Dispose(); arg_FE_0 = 3425304053u; goto IL_F9; }