Logo of «2Captcha»To home page
Captcha bypass tutorials

Was this helpful?

How to bypass Yidun captcha on id7.cloud.huawei.com

Gregory Fisher
Gregory Fisher

Technical engineer

id7.cloud.huawei.com is the European login site for the HUAWEI account. Its login page is protected by Yidun captcha.

The captcha does not appear on every login: whether to show it or let the attempt through is decided by the Huawei server. But the page prepares the parameters for the task in advance, before the widget with the picture appears, and they can be read.

Compared with a plain Yidun setup, this site has three complications.

The site key is not in the page code. A separate request returns it, and to build that request you first need two other values from Huawei.

The Enterprise version is installed. Besides the site key, the task needs three more values — challenge, hcg and hct, and all three are one-time.

The solution is not written into the form. The page packs it into a JSON string together with other values and sends it as a separate request parameter.

Task Parameters

The task type is YidunTaskProxyless if you solve through the service proxies, or YidunTask if you supply your own.

Parameter Type Required Description
type String Yes YidunTaskProxyless or YidunTask
websiteURL String Yes Login page address: https://id7.cloud.huawei.com/CAS/portal/loginAuth.html
websiteKey String Yes Site key, also called captchaId. For this site it is 0f743r3g1gm36431pg87n8rz3grz0ym5
userAgent String No User-Agent of the browser the page was opened with
yidunGetLib String No Address of the file that loads the captcha. Recommended for the Enterprise version
yidunApiServerSubdomain String No Captcha server domain without https://. Huawei uses its own, non-standard one
challenge String No One-time value from the cscPreprocess response
hcg String No One-time value from the same response
hct Number No Timestamp from the same response

The documentation marks the last three parameters as optional, but this site needs them: without them the solution is treated as plain Yidun, while Huawei expects Enterprise.

For the YidunTask type, add the proxy details: proxyType, proxyAddress, proxyPort, proxyLogin and proxyPassword.

How to find parameters

The constant values for this site are these:

The challenge, hcg and hct values are one-time and have to be obtained again before every task. Below is how the page gets them itself and how to repeat that in a script.

Step one: the cscPreprocess request

Open the login page, press F12 and go to the Network tab. Start a login, and a cscPreprocess request with a reflushCode parameter appears among the requests. It is a POST request to an address of the form /CAS/IDM_W/ajaxHandler/cscPreprocess?reflushCode=NUMBER.

In its body the page sends captchaType, clientType, lang and sceneId, plus two of its own service values — pageToken and pageTokenKey. Both are in the localInfo object on the page.

The response looks like this:

json Copy
{
  "appId": "huaweiup",
  "businessId": "huaweiup",
  "cdnDomain": "",
  "challenge": "f4df3943be517cca2b6060842c4cb96daf6b22e2f15f521ef2177031bab2069b",
  "hcg": "1cb7f8d1fa60134e7f5c92b15f96205046cbd91581eb0c16c9d3df63db9967e1",
  "hct": 1788597543413,
  "isSuccess": 1,
  "sceneId": "login",
  "serviceDomain": ["csc-adapter-dre.security.dbankcloud.com"],
  "type": 2
}

From here you take challenge, hcg and hct for the task. The businessId, sceneId and serviceDomain values are needed in the next step, and type is needed when the answer for the server is assembled.

There are two details about the request itself. The pageToken and pageTokenKey pair works only once: on a repeat request with the same pair the server answers with error 10000004, and the page has to be reloaded. The captchaType parameter in the request body accepts only the value 1; any other value returns error 10000001.

The type value in the response is the kind of check in Yidun. Two means the jigsaw: in the captcha library the kinds are listed as JIGSAW 2, POINT 3, SMS 4, INTELLISENSE 5, ICON_POINT 7, INFERENCE 9, WORD_ORDER 10, SPACE 11, VOICE 12. The kind is set by the Huawei configuration, not by the scenario: a request with sceneId register returned the same value.

Step two: the captchaid request

The site key is not in the page code. The Huawei wrapper requests it from the address in serviceDomain:

Copy
https://csc-adapter-dre.security.dbankcloud.com/captcha/v4/captchaid?businessId=huaweiup&sceneId=login&lang=en-US

The response to this request holds everything that remains:

json Copy
{
  "resultCode": 0,
  "resultMessage": "Success",
  "captchaId": "0f743r3g1gm36431pg87n8rz3grz0ym5",
  "vendorServiceDomain": [
    "csc-captcha-dre.security.dbankcloud.com",
    "csc-captcha-dre.security.dbankcloud.cn"
  ],
  "vendorJsURL": [
    "contentcenter-dre.dbankcdn.com/pub_1/cscaptcha_captcha_900_9/b/v3/netease/static/load.min.js"
  ]
}

