Skip to content

Commit

Permalink
Added reCaptchaV3, Added hCaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed Apr 15, 2020
1 parent 22f52a6 commit 323f2b3
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 39 deletions.
77 changes: 62 additions & 15 deletions AntiCaptcha.Sandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,75 @@ static void Main(string[] args)

static async Task Foo()
{
var captcha = new AntiCaptcha(" ## YOUR API KEY ## ");
// .. additionally you can pass your own httpClient class
var captchaWithHttpClient = new AntiCaptcha(" ## YOUR API KEY ## ", new HttpClient());
/*
* Class initialization
* Optionally you can pass 2nd parameter `httpClient` with custom HttpClient to use while requesting API
*/
var captcha = new AntiCaptcha("API_KEY");
var captchaCustomHttp = new AntiCaptcha("API_KEY", new HttpClient());

// Get current balance
/*
* Get current balance
*/
var balance = await captcha.GetBalance();

// Solve image captcha
var image = await captcha.SolveImage("iVBORw0KGgo...");
/*
* Type: Image
*
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/image
*/
var image = await captcha.SolveImage("BASE64_IMAGE");

// Solve ReCaptchaV2
var recaptcha = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com");
var recaptchaInvisible = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true);
/*
* Type: ReCaptcha V2
* Optionally you can pass 3rd parameter `isInvisible` to indicate if the reCaptcha is setup as invisible
*
* Homepage: https://www.google.com/recaptcha/
* Documentation (vendor): https://developers.google.com/recaptcha/docs/display
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha
*/
var reCaptcha = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL");
var reCaptchaInvisible = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", true);

/*
* Type: ReCaptcha V3
* If you get ERROR_INCORRECT_SESSION_DATA error you may need to increase minScore value
*
* Homepage: https://www.google.com/recaptcha/
* Documentation (vendor): https://developers.google.com/recaptcha/docs/v3
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha
*/
var reCaptchaV3 = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", 0.9, "SOME_ACTION");

/*
* Type: hCaptcha
*
* Homepage: https://www.hcaptcha.com/
* Documentation (vendor): https://docs.hcaptcha.com/
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/hcaptcha
*/
var hCaptcha = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL");

// Solve FunCaptcha
var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");
/*
* Type: GeeTest
*
* Homepage: https://www.geetest.com/en
* Documentation (vendor): https://docs.geetest.com/en
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/geetest
*/
var geeTest = await captcha.SolveGeeTest("SITE_KEY", "https://WEBSITE_URL", "CHALLENGE");

// Solve SquareNet
var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);
/*
* Type: FunCaptcha
*
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/funcaptcha
*/
var funCaptcha = await captcha.SolveFunCaptcha("SITE_KEY", "https://WEBSITE_URL");

// Solve GeeTest
var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");
/*
* Type: SquareNet
*/
var squareNet = await captcha.SolveSquareNet("BASE64_IMAGE", "OBJECT_NAME", 3, 3);

Debugger.Break();
}
Expand Down
40 changes: 40 additions & 0 deletions AntiCaptcha/AntiCaptcha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,46 @@ public async Task<AntiCaptchaResult> SolveReCaptchaV2(string googleSiteKey, stri
return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString());
}

public async Task<AntiCaptchaResult> SolveReCaptchaV3(string googleSiteKey, string pageUrl, double minScore, string pageAction, CancellationToken cancellationToken = default)
{
var result = await Solve(5, new Dictionary<string, object>
{
{"task", new Dictionary<string, object>
{
{"type", "RecaptchaV3TaskProxyless"},
{"websiteURL", pageUrl},
{"websiteKey", googleSiteKey},
{"minScore", minScore},
{"pageAction", pageAction},
}
}
}, cancellationToken).ConfigureAwait(false);

if (!result.Success)
return new AntiCaptchaResult(false, result.Response);

return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString());
}

public async Task<AntiCaptchaResult> SolveHCaptcha(string siteKey, string pageUrl, CancellationToken cancellationToken = default)
{
var result = await Solve(10, new Dictionary<string, object>
{
{"task", new Dictionary<string, object>
{
{"type", "HCaptchaTaskProxyless"},
{"websiteURL", pageUrl},
{"websiteKey", siteKey},
}
}
}, cancellationToken).ConfigureAwait(false);

if (!result.Success)
return new AntiCaptchaResult(false, result.Response);

return new AntiCaptchaResult(true, result.Dictionary["gRecaptchaResponse"].ToString());
}

