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

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

elcattivo/CloudFlareUtilities

Repository files navigation

CloudFlare Utilities

NuGet AppVeyor GitHub license GitHub stars NuGet

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

Contributors 4

  •  
  •  
  •  
  •  

Languages