Giter VIP home page Giter VIP logo

captchasharp's Introduction

CaptchaSharp

A .NET library that implements the APIs of the most used captcha solving services out there. The library is fully documented, asynchronous and very easy to use.

All services derive from the same CaptchaService class and have the same code API, so it's very easy to switch between services!

Supported Services

This library supports the following captcha solving services

Supported Captcha Types

This library supports the following captcha types

  • Text (with language options)
  • Image (with options like phrase, case sensitivity, calculations)
  • ReCaptcha v2 (incl. invisible, enterprise)
  • ReCaptcha v3 (incl. enterprise)
  • ArkoseLabs FunCaptcha
  • HCaptcha (incl. invisible, enterprise)
  • KeyCaptcha
  • GeeTest v3
  • GeeTest v4
  • Capy
  • DataDome
  • Cloudflare Turnstile
  • Cloudflare Challenge page
  • Lemin Cropped
  • Amazon WAF
  • Cyber SiARA
  • MT Captcha
  • CutCaptcha
  • Friendly Captcha
  • atb Captcha
  • Tencent Captcha
  • Audio Captcha (with language options)
  • ReCaptcha Mobile

Additional supported features:

  • Proxies
  • User-Agent
  • Cookies

Availability Table

Availability Table Logo

Not every captcha type is supported by each service! You can find a spreadsheet with a breakdown of the supported captcha types for each implemented service at the link below

CaptchaSharp Services Availability

Adding CaptchaSharp to your project

Simply install the nuget package via

Install-Package CaptchaSharp

Usage

First of all, initialize your solver of choice by providing your credentials, for example

CaptchaService service = new TwoCaptchaService("MY_API_KEY");

You can get your remaining balance like this

decimal balance = await service.GetBalanceAsync();

If the provided credentials are wrong, the method above will return a BadAuthenticationException.

If the credentials are correct and the balance is greater than the minimum required for solving a captcha, you can proceed to solve a captcha (e.g., a ReCaptchaV2 task) like this.

StringResponse solution = await service.SolveRecaptchaV2Async("site key", "site url");

The method above can throw the following exceptions:

  • TaskCreationException when the task could not be created, for example due to zero balance or incorrect parameters.
  • TaskSolutionException when the task could not be completed, for example when an image captcha cannot be decoded.
  • TimeoutException when the captcha solution took too long to complete.

You can configure a custom timeout like this

service.Timeout = TimeSpan.FromMinutes(3);

The returned solution will contain two fields:

  • an Id which you can use for reporting a bad solution (if the service supports it) like this

    await service.ReportSolutionAsync(solution.Id, CaptchaType.ReCaptchaV2);

    if the report failed, the method above will throw a TaskReportException.

  • your solution as plaintext

    Console.WriteLine($"The solution is {solution.Response}");

If a method or some of its parameters are not supported, a NotSupportedException or ArgumentException will be thrown.

Proxy, User-Agent, and Cookies

Some services and captcha types can accept additional parameters, like a proxy, user-agent, or cookies.

var sessionParams = new SessionParams
{
    Proxy = new Proxy(
        host: "proxy.example.com",
        port: 8080,
        type: ProxyType.HTTP,
        username: "proxy_username", // optional
        password: "proxy_password" // optional
    ),
    UserAgent = "Mozilla/5.0 ...", // make sure to use an up-to-date user-agent
    Cookies = new Dictionary<string, string>
    {
        { "cookie_name_1", "cookie_value_1" },
        { "cookie_name_2", "cookie_value_2" }
    }
};

// Solve a captcha with session parameters
StringResponse solution = await service.SolveRecaptchaV2Async(
    "site key", "site url", sessionParams: sessionParams);

Console.WriteLine($"The solution is {solution.Response}");

All session parameters are optional, and you can provide only the ones you need.

The service I want to use is not implemented

If the service you want to use is not implemented, you can easily implement it yourself by deriving from the CaptchaService class and implementing the abstract methods, or you can open an issue, and we will try to implement it as soon as possible.

Unit Tests

Unit tests are included in the CaptchaSharp.Tests project. In order to test, you need to:

  1. Run any test once and let it fail. It will create a file called config.json in your bin/Debug/net8.0 folder.
  2. Add your credentials to the config.json file. You can also add a proxy to test proxied endpoints.
  3. Run the tests (one at a time, to avoid overloading the service and overspending).
  4. If you need to test a captcha on a specific website, you can edit the ServiceTests class and change the parameters as you need.

What needs to be improved

  • Drop Newtonsoft.Json for System.Text.Json
  • Implement better exception handling for specific error codes. For example when there is zero balance or when a solver method returns a bad authentication, they will currently fall in the generic TaskCreationException type.
  • Add support for recognition APIs (right now only token-based APIs are supported).

