private void authenticatorTestButton_Click(object sender, EventArgs e)
        {
            // restore the authenticator
            try
            {
                var auth = new BattleNetAuthenticator();
                auth.Restore($"{authField1.Text}{authField2.Text}{authField3.Text}{authField4.Text}", textBox8.Text);

                CodeField.Text = Convert.ToString(auth.CurrentCode);
            }
            catch (InvalidRestoreResponseException re)
            {
                MessageBox.Show(this, re.Message, @"YetAnotherRelogger", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        private bool HandleBattleNetToken()
        {
            var serial      = _wowManager.Settings.AuthenticatorSerial;
            var restoreCode = _wowManager.Settings.AuthenticatorRestoreCode;

            if (string.IsNullOrEmpty(serial) || string.IsNullOrEmpty(restoreCode))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(_wowManager.Settings.AuthenticatorSerial))
            {
                return(false);
            }

            var frame = UIObject.GetUIObjectByName <Frame>(_wowManager, "TokenEnterDialogBackgroundEdit");

            if (frame == null || !frame.IsVisible || !frame.IsShown)
            {
                return(false);
            }

            var editBox = UIObject.GetUIObjectByName <EditBox>(_wowManager, "AccountLoginTokenEdit");

            var auth = new BattleNetAuthenticator();

            try
            {
                auth.Restore(serial, restoreCode);
            }
            catch (Exception ex)
            {
                _wowManager.Profile.Err("Could not get auth token: {0}", ex.Message);
                return(false);
            }

            if (!string.IsNullOrEmpty(editBox.Text))
            {
                Utility.SendBackgroundKey(_wowManager.GameProcess.MainWindowHandle, (char)Keys.End, false);
                Utility.SendBackgroundString(_wowManager.GameProcess.MainWindowHandle, new string('\b', "AccountLoginTokenEdit".Length * 2), false);
                _wowManager.Profile.Log("Pressing 'end' + delete keys to remove contents from {0}", "AccountLoginTokenEdit");
            }

            Utility.SendBackgroundString(_wowManager.GameProcess.MainWindowHandle, auth.CurrentCode);
            Utility.SendBackgroundKey(_wowManager.GameProcess.MainWindowHandle, (char)Keys.Enter, false);
            _wowManager.Profile.Log("Accepting Battle net token.");
            return(true);
        }
Exemplo n.º 3
0
        private void authenticatorTestButton_Click(object sender, EventArgs e)
        {
            // restore the authenticator
            try
            {
                BattleNetAuthenticator auth = new BattleNetAuthenticator();
                auth.Restore(string.Format("{0}{1}{2}{3}", authField1.Text, authField2.Text,
                    authField3.Text, authField4.Text), textBox8.Text);

                CodeField.Text = Convert.ToString(auth.CurrentCode);
            }
            catch (InvalidRestoreResponseException re)
            {
                MessageBox.Show(this, re.Message, "YAR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 4
0
        private void authenticatorTestButton_Click(object sender, EventArgs e)
        {
            // restore the authenticator
            try
            {
                BattleNetAuthenticator auth = new BattleNetAuthenticator();
                auth.Restore(string.Format("{0}{1}{2}{3}", authField1.Text, authField2.Text,
                                           authField3.Text, authField4.Text), textBox8.Text);

                CodeField.Text = Convert.ToString(auth.CurrentCode);
            }
            catch (InvalidRestoreResponseException re)
            {
                MessageBox.Show(this, re.Message, "YAR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            // restore the authenticator
            try
            {
                BattleNetAuthenticator auth = new BattleNetAuthenticator();
                auth.Restore(string.Format("{0}{1}{2}{3}", textBox4.Text, textBox5.Text,
                    textBox7.Text, textBox6.Text), textBox8.Text);
                //Authenticator = auth;

                //MessageBox.Show( "Your authenticator has been restored.\n\nYou will now be prompted where to save your new authenticator and choose your encryption level.", "YAR", MessageBoxButtons.OK, MessageBoxIcon.Information);

                // ok to continue
                //DialogResult = System.Windows.Forms.DialogResult.OK;
                //MessageBox.Show( Convert.ToString( auth.CurrentCode), "YAR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CodeField.Text = Convert.ToString(auth.CurrentCode);
            }
            catch (InvalidRestoreResponseException re)
            {
                MessageBox.Show(this, re.Message, "YAR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
Exemplo n.º 6
0
        private void LogInToBattleNet(ChromeDriver browser)
        {
            var config = ConfigurationService.Get <BattleNetConfig>();

            browser.FindElementById("accountName").SendKeys(config.BattleNetAccount);
            browser.FindElementById("password").SendKeys(config.BattleNetPassword);
            browser.FindElementById("submit").Click();

            Thread.Sleep(2000);

            var element = browser.FindElement(SelectorByAttributeValue("formaction", "/login/en/authenticator/choose/authenticator"));

            element.Click();

            Thread.Sleep(500);

            var authenticator = new BattleNetAuthenticator(config.BattleNetAuthenticatorSerial, config.BattleNetAuthenticatorSecret);

            browser.FindElementById("authValue").SendKeys(authenticator.CurrentCode);
            browser.FindElementById("submit").Click();

            Thread.Sleep(5000);
        }
Exemplo n.º 7
0
        public void Start()
        {
            if (!Parent.IsStarted)
                return;

            if (!File.Exists(Location))
            {
                Logger.Instance.Write("File not found: {0}", Location);
                return;
            }

            _isStopped = false;
            // Ping check
            while (Settings.Default.ConnectionCheckPing && !ConnectionCheck.PingCheck() && !_isStopped)
            {
                Parent.Status = "Wait on internet connection";
                Logger.Instance.WriteGlobal("PingCheck: Waiting 10 seconds and trying again!");
                Thread.Sleep(10000);
            }

            // Check valid host
            while (Settings.Default.ConnectionCheckHostCheck && Settings.Default.ConnectionCheckIpHost &&
                   !ConnectionCheck.CheckValidConnection() && !_isStopped)
            {
                Parent.Status = "Wait on host validation";
                Logger.Instance.WriteGlobal("ConnectionValidation: Waiting 10 seconds and trying again!");
                Thread.Sleep(10000);
            }

            // Check if we need to create a Diablo clone
            if (Parent.UseDiabloClone)
                DiabloClone.Create(Parent);

            Parent.Status = "Prepare Diablo"; // Update Status

            //General.AgentKiller(); // Kill all Agent.exe processes

            // Prepare D3 for launch
            //string agentDBPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
            //                     @"\Battle.net\Agent\agent.db";
            //if (File.Exists(agentDBPath))
            //{
            //    Logger.Instance.Write("Deleting: {0}", agentDBPath);
            //    try
            //    {
            //        File.Delete(agentDBPath);
            //    }
            //    catch (Exception ex)
            //    {
            //        Logger.Instance.Write("Failed to delete! Exception: {0}", ex.Message);
            //        DebugHelper.Exception(ex);
            //    }
            //}

            // Copy D3Prefs
            if (!string.IsNullOrEmpty(Parent.D3PrefsLocation))
                D3Prefs();

            // Registry Changes
            RegistryClass.ChangeLocale(Parent.Diablo.Language); // change language
            RegistryClass.ChangeRegion(Parent.Diablo.Region); // change region

            if (UseIsBoxer)
            {
                IsBoxerStarter();
                if (Proc == null)
                {
                    return;
                }
            }
            else if (Proc == null || (Proc != null && Proc.HasExited))
            {
                try
                {
                    const string arguments = "-launch";
                    var pi = new ProcessStartInfo(Location2, arguments)
                    {
                        WorkingDirectory = Path.GetDirectoryName(Location2)
                    };
                    pi = UserAccount.ImpersonateStartInfo(pi, Parent);
                    // Set working directory to executable location
                    Parent.Status = "Starting Diablo"; // Update Status
                    Proc = Process.Start(pi);

                }
                catch (Exception ex)
                {
                    Parent.Stop();
                    DebugHelper.Exception(ex);
                    return;
                }
            }

            if (!UseIsBoxer) // Don't want to fight with isboxer
            {
                if (CpuCount != Environment.ProcessorCount)
                {
                    ProcessorAffinity = AllProcessors; // set it to all ones
                    CpuCount = Environment.ProcessorCount;
                }
                Proc.ProcessorAffinity = (IntPtr)ProcessorAffinity;
            }

            if (_isStopped)
                return; // Halt here when bot is stopped while we where waiting for it to become active

            // Wait for d3 to fully load
            int state = (Settings.Default.UseD3Starter || UseIsBoxer ? 0 : 2);
            if (ReusedWindow)
                state = 2;
            IntPtr handle = IntPtr.Zero;
            bool timedout = false;
            LimitStartTime(true); // reset startup time
            while (!Proc.HasExited && state < 4)
            {
                if (timedout)
                    return;
                //Debug.WriteLine("Splash: " + FindWindow.FindWindowClass("D3 Splash Window Class", Proc.Id) + " Main:" + FindWindow.FindWindowClass("D3 Main Window Class", Proc.Id));
                switch (state)
                {
                    case 0:
                        handle = FindWindow.FindWindowClass("D3 Splash Window Class", Proc.Id);
                        if (handle != IntPtr.Zero)
                        {
                            Logger.Instance.Write("Diablo:{0}: Found D3 Splash Window ({1})", Proc.Id, handle);
                            state++;
                            LimitStartTime(true); // reset startup time
                        }
                        timedout = LimitStartTime();
                        break;
                    case 1:
                        handle = FindWindow.FindWindowClass("D3 Splash Window Class", Proc.Id);
                        if (handle == IntPtr.Zero)
                        {
                            Logger.Instance.Write("Diablo:{0}: D3 Splash Window Closed ({1})", Proc.Id, handle);
                            state++;
                            LimitStartTime(true); // reset startup time
                        }
                        timedout = LimitStartTime();
                        break;
                    case 2:
                        handle = FindWindow.FindWindowClass("D3 Main Window Class", Proc.Id);
                        if (handle != IntPtr.Zero)
                        {
                            Logger.Instance.Write("Diablo:{0}: Found D3 Main Window ({1})", Proc.Id, handle);
                            state++;
                            LimitStartTime(true); // reset startup time
                        }
                        timedout = LimitStartTime();
                        break;
                    case 3:
                        if (CrashChecker.IsResponding(handle))
                        {
                            MainWindowHandle = handle;
                            state++;
                            LimitStartTime(true); // reset startup time
                        }
                        timedout = LimitStartTime();
                        break;
                }
                Thread.Sleep(500);
            }
            if (timedout)
                return;

            if (Program.IsRunAsAdmin)
                Proc.PriorityClass = General.GetPriorityClass(Priority);
            else
                Logger.Instance.Write(Parent, "Failed to change priority (No admin rights)");
            // Continue after launching stuff
            Logger.Instance.Write("Diablo:{0}: Waiting for process to become ready", Proc.Id);

            DateTime timeout = DateTime.UtcNow;
            while (true)
            {
                if (Program.Pause)
                {
                    timeout = DateTime.UtcNow;
                    return;
                }
                if (General.DateSubtract(timeout) > 30 || Proc.HasExited)
                {
                    Logger.Instance.Write("Diablo:{0}: Failed to start!", Proc.Id);
                    Parent.Restart();
                    return;
                }
                Thread.Sleep(100);
                try
                {
                    Proc.Refresh();
                    if (Proc.WaitForInputIdle(100) || CrashChecker.IsResponding(MainWindowHandle))
                        break;
                }
                catch (Exception ex)
                {
                    DebugHelper.Exception(ex);
                }
            }

            if (!IsRunning)
                return;

            _lastRepsonse = DateTime.UtcNow;

            Thread.Sleep(1500);
            if (NoFrame)
                AutoPosition.RemoveWindowFrame(MainWindowHandle, true); // Force remove window frame
            if (ManualPosSize)
                AutoPosition.ManualPositionWindow(MainWindowHandle, X, Y, W, H, Parent);
            else if (Settings.Default.UseAutoPos)
                AutoPosition.PositionWindows();

            Logger.Instance.Write("Diablo:{0}: Process is ready", Proc.Id);

            if (Parent.Diablo.UseAuthenticator)
            {

                //!!! Try to authentificate

                hControl = FindWindow.FindWindowClass("D3 Main Window Class", Proc.Id);

                SetForegroundWindow(hControl);
                Logger.Instance.Write("Diablo:{0}: Trying to login", Proc.Id);

                try
                {
                    SetForegroundWindow(hControl);
                    SendKeys.SendWait(Parent.Diablo.Username);

                    SetForegroundWindow(hControl);
                    SendKeys.SendWait("{TAB}");

                    SetForegroundWindow(hControl);
                    SendKeys.SendWait(Parent.Diablo.Password);

                    SetForegroundWindow(hControl);
                    SendKeys.SendWait("~");
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }

                if (Parent.Diablo.UseAuthenticator)
                {

                    Thread.Sleep(10000);

                    Logger.Instance.Write("Diablo:{0}: Trying to authentificate", Proc.Id);
                    BattleNetAuthenticator auth = new BattleNetAuthenticator();
                    auth.Restore(Parent.Diablo.Serial2, Parent.Diablo.RestoreCode);
                    string authcode = Convert.ToString(auth.CurrentCode);

                    try
                    {
                        SetForegroundWindow(hControl);
                        SendKeys.SendWait(authcode);

                        SetForegroundWindow(hControl);
                        SendKeys.SendWait("~");
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message);
                    }
                }
                //!!!
            }

            // Demonbuddy start delay
            if (Settings.Default.DemonbuddyStartDelay > 0)
            {
                Logger.Instance.Write("Demonbuddy start delay, waiting {0} seconds",
                    Settings.Default.DemonbuddyStartDelay);
                Thread.Sleep((int)Settings.Default.DemonbuddyStartDelay * 1000);
            }
        }