g1879 / DrissionPage

Python based web automation tool. Powerful and elegant.
https://DrissionPage.cn/
BSD 3-Clause "New" or "Revised" License
8.3k stars 782 forks source link

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

Open leadscloud opened 3 months ago

leadscloud commented 3 months ago

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

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

OpsecGuy commented 3 months 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

M2ATrail commented 4 weeks ago

@OpsecGuy I'm using this but how to get this?

try this command to get the check

while not any(["needs to review the security" in your_driver.html,
           "additional verification required" in your_driver.html,
            "just a moment" in your_driver.title.lower(),
            'security check' in your_driver.title.lower()
            ]):
    your_driver.get(r'https://www.indeed.com/viewjob?jk=50096999662c7c37')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=4c7fd91be25df159')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=616dbdd1e3f69706')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=4c7fd91be25df159')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=4c7fd91be25df159')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=377cc685d2655991')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=4c7fd91be25df159')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=92101c087d5ed0e7')
    your_driver.get(r'https://www.indeed.com/viewjob?jk=4c7fd91be25df159')

I tried this, and also tried getting the css path to get he input id (by adding _response at the end), and it locates the input, but doesn't click()

challenge_iframe = your_driver.ele("#challenge-form", timeout=1).child().child().child().sr.ele("t:iframe", timeout=1)
challenge_button = challenge_iframe.ele("t:input", timeout=1)