Pull to refresh

How to bypass hCaptcha in Modern Times: Has Mavr Left and Been Replaced by a New One? Let's check «new» hcaptcha solver

Level of difficultyEasy
Reading time7 min
Views1.5K
Original author: Александр

If you are into automation and keep up with trends, you’ve probably noticed that, at some point, difficulties in hCaptcha bypass began to emerge. What kind of difficulties? Several major captcha recognition services, such as 2captcha, have removed any mention of how to bypass hCaptcha from their documentation, and the presence of thematic tweets on Twitter (along with official responses from the service) confirms my suspicion that something has happened… Let’s figure out what happened, why 2captcha no longer bypass hCaptcha, and what role solvecaptcha plays in creating new hCaptcha solver.

Judging by the fact that questions have been directed not only at 2captcha but also at Capsolver, it seems that someone called (or perhaps wrote) and requested that they stop doing this (read: “don’t solve our captcha”). The reasons behind this can only be speculated upon, but my modest past experience points to one possibility – a complaint. In any case, while there is no solution to bypass hCaptcha on the aforementioned sites, the need for captcha recognition hasn’t disappeared, has it?

Are There Any Alternatives to Bypass hCaptcha in the Absence of Major Players?

In reality, the problem of hCaptcha bypass existed even when those services provided a solution for this captcha. The captcha itself is quite problematic; it comes in several difficulty levels, each with its own additional parameters and verification methods that complicate the recognition process.

Accordingly, simple automated hCaptcha solver services do not boast a very high bypass success rate (this is sometimes referred to as “probing” – though that term is more associated with services that were popular in the early 2020s).

What Exactly Is hCaptcha That Everyone Wants to Bypass?

In short, for those who are completely out of the loop – what are we even talking about? hCaptcha is essentially an alternative to reCaptcha which, if you don’t delve into the details or look under the hood, isn’t much different from it. It employs roughly the same bypass methods, similar challenges, and identification techniques; the differences lie in the servers that authenticate the token upon solving, and the challenge difficulty is higher for hCaptcha (at least its most difficult version certainly is). So, hCaptcha is essentially a more complex version of reCaptcha, or reCaptcha on steroids.

Practical Implementation of hCaptcha solver Python

I won’t bore you with long discussions about what and how I searched for or which services I tried – let’s get straight to the point: the solution has been found (as the saying goes, “found and found, so why complain”… or rather, resurrected). I took an old method I once used for hCaptcha bypass (this is simple script - hcaptcha solver by python), tweaked it a bit, and here is the script I ended up with.

import requests
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC




# API configuration and target URL
API_KEY = "Your API-Key"
PAGEURL = "URL"




def solve_hcaptcha(sitekey):
    # Step 1: Send a request to obtain captcha_id using the dynamic sitekey
    in_url = "https://api.solvecaptcha.com/in.php"
    payload = {
        'key': API_KEY,
        'method': 'hcaptcha',
        'sitekey': sitekey,
        'pageurl': PAGEURL,
        'json': 1
    }
   
    response = requests.post(in_url, data=payload)
    result = response.json()
   
    if result.get("status") != 1:
        print("Error sending request:", result.get("request"))
        return None
   
    captcha_id = result.get("request")
    print("Received captcha_id:", captcha_id)
   
    # Step 2: Poll for the captcha solution
    res_url = "https://api.solvecaptcha.com/res.php"
    while True:
        params = {
            'key': API_KEY,
            'action': 'get',
            'id': captcha_id,
            'json': 1
        }
        res = requests.get(res_url, params=params)
        data = res.json()
       
        if data.get("status") == 1:
            print("Captcha solved successfully!")
            return data  # The response contains the token and useragent
        elif data.get("request") == "CAPCHA_NOT_READY":
            print("Captcha not ready yet, waiting 5 seconds...")
            time.sleep(5)
        else:
            print("Error retrieving solution:", data.get("request"))
            return None




def set_captcha_token(driver, token):
    # Find or create hidden fields for hCaptcha and reCaptcha
    try:
        driver.find_element(By.NAME, "h-captcha-response")
    except Exception:
        driver.execute_script("""
            var input = document.createElement('input');
            input.type = 'hidden';
            input.name = 'h-captcha-response';
            document.body.appendChild(input);
        """)
    try:
        driver.find_element(By.NAME, "g-recaptcha-response")
    except Exception:
        driver.execute_script("""
            var input = document.createElement('input');
            input.type = 'hidden';
            input.name = 'g-recaptcha-response';
            document.body.appendChild(input);
        """)
    # Insert the token into the fields
    driver.execute_script(f"""
        document.getElementsByName('h-captcha-response')[0].value = '{token}';
        document.getElementsByName('g-recaptcha-response')[0].value = '{token}';
    """)




def show_visual_feedback(driver):
    # Create a banner on the page to indicate that the captcha has been solved
    driver.execute_script("""
        var banner = document.createElement('div');
        banner.innerText = 'Captcha Solved!';
        banner.style.position = 'fixed';
        banner.style.top = '0';
        banner.style.left = '0';
        banner.style.width = '100%';
        banner.style.backgroundColor = 'green';
        banner.style.color = 'white';
        banner.style.fontSize = '24px';
        banner.style.fontWeight = 'bold';
        banner.style.textAlign = 'center';
        banner.style.zIndex = '9999';
        banner.style.padding = '10px';
        document.body.appendChild(banner);
    """)




