Пример #1
0
        public async Task RunScenario(List <LoginPasswordInput> listEmailAndPassword, string to, string subject, string[] emailText)
        {
            using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless()))
                foreach (var emailAndPassword in listEmailAndPassword)
                {
                    try
                    {
                        var login       = emailAndPassword.Login.Trim().ToLower();
                        var mailAddress = new MailAddress(login);
                        if (mailAddress != null)
                        {
                            if (MailRuDomains.Contains(mailAddress.Host))
                            {
                                using (var page = await browser.NewPageAsync())
                                {
                                    await page.GoToAsync(MailRuRegistration.GetLoginUrl());

                                    var isLoginSuccess = await MailRuRegistration.Login(accountName : login, password : emailAndPassword.Password, page : page);

                                    await MailRuRegistration.SendEmail(to : to, subject : subject, text : emailText, page : page);

                                    Info($"Почта отправлена {mailAddress.Address}");
                                }
                            }
                            if (mailAddress.Host.Equals(ServiceDomains.GetDomain(ServiceCode.Yandex)))
                            {
                                using (var page = await browser.NewPageAsync())
                                {
                                    await page.GoToAsync(YandexRegistration.GetLoginUrl());

                                    var isLoginSuccess = await YandexRegistration.Login(accountName : login, password : emailAndPassword.Password, page : page);

                                    await YandexRegistration.SendEmail(to : to, subject : subject, text : emailText, page : page);

                                    Info($"Почта отправлена {mailAddress.Address}");
                                }
                            }
                            if (mailAddress.Host.Equals(ServiceDomains.GetDomain(ServiceCode.Gmail)))
                            {
                                Info($"gmail {mailAddress.Address} {emailAndPassword.Password}");
                            }
                        }
                    }
                    catch (FormatException)
                    {
                        Error($"Некорректный адрес {emailAndPassword.Login}");
                    }
                }
        }