captchasharp's People

Contributors

dependabot[bot] avatar laiteux avatar londek avatar openbullet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

captchasharp's Issues

nocaptchaai support

Hi,

We currently support hCaptcha image solving and cheapest on the market.
We are testing reCaptcha.

Captcha token are not there yet but we have plans.
Emailed you with apikey.

Thank you
https://nocaptchaai.com

Support for capmonster.cloud

Hey there, I think it would be a good addition if you add capmonster.cloud to the available captcha solving services. Thanks and have a good day!

Incorrect sending format OCR for capmonster

[Executing block Solve Image Captcha] TaskSolutionException: Buffer_cannot_be_null.

Solution is here

POST /in.php HTTP/1.1
Host: MYHOST
User-Agent: IPWorks HTTP Component - www.nsoftware.com
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Content-Length: 9371

key=123456&method=base64&body=<URLENCODEBASEIMG>&regsense=1&min_len=5&max_len=5

Where URLENCODEBASEIMG is url encoded base64 image

Fix XEvil

Add FunCaptcha support (needs recognition integration)

2Captcha GeeTest returns empty "successful" response

Original bug report: openbullet/OpenBullet2#687

Version of the software
0.2.3

Operating system
MacOS 12.2.1

Browser / Native
Chrome Version 100.0.4896.75

What happened?
I am using the 2captcha service to solve this GeeTest slider for fun: https://www.geetest.com/demo/slide-float.html
AFAIK, this is not GeeTest v4 because captcha_id parameter is not there as per guide 2captcha guide here.

I get a solution but it is always empty like this:
image

Relevant LoliCode if needed

BLOCK:CurrentUnixTime
  => VAR @now
ENDBLOCK

BLOCK:HttpRequest
LABEL:Http Request - GeeTest challenge page
  url = $"https://www.geetest.com/demo/gt/register-slide?t=<now>"
  maxNumberOfRedirects = 7
  customHeaders = {}
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Parse
LABEL:Parse GeeTest Script - challenge
  input = @data.SOURCE
  attributeName = ""
  jToken = "challenge"
  multiLine = True
  MODE:Json
  => VAR @challenge
ENDBLOCK

BLOCK:Parse
LABEL:Parse GeeTest Script - gt
  input = @data.SOURCE
  attributeName = ""
  jToken = "gt"
  multiLine = True
  MODE:Json
  => VAR @gt
ENDBLOCK

BLOCK:SolveGeeTestCaptcha
  gt = @gt
  apiChallenge = @challenge
  apiServer = "apiv6.geetest.com"
  siteUrl = "https://www.geetest.com/demo/slide-float.html"
  => VAR @solveGeeTestCaptchaOutput
ENDBLOCK

Add support for .Net 4.8

The newest builds now only supports.Net 8.0. Can the nuget package please dual support Standard and Core?

New 2Captcha Geetest Format

New 2captcha res.php json=1 format for geetest method:

{
   "request" : [
      "e33a0658ba8fc5f7ab627f7dac2d72855y",
      "f85fbf3218d4197f72e534fddf7e79c9",
      "f85fbf3218d4197f72e534fddf7e79c9|jordan"
   ],
   "status" : 1
}

Old format:

{
   "request" : {
      "geetest_challenge" : "e33a0658ba8fc5f7ab627f7dac2d72855y",
      "geetest_validate" : "f85fbf3218d4197f72e534fddf7e79c9",
      "geetest_seccode" : "f85fbf3218d4197f72e534fddf7e79c9|jordan"
   },
   "status" : 1
}

Unexpected character encountered while parsing value: [. Path 'request', line 1, position 23.

Add anchor and reload to CapSolver ReCaptcha v3

As written in PR #30, needs to be rethought:


As per the documentation here: https://www.capsolver.com/blog/reCAPTCHA/How-to-bypass-all-the-versions-reCAPTCHA-v2-v3

Using the properties "Anchor" and "Reload" in the CapSolver Google reCAPTCHA v3 request increases the quality score of the solution. Tested and verified to provide a 2x increase in quality score (estimate)

Set as follows;

var captchaService = new CapSolverService("CAP-xxxxxx", null);
captchaService.Anchor = ....;
captchaService.Reload = ....;

Addition of timestamp

Suggestion
Is it possible to add the timestamp of when the captcha was solved. It would be a really great addition.

Thanks in advance!

Adding AYCD AutoSolver

Can I suggest u to add AYCD AutoSolver support on captcha blocks? it is one of the best solver and it would be useful.
thanks
If u need account
please contact me : [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.