示例#1
0
        public static void VerifyCode(AppiumDevice ap, string code)
        {
            Logger.log("Recived code: " + code);
            var el6 = ap.GetElementByID("com.whatsapp:id/verify_sms_code_input");

            el6.SendKeys(code);
        }
示例#2
0
 private void buttonAppiumContacts_Click(object sender, EventArgs e)
 {
     Invoke(
         new Action(() =>
                    appium = new AppiumDevice(Apps.Contacts, Apps.ContatsActivity_Main, new Device(comboBoxAppium.Text)
                                              )
                    )
         );
     ContactsScenario.ImportContacts(appium);
 }
示例#3
0
        public static void ImportContacts(AppiumDevice ap)
        {
            var el1 = ap.GetElementByID("com.google.android.gsf.login:id/skip_button");

            el1.Click();
            var el2 = ap.GetElementByID("com.android.contacts:id/import_contacts_button");

            el2.Click();
            var el3 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.ListView/android.widget.TextView[2]");

            el3.Click();
        }
示例#4
0
 private async void buttonAppiumRun_Click(object sender, EventArgs e)
 {
     try
     {
         Invoke(new Action(() => appium = new AppiumDevice(Apps.WhatsApp, Apps.WhatsAppActivity_Home, new Device(comboBoxAppium.Text))));
         checkActivity.Enabled          = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#5
0
        public static async Task <bool> Registration(AppiumDevice ap, string phone, string cc)
        {
            Logger.log("Inputing number");
            Random random = new Random();
            var    el1    = ap.GetElementByID("com.whatsapp:id/eula_accept");
            await Task.Delay(random.Next(1000, 2000));

            el1.Click();

            var el2 = ap.GetElementByID("com.whatsapp:id/registration_cc");

            el2.Clear();
            el2.SendKeys(cc);
            await Task.Delay(random.Next(1000, 2000));

            var el3 = ap.GetElementByID("com.whatsapp:id/registration_phone");

            el3.SendKeys(phone);

            var el4 = ap.GetElementByID("com.whatsapp:id/registration_submit");

            el4.Click();
            await Task.Delay(random.Next(1000, 2000));

            int  iterations = 0;
            bool banned     = false;

            while (iterations < 60)
            {
                try
                {
                    var el5     = ap.GetElementByID("android:id/button1");
                    var message = ap.GetElementByID("android:id/message");
                    if (message.Text.Contains("banned"))
                    {
                        banned = true;
                        Logger.log("Number " + phone + " banned");
                        break;
                    }

                    el5.Click();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);
                }
            }
            Logger.log("Waiting for code");
            return(banned);
        }
示例#6
0
        public static void WriteName(AppiumDevice ap, string name)
        {
            Logger.log("Writing name " + name);
            var el1 = ap.GetElementByID("com.whatsapp:id/registration_name");

            el1.SendKeys(name);
            var el2 = ap.GetElementByID("com.whatsapp:id/register_name_accept");

            el2.Click();
            var el3 = ap.GetElementByID("com.whatsapp:id/instruction_badge");

            el3.Click();
        }
示例#7
0
 private void buttonAppiumRun_Click(object sender, EventArgs e)
 {
     try
     {
         appium = new AppiumDevice(
             Apps.WhatsApp,
             Apps.WhatsAppActivity_Home,
             new Device(comboBoxAppium.Text)
             );
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#8
0
        public static void WriteName(AppiumDevice ap, string name)
        {
            var el1 = ap.GetElementByID("com.whatsapp:id/registration_name");

            el1.SendKeys(name);
            var el2 = ap.GetElementByID("com.whatsapp:id/register_name_accept");

            el2.Click();
            var el3 = ap.GetElementByID("com.whatsapp:id/instruction_badge");

            el3.Click();
            var el4 = ap.GetElementByAccessibilityID("New chat");

            el4.Click();
        }
示例#9
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);
        }
示例#10
0
        public static async Task <bool> WriteMessages(DeviceController.DeviceController device)
        {
            AppiumDevice ap = device.AppiumDevice;

            NumberBase.NumberBase numberBase = device.NumberBase;
            Logger.log("NumberBase: " + numberBase.Name);
            try
            {
                foreach (var number in numberBase.PhoneNumbers)
                {
                    int iterations = 0;
                    while (iterations < 20)
                    {
                        try
                        {
                            var el17 = ap.GetElementByAccessibilityID("Search");
                            el17.Click();
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    iterations = 0;
                    while (iterations < 20)
                    {
                        try
                        {
                            var el19 = ap.GetElementByID("com.whatsapp:id/search_src_text");
                            el19.SendKeys(number.Number);
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }

                    iterations = 0;
                    while (iterations < 25)
                    {
                        try
                        {
                            var el20 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]");
                            el20.Click();
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    while (iterations < 20)
                    {
                        try
                        {
                            var el21 = ap.GetElementByID("com.whatsapp:id/entry");
                            el21.SendKeys(numberBase.Message.MessageText);
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    while (iterations < 20)
                    {
                        try
                        {
                            var el22 = ap.GetElementByAccessibilityID("Send");
                            el22.Click();

                            Logger.log("Message sent");
                            break;
                        }
                        catch
                        {
                            iterations++;
                            await Task.Delay(1000);
                        }
                    }
                    ap.Back();
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
示例#11
0
        //Old
        public static async void WriteMessage(AppiumDevice ap, string number, string text)
        {
            Logger.log("New message to: " + number);
            int iterations = 0;

            while (iterations < 20)
            {
                try
                {
                    var el17 = ap.GetElementByAccessibilityID("Search");
                    el17.Click();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            iterations = 0;
            while (iterations < 20)
            {
                try
                {
                    var el19 = ap.GetElementByID("com.whatsapp:id/search_src_text");
                    el19.SendKeys(number);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }

            iterations = 0;
            while (iterations < 25)
            {
                try
                {
                    var el20 = ap.GetElementByXpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout[1]/androidx.viewpager.widget.ViewPager/android.widget.LinearLayout/android.widget.ListView/android.widget.RelativeLayout[1]");
                    el20.Click();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            while (iterations < 20)
            {
                try
                {
                    var el21 = ap.GetElementByID("com.whatsapp:id/entry");
                    el21.SendKeys(text);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            while (iterations < 20)
            {
                try
                {
                    var el22 = ap.GetElementByAccessibilityID("Send");
                    el22.Click();

                    Logger.log("Message sent");
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            ap.Back();
        }
示例#12
0
        public static async Task <bool> Registration(
            DeviceController.DeviceController deviceController,
            string emulatorImageName,
            string proxy,
            AppiumDevice appium,
            AbstractSmsRegistrator smsRegistrator,
            string nickname,
            string port
            )
        {
            bool banned     = false;
            int  iterations = 0;

            string command = "emulator @" + emulatorImageName;

            if (!proxy.IsNullOrEmpty())
            {
                command += " -http-proxy " + proxy;
                System.IO.File.AppendAllText("usedproxy.txt", 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");
                    appium = new AppiumDevice(Apps.Contacts,
                                              Apps.ContatsActivity_Main,
                                              new Device(emulatorImageName),
                                              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(appium);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);
                }
            }

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

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    number = await 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");
                    appium = new AppiumDevice(Apps.WhatsApp,
                                              Apps.WhatsAppActivity_Eula,
                                              new Device(emulatorImageName),
                                              port);
                    banned = await WhatsAppScenario.Registration(appium, number, "7");

                    if (banned)
                    {
                        deviceController.Log("Number is banned");
                        Logger.log("Number is banned");
                        appium.CloseApp();
                        smsRegistrator.SetStatus("7" + number, "10");
                        smsRegistrator.SetStatus("7" + number, "-1");
                        iterations = 0;
                        while (iterations < 60)
                        {
                            try
                            {
                                number = await 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);
                }
            }

            smsRegistrator.PhoneReady("7" + number);

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

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

            smsRegistrator.SetStatus("7" + number, "6");

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    WhatsAppScenario.WriteName(appium, nickname);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);
                }
            }
            deviceController.Log("Registration finished");
            return(banned);
        }
示例#13
0
 private void buttonStopAppium_Click(object sender, EventArgs e)
 {
     automatizationTokenSource.Cancel();
     appium = null;
 }
示例#14
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();
        }