hcaptcha-challenger
hcaptcha-challenger copied to clipboard
[Question] Detected by hCAPTCHA challenge
在本地电脑运行成功率很高,在服务器上98%是RETRY错误。
服务器环境下hCaptcha会感知到吗?
我在一周前针对 EPIC 的 Talon service 的测试中发现了这个问题,我当时的结论是 hCaptcha 升级了环境感知的能力。
简单来说就是, 本项目的 undetected chromedriver 也需要更新换代了;也有极小概率是IP有问题。如果你的 token 被标记,你会陷入带水印的交通工具类的分类任务。
是否有比较好或者推荐的解决方案?
hcaptcha的检测是闭源的
经过测试,在本地使用无头浏览器也会大量ENTRY.估计根源在hCaptcha能检测到无头浏览器
额- -这个是基本门槛,实际上还是需要知道 hCaptcha 的检测逻辑。
hcaptcha-challenger 的挑战行为在 undetected-chromedriver 提供的浏览器驱动环境中进行,我个人认为可以在这个项目的源码中寻找突破口。
同样的特征检测在 EPIC 的 Talon service 以及 Google 的 reCAPTCHA v3 中都存在。要实现特征反射或特征镜像最简单的办法就是闭源编译,但我希望能有一种开源且无法被反制的解决方案。
这项工作我大概两个月前就开始折腾了- -但无奈可借鉴的优秀策略都是闭源的,可供参考的文献也少有代码实现基本都是口嗨,我自己也没太多时间泡 GitHub(且在之前 hCaptcha 并不能精确区分 undetected-chromedriver 的流量特征),这事就不了了之了-。-
这是一场永无止境“猫抓老鼠”游戏😂。
目前就是用一台桌面windows在24小时跑。chrome必须在活跃状态,不能缩小到任务栏,否则也会挑战失败
~我主要精力还是在卑微刷算法题~ 我会把相关内容反馈到 undetected-chromedriver
的社区。还不知道在什么环节被检测了,现在下结论还为时尚早~
I broke the ChromeOptions using this code. This will run Chrome in my profile mode, then I can install more extension such as: Ramdom User-Agent, Code Injector,... You can also block cookies from the HCAPTCHA domain on your sample_site. Hopefully this can help you.
#src\sevices\utils\toolbox.py
# - Restrict browser startup parameters
options = uc.ChromeOptions()
options.add_argument("user-data-dir=database\selenium")#If not, this folder creates it even though it doesn't work
#options.add_argument("--log-level=3")
#options.add_argument("--disable-dev-shm-usage")
#options.add_argument("--no-sandbox")
options.add_argument("--disable-blink-features=AutomationControlled")
# - Restrict the language of hCaptcha label
# - Environment variables are valid only in the current process
# and do not affect other processes in the operating system
os.environ["LANGUAGE"] = "zh" if lang is None else lang
options.add_argument(f"--lang={os.getenv('LANGUAGE')}")
if silence is True:
options.add_argument("--disable-gpu")
#options.add_argument("--disable-software-rasterizer")
@kuuyby9duoi This may not be valid, in my previous tests this parameter would highlight the driver's characteristics options.add_argument("--disable-blink-features=AutomationControlled")
更新一下新进展,如果是在Linux服务器上,不要使用无头模式,使用虚拟桌面即可解决该错误
@liuming9157 这不太合理。
你试下在 windows/macOS 上直接运行下面的 py 代码。通过 UC 直接打开挑战演示站点,然后手动激活 checkbox,等待图片加载完后连续 refresh,如果10下左右就出现 Your computer on network has sent too many requests. 的警告,说明被检测了。
作为对比,你可以手动打开浏览器并访问任一 hCAPTCHA演示站点,然后进行同样的操作。
如果你发现后者能够持续更长时间,说明 UC patch 没起作用,同样地 Selenium 更不可能通过挑战。
在 headless 下,UC 会进行多次 CDP 补偿,我暂时不清楚这些修补的意图是什么,但显然如果有头模式下被检测,无头模式肯定是凉凉的~
Demo
# Windows11
# Chrome Version 104.0.5112.81 (Official Build) (64-bit)
# Python3.10
import os
import undetected_chromedriver as uc
from selenium.webdriver import ChromeOptions
def _get_ctx_options():
options = ChromeOptions()
# Select challenge language
os.environ["LANGUAGE"] = "en"
options.add_argument(f"--lang={os.getenv('LANGUAGE')}")
return options
def demo():
"""Your computer on network has sent too many requests."""
url = "https://accounts.hcaptcha.com/demo?sitekey=c86d730b-300a-444c-a8c5-5312e7a93628"
ctx = uc.Chrome(options=_get_ctx_options(), headless=False)
try:
ctx.get(url)
input("Activate and refresh it")
finally:
ctx.quit()
if __name__ == '__main__':
demo()
在不指定 chromedrivedr 路径的情况下, UC 会自动下载最新版本,如果和你的 Chrome 版本对不上会报错
~~cao - - 突然想起一个很重要的问题,hCaptcha 后台其实是可以设置通过率门槛的~~
hcaptcha-challenger 的挑战行为在 undetected-chromedriver 提供的浏览器驱动环境中进行,我个人认为可以在这个项目的源码中寻找突破口。
同样的特征检测在 EPIC 的 Talon service 以及 Google 的 reCAPTCHA v3 中都存在。要实现特征反射或特征镜像最简单的办法就是闭源编译,但我希望能有一种开源且无法被反制的解决方案。
这项工作我大概两个月前就开始折腾了- -但无奈可借鉴的优秀策略都是闭源的,可供参考的文献也少有代码实现基本都是口嗨,我自己也没太多时间泡 GitHub(且在之前 hCaptcha 并不能精确区分 undetected-chromedriver 的流量特征),这事就不了了之了-。-
这是一场永无止境“猫抓老鼠”游戏😂。
大佬试过使用hcpacha官方给残疾人用的无障碍功能吗?是否真的能直接稳定跳过验证?感觉会被收集使用数据,会被官方限制滥用行为