The captchaId field is the websiteKey. The first address from vendorServiceDomain goes into yidunApiServerSubdomain as is, without https://. The first address from vendorJsURL goes into yidunGetLib, but you have to add https:// to it — the server returns it without a scheme.

The captchaId, vendorServiceDomain and vendorJsURL values did not change during testing, so they can be written into the code. Read challenge, hcg and hct anew every time.

Code Examples

Python + requests

This example gets the one-time values, sends the task and collects the solution. Take pageToken and pageTokenKey from the login page: they are unique to each session.

python Copy
import time

import requests

API_KEY = "YOUR_API_KEY"

PAGE_URL = "https://id7.cloud.huawei.com/CAS/portal/loginAuth.html"
WEBSITE_KEY = "0f743r3g1gm36431pg87n8rz3grz0ym5"
API_SUBDOMAIN = "csc-captcha-dre.security.dbankcloud.com"
GET_LIB = ("https://contentcenter-dre.dbankcdn.com"
           "/pub_1/cscaptcha_captcha_900_9/b/v3/netease/static/load.min.js")

PAGE_TOKEN = "VALUE_FROM_THE_PAGE"
PAGE_TOKEN_KEY = "VALUE_FROM_THE_PAGE"

session = requests.Session()
session.headers["User-Agent"] = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
    "(KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
)

preprocess = session.post(
    "https://id7.cloud.huawei.com/CAS/IDM_W/ajaxHandler/cscPreprocess",
    params={"reflushCode": int(time.time() * 1000)},
    data={
        "pageToken": PAGE_TOKEN,
        "pageTokenKey": PAGE_TOKEN_KEY,
        "captchaType": "1",
        "clientType": "cas",
        "lang": "en-us",
        "sceneId": "login",
    },
    timeout=30,
).json()

if preprocess.get("isSuccess") != 1:
    raise RuntimeError(f"cscPreprocess did not return parameters: {preprocess}")

task = {
    "type": "YidunTaskProxyless",
    "websiteURL": PAGE_URL,
    "websiteKey": WEBSITE_KEY,
    "userAgent": session.headers["User-Agent"],
    "yidunGetLib": GET_LIB,
    "yidunApiServerSubdomain": API_SUBDOMAIN,
    "challenge": preprocess["challenge"],
    "hcg": preprocess["hcg"],
    "hct": preprocess["hct"],
}

created = requests.post(
    "https://api.2captcha.com/createTask",
    json={"clientKey": API_KEY, "task": task},
    timeout=30,
).json()

if created.get("errorId") != 0:
    raise RuntimeError(f"Task was not created: {created}")

task_id = created["taskId"]
print("Task created, id", task_id)

for _ in range(24):
    time.sleep(5)

    result = requests.post(
        "https://api.2captcha.com/getTaskResult",
        json={"clientKey": API_KEY, "taskId": task_id},
        timeout=30,
    ).json()

    if result.get("errorId") != 0:
        raise RuntimeError(f"Error: {result}")

    if result.get("status") == "ready":
        validate = result["solution"]["token"]
        print("Solution received:", validate[:30], "…")
        break
else:
    raise RuntimeError("No solution arrived within the time limit")

Python + Playwright

This example opens the login page, reads the service values from it, repeats both Huawei requests, sends the task and assembles the finished authcode.

python Copy
import json
import os
import time

import requests
from playwright.sync_api import sync_playwright

API_KEY = os.getenv("APIKEY_2CAPTCHA", "YOUR_API_KEY")
PAGE_URL = "https://id7.cloud.huawei.com/CAS/portal/loginAuth.html"
WEBSITE_KEY = "0f743r3g1gm36431pg87n8rz3grz0ym5"
API_SUBDOMAIN = "csc-captcha-dre.security.dbankcloud.com"
GET_LIB = ("https://contentcenter-dre.dbankcdn.com"
           "/pub_1/cscaptcha_captcha_900_9/b/v3/netease/static/load.min.js")


def solve(task):
    created = requests.post(
        "https://api.2captcha.com/createTask",
        json={"clientKey": API_KEY, "task": task},
        timeout=30,
    ).json()

    if created.get("errorId") != 0:
        raise RuntimeError(f"Task was not created: {created}")

    task_id = created["taskId"]
    print("Task created, id", task_id)

    for _ in range(24):
        time.sleep(5)

        result = requests.post(
            "https://api.2captcha.com/getTaskResult",
            json={"clientKey": API_KEY, "taskId": task_id},
            timeout=30,
        ).json()

        if result.get("errorId") != 0:
            raise RuntimeError(f"Error: {result}")

        if result.get("status") == "ready":
            return result["solution"]["token"]

    raise RuntimeError("No solution arrived within the time limit")


