Example #1
0
        private void ButtonXlsReg_OnClick(object sender, RoutedEventArgs e)
        {
            ButtonIsEnable(false);
            var sfd = new OpenFileDialog
            {
                Filter           = "Excel 2016 (*.xlsx)|*.xlsx",
                InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
                RestoreDirectory = true
            };

            if (sfd.ShowDialog() == false)
            {
                ButtonIsEnable(true);
                return;
            }

            Task.Run(async() =>
            {
                try
                {
                    Utils.PersonsList = await XlsxRegistration.ParsePersonsList(sfd.FileName);
                    RegCount          = Utils.PersonsList.Count.ToString();
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex.Message);
                }
            }).Wait();
            ButtonIsEnable(true);
        }
Example #2
0
        private static void LoadBrowsers(double browsersNum)
        {
            var count = Utils.DriverList.Count;

            for (var i = count; i < browsersNum + count; i++)
            {
                try
                {
                    var options = new ChromeOptions();
                    if (File.Exists("extension.crx"))
                    {
                        options.AddExtension(Path.GetFullPath("extension.crx"));
                    }
                    else
                    {
                        options.AddArgument("-incognito");
                    }

                    var driver       = new ChromeDriver(options);
                    var driverStruct = new DriverStruct
                    {
                        Driver    = driver,
                        Num       = i,
                        IsEnabled = true
                    };
                    Utils.DriverList.Add(driverStruct);
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex);
                }
            }
        }
Example #3
0
        public static async Task SaveInXls(IList <PersonStruct> collection, string fileName)
        {
            await Task.Run(() =>
            {
                try
                {
                    if (!collection.Any())
                    {
                        return;
                    }

                    var xssf  = new XSSFWorkbook();
                    var sheet = xssf.CreateSheet();

                    AddRowsToXls(collection.Where(x => x != null), ref sheet);

                    using (var file = new FileStream(fileName, FileMode.Create))
                    {
                        xssf.Write(file);
                    }
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex.Message);
                }
                Informer.RaiseOnResultReceived($"{fileName} successfully saved");
            });
        }
