private async Task <SolveResult> SolveChallenge(string html)
        {
            JsChallenge challenge;

            try
            {
                challenge = JsChallenge.Parse(html, SiteUrl);
            }
            catch (Exception)
            {
                // The exception can be caused by Im Under Attack Mode or a new challenge
                // If we throw the exception there are no more retries. In IUAM is better to wait a bit and retry.
                await Task.Delay(ClearanceDelay);

                return(new SolveResult(false, LayerJavaScript, Errors.SomethingWrongHappened, DetectResult));
            }

            var jschlAnswer = challenge.Solve();

            var solution = new JsChallengeSolution(SiteUrl, challenge.Form, jschlAnswer);

            await Task.Delay(ClearanceDelay <= 0?challenge.Delay : ClearanceDelay);

            return(await SubmitJsSolution(solution));
        }
Example #2
0
        private async Task <SolveResult> SubmitJsSolution(JsChallengeSolution solution)
        {
            var request = new HttpRequestMessage(HttpMethod.Get, new Uri(solution.ClearanceUrl));

            request.Headers.Referrer = SiteUrl;

            var response = await HttpClient.SendAsync(request);

            return(GetSolveResult(response));
        }
Example #3
0
        private async Task <SolveResult> SolveChallenge(string html)
        {
            var challenge = JsChallenge.Parse(html, SiteUrl);

            var jschl_answer = challenge.Solve();

            var solution = new JsChallengeSolution(SiteUrl, challenge.Form, jschl_answer);

            await Task.Delay(ClearanceDelay <= 0?challenge.Script.Delay : ClearanceDelay);

            return(await SubmitJsSolution(solution));
        }