示例#1
0
        private async void buttontTest_Click(object sender, EventArgs e)
        {
            Random        r           = new Random();
            List <string> numbers     = new List <string>();
            var           numberBases = ms.GetNumberBases();

            foreach (var numberBase in numberBases.Values)
            {
                numbers = numbers.Concat(numberBase.Numbers).ToList();
            }
            foreach (var number in numbers)
            {
                int iterations = 0;
                while (iterations < 60)
                {
                    try
                    {
                        WhatsAppScenario.WriteMessage(appium, number, richTextBoxMessage.Text);
                        await Task.Delay(r.Next(10000, 20000));

                        break;
                    }
                    catch
                    {
                        iterations++;
                        await Task.Delay(5000);
                    }
                }
            }


            /*Random r = new Random();
             * int count = 0;
             * var startTime = DateTime.Now.ToLocalTime();
             * while (true)
             * {
             *  int number = r.Next(7999999) + 2000000;
             *
             *  string response = await Task.Run(() => ms.sendMessageAsync("3712" + number.ToString(), r.Next().ToString()));
             *
             *  listBoxServerAnswers.Items.Add(response);
             *  if (response.Contains("not equals authenticated."))
             *  {
             *      return;
             *  }
             *  count++;
             *  string timediff = (DateTime.Now.ToLocalTime() - startTime).ToString();
             *  labelServerAnswer.Text = "Server answers: (Count:" + count.ToString() + " Timediff: " + timediff + ")";
             * }*/
        }
示例#2
0
        private async void timerGetCode_Tick(object sender, EventArgs e)
        {
            try
            {
                string code = await smsActivate.GetCode(textBoxCC.Text + textBoxPhone.Text);

                if (code != "STATUS_WAIT_CODE")
                {
                    textBoxCode.Text     = code;
                    timerGetCode.Enabled = false;
                    WhatsAppScenario.VerifyCode(appium, code);
                }
            }catch (Exception ex)
            {
                timerGetCode.Enabled = false;
                MessageBox.Show(ex.Message, "SMS ACTIVATE");
            }
        }
示例#3
0
        public async void CreateDeviceController(
            string deviceName,
            string proxy,
            string smsRegistrator,
            string nickname,
            AppiumDevice device,
            string port,
            NumberBase.NumberBase numberBase
            )
        {
            DeviceController.DeviceController deviceController =
                new DeviceController.DeviceController(
                    deviceName,
                    proxy,
                    smsRegistrator,
                    nickname,
                    null,
                    port,
                    numberBase
                    );
            DeviceControllers.Add(deviceController);

            deviceController.DeviceControllerForm.Show();
            try
            {
                if (await WhatsAppScenario.Registration(deviceController))
                {
                    await WhatsAppScenario.WriteMessages(deviceController);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }



            // Automatization(comboBoxAppium.Text, textBoxProxy.Text);
        }
示例#4
0
        public static async Task <bool> Registration(
            DeviceController.DeviceController deviceController
            )
        {
            bool banned     = false;
            int  iterations = 0;

            string command = "emulator @" + deviceController.DeviceName;

            if (!deviceController.Proxy.IsNullOrEmpty())
            {
                command += " -http-proxy " + deviceController.AppiumDevice;
                System.IO.File.AppendAllText("usedproxy.txt", deviceController.Proxy + "\n");
                System.IO.File.AppendAllText("usedproxy.txt", "\n");
            }
            command += " -wipe-data -no-snapshot-load";
            deviceController.Log("Emulator starting");
            Logger.log("Emulator starting");
            CommandExecutor.ExecuteCommandAsync(command);
            await Task.Delay(5000);

            /*Open contacts*/
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Running Contacts app");
                    Logger.log("Running Contacts app");
                    deviceController.AppiumDevice = new AppiumDevice(Apps.Contacts,
                                                                     Apps.ContatsActivity_Main,
                                                                     new Device(deviceController.DeviceName),
                                                                     deviceController.Port
                                                                     );
                    ContactsScenario.GenerateVCard(deviceController);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            /*Import Contacts*/
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Importing contacts");
                    Logger.log("Importing contacts");
                    ContactsScenario.ImportContacts(deviceController.AppiumDevice);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);
                }
            }

            /*Get number to activate*/
            string number = "";

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    number = await deviceController.SmsRegistrator.GetNumber();

                    deviceController.Log("Recived number: " + number);
                    Logger.log("Recived number: " + number);
                    number = number.Remove(0, 1);
                    break;
                }
                catch
                {
                    iterations++;
                    if (iterations > 10)
                    {
                        throw new Exception("Sms registrator error");
                    }
                    await Task.Delay(2000);
                }
            }

            Random random = new Random();

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Registration started");
                    Logger.log("Registration started");
                    deviceController.AppiumDevice = new AppiumDevice(Apps.WhatsApp,
                                                                     Apps.WhatsAppActivity_Eula,
                                                                     new Device(deviceController.DeviceName),
                                                                     deviceController.Port);
                    banned = await WhatsAppScenario.Registration(deviceController.AppiumDevice, number, "7");

                    if (banned)
                    {
                        deviceController.Log("Number is banned");
                        Logger.log("Number is banned");
                        deviceController.AppiumDevice.CloseApp();
                        deviceController.SmsRegistrator.SetStatus("7" + number, "10");
                        deviceController.SmsRegistrator.SetStatus("7" + number, "-1");
                        iterations = 0;
                        while (iterations < 60)
                        {
                            try
                            {
                                number = await deviceController.SmsRegistrator.GetNumber();

                                deviceController.Log("Waiting for code");
                                Logger.log("Waiting for code");
                                number = number.Remove(0, 1);
                                break;
                            }
                            catch
                            {
                                iterations++;
                                await Task.Delay(5000);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch
                {
                    iterations++;
                    await Task.Delay(2000);
                }
            }

            deviceController.SmsRegistrator.PhoneReady("7" + number);

            iterations = 0;
            while (iterations < 1200)
            {
                try
                {
                    string code = await deviceController.SmsRegistrator.GetCode("7" + number);

                    if (code != "STATUS_WAIT_CODE")
                    {
                        WhatsAppScenario.VerifyCode(deviceController.AppiumDevice, code);
                        break;
                    }
                    else
                    {
                        iterations++;
                        await Task.Delay(1000);
                    }
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }

            deviceController.SmsRegistrator.SetStatus("7" + number, "6");

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    WhatsAppScenario.WriteName(deviceController.AppiumDevice, deviceController.Nickname);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);

                    if (iterations > 55)
                    {
                        return(true);
                    }
                }
            }
            deviceController.Log("Registration finished");
            return(banned);
        }
