Beispiel #1
0
 public void Start()
 {
     try
     {
         Server.Local = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Server.LocalPort);
         _mainSocket.Bind(Local);
         _mainSocket.Listen(10);
         while (true)
         {
             var source      = _mainSocket.Accept();
             var destination = new Server();
             _targetSocket = destination._mainSocket;
             var state = new State(source, destination._mainSocket);
             destination.Connect(Remote, source);
             source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
         }
     }
     catch (Exception ex)
     {
         if (ex is SocketException && (ex as SocketException).SocketErrorCode == SocketError.AddressAlreadyInUse)
         {
             Server.LocalPort++;
             Server.FiddlerPort++;
             this.Start();
         }
         Bot.Log(ex.ToString());
         Form1.form1.StartLocalProxy();
         Client.lostConnection = true;
     }
 }
Beispiel #2
0
        private void FakeMove_Elapsed(object sender, ElapsedEventArgs e)
        {
            Bot.Log("Fake move called");
            var rand = new Random();

            BotClick(rand.Next(10, 990), rand.Next(0, 300));
        }
Beispiel #3
0
 private void UpdateStats()
 {
     try
     {
         usernamelabel.Text = Account.UserName;
         useridlabel.Text   = Account.ID;
         levellabel.Text    = Account.Level;
         ranklabel.Text     = Account.Rank;
         if (Client.running)
         {
             collectedDiamonds.Text  = Client.collectedDiamonds.ToString();
             collectedGolds.Text     = Client.collectedGolds.ToString();
             collectedElixirs.Text   = Client.collectedElixirs.ToString();
             collectedGlows.Text     = Client.collectedGlows.ToString();
             gaineddiamondlabel.Text = Client.gainedDiamond.ToString();
             gainedgoldlabel.Text    = Client.gainedGold.ToString();
             gainedelixirlabel.Text  = Client.gainedElixir.ToString();
             int num = Convert.ToInt32(new DateTime(DateTime.Now.Subtract(Client.sessionStartTime).Ticks).ToString("d "));
             num--;
             this.runtimeLabel.Text          = num + " days " + new DateTime(DateTime.Now.Subtract(Client.sessionStartTime).Ticks).ToString("HH:mm:ss");
             this.sessionStartTimeLabel.Text = Client.sessionStartTime.ToShortDateString() + " " + Client.sessionStartTime.ToLongTimeString();
         }
     }
     catch (Exception e)
     {
         Bot.Log(e.ToString());
     }
 }
Beispiel #4
0
        private void ExecuteJavaScript()
        {
            if (!browser.IsBrowserInitialized)
            {
                Bot.Log("Browser isn't initialized yet!");
                return;
            }

            Client.collecting = true;
            Client.collecting = false;
        }
Beispiel #5
0
        public void Authenticate()
        {
            Licensing.User user = new Licensing.User();
            user.hWID      = Program.fingerprint;
            user.timeStamp = DateTime.Now;

            try
            {
                var res    = CheckLicense(user).GetAwaiter().GetResult();
                var aTimer = new System.Timers.Timer(6 * 1000); //one hour in milliseconds
                aTimer.Enabled = true;

                if (res.status)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        label2.Text = res.expirationDate.ToString();
                        Bot.Log("License valid until: " + res.expirationDate);
                        DownloadFiles();
                    });
                    aTimer.Elapsed += new ElapsedEventHandler((sender, e) => OnTimedEvent(sender, e, res.expirationDate));
                    aTimer.Start();
                }
                else
                {
                    try
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            buttonStart.Invoke((MethodInvoker)(() =>
                            {
                                buttonStart.Enabled = false;
                            }));
                            Bot.Log(
                                "You don't have a valid license to use the bot! " +
                                "Please contact on the Discord server for more information.");
                        });
                    }
                    catch
                    {
                        Application.Exit();
                    }
                }
            }
            catch (Exception ex)
            {
                buttonStart.Invoke((MethodInvoker)(() =>
                {
                    buttonStart.Enabled = false;
                }));
                ShowErrorAndClose(ex.Message);
            }
        }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            GetUserSettings();
            Assembly assembly = Assembly.GetExecutingAssembly();

            FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            this.Text += $" v{ versionInfo.FileVersion }";

            Bot.Log("Armada Battle bot - ArmadaCollector");
            Bot.Log("Current version: v" + assembly.GetName().Version.ToString(3));
            Bot.Log("HWID: " + Program.fingerprint);
        }