with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()

    try:
        page.goto(PAGE_URL)
        page.wait_for_function("window.localInfo !== undefined", timeout=30000)

        local_info = page.evaluate("""() => ({
            pageToken: window.localInfo.pageToken,
            pageTokenKey: window.localInfo.pageTokenKey,
            sceneId: window.localInfo.cscSceneId,
            captchaType: window.localInfo.displayCaptchaType,
            lang: window.localInfo.lang || 'en-us',
        })""")

        preprocess = page.evaluate("""async (info) => {
            const body = new URLSearchParams({
                pageToken: info.pageToken,
                pageTokenKey: info.pageTokenKey,
                captchaType: info.captchaType,
                clientType: 'cas',
                lang: info.lang,
                sceneId: info.sceneId,
            });
            const url = '/CAS/IDM_W/ajaxHandler/cscPreprocess?reflushCode=' + Date.now();
            const response = await fetch(url, {
                method: 'POST',
                credentials: 'include',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body,
            });
            return response.json();
        }""", local_info)

        if preprocess.get("isSuccess") != 1:
            raise RuntimeError(f"cscPreprocess did not return parameters: {preprocess}")

        user_agent = page.evaluate("navigator.userAgent")

        validate = solve({
            "type": "YidunTaskProxyless",
            "websiteURL": PAGE_URL,
            "websiteKey": WEBSITE_KEY,
            "userAgent": user_agent,
            "yidunGetLib": GET_LIB,
            "yidunApiServerSubdomain": API_SUBDOMAIN,
            "challenge": preprocess["challenge"],
            "hcg": preprocess["hcg"],
            "hct": preprocess["hct"],
        })

        authcode = json.dumps({
            "type": preprocess["type"],
            "sceneId": preprocess["sceneId"],
            "lang": local_info["lang"],
            "challenge": preprocess["challenge"],
            "hcg": preprocess["hcg"],
            "hct": preprocess["hct"],
            "validate": validate,
        })

        print("Finished authcode:", authcode[:80], "…")

    except Exception as e:
        print(f"Error: {e}")
    finally:
        browser.close()

How to use the received token

This is the step where this site differs from a plain Yidun setup the most.

The service returns the solution in the solution.token field. In Yidun this value is called validate. It is usually written into a hidden form field. On the Huawei login page such a field exists — an input with the identifier captchaInfo inside the hwid-captchaHtml block — but the page handler does not read it.

Instead the page builds a JSON string from the solution and sends it as a separate request parameter named authcode. In the page code it looks like this:

javascript Copy
getRandomCode: function (result) {
    var t = { validate: result.validate };
    return JSON.stringify(be.extend(this.secondverifyParam, t));
}

The page assembled the secondverifyParam object earlier, from the cscPreprocess response. In the end authcode holds seven values:

json Copy
{
  "type": 2,
  "sceneId": "login",
  "lang": "en-US",
  "challenge": "f4df3943be517cca2b6060842c4cb96daf6b22e2f15f521ef2177031bab2069b",
  "hcg": "1cb7f8d1fa60134e7f5c92b15f96205046cbd91581eb0c16c9d3df63db9967e1",
  "hct": 1788597543413,
  "validate": "SOLUTION_FROM_THE_SERVICE"
}

Two rules follow from this. The challenge, hcg and hct values are needed twice: first in the task, then in authcode, and they have to be the same values. And the solution on its own is of no use: the server expects it inside the string, not separately.

Common Errors and Solutions

Error or problem Cause Solution
The service solves the captcha, but the Huawei server rejects the answer challenge, hcg and hct were not passed in the task Pass all three: this site runs the Enterprise version
Task creation error because of the site key The key was looked for in the page code, where it is not The key comes from the captcha/v4/captchaid request, given in the article
The answer arrives, but the server returns a validation error The task and the authcode ended up with different challenge, hcg and hct Get the triple once and use it in both places
The cscPreprocess request returns error 10000004 The pageToken and pageTokenKey pair was already used The values are one-time. Reload the page and take new ones
The cscPreprocess request returns error 10000001 A captchaType other than 1 was passed in the request body Only the value 1 is allowed here. This field is unrelated to the Yidun kind of check
The form is submitted without a solution The solution was written into the hidden captchaInfo field The field exists on the page, but the handler does not read it. Assemble authcode
The captcha does not appear at all The server decided the check was not needed This is normal. Handle both cases: with a captcha and without
The server replies that the parameters are stale Too much time passed between getting the triple and sending it Collect the parameters right before creating the task

The full list of error codes is on the Error codes page, linked below.