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

Cloudflare Turnstile solver giving ERROR_BAD_PARAMETERS

Open Binit-Dhakal opened this issue 1 year ago • 19 comments

Hello there, I am trying to use this library to solve Cloudflare turnstile captcha for one of the sites. But I am getting ERROR BAD PARAMETERS as the error. Here is the full log.

result = solver.turnstile(
   ...:         sitekey='0x4AAAAAAAAjq6WYeRDKmebM',
   ...:         url='https://recorder.maricopa.gov/recdocdata/'
   ...: )
---------------------------------------------------------------------------
ApiException                              Traceback (most recent call last)
Cell In[3], line 1
----> 1 result = solver.turnstile(
      2         sitekey='0x4AAAAAAAAjq6WYeRDKmebM',
      3         url='https://recorder.maricopa.gov/recdocdata/'
      4 )

File ~/.local/lib/python3.8/site-packages/twocaptcha/solver.py:443, in TwoCaptcha.turnstile(self, sitekey, url, **kwargs)
    429 def turnstile(self, sitekey, url, **kwargs):
    430     '''
    431     Wrapper for solving Cloudflare Turnstile
    432 
   (...)
    440 
    441     '''
--> 443     result = self.solve(sitekey=sitekey,
    444                         url=url,
    445                         method='turnstile',
    446                         **kwargs)
    447     return result

File ~/.local/lib/python3.8/site-packages/twocaptcha/solver.py:492, in TwoCaptcha.solve(self, timeout, polling_interval, **kwargs)
    475 def solve(self, timeout=0, polling_interval=0, **kwargs):
    476     '''
    477     sends captcha, receives result
    478 
   (...)
    489     result : string
    490     '''
--> 492     id_ = self.send(**kwargs)
    493     result = {'captchaId': id_}
    495     if self.callback is None:

File ~/.local/lib/python3.8/site-packages/twocaptcha/solver.py:546, in TwoCaptcha.send(self, **kwargs)
    542 params = self.rename_params(params)
    544 params, files = self.check_hint_img(params)
--> 546 response = self.api_client.in_(files=files, **params)
    548 if not response.startswith('OK|'):
    549     raise ApiException(f'cannot recognize response {response}')

File ~/.local/lib/python3.8/site-packages/twocaptcha/api.py:76, in ApiClient.in_(self, files, **kwargs)
     73 resp = resp.content.decode('utf-8')
     75 if 'ERROR' in resp:
---> 76     raise ApiException(resp)
     78 return resp

ApiException: ERROR_BAD_PARAMETERS

Any help will be appreciated.

Thank you

Binit-Dhakal avatar Jul 28 '23 17:07 Binit-Dhakal

i have the same issue

Jackson-Vieira avatar Jan 26 '24 00:01 Jackson-Vieira

me too @nathanielobrown @henry-swe

dh12306 avatar Feb 05 '24 03:02 dh12306

@Binit-Dhakal have you solved ?

dh12306 avatar Feb 05 '24 08:02 dh12306

Hello @dh12306, Sorry but I was not able to bypass Cloudflare for that website. I was able to bypass it using an "undetected chromedriver", but it made our project's overall structure complicated as we were primarily using playwright and scrapy so we had to unfortunately skip this site. There must be other solutions for Cloudflare which I am not aware of.

Thank you

Binit-Dhakal avatar Feb 05 '24 09:02 Binit-Dhakal

This issue is still around -- any updates on it?

mauricio-gg avatar Apr 29 '24 13:04 mauricio-gg

I also wonder when this will be fixed and how to solve it?

devnos avatar Jul 02 '24 17:07 devnos

Hello, guys, have you solved that Bad parameter error issue while bypassing turnstile? If you have solution, please let me know.

cg-tester avatar Jul 04 '24 08:07 cg-tester

@Binit-Dhakal I can't bypass even by using undetected_chromedriver. Can you help me?