Beispiel #7
0
 private void buttonStop_Click(object sender, EventArgs e)
 {
     if (worker != null)
     {
         if (worker.IsAlive)
         {
             worker.Abort();
         }
     }
     fakeMove.Stop();
     fakeMove.Enabled = false;
     Bot.Log("Bot stopped.");
     Client.running = false;
 }
Beispiel #8
0
 private void ButtonLoginPlayer_Click(object sender, EventArgs e)
 {
     SaveUserSettings();
     try
     {
         loginButton.Enabled = false;
         Client.username     = userTextBox.Text;
         Client.password     = passTextBox.Text;
         browser.ExecuteScriptAsync("var event = new Event('input', { bubbles: true }); \ndocument.getElementsByName('username')[0].value = '" + userTextBox.Text + "'; document.getElementsByName('username')[0].dispatchEvent(event);");
         browser.ExecuteScriptAsync("document.getElementsByName('password')[0].value = '" + passTextBox.Text + "'; document.getElementsByName('password')[0].dispatchEvent(event);");
         Task.Delay(300).Wait();
         browser.ExecuteScriptAsync("document.getElementsByClassName('nk-btn col-md-12 col-xs-12 bg-main-2')[0].click();");
     }
     catch (Exception ex)
     {
         Bot.Log("Can't navigate to webpage: " + ex.ToString());
     }
 }
