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); }
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); }
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); }
public async Task Send(AuthPacket packet) { try { await Task.Run(() => packet.Finish()); client.Send(packet.Data); } catch (Exception ex) { Dispose(); Log.Error(ex.Message); } }
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); }
public void Send(AuthPacket packet) { try { packet.Finish(); if (packet.Header != null) PacketLog.Write<AuthServerMessage>(packet.Header.Message, packet.Data, client.RemoteEndPoint); if (Crypt != null && Crypt.IsInitialized) Crypt.Encrypt(packet.Data, packet.Data.Length); var socketEventargs = new SocketAsyncEventArgs(); socketEventargs.SetBuffer(packet.Data, 0, packet.Data.Length); socketEventargs.Completed += SendCompleted; socketEventargs.UserToken = packet; socketEventargs.RemoteEndPoint = client.RemoteEndPoint; socketEventargs.SocketFlags = SocketFlags.None; client.Send(packet.Data); } catch (Exception ex) { Dispose(); ExceptionLog.Write(ex); Log.Error(ex.Message); } }
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); }
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); }