From af21cbd1c208f081b179b0bd46027b547731b7ee Mon Sep 17 00:00:00 2001 From: PBadicean Date: Fri, 28 Apr 2023 11:53:25 +0300 Subject: [PATCH] Added AmazonWAF method (#17) * Added AmazonWAF method * fix typo * add new params --------- Co-authored-by: Badichan Polina --- README.md | 16 ++++++++++++++++ api2captcha.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/README.md b/README.md index f42dc1d..3ff2a8f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The easiest way to quickly integrate [2Captcha] into your code to automate solvi - [Canvas](#canvas) - [ClickCaptcha](#clickcaptcha) - [Rotate](#rotate) + - [AmazonWAF](#amazon-waf) - [CloudflareTurnstile](#cloudflare-turnstile) - [Lemin Cropped Captcha](#lemin-cropped-captcha) - [GeeTestV4](#geetestv4) @@ -326,6 +327,21 @@ cap := api2captcha.CloudflareTurnstile{ } ``` +### Amazon WAF +Use this method to solve Amazon WAF Captcha also known as AWS WAF Captcha is a part of Intelligent threat mitigation for Amazon AWS. Returns JSON with the token. + +```go +cap := api2captcha.AmazonWAF { + Iv: "CgAHbCe2GgAAAAAj", + SiteKey: "0x1AAAAAAAAkg0s2VIOD34y5", + Url: "https://non-existent-example.execute-api.us-east-1.amazonaws.com/latest", + Context: "9BUgmlm48F92WUoqv97a49ZuEJJ50TCk9MVr3C7WMtQ0X6flVbufM4n8mjFLmbLVAPgaQ1Jydeaja94iAS49ljb", + ChallengeScript: "https://41bcdd4fb3cb.610cd090.us-east-1.token.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/challenge.js" + CaptchaScript: "https://41bcdd4fb3cb.610cd090.us-east-1.captcha.awswaf.com/41bcdd4fb3cb/0d21de737ccb/cd77baa6c832/captcha.js" + +} +``` + ## Other methods ### Send / GetResult diff --git a/api2captcha.go b/api2captcha.go index ead4646..0ab014a 100644 --- a/api2captcha.go +++ b/api2captcha.go @@ -143,6 +143,15 @@ type ( Lang string } + AmazonWAF struct { + Iv string + SiteKey string + Url string + Context string + ChallengeScript string + CaptchaScript string + } + GeeTestV4 struct { CaptchaId string Url string @@ -771,6 +780,38 @@ func (c *Text) ToRequest() Request { return req } +func (c * AmazonWAF ) ToRequest() Request { + req := Request{ + Params: map[string]string{"method":"amazon_waf"}, + } + + if c.Iv != "" { + req.Params["iv"] = c.Iv + } + + if c.SiteKey != "" { + req.Params["sitekey"] = c.SiteKey + } + + if c.Url != "" { + req.Params["pageurl"] = c.Url + } + + if c.Context != "" { + req.Params["context"] = c.Context + } + + if c.ChallengeScript != "" { + req.Params["challenge_script"] = c.ChallengeScript + } + + if c.CaptchaScript != "" { + req.Params["captcha_script"] = c.CaptchaScript + } + + return req +} + func (c *GeeTestV4) ToRequest() Request { req := Request{ Params: map[string]string{"method": "geetest_v4"},