Skip to content

Commit

Permalink
Added AmazonWAF method (#17)
Browse files Browse the repository at this point in the history
* Added AmazonWAF method

* fix typo

* add new params

---------

Co-authored-by: Badichan Polina <[email protected]>
  • Loading branch information
PBadicean and PBadicean authored Apr 28, 2023
1 parent 529439b commit af21cbd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions api2captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"},
Expand Down

0 comments on commit af21cbd

Please sign in to comment.