Beispiel #9
0
        private async Task <RoleValidation> CheckLicense(Licensing.User user)
        {
            try
            {
                using (var httpClient = new HttpClient())
                {
#if DEBUG
                    //httpClient.BaseAddress = new Uri("https://akchan.me/");
                    httpClient.BaseAddress = new Uri("http://localhost:5000/");
#else
                    httpClient.BaseAddress = new Uri("https://akchan.me/");
#endif
                    httpClient.DefaultRequestHeaders.Accept.Clear();
                    httpClient.DefaultRequestHeaders.Accept.Add(
                        new MediaTypeWithQualityHeaderValue("application/json"));


                    //var crypto = new ClsCrypto("lol");
                    //DateTime result;
                    //DateTime.TryParse(crypto.Encrypt(user.timeStamp.ToString()), out result);
                    //user.timeStamp = result;

                    using (var response = httpClient.PostAsJsonAsync("api/checkLicense", user).Result)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            RoleValidation roleValidation = response.Content.ReadAsAsync <RoleValidation>().Result;
                            return(roleValidation);
                        }
                        else
                        {
                            Bot.Log("Can't connect to the license server.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorAndClose(ex.Message);
            }
            return(new RoleValidation());
        }
Beispiel #10
0
        private void Browser_ConsoleMessage(object sender, ConsoleMessageEventArgs e)
        {
            var task = Task.Run(() => {
                var m = Regex.Match(e.Message, @"collected: ([0-9]+).([#a-z]+)", RegexOptions.None);
                if (!m.Success)
                {
                    return;
                }

                var value = m.Groups[1].Value;
                var type  = m.Groups[2].Value;

                switch (type)
                {
                case "golds":
                    Client.gainedGold = Client.collectedGolds += Convert.ToInt32(value);
                    Bot.Log("Collected " + value + " " + type);
                    break;

                case "diamonds":
                    Client.gainedDiamond = Client.collectedDiamonds += Convert.ToInt32(value);
                    Bot.Log("Collected " + value + " " + type);
                    break;

                case "#money":
                    Client.gainedDiamond = Client.collectedDiamonds += Convert.ToInt32(value);
                    Bot.Log("Collected " + value + " " + "diamonds");
                    break;

                case "elixirs":
                    Client.gainedElixir = Client.collectedElixirs += Convert.ToInt32(value);
                    Bot.Log("Collected Elixir");
                    break;

                case "box":
                    Client.collectedGlows += Convert.ToInt32(value);
                    break;
                }
            });

            task.Wait();
        }
Beispiel #11
0
        private async void DownloadFiles()
        {
            try
            {
                using (var httpClient = new HttpClient())
                {
#if DEBUG
                    //httpClient.BaseAddress = new Uri("https://akchan.me/");
                    httpClient.BaseAddress = new Uri("http://localhost:5000/");
#else
                    httpClient.BaseAddress = new Uri("https://akchan.me/");
#endif
                    httpClient.DefaultRequestHeaders.Accept.Clear();
                    httpClient.DefaultRequestHeaders.Accept.Add(
                        new MediaTypeWithQualityHeaderValue("application/json"));

                    using (clientCore = httpClient.GetAsync("source/client_c.bin").Result)
                    {
                        clientCore.EnsureSuccessStatusCode();
                        // Download client_c.bin
                        if (clientCore.IsSuccessStatusCode)
                        {
                            Bot.Log("Downloaded necessary files");
                            Client.scriptCode = await clientCore.Content.ReadAsStringAsync();
                        }
                        else
                        {
                            ShowErrorAndClose("Failed to download necessary files.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorAndClose(ex.Message);
            }
        }
Beispiel #12
0
        private void ButtonStart_Click(object sender, EventArgs e)
        {
            double restartInterval = (double)numericUpDownRestart.Value * 60 * 60 * 3600;

            System.Timers.Timer restartTimer = new System.Timers.Timer(restartInterval);
            if (fakeMove == null)
            {
                fakeMove = new System.Timers.Timer(6 * 1000); //one hour in millisecond
            }
            restartTimer.Elapsed += RestartTimer_Elapsed;

            if (buttonStart.Text == "Start")
            {
                if (!Client.ready)
                {
                    Bot.Log("Please wait until game loads.");
                    return;
                }

                Client.manuelStart = true;
                if (restartInterval > 0)
                {
                    restartTimer.Start();
                }
                BootstrapClient();
            }
            else if (buttonStart.Text == "Stop")
            {
                restartTimer.Stop();
                restartTimer.Close();
                buttonStart.Text = "Start";
                browser.Reload();
                Client.collecting  = false;
                Client.manuelStart = false;
            }
        }
Beispiel #13
0
        private void Browser_JavascriptMessageReceived(object sender, JavascriptMessageReceivedEventArgs e)
        {
            var msg = (string)e.Message;

            Bot.Log(msg);
        }
Beispiel #14
0
 private void saveSettingsButton_Click(object sender, EventArgs e)
 {
     Bot.Log("Saved settings.");
     SaveUserSettings();
 }
Beispiel #15
0
        private async void BootstrapClient()
        {
            string lines = "";

#if DEBUG
            // === Replacement for Logic.js ===
            lines = File.ReadAllText(@"C:\Users\Abdullah\Desktop\ArColWeb\src\public\source\client_c.bin");
#else
            lines = Client.scriptCode;
#endif
            var    decText        = StringCipher.Decrypt(lines, "enjoylowlife");
            int    quantity       = 10000;
            string cannonBallType = "_id.cannonballDivisional";
            string pirateType     = "Juliette";
            metroComboBoxQuantity.Invoke((MethodInvoker)(() =>
            {
                quantity = Convert.ToInt32(metroComboBoxQuantity.Text);
            }));
            metroComboBoxCbType.Invoke((MethodInvoker)(() =>
            {
                cannonBallType = metroComboBoxCbType.Text;
                switch (cannonBallType)
                {
                case "Divisional":
                    cannonBallType = "_id.cannonballDivisional";
                    break;

                case "Hollow":
                    cannonBallType = "_id.cannonballHollow";
                    break;

                case "Stone":
                    cannonBallType = "_id.cannonballStone";
                    break;

                case "Slime":
                    cannonBallType = "_id.cannonballSlime";
                    break;

                default:
                    cannonBallType = "_id.cannonballHollow";
                    break;
                }
            }));
            metroComboBoxEquipPirates.Invoke((MethodInvoker)(() =>
            {
                pirateType = metroComboBoxEquipPirates.Text;
            }));
            await browser.EvaluateScriptAsync("let shootObj=[];" +
                                              "bs = {" +
                                              "   cb:false," +
                                              "   sa:false," +
                                              "   buyCannonball:{}," +
                                              "   equipPirates:{}," +
                                              "   sn:false," +
                                              "   ai:false," +
                                              "   onlyFullHp:" +
                                              "   false," +
                                              "   repLimit:50" +
                                              "}");

            if (collectboxcheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.cb=true;");
            }
            if (shootmonstercheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.sa=true;");
            }
            if (shootnpccheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.sn=true;");
            }
            if (avoidislandcheckbox.Checked)
            {
                await browser.EvaluateScriptAsync("bs.ai=true;");
            }
            if (checkBoxShootBack.Checked)
            {
                await browser.EvaluateScriptAsync("bs.shootBack=true;");
            }
            if (checkBoxEquipSails.Checked)
            {
                await browser.EvaluateScriptAsync("bs.equipSails=true;");
            }
            if (checkboxShootOnlyFullHp.Checked)
            {
                await browser.EvaluateScriptAsync("bs.onlyFullHp=true;");
            }
            if (checkBoxBuyCannonballs.Checked)
            {
                await browser.EvaluateScriptAsync("bs.buyCannonball.active=true;" +
                                                  "bs.buyCannonball.type=" + cannonBallType + ";" +
                                                  "bs.buyCannonball.quantity= " + quantity + ";" +
                                                  "bs.buyCannonball.ifBelow= " + numericUpDownIfBelow.Value + ";");
            }
            if (metroCheckBoxEquipPirates.Checked)
            {
                await browser.EvaluateScriptAsync("bs.equipPirates.active=true;" +
                                                  "bs.equipPirates.type=" + pirateType + ";");
            }
            await browser.EvaluateScriptAsync("bs.repLimit=" + numericUpDown1.Value + ";");

            if (collectboxcheckbox.Checked || shootnpccheckbox.Checked || shootmonstercheckbox.Checked)
            {
                await browser.EvaluateScriptAsync(decText); // change this !!!

                if (listBox1.Items.Count > 0)
                {
                    foreach (var item in listBox1.Items)
                    {
                        await browser.EvaluateScriptAsync("shootObj.push(\"" + item + "\");")
                        .ContinueWith(t =>
                        {
                            if (!t.IsFaulted)
                            {
                                var response = t.Result;
                                Bot.Log(response.Message);
                            }
                        });
                    }
                }

                Client.sessionStartTime = DateTime.Now;
                Client.running          = true;
                buttonStart.Text        = "Stop";
                Bot.Log("Bot started.");
            }
            else
            {
                Bot.Log("Check at least one checkbox to perform tasks!");
            }
            if (fakeMove.Enabled != true)
            {
                fakeMove.Enabled  = true;
                fakeMove.Elapsed += FakeMove_Elapsed;
                fakeMove.Start();
            }
        }
Beispiel #16
0
        private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
        {
            if (e.Frame.IsMain)
            {
                loginButton.Invoke((MethodInvoker)(() =>
                {
                    loginButton.Enabled = true;
                }));

                if (browser.Address.Contains("homepage"))
                {
                    browser.ExecuteScriptAsync("document.getElementsByClassName('col-md-offset-4 playbutton fs-30 hvr-wobble-to-bottom-right')[0].click();");
                    browser.GetSourceAsync().ContinueWith(taskHtml =>
                    {
                        var html         = taskHtml.Result;
                        string pattern   = @"([A-Za-z0-9]+)<\/b>";
                        var m            = Regex.Matches(html, pattern);
                        Account.ID       = m[0].Groups[1].Value;
                        Account.UserName = m[1].Groups[1].Value;
                        Account.Level    = m[2].Groups[1].Value;
                        Account.Rank     = m[3].Groups[1].Value;
                    });
                }
                else if (browser.Address.Contains("play"))
                {
                    Bot.Log("Loading game...");
                    browser.ExecuteScriptAsync("document.getElementsByClassName('btn btn-sm btn-default')[2].click();");
                    browser.GetSourceAsync().ContinueWith(taskHtml =>
                    {
                        var html = taskHtml.Result;
                        if (html.Contains("Multiple entries!") || html.Contains("Birden fazla giriş!"))
                        {
                            Thread.Sleep(3000);
                            BotClick(450, 340);
                        }

                        if (Client.manuelStart)
                        {
                            Task.Delay(5000).ContinueWith(action =>
                            {
                                var script = @"(function () {
                                if (ArmadaBattle && ArmadaBattle.Game && ArmadaBattle.Game.myPlayer)
                                     return true;
                                })();";
                                var result = browser.EvaluateScriptAsync(script).ContinueWith(x =>
                                {
                                    var response = x.Result;
                                    if (response.Success && response.Result != null)
                                    {
                                        if ((dynamic)response.Result == true)
                                        {
                                            Task.Delay(2000).ContinueWith(a =>
                                            {
                                                Bot.Log("Restarting...");
                                                BootstrapClient();
                                            });
                                        }
                                    }
                                });
                            });
                        }
                    });
                    Client.ready = true;
                }
            }
        }