g1879 / DrissionPage

基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。
https://drissionpage.cn
BSD 3-Clause "New" or "Revised" License
7.68k stars 727 forks source link

动作链无法绕过cloudflare的5s盾 #329

Open leadscloud opened 1 month ago

leadscloud commented 1 month ago

模拟鼠标可以点击成功,但无法绕过cloudflare的turnstile验证,我测试了下,只要真正的鼠标点击下就能立即过。但程序page.actions的点击是无法通过的。

模拟的鼠标行为估计是检测到了。

OpsecGuy commented 1 month ago

You're wrong if google translates your words correctly. You can bypass captcha using built-in DrssionPage click method.

Here is my code that I tested now and works without issues:

driver = self.create_new_driver()
driver.get(target)
print(f"[{self.thread_id}] Browser started [PID: {driver.process_id}]")
time.sleep(8.0 if not self.summary.emulation_force else 12.0)

if "access denied" in driver.title.lower():
    raise Exception('Access Denied')

if "needs to review the security" in driver.html or "just a moment" in driver.title.lower():
    print(f'[{self.thread_id}] Captcha detected!')
    bypass_failed_times = 0
    while bypass_failed_times < 2:
        try:
            challenge_frame = driver.ele("ANTI COPY-PASTE", timeout=1).sr.ele("t:iframe", timeout=1) # Can be outdated in the future
            challenge_iframe_body = challenge_frame.ele("ANTI COPY-PASTE", timeout=1).sr
            challenge_button = challenge_iframe_body.ele("t:input", timeout=1)
            challenge_button.click()
            break
        except Exception:
            bypass_failed_times += 1
            print(f"[{self.thread_id}] {bypass_failed_times=}/2")
            time.sleep(2.0)

... LOGIC GOES HERE

image