public static void OnJoinRequest(AuthPacket packet, Client client) { var clientSalt = BitConverter.GetBytes(packet.Read <uint>(32)); var serverSalt = new byte[0].GenerateRandomKey(4); client.Session.GenerateSessionKey(clientSalt, serverSalt); // Continue if sessionKey is not empty if (client.Session.GameAccount.SessionKey != "") { var joinResponse = new AuthPacket(AuthServerMessage.JoinResponse, AuthChannel.WoW); joinResponse.Write(Manager.RealmMgr.RealmList.Count == 0, 1); joinResponse.Write(BitConverter.ToUInt32(serverSalt, 0), 32); joinResponse.Write(Manager.RealmMgr.RealmList.Count, 5); foreach (var realm in Manager.RealmMgr.RealmList) { var ip = IPAddress.Parse(realm.Value.IP).GetAddressBytes(); var port = BitConverter.GetBytes(realm.Value.Port); Array.Reverse(port); joinResponse.Write(ip); joinResponse.Write(port); } joinResponse.Write(0, 5); client.SendPacket(joinResponse); } }
public static void OnJoinRequest(AuthPacket packet, Client client) { var clientSalt = BitConverter.GetBytes(packet.Read<uint>(32)); var serverSalt = new byte[0].GenerateRandomKey(4); client.Session.GenerateSessionKey(clientSalt, serverSalt); // Continue if sessionKey is not empty if (client.Session.GameAccount.SessionKey != "") { var joinResponse = new AuthPacket(AuthServerMessage.JoinResponse, AuthChannel.WoW); joinResponse.Write(Manager.RealmMgr.RealmList.Count == 0, 1); joinResponse.Write(BitConverter.ToUInt32(serverSalt, 0), 32); joinResponse.Write(Manager.RealmMgr.RealmList.Count, 5); foreach (var realm in Manager.RealmMgr.RealmList) { var ip = IPAddress.Parse(realm.Value.IP).GetAddressBytes(); var port = BitConverter.GetBytes(realm.Value.Port); Array.Reverse(port); joinResponse.Write(ip); joinResponse.Write(port); } joinResponse.Write(0, 5); client.SendPacket(joinResponse); } }
public static void OnProofResponse(AuthPacket packet, AuthSession session) { var moduleCount = packet.Read <byte>(3); for (int i = 0; i < moduleCount; i++) { var dataSize = packet.Read <int>(10); var stateId = packet.Read(1)[0]; switch (stateId) { case 1: SendAuthComplete(false, AuthResult.GlobalSuccess, session); break; case 2: // 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); SendProofVerification(session, clientChallenge); } else { SendAuthComplete(true, AuthResult.BadLoginInformation, session); } break; default: break; } } }
public static void OnProofResponse(AuthPacket packet, AuthSession 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: SendAuthComplete(false, AuthResult.GlobalSuccess, session); 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); SendProofValidation(session, clientChallenge); } else SendAuthComplete(true, AuthResult.BadLoginInformation, session); break; default: break; } } }
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); } }
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; } } }
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; } } }
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); } } }
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); } } }
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); } }
public void Read(AuthPacket packet) { Program = packet.ReadFourCC(); Platform = packet.ReadFourCC(); Version = packet.Read<int>(32); }