Skip to content
This repository was archived by the owner on Mar 27, 2020. It is now read-only.

Updated CF check : function evals etc #44

Open
Mandrakia opened this issue Mar 21, 2019 · 19 comments
Open

Updated CF check : function evals etc #44

Mandrakia opened this issue Mar 21, 2019 · 19 comments

Comments

@Mandrakia
Copy link

It doesn't work anymore on https://www.japscan.to
The check now includes function evals (btoa/atob) and dom evaluation (getElementById)

@garfield69
Copy link

seeing many Jackett users reporting issue with a whole range of sites today.
Jackett is using CloudFlareUtilities 1.3.0
I'm hoping its similar to what has been raised here, if not, then apologies for hijacking the ticket.
typical stack dump:

2019-03-22 06:01:48.3142 Debug WebClient(HttpWebClient).GetString(Url:https://www2.yggtorrent.gg/engine/search?category=all&name=&description=&file=&uploader=&sub_category=&do=search&order=desc&sort=publish_date) 
2019-03-22 06:01:48.6631 Debug Saving new config file: C:\ProgramData\Jackett\Indexers\yggtorrent.json.3a85506f8e954d8ba40d0e376d28f8b8.tmp 
2019-03-22 06:01:48.6631 Info Executed action Jackett.Server.Controllers.IndexerApiController.Test (JackettConsole) in 352.5767ms 
2019-03-22 06:01:48.6631 Error Jackett.Common.IndexerException: Exception (yggtorrent): Specified argument was out of the range of valid values.
Parameter name: Unknown operator:  ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Unknown operator: 
   at CloudFlareUtilities.ChallengeSolver.ApplyDecodingStep(Double number, Tuple`2 step)
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
   at CloudFlareUtilities.ChallengeSolver.ResolveStepGroup(IEnumerable`1 group)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CloudFlareUtilities.ChallengeSolver.DecodeSecretNumber(String challengePageContent, String targetHost)
   at CloudFlareUtilities.ChallengeSolver.Solve(String challengePageContent, String targetHost)
   at CloudFlareUtilities.ClearanceHandler.<PassClearance>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CloudFlareUtilities.ClearanceHandler.<SendAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Utils.Clients.HttpWebClient.<Run>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Utils.Clients.WebClient.<GetString>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseWebIndexer.<RequestStringWithCookies>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Indexers.CardigannIndexer.<PerformQuery>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseIndexer.<ResultsForQuery>d__69.MoveNext()
   --- End of inner exception stack trace ---
   at Jackett.Common.Indexers.BaseIndexer.<ResultsForQuery>d__69.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseWebIndexer.<ResultsForQuery>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Services.IndexerManagerService.<TestIndexer>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Server.Controllers.IndexerApiController.<Test>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.<Execute>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Server.Middleware.CustomExceptionHandler.<Invoke>d__3.MoveNext() Jackett.Common.IndexerException: Exception (yggtorrent): Specified argument was out of the range of valid values.
Parameter name: Unknown operator:  ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: Unknown operator: 
   at CloudFlareUtilities.ChallengeSolver.ApplyDecodingStep(Double number, Tuple`2 step)
   at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
   at CloudFlareUtilities.ChallengeSolver.ResolveStepGroup(IEnumerable`1 group)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CloudFlareUtilities.ChallengeSolver.DecodeSecretNumber(String challengePageContent, String targetHost)
   at CloudFlareUtilities.ChallengeSolver.Solve(String challengePageContent, String targetHost)
   at CloudFlareUtilities.ClearanceHandler.<PassClearance>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at CloudFlareUtilities.ClearanceHandler.<SendAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Utils.Clients.HttpWebClient.<Run>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Utils.Clients.WebClient.<GetString>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseWebIndexer.<RequestStringWithCookies>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Jackett.Common.Indexers.CardigannIndexer.<PerformQuery>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseIndexer.<ResultsForQuery>d__69.MoveNext()
   --- End of inner exception stack trace ---
   at Jackett.Common.Indexers.BaseIndexer.<ResultsForQuery>d__69.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Indexers.BaseWebIndexer.<ResultsForQuery>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Common.Services.IndexerManagerService.<TestIndexer>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Server.Controllers.IndexerApiController.<Test>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.<Execute>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Jackett.Server.Middleware.CustomExceptionHandler.<Invoke>d__3.MoveNext()
2019-03-22 06:01:48.6881 Debug The response will be compressed with 'gzip'. 

@Mandrakia
Copy link
Author

Cloudflare just rolleback the changes it seems.

@garfield69
Copy link

Hmm. the problem I posted in #44 (comment) about a week ago is back, currently seeing it on https://www.digbt.org/, https://www.spacetorrent.cloud/ and https://wvw.t9.pe/ just to name a few sites.
Same stack trace as previously so I haven't bothered re-posting it.

@RichJohnsone
Copy link

Same thing happening to me on hundreds of sites

@Mandrakia
Copy link
Author

I managed to get the right answer despite the new scripts, but I still can't make it work the Clearance URL is the right one, but I still get not clearance cookie, just a 302 response.

I think there's something wrong with the headers somewhere.

@Zaczero
Copy link

Zaczero commented Mar 30, 2019

@Mandrakia 302 response without clearance cookie is failed challenge. Double check the values.

@garfield69
Copy link

@elcattivo are you available to assist with resolving this issue?

@garfield69
Copy link

@kaso17 we've got about 7 indexers that are impacted by this at the moment.
progress on this ticket seems to have stalled.
I don't suppose you've got the time to take a look and knock up a solution?

@Zaczero
Copy link

Zaczero commented Apr 16, 2019

@garfield69 I managed to fix challenge solving on my library https://github.com/Zaczero/CloudflareSolver which uses a bit different approach (it executes JavaScript instead of parsing it like CFU does). Maybe it can be used as an alternative while we wait for fix from elcattivo.

@Mandrakia
Copy link
Author

I went the same route, I used JINT to execute the javascript. Kept everything the same just modified the solver to use JINT.

@TK34213
Copy link

TK34213 commented May 2, 2019

@Mandrakia do you have a code example?

@Zaczero I copied and pasted your 'getting started' code but it is stuck at cf.Solve() call. how can i debug what is happening? my site has cloudflare challenge, no captcha

@Zaczero
Copy link

Zaczero commented May 2, 2019

@Taein-Kim on the solve() line at the end change .Result to .GetAwaiter().GetResult()

@TK34213
Copy link

TK34213 commented May 2, 2019

@Zaczero I tried that but did not work. why would it change though? GetResult() has to block until the result is returned which would be the same as just calling Result?

@Mandrakia
Copy link
Author

Mandrakia commented May 2, 2019

  private static string DecodeSecretNumber(string challengePageContent, string targetHost)
    {
        var script = Regex.Matches(challengePageContent, ScriptPattern, RegexOptions.Singleline)
            .Cast<Match>().Select(m => m.Groups["Content"].Value)
            .First(c => c.Contains("jschl-answer"));

        var doc = new AngleSharp.Parser.Html.HtmlParser().Parse(challengePageContent);
        string kContent = doc.QuerySelector("div[id^=\"cf-dn\"]").InnerHtml;
        var reg = Regex.Match(script, @"var s,t,o,p,b,r,e,a,k,i,n,g,f, " + "(.+?)=\\{\"(.+?)\"");
        var varA = reg.Groups[1].Value;
        var varB = reg.Groups[2].Value;

        var initValue = Regex.Match(script, varA + "=\\{\"" + varB + "\":(.+?)\\}").Groups[1].Value;
        var st = challengePageContent.Replace(";" + varA + "." + varB, "\r\n" + varA + "." + varB).Replace(";a.value", "\r\na.value");
        var steps = st.Split("\r\n").Where(x => x.StartsWith(varA + "." + varB)).Select(x => x.Replace(varA + "." + varB, "a"));

        var engine = new Engine();
        engine.SetValue("atob",new Func<string,string>( CustomAtob));
        engine.SetValue("t", targetHost);
        engine.SetValue("k", "test");
        engine.Execute("var a=" + initValue + ";");
        engine.Execute("var g = String.fromCharCode;");
        engine.Execute("var  o = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";");
        engine.Execute("var document = {}; document.getElementById = function(elem){ return {innerHTML :'" + kContent + "'};};");
        engine.Execute("var e = function(s) {          s += \"==\".slice(2 - (s.length & 3));     var bm, r = \"\", r1, r2, i = 0;       for (; i < s.length;) { bm = o.indexOf(s.charAt(i++)) << 18 | o.indexOf(s.charAt(i++)) << 12 | (r1 = o.indexOf(s.charAt(i++))) << 6 | (r2 = o.indexOf(s.charAt(i++)));              r += r1 === 64 ? g(bm >> 16 & 255): r2 === 64 ? g(bm >> 16 & 255, bm >> 8 & 255): g(bm >> 16 & 255, bm >> 8 & 255, bm & 255); } return r;};");

        foreach (var step in steps)
        {
            var modStep = step.Replace("(true+\"\")[0]+\".\"+([][\"fill\"]+\"\")[3]+(+(101))[\"to\"+String[\"name\"]](21)[1]+(false+\"\")[1]+(true+\"\")[1]+Function(\"return escape\")()((\"\")[\"italics\"]())[2]+(true+[][\"fill\"])[10]+(undefined+\"\")[2]+(true+\"\")[3]+(+[]+Array)[10]+(true+\"\")[0]", "\"t.charCodeAt\"");
            modStep = modStep.Replace("function(p){var p = eval(eval(atob(\"ZG9jdW1l\")+(undefined+\"\")[1]+(true+\"\")[0]+(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]+(false+[0]+String)[20]+(true+\"\")[3]+(true+\"\")[0]+\"Element\"+(+[]+Boolean)[10]+(NaN+[Infinity])[10]+\"Id(\"+(+(20))[\"to\"+String[\"name\"]](21)+\").\"+atob(\"aW5uZXJIVE1M\"))); return +(p)}()", kContent);
            modStep = modStep.Replace("(true+\"\")[0]+\".ch\"+(false+\"\")[1]+(true+\"\")[1]+Function(\"return escape\")()((\"\")[\"italics\"]())[2]+\"o\"+(undefined+\"\")[2]+(true+\"\")[3]+\"A\"+(true+\"\")[0]", "\"t.charCodeAt\"");
            engine.Execute(modStep);
        }
        var tmpValue = engine.Execute("a.toFixed(10)").GetCompletionValue().AsString();
        return tmpValue;
    }

Not pretty but it does the job.

@Zaczero
Copy link

Zaczero commented May 2, 2019

@Taein-Kim because some apps get stuck on .Result and changing that helps. Does it stuck on default uam.zaczero.pl link or only yours? Please wait up to 30 seconds and you should get a result. If you don't could you send me the URL so I can investigate that

@TK34213
Copy link

TK34213 commented May 2, 2019

@Zaczero here is the exact code

                var cf = new CloudflareSolver();

                var httpClientHandler = new HttpClientHandler()
                { 
                    AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate,
                };
                var httpClient = new HttpClient(httpClientHandler);
                var uri = new Uri("https://uam.zaczero.pl/");
                var result = cf.Solve(httpClient, httpClientHandler, uri).GetAwaiter().GetResult();

Using debugger, i found it is stuck at https://github.com/Zaczero/CloudflareSolver/blob/master/CloudflareSolver/CloudflareSolver.cs#L211 and never gets to line 214

@arsenicks
Copy link

Hey! Do you guy's need anything to help advance on this ? There a bunch of Indexer impacted in Jackett and few of us could probably give you debug info and logs if that's what you want!

Anything ?

@RyuzakiH
Copy link

I tried fixing this library but it wasn't easy, also @Zaczero deleted his repository.
I updated Zaczero's CloudflareSolver (old fork) so it can solve the javascript & captcha challenge.
Also, Integrated the ClearanceHandler of this library adding captcha solving capabilities of CloudflareSolver.
https://github.com/RyuzakiH/CloudflareSolverRe
I hope it helps.

@Zaczero
Copy link

Zaczero commented Jul 19, 2019

@RyuzakiH ^^ gj

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants