public ManagedAmeisenBot(WowProcess wowProcess, WowAccount wowAccount, AmeisenBot ameisenBot) { WowProcess = wowProcess; WowAccount = wowAccount; AmeisenBot = ameisenBot; StartState = BotStartState.None; }
private void HandleLogin(TrashMem trashMem, Process process, WowAccount wowAccount) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tHandling Login into account: {wowAccount.Username}:{wowAccount.CharacterName}:{wowAccount.CharacterSlot}", LogLevel.Verbose); foreach (char c in wowAccount.Username) { SendKeyToProcess(process, c, char.IsUpper(c)); Thread.Sleep(10); } Thread.Sleep(100); SendKeyToProcess(process, 0x09); Thread.Sleep(100); bool firstTime = true; do { if (!firstTime) { SendKeyToProcess(process, 0x0D); } foreach (char c in wowAccount.Password) { SendKeyToProcess(process, c, char.IsUpper(c)); Thread.Sleep(10); } Thread.Sleep(500); SendKeyToProcess(process, 0x0D); Thread.Sleep(3000); firstTime = false; } while (trashMem.ReadString(OffsetList.StaticGameState, Encoding.ASCII, 10) == "login"); }
/// <summary> /// 登陆握手 /// </summary> /// <param name="netState"></param> /// <param name="packetReader"></param> public static void Auth_HandleAuthChallenge(NetState netState, PacketReader packetReader) { AuthExtendData extendData = netState.GetComponent <AuthExtendData>(AuthExtendData.COMPONENT_ID); if (extendData == null) { Debug.WriteLine("Auth_PacketHandlers.Auth_HandleAuthChallenge(...) - extendData == null error!"); return; } if (extendData.IsLoggedIn == true) { Debug.WriteLine("Auth_PacketHandlers.Auth_HandleAuthChallenge(...) - extendData.IsLoggedIn == false error!"); return; } extendData.AuthChallenge.AuthLogonChallenge = AuthLogonChallenge.ReadAuthLogonChallenge(packetReader); // 版本验证 if (extendData.AuthChallenge.AuthLogonChallenge.Build > (ushort)CLIENT_VERSIONS.CLIENT_MAX || extendData.AuthChallenge.AuthLogonChallenge.Build < (ushort)CLIENT_VERSIONS.CLIENT_MIN) { netState.Send(new Auth_AuthChallengeResultError(LogineErrorInfo.LOGIN_WRONG_BUILD_NUMBER)); return; } // 帐号是否存在 WowAccount wowAccount = WowAccountHandler.GetAccount(extendData.AuthChallenge.AuthLogonChallenge.AccountName); if (wowAccount == null) { netState.Send(new Auth_AuthChallengeResultError(LogineErrorInfo.LOGIN_NO_ACCOUNT)); return; } extendData.WowAccount = wowAccount; // 帐号是否停用 if (wowAccount.Banned) { netState.Send(new Auth_AuthChallengeResultError(LogineErrorInfo.LOGIN_ACCOUNT_CLOSED)); return; } // 帐号是否在线 if (wowAccount.Locked) { netState.Send(new Auth_AuthChallengeResultError(LogineErrorInfo.LOGIN_ACCOUNT_FREEZED)); return; } // 成功 更新IP WowAccountHandler.UpdateAccountLastIP(wowAccount.AccountName, netState.NetAddress.Address.ToString()); // 登陆成功 extendData.IsLoggedIn = true; // 获取SRP的Key extendData.SRP = new SecureRemotePassword(true, wowAccount.AccountName, wowAccount.Password); netState.Send(new Auth_AuthChallengeResult(extendData.SRP)); }
public bool DoLogin(Process process, WowAccount wowAccount, IOffsetList offsetlist, int maxTries = 4) { try { TrashMem trashMem = new TrashMem(process); int count = 0; LoginInProgress = true; LoginInProgressCharactername = wowAccount.CharacterName; OffsetList = offsetlist; while (trashMem.ReadInt32(offsetlist.StaticIsWorldLoaded) != 1) { if (process.HasExited || count >= maxTries) { return(false); } switch (trashMem.ReadString(offsetlist.StaticGameState, Encoding.ASCII, 10)) { case "login": HandleLogin(trashMem, process, wowAccount); count++; break; case "charselect": HandleCharSelect(trashMem, process, wowAccount); break; default: count++; break; } Thread.Sleep(2000); } } catch (Exception e) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tCrash at Login: \n{e}", LogLevel.Error); return(false); } AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tLogin successful...", LogLevel.Verbose); LoginInProgress = false; LoginInProgressCharactername = string.Empty; return(true); }
private void HandleCharSelect(TrashMem trashMem, Process process, WowAccount wowAccount) { AmeisenBotLogger.Instance.Log($"[{process.Id.ToString("X" , CultureInfo.InvariantCulture.NumberFormat)}]\tHandling Characterselection: {wowAccount.Username}:{wowAccount.CharacterName}:{wowAccount.CharacterSlot}", LogLevel.Verbose); int currentSlot = trashMem.ReadInt32(OffsetList.StaticCharacterSlotSelected); while (currentSlot != wowAccount.CharacterSlot) { SendKeyToProcess(process, 0x28); Thread.Sleep(200); currentSlot = trashMem.ReadInt32(OffsetList.StaticCharacterSlotSelected); } SendKeyToProcess(process, 0x0D); }
private WowProcess StartNewWowProcess(WowAccount account) { List <WowProcess> wowProcesses; do { wowProcesses = BotUtils.GetRunningWows(OffsetList) .Where(p => !p.LoginInProgress && p.CharacterName?.Length == 0).ToList(); // Start new Wow process if (wowProcesses?.Count == 0) { StartNewWow(account); } } while (wowProcesses?.Count == 0); return(wowProcesses.First()); }
/// <summary> /// /// </summary> public Realm_RequestSessionResult(uint iSerial, WowAccount account, SecureRemotePassword srp) : base((long)RealmOpCode.CMSG_REQUEST_SESSION_RESULT, 0 /* ProcessNet.REALM_HEAD_SIZE + ? */) { WriterStream.Write((byte)RealmOpCode.CMSG_REQUEST_SESSION_RESULT); // ×ֶαàºÅ WriterStream.Write((ushort)0); // ×Ö¶ÎÊ£Óà´óС ////////////////////////////////////////////////////////////////////////// WriterStream.Write((uint)iSerial); WriterStream.Write(true); // ³É¹¦ WriterStream.Write((uint)account.AccountGuid); WriterStream.Write((int)account.AccessLevel); WriterStream.Write((bool)account.IsTBC); byte[] byteSessionKey = srp.SessionKey.GetBytes(40); WriterStream.Write(byteSessionKey, 0, 40); ////////////////////////////////////////////////////////////////////////// WriterStream.Seek(1, SeekOrigin.Begin); WriterStream.Write((ushort)(WriterStream.Length - ProcessNet.REALM_HEAD_SIZE)); }
private void SetupNewAmeisenBot(WowAccount account, WowProcess wowProcess) { WowAccounts[account] = BotStartState.BotIsAttaching; TrashMem trashMem = new TrashMem(wowProcess.Process); MemoryWowDataAdapter memoryWowDataAdapter = new MemoryWowDataAdapter(trashMem, OffsetList); MemoryWowActionExecutor memoryWowActionExecutioner = new MemoryWowActionExecutor(trashMem, OffsetList); AmeisenNavPathfindingClient ameisenNavPathfindingClient = new AmeisenNavPathfindingClient(Settings.AmeisenNavmeshServerIp, Settings.AmeisenNavmeshServerPort, wowProcess.Process.Id); LuaHookWowEventAdapter luaHookWowEventAdapter = new LuaHookWowEventAdapter(memoryWowActionExecutioner); BasicMeleeMovementProvider basicMeleeMovementProvider = new BasicMeleeMovementProvider(); SimpleAutologinProvider simpleAutologinProvider = new SimpleAutologinProvider(); AmeisenBot ameisenBot = new AmeisenBot(trashMem, memoryWowDataAdapter, simpleAutologinProvider, wowProcess.Process); ManagedAmeisenBot managedAmeisenBot = new ManagedAmeisenBot(wowProcess, account, ameisenBot); if (ameisenBot.AutologinProvider.DoLogin(wowProcess.Process, account, OffsetList)) { ameisenBot.Attach(memoryWowActionExecutioner, ameisenNavPathfindingClient, luaHookWowEventAdapter, basicMeleeMovementProvider, null); if (Settings.WowPositions.ContainsKey(account.CharacterName)) { ameisenBot.SetWindowPosition(Settings.WowPositions[account.CharacterName]); } ManagedAmeisenBots.Add(managedAmeisenBot); IAmeisenBotViews.OfType <WowView>().ToList().RemoveAll(v => v.WowProcess.Process.Id == managedAmeisenBot.WowProcess.Process.Id); WowAccounts[account] = BotStartState.BotIsAttached; } else { // we failed to login, restart wow... if (!wowProcess.Process.HasExited) { wowProcess.Process.Kill(); } WowAccounts[account] = BotStartState.None; } }
/// <summary> /// /// </summary> /// <param name="netState"></param> /// <param name="packetReader"></param> public static void Realm_HandleRequestSession(NetState netState, PacketReader packetReader) { RealmExtendData extendData = netState.GetComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID); if (extendData == null) { Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRequestSession(...) - extendData == null error!"); return; } if (extendData.IsLoggedIn == false) { Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRequestSession(...) - extendData.IsLoggedIn == false error!"); return; } uint iSerial = packetReader.ReadUInt32(); string strAccountName = packetReader.ReadUTF8StringSafe(); WowAccount wowAccount = WowAccountHandler.GetAccount(strAccountName); if (wowAccount == null) { netState.Send(new Realm_RequestSessionResultError(iSerial)); return; } SecureRemotePassword srp = SrpHandler.GetSRP(strAccountName); if (srp == null) { netState.Send(new Realm_RequestSessionResultError(iSerial)); return; } netState.Send(new Realm_RequestSessionResult(iSerial, wowAccount, srp)); }
private void StartNewWow(WowAccount account) { WowAccounts[account] = BotStartState.WowStartInProgress; Process.Start(Settings.WowExePath).WaitForInputIdle(); WowAccounts[account] = BotStartState.WowIsRunning; }