示例#1
0
        private void Check(CheckParams checkParams, CancellationToken token)
        {
            if (checkParams == null)
            {
                throw new ArgumentNullException(nameof(checkParams));
            }

            try
            {
                NetHelper nHelper = new NetHelper {
                    UserAgent = UserAgentsManager.GetRandomUserAgent()
                };

                var context = new StateContext(_logger, _proxyManager, _captchaService);
                context.OnCheckCompleted += _context_OnCheckCompleted;
                context.Handle(checkParams, nHelper, token);
                context.OnCheckCompleted -= _context_OnCheckCompleted;
            }
            catch (Exception exception)
            {
                _logger.Debug("error while check");
                _logger.Error(exception);

                _accChecked++;
                _badAccounts++;

                FireOnCheckCompleted(CheckResults.Bad, checkParams);

                _eventAggregator.SendMessage(new InformUserMessage(new InformUserMessage.Message(exception.Message, InformUserMessage.MessageType.Error)));
            }
        }
示例#2
0
        public void FireOnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
        {
            var evt = OnCheckCompleted;

            // ReSharper disable once UseNullPropagation
            if (evt != null)
            {
                evt(context, results, checkParams);
            }
        }
示例#3
0
 private void _context_OnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     if (results != CheckResults.Init)
     {
         Interlocked.Increment(ref _accChecked);
         if (results == CheckResults.Bad)
         {
             Interlocked.Increment(ref _badAccounts);
         }
         else if (results == CheckResults.Good)
         {
             Interlocked.Increment(ref _validAccounts);
         }
     }
     FireOnCheckCompleted(results, checkParams);
 }
示例#4
0
        public override void Handle(NetHelper nHelper)
        {
            var    metadataFinder = new MetadataFinder(Context.CheckParams.Account);
            string metadata       = metadataFinder.Find(_getMetadataTimeout);

            if (Properties.Settings.Default.Mode == 0 || Properties.Settings.Default.Mode == 2)
            {
                var proxy = Context.ProxyManager.GetProxy();

                if (proxy == null)
                {
                    //Context.State = null;
                    //throw new ApplicationException("proxy not found");
                }
                else
                {
                    nHelper.Proxy = proxy;
                }
            }

            var output = nHelper.GET(Globals.LOG_URL);

            if (StateContext.IsError(output))
            {
                Context.ProxyManager.RemoveProxy(nHelper.Proxy);
                return;
            }

            var attributes = StateContext.ParseAccountAttributes(Context.CheckParams.Account, metadata);

            foreach (Match match in _attributesRegex.Matches(output))
            {
                attributes.Add(match.Groups[1].ToString(), match.Groups[2].ToString());
            }

            string response = nHelper.POST(Globals.POST_URL, attributes);

            Context.SetValidationState(response);
        }
示例#5
0
        public override void Handle(NetHelper nHelper)
        {
            var account      = Context.CheckParams.Account;
            var proxyManager = Context.ProxyManager;

            if (StateContext.IsBadLog(_response))
            {
                Context.FireOnCheckCompleted(Context, CheckResults.Bad, Context.CheckParams);
            }
            else if (StateContext.IsSecurityQuestion(_response))
            {
                nHelper.GET("http://amazon.com/homepage=true");
                Context.GatherInformation(nHelper, account);

                Context.FireOnCheckCompleted(Context, CheckResults.Good, Context.CheckParams);
            }
            else if (StateContext.IsCookiesDisabled(_response))
            {
                Context.SetRestartState();
                return;
            }
            else if (StateContext.IsCaptchaMsg(_response))
            {
                if (Properties.Settings.Default.Mode == 0 || Properties.Settings.Default.Mode == 1)
                {
                    string captchaUrl = "https://opfcaptcha-prod.s3.amazonaws.com" +
                                        _response.Split(new[] { "opfcaptcha-prod.s3.amazonaws.com" },
                                                        StringSplitOptions.None)[1].Split('"')[0];
                    byte[] captchaBytes;

                    using (WebClient wc = new WebClient())
                        captchaBytes = wc.DownloadData(captchaUrl);

                    var captchaResult = Context.CaptchaService.DecodeCaptchaAsync(captchaBytes).Result;

                    if (captchaResult != null)
                    {
                        var metadataFinder = new MetadataFinder(account);
                        var metadata       = metadataFinder.Find(_getMetadataTimeout);

                        var attributes = StateContext.ParseAccountAttributes(account, metadata);

                        foreach (Match m in _attributesRegex.Matches(_response))
                        {
                            attributes.Add(m.Groups[1].ToString(), m.Groups[2].ToString());
                        }

                        attributes.Add("guess", captchaResult.Text);

                        var response = nHelper.POST(Globals.POST_URL, attributes);
                        Init(response);

                        // limit captcha attemts
                        if (_captchaCounter >= 5)
                        {
                            Context.SetFinishState();
                            return;
                        }

                        _captchaCounter++;

                        return;
                    }
                    //todo: captcha not recognized, so need to request new one
                }
                else
                {
                    proxyManager.RemoveProxy(nHelper.Proxy);
                    Context.SetRestartState();
                    return;
                }
            }
            else if (StateContext.IsAskCredentials(_response))
            {
                Context.SetRestartState();
            }
            else if (StateContext.IsAnotherDevice(_response))
            {
                Context.FireOnCheckCompleted(Context, CheckResults.Good, Context.CheckParams);
            }
            else if (StateContext.IsError(_response))
            {
                proxyManager.RemoveProxy(nHelper.Proxy);
                Context.SetRestartState();
                return;
            }
            else
            {
                Context.GatherInformation(nHelper, account);

                Context.FireOnCheckCompleted(Context, CheckResults.Good, Context.CheckParams);
            }

            Context.SetFinishState();
        }
示例#6
0
 public ValidationState(StateContext context) : base(context)
 {
 }
 public ValidationState(StateContext context) : base(context)
 {
 }
示例#8
0
 private void _context_OnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     if (results != CheckResults.Init)
     {
         Interlocked.Increment(ref _accChecked);
         if (results == CheckResults.Bad)
         {
             Interlocked.Increment(ref _badAccounts);
         }
         else if (results == CheckResults.Good)
         {
             Interlocked.Increment(ref _validAccounts);
         }
     }
     FireOnCheckCompleted(results, checkParams);
 }
示例#9
0
        private void Check(CheckParams checkParams, CancellationToken token)
        {
            if (checkParams == null)
                throw new ArgumentNullException(nameof(checkParams));

            try
            {
                NetHelper nHelper = new NetHelper { UserAgent = UserAgentsManager.GetRandomUserAgent() };

                var context = new StateContext(_logger, _proxyManager, _captchaService);
                context.OnCheckCompleted += _context_OnCheckCompleted;
                context.Handle(checkParams, nHelper, token);
                context.OnCheckCompleted -= _context_OnCheckCompleted;
            }
            catch (Exception exception)
            {
                _logger.Debug("error while check");
                _logger.Error(exception);

                _accChecked++;
                _badAccounts++;

                FireOnCheckCompleted(CheckResults.Bad, checkParams);

                _eventAggregator.SendMessage(new InformUserMessage(new InformUserMessage.Message(exception.Message, InformUserMessage.MessageType.Error)));
            }
        }
示例#10
0
 public void FireOnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     var evt = OnCheckCompleted;
     // ReSharper disable once UseNullPropagation
     if (evt != null)
     {
         evt(context, results, checkParams);
     }
 }
示例#11
0
 public RestartState(StateContext context) : base(context)
 {
 }
示例#12
0
 public RestartState(StateContext context) : base(context)
 {
 }