Пример #2
0
        protected async Task <IAccountData> Registration(IAccountData accountData, SmsServiceCode smsServiceCode, ServiceCode serviceCode, CountryCode countryCode = CountryCode.RU, ILog log = null)
        {
            try
            {
                log?.Debug($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}  via {Enum.GetName(typeof(SmsServiceCode), smsServiceCode)} start... - {DateTime.Now} {Environment.NewLine}");
                if (string.IsNullOrEmpty(accountData.AccountName))
                {
                    accountData.AccountName = Transliteration.CyrillicToLatin($"{accountData.Firstname.ToLower()}.{accountData.Lastname.ToLower()}", Language.Russian);
                    accountData.AccountName = accountData.AccountName.Replace("`", "");
                }
                accountData = StoreAccountData(accountData);
                ISmsService smsService = _smsServices.GetSmsService(smsServiceCode);
                IBot        iBot;
                switch (serviceCode)
                {
                case ServiceCode.MailRu:
                    iBot = new MailRuRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Yandex:
                    iBot = new YandexRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Gmail:
                    iBot = new GmailRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Facebook:
                    iBot = new FacebookRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Vk:
                    iBot = new VkRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Ok:
                    iBot = new OkRegistration(accountData, smsService, _chromiumSettings);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                //var countryCode = CountryCode.RU;
                if (!string.IsNullOrEmpty(accountData.PhoneCountryCode))
                {
                    countryCode = (CountryCode)Enum.Parse(typeof(CountryCode), accountData.PhoneCountryCode);
                }
                accountData = await iBot.Registration(countryCode);

                StoreAccountData(accountData);
            }
            catch (Exception exception)
            {
                log?.Error(exception);
            }
            finally
            {
                log?.Debug($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}  via {Enum.GetName(typeof(SmsServiceCode), smsServiceCode)} finish... - {DateTime.Now} {Environment.NewLine}");
            }
            return(accountData);
        }
Пример #3
0
        public async Task <List <string> > RunScenario(string[] emails)
        {
            var result          = new List <string>();
            var listMailAddress = new Dictionary <string, MailAddress>(emails.Length);

            try
            {
                var dnsLite = new DnsLite();
                // https://developers.google.com/speed/public-dns/
                //http://www.opendns.com/opendns-ip-addresses/
                var dnslist = new List <string>
                {
                    "8.8.8.8",
                    "8.8.4.4",
                    "208.67.222.222",
                    "208.67.220.220"
                };

                var oldStyleList = new ArrayList();
                foreach (var s in dnslist)
                {
                    oldStyleList.Add(s);
                }
                dnsLite.setDnsServers(oldStyleList);

                foreach (var email in emails.Where(x => !string.IsNullOrEmpty(x)).Select(x => x.ToLower()).Distinct().ToArray())
                {
                    MailAddress mailAddress;
                    try
                    {
                        mailAddress = new MailAddress(email);
                    }
                    catch (FormatException)
                    {
                        mailAddress = null;
                    }

                    if (mailAddress != null)
                    {
                        if (EmailValidator.Validate(mailAddress.Address))
                        {
                            var servers = dnsLite.getMXRecords(mailAddress.Host).OfType <MXRecord>().OrderBy(record => record.preference).Select(x => "smtp://" + x.exchange).Distinct().ToList();
                            //var servers = dnsLite.getMXRecords(mailAddress.Host).OfType<MXRecord>().Distinct().ToList();
                            if (servers.Count > 0)
                            {
                                listMailAddress[mailAddress.Address] = mailAddress;
                                result.Add(mailAddress.Address);
                                Info($"{email} - успешная проверка написания");
                            }
                            else
                            {
                                Info($"{email} - ошибка Mx records");
                            }
                        }
                        else
                        {
                            Info($"{email} - ошибка rfc653x");
                        }
                    }
                    else
                    {
                        Info($"{email} - ошибка написания");
                    }
                }

                //проверка попыткой регистрации
                using (var browser = await PuppeteerBrowser.GetBrowser(_chromiumSettings.GetPath(), _chromiumSettings.GetHeadless()))
                    foreach (var item in listMailAddress)
                    {
                        if (MailRuDomains.Contains(item.Value.Host))
                        {
                            using (var page = await browser.NewPageAsync())
                            {
                                await page.GoToAsync(MailRuRegistration.RegistrationUrl);

                                var emailAlreadyRegistered = await MailRuRegistration.EmailAlreadyRegistered(item.Value.User, item.Value.Host, page);

                                if (emailAlreadyRegistered)
                                {
                                    Info($"{item.Value.Address} - успешная проверка регистрацией - адрес существует");
                                }
                                else
                                {
                                    Info($"{item.Value.Address} - ошибка - проверка регистрацией - адрес не существует");
                                    result.Remove(item.Value.Address);
                                }
                            }
                        }
                        if (item.Value.Host.Equals(ServiceDomains.GetDomain(ServiceCode.Yandex)))
                        {
                            using (var page = await browser.NewPageAsync())
                            {
                                await page.GoToAsync(YandexRegistration.RegistrationUrl);

                                var emailAlreadyRegistered = await YandexRegistration.EmailAlreadyRegistered(item.Value.User, page);

                                if (emailAlreadyRegistered)
                                {
                                    Info($"{item.Value.Address} - успешная проверка регистрацией - адрес существует");
                                }
                                else
                                {
                                    Info($"{item.Value.Address} - ошибка - проверка регистрацией - адрес не существует");
                                    result.Remove(item.Value.Address);
                                }
                            }
                        }
                        if (item.Value.Host.Equals(ServiceDomains.GetDomain(ServiceCode.Gmail)))
                        {
                            using (var page = await browser.NewPageAsync())
                            {
                                await page.GoToAsync(GmailRegistration.RegistrationUrl);

                                var emailAlreadyRegistered = await GmailRegistration.EmailAlreadyRegistered(item.Value.User, page, _chromiumSettings.GetPath());

                                if (emailAlreadyRegistered)
                                {
                                    Info($"{item.Value.Address} - успешная проверка регистрацией - адрес существует");
                                }
                                else
                                {
                                    Info($"{item.Value.Address} - ошибка - проверка регистрацией - адрес не существует");
                                    result.Remove(item.Value.Address);
                                }
                            }
                        }
                    }
            }
            catch (Exception exception)
            {
                Error(exception.ToString());
            }
            return(result);
        }
Пример #4
0
        private async Task <IAccountData> Demo(ServiceCode serviceCode, SmsServiceCode?smsServiceCode = null, CountryCode?countryCode = null, bool byPhone = true)
        {
            try
            {
                var useChromiumSettings = cmbBrowserProfile.SelectedIndex == 0;
                var folder = ((BrowserProfileItem)cmbBrowserProfile.SelectedItem).Folder;

                ISmsService smsService = null;
                if (byPhone)
                {
                    if (smsServiceCode == null)
                    {
                        smsService = _smsServices.GetSmsService(((SmsServiceItem)cmbSmsService.SelectedItem).SmsServiceCode);
                    }
                    else
                    {
                        smsService = _smsServices.GetSmsService(smsServiceCode.Value);
                    }
                }
                textBox1.AppendText($@"{Enum.GetName(typeof(ServiceCode), serviceCode)} start... - {DateTime.Now} {Environment.NewLine}");
                IBot iBot        = null;
                var  accountData = CreateAccountDataFromUi();
                if (string.IsNullOrEmpty(accountData.AccountName))
                {
                    accountData.AccountName = Transliteration.CyrillicToLatin($"{accountData.Firstname.ToLower()}.{accountData.Lastname.ToLower()}", Language.Russian);
                    accountData.AccountName = accountData.AccountName.Replace("`", "");
                }
                accountData = StoreAccountData(accountData);
                var chromiumSettings = CompositionRoot.Resolve <IChromiumSettings>();
                chromiumSettings.Proxy = $"{_oneProxyControl.ProxyRecord}";
                switch (serviceCode)
                {
                case ServiceCode.MailRu:
                    iBot = new MailRuRegistration(accountData, smsService, chromiumSettings);
                    //iBot = new MailRuRegistration(accountData, smsService, _browserProfileService);
                    break;

                case ServiceCode.Yandex:
                    iBot = new YandexRegistration(accountData, smsService, chromiumSettings);
                    break;

                case ServiceCode.Gmail:
                    iBot = new GmailRegistration(accountData, smsService, chromiumSettings);
                    break;

                case ServiceCode.Facebook:
                    accountData.Firstname = Transliteration.CyrillicToLatin(accountData.Firstname, Language.Russian);
                    accountData.Firstname = accountData.Firstname.Replace("`", "");
                    accountData.Lastname  = Transliteration.CyrillicToLatin(accountData.Lastname, Language.Russian);
                    accountData.Lastname  = accountData.Lastname.Replace("`", "");
                    iBot = new FacebookRegistration(accountData, smsService, chromiumSettings);
                    break;

                case ServiceCode.Vk:
                    iBot = new VkRegistration(accountData, smsService, chromiumSettings);
                    break;

                case ServiceCode.Ok:
                    iBot = new OkRegistration(accountData, smsService, chromiumSettings);
                    break;

                case ServiceCode.Instagram:
                    iBot = useChromiumSettings ?
                           new InstagramRegistration(accountData, smsService, chromiumSettings) :
                           new InstagramRegistration(accountData, smsService, _browserProfileService, folder);
                    break;

                case ServiceCode.Twitter:
                    iBot = useChromiumSettings ?
                           new TwitterRegistration(accountData, smsService, chromiumSettings) :
                           new TwitterRegistration(accountData, smsService, _browserProfileService, folder);
                    break;
                }
                if (countryCode == null)
                {
                    countryCode = ((CountryItem)cmbCountry.SelectedItem).CountryCode;
                }
                if (iBot != null)
                {
                    textBox1.AppendText($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}... {JsonConvert.SerializeObject(accountData)} {Environment.NewLine}");
                    accountData = await iBot.Registration(countryCode.Value);
                }
                StoreAccountData(accountData);
                textBox1.AppendText($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}... {JsonConvert.SerializeObject(accountData)} {Environment.NewLine}");
                textBox1.AppendText($@"{Enum.GetName(typeof(ServiceCode), serviceCode)} finish... - {DateTime.Now} {Environment.NewLine}");
                return(accountData);
            }
            catch (Exception exception)
            {
                textBox1.AppendText($"{exception}");
            }
            return(null);
        }