2captcha-go icon indicating copy to clipboard operation
2captcha-go copied to clipboard

Turnstile method appears to be broken.

Open LockBitSupp opened this issue 9 months ago • 1 comments

Hello, When attempting to use the cloudflare turnstile method to solve standalone turnstile captchas, it seems to always return an API error on the current version of the package.

for example, take the below code.

func handleTurnstileCaptcha() {
	cap := api2captcha.CloudflareTurnstile{SiteKey: "0x4AAAAAAADnPIDROrmt1Wwj", Url: "https://account.jagex.com"}
	solver := api2captcha.NewClient("CENSORED_API_KEY")
	solution, err := solver.Send(cap.ToRequest())
	if err != nil {
		zl.ErrorErr("Failed to solve captcha: ", err)
		log.Print(err)
		log.Print(cap.ToRequest())
		log.Print(solution)
	}
	if solution != "" {
		zl.Info("Got captcha solution: " + solution)
	}
}

This will always return api2captcha.ErrApi

2024/05/01 04:05:43 api2captcha: API error
2024/05/01 04:05:43 {map[method:turnstile pageurl:account.jagex.com sitekey:0x4AAAAAAADnPIDROrmt1Wwj] map[]}

When emulating the request this code sends in a http client we can see more details on the resulting error.

POST https://api.2captcha.com/createTask
Accept: application/json

{
    "clientKey":"CENSORED_API_KEY",
    "task": {
        "type":"TurnstileTaskProxyless",
        "websiteURL":"https://account.jagex.com",
        "websiteKey":"0x4AAAAAAADnPIDROrmt1Wwj"
    }
}
---
{
  "errorId": 110,
  "errorCode": "ERROR_BAD_PARAMETERS",
  "errorDescription": "The required captcha parameters in your reques are missing or have incorrect format. Please make sure your request payload has proper format for selected task type."
}

It seems the 2captcha api is expecting additional parameters, that the CloudflareTurnstile struct does not currently contain.

LockBitSupp avatar May 01 '24 03:05 LockBitSupp

After reading more of the documentation, api2captcha.CloudflareTurnstile lacks a large number of the required attributes for solving this captcha, resulting in APIError on attempt to solve. The 2captcha api documentation for Turnstile has a table listing variables for the turnstile method, both required and non-required, currently the struct for cloudflare turnstile is lacking, Useragent (required for standalone and challenge page) Action (required for challenge page) Data (required for challenge page) Pagedata (required for challenge page)

Could we please see implementation into the library.

LockBitSupp avatar May 01 '24 03:05 LockBitSupp

@LockBitSupp We have made new changes to this method, try using it with the latest adjustments.

PBadicean avatar Jun 20 '24 16:06 PBadicean