Skip to content

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.

License

Notifications You must be signed in to change notification settings

twix20/CloudFlareUtilities

 
 

Repository files navigation

CloudFlare Utilities

NuGet Pre Release AppVeyor Codecov GitHub license

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.

Contributors

Features

  • No dependencies (e.g. no external JavaScript interpreter required)
  • Easily integrated into your project (implemented as DelegatingHandler; e.g. can be used with HttpClient)
  • Usable on many different platforms (NET Standard 1.1)

Usage

try
{
    // Create the clearance handler.
    var handler = new ClearanceHandler
    {
        MaxRetries = 2 // Optionally specify the number of retries, if clearance fails (default is 3).
    };

    // Create a HttpClient that uses the handler to bypass CloudFlare's JavaScript challange.
    var client = new HttpClient(handler);

    // Use the HttpClient as usual. Any JS challenge will be solved automatically for you.
    var content = await client.GetStringAsync("http://protected-site.tld/");
}
catch (AggregateException ex) when (ex.InnerException is CloudFlareClearanceException)
{
    // After all retries, clearance still failed.
}
catch (AggregateException ex) when (ex.InnerException is TaskCanceledException)
{
    // Looks like we ran into a timeout. Too many clearance attempts?
    // Maybe you should increase client.Timeout as each attempt will take about five seconds.
}

About

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%