示例#5
0
 private void buttonVerifyCode_Click(object sender, EventArgs e)
 {
     Task.Run(() => WhatsAppScenario.VerifyCode(appium, textBoxCode.Text));
 }
示例#6
0
 private void buttonRegistration_Click(object sender, EventArgs e)
 {
     Invoke(new Action(() => WhatsAppScenario.Registration(appium, textBoxPhone.Text, textBoxCC.Text)));
 }
示例#7
0
        public async void AutomatizationCancellable(CancellationTokenSource cancellationTokenSource)
        {
            checkActivity.Enabled = true;
            bool banned = false;
            // string command = "cd " + textBoxAppiumSendKeys.Text;
            //CommandExecutor.ExecuteCommandAsync(command);
            int    iterations = 0;
            string command    = "emulator @" + comboBoxAppium.Text;

            if (textBoxProxy.Text != "")
            {
                command += " -http-proxy " + textBoxProxy.Text;
                System.IO.File.AppendAllText("usedproxy.txt", textBoxProxy.Text + "\n");
            }
            command += " -wipe-data -no-snapshot-load";

            CommandExecutor.ExecuteCommandAsync(command);
            await Task.Delay(25000);


            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    appium = new AppiumDevice(Apps.Contacts,
                                              Apps.ContatsActivity_Main,
                                              new Device(comboBoxAppium.Text));
                    SendVCard();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    ContactsScenario.ImportContacts(appium);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }

            await Task.Delay(2000);


            string number = "";

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    number = await smsActivate.GetNumber();

                    number = number.Remove(0, 1);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }
            do
            {
                Random random = new Random();
                iterations = 0;
                while (iterations < 60)
                {
                    try
                    {
                        appium = new AppiumDevice(Apps.WhatsApp,
                                                  Apps.WhatsAppActivity_Eula,
                                                  new Device(comboBoxAppium.Text));
                        // await Task.Delay(random.Next(4000, 6000));
                        banned = await WhatsAppScenario.Registration(appium, number, "7");

                        if (banned)
                        {
                            appium.CloseApp();
                            smsActivate.setStatus("7" + number, "10");
                            smsActivate.setStatus("7" + number, "-1");
                            iterations = 0;
                            while (iterations < 60)
                            {
                                try
                                {
                                    number = await smsActivate.GetNumber();

                                    number = number.Remove(0, 1);
                                    break;
                                }
                                catch
                                {
                                    iterations++;
                                    await Task.Delay(5000);
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        iterations++;
                        await Task.Delay(5000);
                    }
                }
            } while (!banned);


            smsActivate.PhoneReady("7" + number);
            iterations = 0;
            while (iterations < 1200)
            {
                try
                {
                    string code = await smsActivate.GetCode("7" + number);

                    if (code != "STATUS_WAIT_CODE")
                    {
                        WhatsAppScenario.VerifyCode(appium, code);
                    }
                    else
                    {
                        iterations++;
                        await Task.Delay(1000);
                    }
                }
                catch (Exception ex)
                {
                    iterations++;

                    await Task.Delay(1000);
                }
            }

            smsActivate.setStatus("7" + number, "6");

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    WhatsAppScenario.WriteName(appium, textBoxName.Text);
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Settings.Default.PathToDirectory + "/success.wav");
            player.Play();
            // devices.Add(new Device(comboBoxAppium.Text));
            // new DeviceForm(comboBoxAppium.Text, textBoxProxy.Text).Show();
        }