cg-tester avatar Jul 04 '24 10:07 cg-tester

I am having problems as well, but I think CF may have changed something on their end. It was working fine a few days ago

mauricio-gg avatar Jul 04 '24 11:07 mauricio-gg

@mauricio-gg did you try it with 2captcha?

cg-tester avatar Jul 04 '24 12:07 cg-tester

@cg-tester I switched from using their python wrapper to my own functions to call on their API because the wrapper does not support all captcha types.

Anyway, I use 2captcha and I can see that params are getting passed and that I am receiving a response and using it in the callback function, but then we just end up back in the CF page. This was working fine and just stopped working recently.

mauricio-gg avatar Jul 04 '24 12:07 mauricio-gg

@mauricio-gg can we meet on skype?

cg-tester avatar Jul 04 '24 12:07 cg-tester

i have the same issue any updates based on this issue ?

heliyahasaniherculesai avatar Jul 18 '24 13:07 heliyahasaniherculesai

Hey guys, I was randomly checking for other issues related to Cloudfare Turnstile. I figured I could help. I was getting the same issue some hours back took 2-3 days to get it to work but stuck on the last part.

First of all, make sure to submit it as a post sorry my requirements were in javascript so haven't tested with this module.

then I made a big URL with all the params:

https://2captcha.com/in.php?key={apiKey}&method=turnstile&json=1&sitekey=${siteKey}&pageurl=${pageUrl}&useragent=${userAgent}&action=${dataAction}&data=${dataData}&pagedata=${dataPagedata}

UserAgent, page URL, and siteKey are shown as compulsory officially but if action, data, and pagedata are present, we need to give them. can be found with this selector: [data-captcha-type="turnstile"]

There would be data-data parameters and many more refer to the table below:

image URL: https://2captcha.com/blog/bypass-cloudflare-turnstile-captcha

Then you would hopefully be getting a response ID which you can change for the solution and user agent.

I am here stuck unable to figure out how to get the captcha to be verified as there is no submit button I have tried attaching the input value by setting its value but still unable to submit. Can anyone help me?

hadi-14 avatar Jul 18 '24 20:07 hadi-14

i have the same issue any updates based on this issue ?

I solved the issue. There are two type of turnstile captcha which are standalone and challenge. For challenge a javascript code should be ingested otherwise it will throw some errors.

heliyahasaniherculesai avatar Jul 25 '24 08:07 heliyahasaniherculesai

Could you guide me regarding both of them as I mentioned I am injecting the solution key into the captcha but it doesn't;t get solved or passed ie submitted.

hadi-14 avatar Jul 26 '24 11:07 hadi-14

Could you guide me regarding both of them as I mentioned I am injecting the solution key into the captcha but it doesn't;t get solved or passed ie submitted.

script = """ console.clear = () => console.log('Console was cleared') const i = setInterval(() => { console.log(window.turnstile) if (window.turnstile) { console.log("injected") clearInterval(i) window.turnstile.render = (a, b) => { let params = { sitekey: b.sitekey, pageurl: window.location.href, data: b.cData, pagedata: b.chlPageData, action: b.action, userAgent: navigator.userAgent, json: 1 } console.log('intercepted-params:' + JSON.stringify(params)) window.cfCallback = b.callback return } } }, 10) """ you should ingest this java script code based on the tool that you are using I hope this assists

heliyahasaniherculesai avatar Jul 26 '24 12:07 heliyahasaniherculesai

But I am getting the solution this gives me the required parameters such as sitekey, data, pagedata and more. How does it submit with the captcha response

hadi-14 avatar Jul 26 '24 22:07 hadi-14

But I am getting the solution this gives me the required parameters such as sitekey, data, pagedata and more. How does it submit with the captcha response

The code that I have shared is to get those parameters please check the documentation for it for further functions to retrive those. They wrote an article about it.

heliyahasaniherculesai avatar Jul 30 '24 07:07 heliyahasaniherculesai