Example #4
0
        internal static async Task <List <HttpRequest> > GetRequestList(IEnumerable <string> proxies)
        {
            var list = new List <HttpRequest>();

            try
            {
                foreach (var x in proxies.Distinct().Where(x => !string.IsNullOrEmpty(x)))
                {
                    try
                    {
                        var str = new ProxyStruct();
                        var arr = x.Split('@');
                        str.Host  = arr[1];
                        str.Login = arr[0];

                        switch (arr[2].ToLower())
                        {
                        case "http":
                        case "https":
                            str.Type = ProxyType.Http;
                            break;

                        case "socks4":
                            str.Type = ProxyType.Socks4;
                            break;

                        case "socks4a":
                            str.Type = ProxyType.Socks4a;
                            break;

                        case "socks5":
                            str.Type = ProxyType.Socks5;
                            break;

                        default:
                            str.Type = ProxyType.Http;
                            break;
                        }

                        list.Add(await RequestHelper.GetRequestTaskAsync(str));
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Informer.RaiseOnResultReceived(ex);
            }

            if (list.Count == 0)
            {
                list.Add(RequestHelper.GetRequest);
            }

            return(list);
        }
Example #5
0
        public static async Task <List <PersonStruct> > ParsePersonsList(string workBookPath)
        {
            return(await Task.Run(() =>
            {
                var list = new List <PersonStruct>();
                try
                {
                    var fileFullPath = Path.GetFullPath(workBookPath);

                    XSSFWorkbook xssfwb;
                    using (var file = new FileStream(fileFullPath, FileMode.Open, FileAccess.Read))
                        xssfwb = new XSSFWorkbook(file);

                    var sheet = xssfwb.GetSheet(xssfwb.GetSheetName(0));

                    for (var num = 1; num <= sheet.LastRowNum; num++)
                    {
                        try
                        {
                            var row = sheet.GetRow(num);
                            if (row == null) //null is when the row only contains empty cells
                            {
                                continue;
                            }

                            var proxy = new ProxyStruct
                            {
                                Host = row.GetCell(4).StringCellValue,
                                Login = row.GetCell(5).StringCellValue,
                                Type = (ProxyType)Enum.Parse(typeof(ProxyType), row.GetCell(6).StringCellValue)
                            };

                            var person = new PersonStruct
                            {
                                FirstName = row.GetCell(2).StringCellValue,
                                LastName = row.GetCell(3).StringCellValue,
                                Mail = row.GetCell(0).StringCellValue,
                                Pass = row.GetCell(1).StringCellValue,
                                Proxy = proxy
                            };
                            list.Add(person);
                        }
                        catch (Exception ex)
                        {
                            Informer.RaiseOnResultReceived(ex.Message);
                            Informer.RaiseOnResultReceived($"Is error in {num + 1} row");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex.Message);
                }
                return list;
            }));
        }
Example #6
0
        internal static async Task <HttpRequest> GetRequestTaskAsync(ProxyStruct str)
        {
            var req = GetRequest;

            return(await Task.Run(() =>
            {
                try
                {
                    var host = str.Host;
                    var login = str.Login;
                    var type = str.Type;

                    if (string.IsNullOrEmpty(host) || !host.Contains(":"))
                    {
                        return req;
                    }

                    var arr = host.Split(':');
                    switch (type)
                    {
                    case ProxyType.Http:
                        req.Proxy = new HttpProxyClient(arr[0], int.Parse(arr[1]));
                        break;

                    case ProxyType.Socks4:
                        req.Proxy = new Socks4ProxyClient(arr[0], int.Parse(arr[1]));
                        break;

                    case ProxyType.Socks4a:
                        req.Proxy = new Socks4aProxyClient(arr[0], int.Parse(arr[1]));
                        break;

                    case ProxyType.Socks5:
                        req.Proxy = new Socks5ProxyClient(arr[0], int.Parse(arr[1]));
                        break;

                    default:
                        req.Proxy = new HttpProxyClient(arr[0], int.Parse(arr[1]));
                        break;
                    }

                    if (!string.IsNullOrEmpty(login) && login.Contains(":"))
                    {
                        var arrr = login.Split(':');
                        req.Proxy.Username = arrr[0];
                        req.Proxy.Password = arrr[1];
                    }
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex);
                }
                return req;
            }));
        }
Example #7
0
        private async void ButtonConfStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (Utils.PersonsList.Count < 1)
            {
                return;
            }

            ButtonIsEnable(false);
            Utils.IsPermit   = true;
            Utils.ResultPers = new List <PersonStruct>();

            var list = Utils.PersonsList;

            await Task.Run(async() =>
            {
                while (list.Count > 0 && Utils.IsPermit)
                {
                    var current = list[0];
                    Utils.PersonsList.Remove(list[0]);

                    try
                    {
                        var result = await MailConfirm.AcceptConfirm(current.Mail, current.Pass);
                        if (result)
                        {
                            Informer.RaiseOnResultReceived($"{list[0].Mail} successfully confirmed");
                            current.Result = "confirmed";
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        Informer.RaiseOnResultReceived($"{list[0].Mail} is not confirmed");
                        current.Result = "fail confirm";
                    }

                    Utils.ResultPers.Add(current);
                }

                await XlsxSave.SaveInXls(Utils.ResultPers, "ResultConf.xlsx");
                await XlsxSave.SaveInXls(list, "RestConf.xlsx");
                Utils.DisposeWebDrivers();
            });

            ButtonIsEnable(true);
        }
Example #8
0
        private async void ButtonStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (!Codes.Any())
            {
                Informer.RaiseOnResultReceived("No codes found");
                return;
            }

            ButtonIsEnabled(false);
            Utils.IsPermit = true;
            if (Utils.DriverList.Count > Settings.Default.CaptchaNum)
            {
                var num = Utils.DriverList.Count - Settings.Default.CaptchaNum;
                DeleteBrowsers(num);
            }
            else
            {
                var num = Settings.Default.CaptchaNum - Utils.DriverList.Count;
                LoadBrowsers(num);
            }
            CaptchaTimer.Elapsed += CaptchaTimer_Elapsed;
            Utils.CancelToken     = new CancellationTokenSource();
            CaptchaTimer.Start();

            await Task.Run(async() =>
            {
                try
                {
                    await MainCycle.InitializTask(Codes, Proxies, Settings.Default.CaptchaNum);
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex);
                }
            });

            ButtonStop_OnClick(ButtonStop, null);
            ButtonIsEnabled(true);
        }
Example #9
0
        private void ButtonAddCodes_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var button = sender as Button;
                if (button == null)
                {
                    return;
                }

                var ofd = new OpenFileDialog
                {
                    Multiselect      = false,
                    CheckFileExists  = true,
                    CheckPathExists  = true,
                    Filter           = "Text File (TXT)|*.TXT",
                    InitialDirectory = Environment.CurrentDirectory
                };

                if (ofd.ShowDialog() != true)
                {
                    return;
                }

                if (Equals(button, ButtonCodes))
                {
                    Codes = File.ReadAllLines(ofd.FileName);
                }
                else
                {
                    Proxies = File.ReadAllLines(ofd.FileName);
                }
            }
            catch (Exception ex)
            {
                Informer.RaiseOnResultReceived(ex);
            }
        }