def main():
    # Initialize Selenium WebDriver (Chrome)
    driver = webdriver.Chrome()
    driver.get(PAGEURL)
   
    # Wait for the element with data-sitekey to appear on the page
    try:
        sitekey_element = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.CSS_SELECTOR, '[data-sitekey]'))
        )
        # Dynamically extract the sitekey
        sitekey = sitekey_element.get_attribute("data-sitekey")
        print("Extracted sitekey:", sitekey)
    except Exception as e:
        print("Failed to find element with data-sitekey:", e)
        driver.quit()
        return




    # Solve hCaptcha using the dynamically extracted sitekey
    solution = solve_hcaptcha(sitekey)
    if solution:
        token = solution.get("request")
        user_agent = solution.get("useragent")
        print("Received token:", token)
        print("User-Agent:", user_agent)
       
        # Insert the token into the hidden form fields
        set_captcha_token(driver, token)
        print("Token successfully inserted into the form fields.")
       
        # Display visual feedback indicating that the captcha has been solved
        show_visual_feedback(driver)
       
        # If needed, the form can be automatically submitted:
        # driver.find_element(By.ID, "submit-button").click()
       
        # Keep the browser open for demonstration (10 seconds)
        time.sleep(10)
        driver.quit()
    else:
        print("Failed to solve the captcha.")
        driver.quit()




if __name__ == "__main__":
    main()

What Does the Script Do:

Step-by-step Description of the Script's Operation

  1. Initialization and Page Loading
    The script uses Selenium WebDriver (in this case for the Chrome browser) to open the target page. In my example (see the video below), this involves three different URLs: demo pages featuring hCaptcha at three levels of difficulty (easy, moderate, difficult).

  2. Extracting the Sitekey
    Every hCaptcha page contains a special attribute data-sitekey, which serves as a unique identifier for the captcha on that page. The script waits for an element with this attribute to appear and dynamically extracts its value. This theoretically allows it to work on any page that uses hCaptcha. If, for some reason, the script fails to capture this parameter, you’ll need to examine the page—but in most cases it should work.

  3. Sending a Request to the API to Solve the Captcha
    After obtaining the sitekey, the script sends a POST request to the API service (in this case, https://api.solvecaptcha.com/in.php) with the following parameters:

    • API key – for authentication.

    • Method – specifying the captcha type, in this case "hcaptcha".

    • sitekey – the dynamically extracted value.

    • pageurl – the full URL of the page containing the captcha.

    • json – a parameter to request the response in JSON format.

  4. The API returns a unique captcha identifier (captcha_id), which is used in subsequent requests to check whether the captcha has been solved.

  5. Requesting the Captcha Solution
    Once the identifier is received, the script repeatedly sends GET requests to the API to see if the solution is ready. If the captcha hasn’t yet been solved, the API responds with the message "CAPCHA_NOT_READY" and the script waits 5 seconds before trying again. Once the captcha is solved, the API returns the solution token along with an additional useragent field.

  6. Inserting the Token into Hidden Form Fields
    After obtaining the token, the script checks for the presence of the hidden fields h-captcha-response and g-recaptcha-response on the page. If they are absent, the script automatically creates them using JavaScript. The token is then inserted into these fields, allowing the site to accept the captcha solution as valid.

Enhancements

For clarity, I added the following code to the script:

def show_visual_feedback(driver):
    # Create a banner on the page to indicate that the captcha has been solved
    driver.execute_script("""
        var banner = document.createElement('div');
        banner.innerText = 'Captcha Solved!';
        banner.style.position = 'fixed';
        banner.style.top = '0';
        banner.style.left = '0';
        banner.style.width = '100%';
        banner.style.backgroundColor = 'green';
        banner.style.color = 'white';
        banner.style.fontSize = '24px';
        banner.style.fontWeight = 'bold';
        banner.style.textAlign = 'center';
        banner.style.zIndex = '9999';
        banner.style.padding = '10px';
        document.body.appendChild(banner);
    """)

This code adds a fixed banner on the page that displays “Captcha Solved!”. You can comment out or remove this code—it does not affect the functionality of the captcha solver.

Also, comment out (or remove) this line if you do not wish to launch the browser:

# show_visual_feedback(driver)

What Else?

If needed, the script can automatically submit the form (for example, by simulating a click on the submit button) if this is required by the site’s logic. Just uncomment the following line:

# driver.find_element(By.ID, "submit-button").click()

And what’s next? The rest is up to you—the script works, and I’ve found a complete solution. In short, you can stop complaining about hCaptcha no longer being solvable. By the way, I also developed a script in Node.js, but something went awry, so I abandoned it and focused on Python. If someone really needs it, I might consider creating a Node.js version.

Tags:
Hubs:
If this publication inspired you and you want to support the author, do not hesitate to click on the button
Total votes 1: ↑1 and ↓0+1
Comments0

Articles