示例#1
0
        public static async void GenerateVCard(DeviceController.DeviceController device)
        {
            var    phoneNumbers = device.DB.PhoneNumbers.Where(p => p.NumberBaseId == device.NumberBase.Id).ToList();
            var    pathToExe    = System.Reflection.Assembly.GetEntryAssembly().Location.Split('\\');
            string path         = string.Join("\\", pathToExe.Take(pathToExe.Count() - 1).ToArray());
            string filename     = path + "\\" + device.NumberBase.Name + ".vcf";
            string vcf          = "";

            foreach (var phoneNumber in phoneNumbers)
            {
                vcf += "BEGIN:VCARD\nVERSION:2.1\nN:;+" + phoneNumber.Number + ";;;\nFN:+" + phoneNumber.Number + "\nTEL;CELL:+" + phoneNumber.Number + "\nEND:VCARD\n";
            }

            if (!File.Exists(filename))
            {
                File.Create(filename);
            }

            System.IO.File.WriteAllText(filename, vcf);
            string command = "cd " + Properties.Settings.Default.PathToSDK + "\\platform-tools";

            CommandExecutor.ExecuteCommandAsync(command);
            command = " push " + filename + " /sdcard";
            CommandExecutor.AdbExecutor(command);
            device.AppiumDevice.driver.PushFile("/sdcard", new FileInfo(device.NumberBase.Name + ".vcf"));
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }