AwsWafCaptcha: solving AWS WAF
Create the task with the createTask method and get the result with the getTaskResult method.
The task type types
that we support:
AntiAwsWafTask
this task type require your own proxies.AntiAwsWafTaskProxyLess
this task type don’t require your own proxies.
Create Task
Create a recognition task with the createTask method.
Task Object Structure
Properties | Type | Required | Description |
---|---|---|---|
type | String | Required | AntiAwsWafTask AntiAwsWafTaskProxyLess |
proxy | String | Optional | Learn Using proxies |
websiteURL | String | Required | The url of the page that returns captcha related information |
awsKey | String | Optional | The key value returned by the captcha page |
awsIv | String | Optional | The iv value returned by the captcha page |
awsContext | String | Optional | The context value returned by the captcha page |
awsChallengeJS | String | Optional | The challenge.js link returned by the captcha page |
awsApiJs | String | Optional | The jsapi.js link returned by the captcha page |
awsProblemUrl | String | Optional | The problem endpoint url containing keywords like problem , num_solutions_required , etc. |
awsApiKey | String | Optional | The api_key value of the problem endpoint |
awsExistingToken | String | Optional | The aws-waf-token used for the last verification |
If you are unsure about which parameters to pass to capsolver, please refer to the following scenarios for different parameter combinations. If your situation is not covered, please contact our customer service for assistance.
Situation | Passing Parameters | Prerequisites |
---|---|---|
Situation 1 | websiteURL | The aws captcha page response code may be 405, and the following parameters can be found in the html:window.gokuProps = {"key":"AQID...","iv":"A6we...","context":"rGXm.."} |
Situation 2 | websiteURL awsKey awsIv awsContext awsChallengeJS | Under the precondition of situation 1, if capsolver returns an error message:Captcha render unexpect status code XXX, please pass in the awsKey, awsIv, awsContext and awsChallengeJs parameters , Indicates that the server did not trigger the captcha. Please manually parse the key, iv, and context parameters and pass them to capsolver.Special attention If you receive an error message saying timeout metering, your parameters have expired, please update awsKey, awsIv, awsContext or awsChallengeJS. , it indicates that the four parameters you provided do not correspond to each other or have expired. It is recommended to parse all parameters in real-time for each request. |
Situation 3-1 | websiteURL awsChallengeJS | When the page cannot find key, iv, context, but has challenge.js, pass challenge.js to capsolver as the value of awsChallengeJS. |
Situation 3-2 | websiteURL awsApiJs | Based on situation 3-1, if it is not clear where challenge.js comes from, but the page has jsapi.js, it means that challenge.js is assembled from the code of jsapi.js, then jsapi.js can be directly passed to capsolver as the value of awsApiJs. |
Situation 4 | websiteURL awsProblemUrl | In special cases, when the page cannot find key, iv, context, challenge.js, and only has captcha.js, you need to pass the problem endpoint url to capsolver. awsProblemUrl should contain values such as problem and num_solutions_required . These values can be found by searching for visualSolutionsRequired in the page html. awsProblemUrl complete example: https://ait.2608283a.us-east-1.captcha.awswaf.com/ait/ait/ait/problem?kind=visual&domain=www.amazon.com&locale=en-us&problem=gridcaptcha-5-0.15-0&num_solutions_required=2 |
Situation 5 | websiteURL awsApiKey awsApiJs awsExistingToken | This usually occurs in situations requiring secondary verification. The problem endpoint contains an api_key (whose value is typically constant for each website) as awsApiKey . The page has a jsapi.js as awsApiJs , and the aws-waf-token from the previous verification is passed to capsolver as awsExistingToken |
Example Request
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "AntiAwsWafTask", // AntiAwsWafTaskProxyLess
"websiteURL": "https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest", // Required
"awsKey": "AQIDAHjcYu/GjX+QlghicBg......shMIKvZswZemrVVqA==", // Optional
"awsIv": "CgAAFDIlckAAAAid", // Optional
"awsContext": "7DhQfG5CmoY90ZdxdHCi8WtJ3z......njNKULdcUUVEtxTk=", // Optional
"awsChallengeJS": "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb......a6c832/challenge.js", // Optional
"awsApiJs": "https://9175c2fd4189.edge.captcha-sdk.awswaf.com/9175c2fd4189/jsapi.js", // Optional
"awsProblemUrl": "https://ait...awswaf.com/ait/ait/ait/problem?kind=visual&...&problem=gridcaptcha-5-0.1-0&num_solutions_required=2", // Optional
"awsApiKey": "Sps+L2gV...", // Optional
"awsExistingToken": "5na16dg6-216a-...", // Optional
"proxy": "http:ip:port:user:pass" // socks5:ip:port:user:pass
}
}
After you submit the task to us, you should receive in the response a ‘taskId’ if it’s successful. Please read errorCode: full list of errors if you didn’t receive the task id. For more information, you can also refer to this blog post How to solve aws amazon captcha token
Example Response
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}
Getting Results
After you have the taskId, you need to submit the taskId to retrieve the solution. Response structure is explained in getTaskResult.
Depending on the system load, you will get the results within the interval of 5s
to 30s
Example Request
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}
Example Response
{
"errorId": 0,
"taskId": "646825ef-9547-4a29-9a05-50a6265f9d8a",
"status": "ready",
"solution": {
"cookie": "223d1f60-0e9f-4238-ac0a-e766b15a778e:EQoAf0APpGIKAAAA:AJam3OWpff1VgKIJxH4lGMMHxPVQ0q0R3CNtgcMbR4VvnIBSpgt1Otbax4kuqrgkEp0nFKanO5oPtwt9+Butf7lt0JNe4rZQwZ5IrEnkXvyeZQPaCFshHOISAFLTX7AWHldEXFlZEg7DjIc="
}
}
Use SDK Request
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "AntiAwsWafTask",
"websiteURL": "https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest",
"proxy": "ip:port:user:pass"
})
Sample Code
# pip install requests
import requests
import time
api_key = "YOUR_API_KEY" # TODO: your api key of capsolver
site_url = "https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest" # TODO: page url of your site
def capsolver():
payload = {
"clientKey": api_key,
"task": {
"type": 'AntiAwsWafTaskProxyLess',
"websiteURL": site_url
}
}
res = requests.post("https://api.capsolver.com/createTask", json=payload)
resp = res.json()
task_id = resp.get("taskId")
if not task_id:
print("Failed to create task:", res.text)
return
print(f"Got taskId: {task_id} / Getting result...")
while True:
time.sleep(1) # delay
payload = {"clientKey": api_key, "taskId": task_id}
res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
resp = res.json()
status = resp.get("status")
if status == "ready":
return resp.get("solution", {}).get('cookie')
if status == "failed" or resp.get("errorId"):
print("Solve failed! response:", res.text)
return
token = capsolver()
print(token)