Example #10
0
        private async void ButtonRegStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (Utils.PersonsList.Count < 1)
            {
                return;
            }

            ButtonIsEnable(false);
            Utils.CaptchaLife     = 120;
            Utils.MaxCaptchaQueue = 10;
            Utils.IsPermit        = true;
            Utils.AntigateService = "rucaptcha.com";
            CaptchaTimer.Elapsed += RaiseOnTimerElapsed;
            CaptchaTimer.Start();
            Utils.ResultPers = new List <PersonStruct>();

            var list = Utils.PersonsList;

            await Task.Run(async() =>
            {
                while (list.Count > 0 && Utils.IsPermit)
                {
                    var current = new PersonStruct();
                    try
                    {
                        while (Utils.CaptchaQueueCount < 1 && Utils.IsPermit)
                        {
                            await Task.Delay(1000);
                        }

                        if (!Utils.IsPermit)
                        {
                            break;
                        }

                        current = list[0];
                        Utils.PersonsList.Remove(current);

                        var result = await MainCycle.GetResult(list[0], Utils.CaptchaQueue);

                        if (result == "Compleate")
                        {
                            Informer.RaiseOnResultReceived($"Account for {list[0].Mail} successfully registered");
                            current.Result = "registered but not confirmed";
                        }
                        else
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is already"))
                        {
                            current.Result = "confirmed";
                        }
                        else if (ex.Message.Contains("Не удалось соединиться с HTTP-сервером"))
                        {
                            current.Result = "proxy fail";
                        }
                        else
                        {
                            current.Result = "fail register";
                        }
                        Informer.RaiseOnResultReceived(ex.Message.Contains("Не удалось соединиться с HTTP-сервером")
                            ? $"Bad proxy {current.Proxy.Host} for {current.Mail}"
                            : $"{ex.Message} for {current.Mail}");
                    }
                    Utils.ResultPers.Add(current);
                }

                //CaptchaTimer.Stop();
                //CaptchaTimer.Elapsed -= RaiseOnTimerElapsed;

                await XlsxSave.SaveInXls(Utils.ResultPers, "ResultReg.xlsx");
                await XlsxSave.SaveInXls(list, "RestReg.xlsx");

                Utils.DisposeWebDrivers();
            });

            ButtonIsEnable(true);
        }
Example #11
0
        public static async Task InitializTask(IEnumerable <string> codes, IEnumerable <string> proxies, int dop)
        {
            try
            {
                var reqList = await ProxyHelper.GetRequestList(proxies);

                await codes.Distinct().ForEachAsync(dop, async code =>
                {
                    string result;
                    while (true)
                    {
                        try
                        {
                            HttpRequest req;
                            var challenge = string.Empty;
                            lock (Locker)
                            {
                                req = reqList[0];
                                reqList.Move(req);

                                while (Utils.IsPermit)
                                {
                                    if (Utils.CaptchaQueueCount > 0)
                                    {
                                        challenge = Utils.CaptchaQueue.Challenge;
                                        break;
                                    }
                                    Task.Delay(500).Wait();
                                }
                            }

                            if (!Utils.IsPermit)
                            {
                                return;
                            }

                            result = await MainRequest.Get(code, req, challenge);

                            if (result.StartsWith("403"))
                            {
                                result = "403";
                                //continue;
                            }
                            else
                            {
                                dynamic json = JObject.Parse(result);
                                result       = json.products[0]["title"].ToString();
                            }
                        }
                        catch (Exception)
                        {
                            result = "Invalid";
                        }
                        break;
                    }

                    var res = new MenuStruct {
                        Code = code, Result = result
                    };
                    Informer.RaiseStrReceived(res);
                    Utils.ResultAll.Add(res);
                    switch (result)
                    {
                    case "403":
                        Utils.Result403.Add(res);
                        break;

                    case "Invalid":
                        Utils.ResultFalse.Add(res);
                        break;

                    default:
                        Utils.ResultTrue.Add(res);
                        break;
                    }

                    Utils.SetIncrement();
                });
            }
            catch (Exception ex)
            {
                Informer.RaiseOnResultReceived(ex);
            }
        }