Detected a Cloudflare version 2 Captcha challenge
siroo2137 opened this issue · comments
error:
cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.
Could you provide more information:
- What version of python-aternos have you installed?
- On which device do you use this module (your PC or VPS like Repl.it)?
- If it's your computer, where do you live (USA, Europe, Russia or China/Japan)?
I checked the latest version (1.1.2) on Repl.it and my PC. It works properly.
To reproduce the error, I need to connect to VPN or test python-aternos on other python hostings.
Anyway, the problem is in cloudscraper library.
You can try installing python-aternos in the development mode and adding to the 202th line in atconnect.py
these parameters to CloudScraper constructor:
self.session = CloudScarper(
browser='chrome'
)
If these changes didn't help, install Node.js and use it in CloudScraper:
self.session = CloudScarper(
interpreter='nodejs'
)
# And also try
self.session = CloudScraper(
interpreter='nodejs',
browser='chrome'
)
Could you provide more information:
- What version of python-aternos have you installed?
- On which device do you use this module (your PC or VPS like Repl.it)?
- If it's your computer, where do you live (USA, Europe, Russia or China/Japan)?
- i installed python-aternos via pip (pip install python-aternos) and the version is i think 2.0.1
- i use the module on my pc (windows)
- i live in poland (and i don't use any vpns)
Anyway, the problem is in cloudscraper library.
You can try installing python-aternos in the development mode and adding to the 202th line in
atconnect.py
these parameters to CloudScraper constructor:self.session = CloudScarper( browser='chrome' )If these changes didn't help, install Node.js and use it in CloudScraper:
self.session = CloudScarper( interpreter='nodejs' ) # And also try self.session = CloudScraper( interpreter='nodejs', browser='chrome' )
and after doing this (installing python-aternos in development mode and changing the line 202 to
self.session = CloudScarper(
browser='chrome'
)
in atconnect.py)
it still displays the same error
same here i changed the line 202 and still get the same error
same here i changed the line 202 and still get the same error
everything is exactly the same for me
@siroo2137, @BABAROKA911, @reka7490,
This error means that Cloudflare responses with hCaptcha which cloudscraper cannot pass.
You can use services like 2captcha or automated captcha solvers based on machine learning.
I'll implement captcha solving through the 1st way (paid services) soon.
Please, update to the latest version:
pip install -U "python-aternos>=2.1.1"
Here's how to add a captcha solver API key:
from python_aternos import Client
at = Client.from_credentials(
'username',
'password',
captcha={
'provider': '2captcha',
'api_key': 'your_api_key',
}
)
All available captcha solvers you can find here.
Just copy "capctha={...}" from that page and paste to the code below.
I didn't test it. Please, notify about all bugs in this issue.
@siroo2137, @reka7490,
could you check this feature?
да без б
>>> from python_aternos import Client
>>> at = Client.from_credentials('world35g', 'world35g', captcha={'api_key': 'test'})
>>> at.atconn.session.captcha
{}
Да, параметры почему-то не передаются в конструктор CloudScaper (в т.ч. и словарь captcha
).
Постараюсь исправить как можно быстрее.
Right, parameters are not passed to a CloudScraper constructor (including captcha
dictionary) for some unknown reason.
I'll try to fix it as soon as possible.
@siroo2137, @reka7490, @BABAROKA911,
Maybe fixed in 092f935
Please, update to the latest version:
pip install -U "python-aternos>=2.1.2"
I'm still surprised why Cloudflare allows me send requests from my devices and even from Replit.
Возможно, пофикшено в коммите 092f935
Обновитесь до последней версии, пожалуйста.
Меня всё ещё удивляет, что Клаудфлэр пропускает запросы с моих устройств (даже с Replit-а).
From v3.0.0
, any arguments to CloudScraper are passed this way:
from python_aternos import Client
at = Client()
at.atconn.session.captcha = {
'provider': '2captcha',
'api_key': 'your_api_key',
}
at.login('username', 'password')
From
v3.0.0
, any arguments to CloudScraper are passed this way:from python_aternos import Client at = Client() at.atconn.session.captcha = { 'provider': '2captcha', 'api_key': 'your_api_key', } at.login('username', 'password')
I have added in that bit, I still get
cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 Captcha challenge, This feature is not available in the opensource (free) version.
Do I need to install in development mode while changing those lines?
Okay, so I have dug a bit deeper trying to get 2captcha to work, according to the Cloudflare turnstile documentation, I need the sitekey and turnstile can be loaded 2 ways:
Implicitly render the Turnstile widget
So, basically, it is the easiest to solve as the sitekey is loaded in the HTML sort of like this:
<div class="cf-turnstile" data-sitekey="yourSitekey" data-callback="javascriptCallback"></div>
Explicitly render the Turnstile widget
This one here is the problem, as it is much harder to solve, it has the sitekey on a javascript that you must intercept to get the sitekey, and unfortunately, Aternos uses this method.
Here is the place where the sitekey is stored.
window.onloadTurnstileCallback = function () {
turnstile.render('#example-container', {
sitekey: '<YOUR_SITE_KEY>',
callback: function(token) {
console.log(`Challenge Success ${token}`);
},
});
};
So, as per the 2captcha documentation I tried intercepting
# Inject JavaScript code to intercept turnstile.render() arguments
script = """
const i = setInterval(()=>{
if (window.turnstile) {
clearInterval(i)
window.turnstile.render = (a,b) => {
console.log(b)
return 'foo'
}
}
},50)
"""
browser.execute_script(script)
# Wait for the JavaScript code to execute
time.sleep(5)
# Retrieve the browser's log entries
logs = browser.get_log("browser")
for log in logs:
print(log["message"])
But ultimately, this failed as well, seems like aternos has some sort of system in place that can detect when such attempts are made and refuse to connect with the 403 response...
I don't know where to go from here
@Aeron-Emory, please, read #62 (comment)
I'll notify about any updates in the issue 62.
Thanks a lot for your research, this could help.