private static void InitAuthentication(MooNetClient client, bnet.protocol.authentication.LogonRequest request) { client.LoginEmail = request.Email; var account = AccountManager.GetAccountByEmail(request.Email.ToLower()); // check if account exists. if (account == null) // we should be returning an error to client /raist. { client.AuthenticationErrorCode = AuthenticationErrorCodes.NoGameAccount; client.AuthenticationComplete(); return; } var thumbprintData = "f9513183031b3836103ac3a3bb606c0e06fd3b94ae4a6b6e405844085b794e901b0ebb1db650b85bac4b489a38a1ca9dcef2bbd13445d0cd85accfc62d84bc3a8d960b1a7a65cd8d3f72a172f41dca98459015ffbd25d766b02824a42dacb7c4cd64f4b3b9e316de23ec1dbb0153b73a4fa58ffb39c3f484b4b478a660dc8979e16e52f978a0ca2fc4184fa0f69844d73ef99f47e3ccb02cf6a636b4ae9513404eee7e0ad536dcef50cd1699e38195e6afdd3655a3a3529b4e52b33ac5d04f5fa2b15536a2c782c89c0acf133e14eac15af035abf5e44e9e1124a3397dac8f90a4ccb1717540698869fc1ba9037e099d68698ecf17ffdd36f07013176be24269fda1e5d221708181d95474fc1d74bb901062a9f6a3e24aef79e9d583d9126796d63c153a0f75f02da27ecc0971f39a46ec29087c3ae474e08fdf8f65d1445b293399bc495ff651b7d2d7a36216ba5e4400ea7bbc884dc4cf3ed27f14501b8bb7fc0f86b5089880e6889bcd851153e299a337d6c945f710559595e351995341cbef44abac379cf0f845b362d294eec390d50f1a50089d250eae1b1205cea1aff514de076516f467cd077a1fbb759b415dc6c0ea1617f31f7d764a0d60d5b67aa82b4202b2a9455eb9ca3683955ec45aaf56aba42a2f3ae9be5f3eed093a6601816d00e0569bfcb91fb7843945336c99757812d373d510d25744f9480b6cc87e8a".ToByteArray(); var srp6a = new SRP6a(account); // create srp6 handler to process the authentication. OngoingAuthentications.Add(client, srp6a); // request client to load thumbprint.dll for authentication. var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder() .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder() .SetRegion(0x00005858) // XX .SetUsage(0x61757468) // auth - thumbprint.dll .SetHash(ByteString.CopyFrom(VersionInfo.MooNet.ThumbprintHashMap[client.Platform]))) .SetMessage(ByteString.CopyFrom(thumbprintData)) .Build(); client.ThumbprintReq = true; client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, callback => { })); }
private static void InitAuthentication(MooNetClient client, bnet.protocol.authentication.LogonRequest request) { var account = AccountManager.GetAccountByEmail(request.Email.ToLower()); // check if account exists. if (account == null) // we should be returning an error to client /raist. { client.AuthenticationErrorCode = AuthenticationErrorCodes.NoGameAccount; client.AuthenticationCompleteSignal.Set(); return; } var srp6a = new SRP6a(account); // create srp6 handler to process the authentication. OngoingAuthentications.Add(client, srp6a); // request client to load password.dll for authentication. var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder() .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder() .SetRegion(0x00005553) // us .SetUsage(0x61757468) // auth - password.dll .SetHash(ByteString.CopyFrom(VersionInfo.MooNet.AuthModuleHashMap[client.Platform]))) .SetMessage(ByteString.CopyFrom(srp6a.LogonChallenge)) .Build(); //client.MakeRPCWithListenerId(request.ListenerId, () => // bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, ModuleLoadResponse)); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, ModuleLoadResponse)); }
private void SendConnectionInfo(MooNetClient client) { // Lock party and close privacy level while entering game var channelStatePrivacyLevel = bnet.protocol.channel.ChannelState.CreateBuilder() .SetPrivacyLevel(bnet.protocol.channel.ChannelState.Types.PrivacyLevel.PRIVACY_LEVEL_CLOSED).Build(); var notificationPrivacyLevel = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(client.Account.CurrentGameAccount.BnetEntityId) .SetStateChange(channelStatePrivacyLevel) .Build(); var gameChannel = ChannelManager.GetChannelByEntityId(this.BnetEntityId); client.MakeTargetedRPC(gameChannel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, notificationPrivacyLevel, callback => { })); var channelStatePartyLock = bnet.protocol.channel.ChannelState.CreateBuilder() .AddAttribute(bnet.protocol.attribute.Attribute.CreateBuilder() .SetName("D3.Party.LockReasons") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1).Build()) .Build()).Build(); var notificationPartyLock = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder() .SetAgentId(client.Account.CurrentGameAccount.BnetEntityId) .SetStateChange(channelStatePartyLock) .Build(); client.MakeTargetedRPC(gameChannel, () => bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, notificationPartyLock, callback => { })); // send the notification. var connectionInfo = GetConnectionInfoForClient(client); var connectionInfoAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("connection_info") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(connectionInfo.ToByteString()).Build()) .Build(); var gameHandleAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("game_handle") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(this.GameHandle.ToByteString()).Build()) .Build(); var requestIdAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("game_request_id") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetUintValue(this.RequestId).Build()) .Build(); var notificationBuilder = bnet.protocol.notification.Notification.CreateBuilder() .SetSenderId(bnet.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(0).Build()) .SetTargetId(client.Account.CurrentGameAccount.BnetEntityId) .SetType("GAME_CONNECTION_INFO") .AddAttribute(connectionInfoAttribute) .AddAttribute(gameHandleAttribute) .AddAttribute(requestIdAttribute) .Build(); client.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(client).OnNotificationReceived(null, notificationBuilder, callback => { })); }
public static void HandleAuthResponse(MooNetClient client, int moduleId, byte[] authMessage) { if(!OngoingAuthentications.ContainsKey(client)) return; // TODO: disconnect him also. /raist. var srp6 = OngoingAuthentications[client]; byte[] A = authMessage.Skip(1).Take(128).ToArray(); // client's public ephemeral byte[] M_client = authMessage.Skip(1 + 128).Take(32).ToArray(); // client's proof of session key. byte[] seed = authMessage.Skip(1 + 32 + 128).Take(128).ToArray(); // client's second challenge. var success = srp6.Verify(A, M_client, seed); if (Config.Instance.DisablePasswordChecks || success) // if authentication is sucesseful or password check's are disabled. { // send the logon proof. var message = bnet.protocol.authentication.ModuleMessageRequest.CreateBuilder() .SetModuleId(moduleId) .SetMessage(ByteString.CopyFrom(srp6.LogonProof)) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleMessage(null, message, callback => client.AuthenticationComplete())); /* // This file current does not exist - future use maybe? -Egris var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder() .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder() .SetRegion(0x00005858) // XX .SetUsage(0x61757468) // auth - ??.dll .SetHash(ByteString.CopyFrom("72dd40a65ccadc04fe4ece1323effd3177f4afb9f88a96905a7a30db42c0ae0f".ToByteArray()))) .SetMessage(ByteString.Empty) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, ModuleLoadResponse)); */ client.Account = AccountManager.GetAccountByEmail(srp6.Account.Email); //if (client.Account.LoggedInClient != null) // client.Account.LoggedInClient.Connection.Disconnect(); //client.Account.LoggedInClient = client; } else // authentication failed because of invalid credentals. { client.AuthenticationErrorCode = AuthenticationErrorCodes.InvalidCredentials; } OngoingAuthentications.Remove(client); }
public static void SendAccountSettings(MooNetClient client) { var accset = new bnet.protocol.authentication.AccountSettingsNotification.Builder(); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(168)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(184)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(185)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(186)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(187)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(188)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(193)); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).AccountSettings(null, accset.Build(), delegate(bnet.protocol.NO_RESPONSE a) { })); }
public static void HandleAuthResponse(MooNetClient client, int moduleId, byte[] authMessage) { if (!OngoingAuthentications.ContainsKey(client)) return; // TODO: disconnect him also. /raist. var srp6 = OngoingAuthentications[client]; byte[] A = authMessage.Skip(1).Take(128).ToArray(); // client's public ephemeral byte[] M_client = authMessage.Skip(1 + 128).Take(32).ToArray(); // client's proof of session key. byte[] seed = authMessage.Skip(1 + 32 + 128).Take(128).ToArray(); // client's second challenge. var success = srp6.Verify(A, M_client, seed); //if (Config.Instance.DisablePasswordChecks || success) if (success) { client.SessionKey = srp6.SessionKey; // send the logon proof. var message = bnet.protocol.authentication.ModuleMessageRequest.CreateBuilder() .SetModuleId(moduleId) .SetMessage(ByteString.CopyFrom(srp6.LogonProof)) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleMessage(null, message, callback => client.CheckAuthenticator())); client.Account = AccountManager.GetAccountByEmail(srp6.Account.Email); //if (client.Account.LoggedInClient != null) // client.Account.LoggedInClient.Connection.Disconnect(); //client.Account.LoggedInClient = client; } else // authentication failed because of invalid credentals. { client.AuthenticationErrorCode = AuthenticationErrorCodes.InvalidCredentials; //end authentication client.AuthenticationComplete(); } OngoingAuthentications.Remove(client); }
public static void HandleAuthResponse(MooNetClient client, int moduleId, byte[] authMessage) { if(!OngoingAuthentications.ContainsKey(client)) return; // TODO: disconnect him also. /raist. var srp6 = OngoingAuthentications[client]; byte[] A = authMessage.Skip(1).Take(128).ToArray(); // client's public ephemeral byte[] M_client = authMessage.Skip(1 + 128).Take(32).ToArray(); // client's proof of session key. byte[] seed = authMessage.Skip(1 + 32 + 128).Take(128).ToArray(); // client's second challenge. if(srp6.Verify(A,M_client,seed)) // authentication sucesseful { // send the logon proof. var message = bnet.protocol.authentication.ModuleMessageRequest.CreateBuilder() .SetModuleId(moduleId) .SetMessage(ByteString.CopyFrom(srp6.LogonProof)) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleMessage(null, message, callback => { })); client.Account = AccountManager.GetAccountByEmail(srp6.Account.Email); if (client.Account.LoggedInClient != null) client.Account.LoggedInClient.Connection.Disconnect(); client.Account.LoggedInClient = client; } else // authentication failed because of invalid credentals. { client.AuthenticationErrorCode = AuthenticationErrorCodes.InvalidCredentials; } OngoingAuthentications.Remove(client); client.AuthenticationCompleteSignal.Set(); // signal about completion of authentication processes so we can return the response for AuthenticationService:LogonRequest. }
private void SendConnectionInfo(MooNetClient client) { if (client == this.Channel.Owner) // we should send a GameFoundNotification to part leader { var builder = bnet.protocol.game_master.GameFoundNotification.CreateBuilder(); builder.AddConnectInfo(GetConnectionInfoForClient(client)); builder.SetRequestId(this.RequestId); builder.SetGameHandle(this.GameHandle); client.MakeTargetedRPC(this, () => bnet.protocol.game_master.GameFactorySubscriber.CreateStub(client).NotifyGameFound(null, builder.Build(), callback => { })); } else // where as other members should get a bnet.protocol.notification.Notification { var connectionInfo = GetConnectionInfoForClient(client); var connectionInfoAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("connection_info") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(connectionInfo.ToByteString()).Build()) .Build(); var gameHandleAttribute = bnet.protocol.attribute.Attribute.CreateBuilder().SetName("game_handle") .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(this.GameHandle.ToByteString()).Build()) .Build(); var builder = bnet.protocol.notification.Notification.CreateBuilder() .SetSenderId(this.Channel.Owner.CurrentToon.BnetEntityID) .SetTargetId(client.CurrentToon.BnetEntityID) .SetType("GAME_CONNECTION_INFO") .AddAttribute(connectionInfoAttribute) .AddAttribute(gameHandleAttribute); client.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(client).OnNotificationReceived(null, builder.Build(), callback => { })); } }
public static void SendAccountSettings(MooNetClient client) { var accset = new bnet.protocol.authentication.AccountSettingsNotification.Builder(); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(111)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(227)); accset.AddLicenses(new bnet.protocol.account.AccountLicense.Builder().SetId(168)); //Full Game - Removes upgrade banner client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).AccountSettings(null, accset.Build(), delegate(bnet.protocol.NO_RESPONSE a) { })); }
public static void HandleAuthResponse(MooNetClient client, int moduleId, byte[] authMessage) { if(!OngoingAuthentications.ContainsKey(client)) return; // TODO: disconnect him also. /raist. var srp6 = OngoingAuthentications[client]; byte[] A = authMessage.Skip(1).Take(128).ToArray(); // client's public ephemeral byte[] M_client = authMessage.Skip(1 + 128).Take(32).ToArray(); // client's proof of session key. byte[] seed = authMessage.Skip(1 + 32 + 128).Take(128).ToArray(); // client's second challenge. var success = srp6.Verify(A, M_client, seed); if (Config.Instance.DisablePasswordChecks || success) // if authentication is sucesseful or password check's are disabled. { // send the logon proof. var message = bnet.protocol.authentication.ModuleMessageRequest.CreateBuilder() .SetModuleId(moduleId) .SetMessage(ByteString.CopyFrom(srp6.LogonProof)) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleMessage(null, message, callback => client.AuthenticationComplete())); /* var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder() .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder() .SetRegion(VersionInfo.MooNet.Regions[VersionInfo.MooNet.Region]) .SetUsage(0x61757468) // auth - RiskFingerprint.dll .SetHash(ByteString.CopyFrom("bcfa324ab555fc66614976011d018d2be2b9dc23d0b54d94a3bd7d12472aa107".ToByteArray()))) .SetMessage(ByteString.Empty) .Build(); client.MakeRPC(() => bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, ModuleLoadResponse)); */ client.Account = AccountManager.GetAccountByEmail(srp6.Account.Email); //if (client.Account.LoggedInClient != null) // client.Account.LoggedInClient.Connection.Disconnect(); //client.Account.LoggedInClient = client; } else // authentication failed because of invalid credentals. { client.AuthenticationErrorCode = AuthenticationErrorCodes.InvalidCredentials; //end authentication client.AuthenticationComplete(); } OngoingAuthentications.Remove(client); }