public async Task<AntiCaptchaResult> SolveFunCaptcha(string funCaptchaPublicKey, string pageUrl, CancellationToken cancellationToken = default)
{
var result = await Solve(10, new Dictionary<string, object>
Expand Down
8 changes: 4 additions & 4 deletions AntiCaptcha/AntiCaptcha.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<PackageLicenseUrl></PackageLicenseUrl>
<PackageProjectUrl>https://github.com/Zaczero/AntiCaptcha</PackageProjectUrl>
<PackageIconUrl></PackageIconUrl>
<Version>1.2</Version>
<PackageTags>anticaptcha, captcha, solver, recaptcha, google, text, image, wrapper, api</PackageTags>
<Version>1.3</Version>
<PackageTags>anticaptcha, captcha, solver, google, recaptcha, hcaptcha, geetest, text, image, wrapper, api</PackageTags>
<PackageId>AntiCaptchaAPI</PackageId>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/Zaczero/AntiCaptcha</RepositoryUrl>
<PackageIcon>AntiCaptcha.png</PackageIcon>
Expand Down
87 changes: 67 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,75 @@ An online captcha solving and image recognition service.
### Sample code

```cs
var captcha = new AntiCaptcha(" ## YOUR API KEY ## ");
// .. additionally you can pass your own httpClient class
var captchaWithHttpClient = new AntiCaptcha(" ## YOUR API KEY ## ", new HttpClient());

// Get current balance
/*
* Class initialization
* Optionally you can pass 2nd parameter `httpClient` with custom HttpClient to use while requesting API
*/
var captcha = new AntiCaptcha("API_KEY");
var captchaCustomHttp = new AntiCaptcha("API_KEY", new HttpClient());

/*
* Get current balance
*/
var balance = await captcha.GetBalance();

// Solve image captcha
var image = await captcha.SolveImage("iVBORw0KGgo...");

// Solve ReCaptchaV2
var recaptcha = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com");
var recaptchaInvisible = await captcha.SolveReCaptchaV2("GOOGLE_SITE_KEY", "https://example.com", true);

// Solve FunCaptcha
var fun = await captcha.SolveFunCaptcha("FUN_CAPTCHA_PUBLIC_KEY", "https://example.com");

// Solve SquareNet
var square = await captcha.SolveSquareNet("iVBORw0KGgo...", "banana", 3, 3);

// Solve GeeTest
var gee = await captcha.SolveGeeTest("GEE_TEST_KEY", "https://example.com", "CHALLENGE");
/*
* Type: Image
*
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/image
*/
var image = await captcha.SolveImage("BASE64_IMAGE");

/*
* Type: ReCaptcha V2
* Optionally you can pass 3rd parameter `isInvisible` to indicate if the reCaptcha is setup as invisible
*
* Homepage: https://www.google.com/recaptcha/
* Documentation (vendor): https://developers.google.com/recaptcha/docs/display
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha
*/
var reCaptcha = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL");
var reCaptchaInvisible = await captcha.SolveReCaptchaV2("SITE_KEY", "https://WEBSITE_URL", true);

/*
* Type: ReCaptcha V3
* If you get ERROR_INCORRECT_SESSION_DATA error you may need to increase minScore value
*
* Homepage: https://www.google.com/recaptcha/
* Documentation (vendor): https://developers.google.com/recaptcha/docs/v3
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/recaptcha
*/
var reCaptchaV3 = await captcha.SolveReCaptchaV3("SITE_KEY", "https://WEBSITE_URL", 0.9, "SOME_ACTION");

/*
* Type: hCaptcha
*
* Homepage: https://www.hcaptcha.com/
* Documentation (vendor): https://docs.hcaptcha.com/
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/hcaptcha
*/
var hCaptcha = await captcha.SolveHCaptcha("SITE_KEY", "https://WEBSITE_URL");

/*
* Type: GeeTest
*
* Homepage: https://www.geetest.com/en
* Documentation (vendor): https://docs.geetest.com/en
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/geetest
*/
var geeTest = await captcha.SolveGeeTest("SITE_KEY", "https://WEBSITE_URL", "CHALLENGE");

/*
* Type: FunCaptcha
*
* Documentation (anti-captcha): https://anti-captcha.com/apidoc/funcaptcha
*/
var funCaptcha = await captcha.SolveFunCaptcha("SITE_KEY", "https://WEBSITE_URL");

/*
* Type: SquareNet
*/
var squareNet = await captcha.SolveSquareNet("BASE64_IMAGE", "OBJECT_NAME", 3, 3);
```

### And here is the result structure *(the same for all methods)*
Expand Down

0 comments on commit 323f2b3

Please sign in to comment.