Bypass captcha using Go

CAPTCHAFORUM

Administrator
1663307432617.png

Solve captcha with Go lang module online.

Golang package for easy integration with the API of 2Captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.

1663307479010.png

Installation
The script package can be installed using the package installer or manually.

GitHub
To install the api client, use this:

Code:
go get -u github.com/2captcha/2captcha-go

We invite you to explore our GitHub repository where you can find libraries and modules for easy integration with our API.


Configuration
Client instance can be created like this:

Code:
client := api2captcha.NewClient('YOUR_API_KEY')

You also have the ability to customize some of the options for the created instance:

Code:
client.SoftId = 123
client.Callback = "https://your.site/result-receiver"
client.DefaultTimeout = 120
client.RecaptchaTimeout = 600
client.PollingInterval = 100

1663307723311.png

Solve captcha
When you submit any image-based captcha use can provide additional options to help 2Captcha workers to solve it properly

Client instance options:
View attachment 1924

IMPORTANT: once callback is defined for Client instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL. To get the answer manually use getResult method


Basic example
Example below shows a basic solver call example with error handling.
Code:
cap := api2captcha.Normal{
   File: "/path/to/normal.jpg",
}

code, err := client.Solve(cap.ToRequest())
if err != nil {
  if err == api2captcha.ErrTimeout {
    log.Fatal("Timeout");
  } else if err == api2captcha.ErrApi {
    log.Fatal("API error");
  } else if err == api2captcha.ErrNetwork {
    log.Fatal("Network error");
  } else {
    log.Fatal(err);
  }
}
fmt.Println("code "+code)

Normal Captcha
To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image.

Code:
cap := api2captcha.Normal{
    File: "/path/to/normal.jpg",
    Numeric: 4,
    MinLen: 4,
    MaxLen: 20,
    Phrase: true,
    CaseSensitive: true,
    Lang: "en",
    HintImgFile: "/path/to/hint.jpg",
    HintText: "Type red symbols",
}


Text Captcha
This method can be used to bypass a captcha that requires to answer a question provided in clear text.
Code:
cap := api2captcha.Text{
    Text: "If tomorrow is Saturday, what day is today?",
    Lang: "en",
}

reCAPTCHA v2
Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
Code:
cap := api2captcha.ReCaptcha{
    SiteKey: "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-",
    Url: "https://mysite.com/page/with/recaptcha",
    Invisible: true,
    Action: "verify",
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

reCAPTCHA v3
This method provides reCAPTCHA V3 solver and returns a token.
Code:
cap := api2captcha.ReCaptcha{
    SiteKey: "6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-",
    Url: "https://mysite.com/page/with/recaptcha",
    Version: "v3",
    Action: "verify",
    Score: 0.3,
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

FunCaptcha
FunCaptcha (Arkoselabs) solving method. Returns a token.
Code:
cap := api2captcha.FunCaptcha{
    SiteKey: "69A21A01-CC7B-B9C6-0F9A-E7FA06677FFC",
    Url: "https://mysite.com/page/with/funcaptcha",
    Surl: "https://client-api.arkoselabs.com",
    UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36",
    Data: map[string]string{"anyKey":"anyValue"},  
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

GeeTest
Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.
Code:
cap := api2captcha.GeeTest{
    GT: "f2ae6cadcf7886856696502e1d55e00c",
    ApiServer: "api-na.geetest.com",
    Challenge: "12345678abc90123d45678ef90123a456b",
    Url: "https://mysite.com/captcha.html",
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

hCaptcha
Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.
Code:
cap := api2captcha.HCaptcha{
    SiteKey: "10000000-ffff-ffff-ffff-000000000001",
    Url: "https://mysite.com/captcha.html",  
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

KeyCaptcha
Token-based method to solve KeyCaptcha.
Code:
cap := api2captcha.KeyCaptcha{
    UserId: 10,
    SessionId: "493e52c37c10c2bcdf4a00cbc9ccd1e8",
    WebServerSign: "9006dc725760858e4c0715b835472f22",
    WebServerSign2: "9006dc725760858e4c0715b835472f22",
    Url: "https://www.keycaptcha.ru/demo-magnetic/",  
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

Capy
Token-based method to bypass Capy puzzle captcha.
Code:
cap := api2captcha.Capy{
    SiteKey: "PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v",
    Url: "https://www.mysite.com/captcha/",  
}
req := cap.ToRequest()
req.SetProxy("HTTPS", "login:password@IP_address:PORT")
code, err := client.solve(req)

Grid
Grid method is originally called Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes.
Code:
cap := api2captcha.Grid{
    File: "path/to/captcha.jpg",
    Rows: 3,
    Cols: 3,
    PreviousId: 0,
    CanSkip: false,
    Lang: "en",
    HintImageFile: "path/to/hint.jpg",
    HintText: "Select all images with an Orange",
}

Canvas
Canvas method can be used when you need to draw a line around an object on image. Returns a set of points' coordinates to draw a polygon.
Code:
cap := api2captcha.Canvas{
    File: "path/to/captcha.jpg",
    PreviousId: 0,
    CanSkip: false,
    Lang: "en",
    HintImageFile: "path/to/hint.jpg",
    HintText: "Draw around apple",
}

ClickCaptcha
ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.
Code:
cap := api2captcha.Coordinates{
    File: "path/to/captcha.jpg",
    Lang: "en",
    HintImageFile: "path/to/hint.jpg",
    HintText: "Connect the dots",
}

Rotate
This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle.
Code:
cap := api2captcha.Rotate{
    File: "path/to/captcha.jpg",
    Angle: 40,
    Lang: "en",
    HintImageFile: "path/to/hint.jpg",
    HintText: "Put the images in the correct way",
}



Other methods
These methods can be used for manual captcha submission and answer polling.

send / getResult
These methods can be used for manual captcha submission and answer polling.

Code:
id, err := client.Send(cap.ToRequest())
if err != nil {
   log.Fatal(err);
}

time.Sleep(10 * time.Second)

code, err := client.GetResult(id)
if err != nil {
   log.Fatal(err);
}

if code == nil {
   log.Fatal("Not ready")
}

fmt.Println("code "+*code)

balance
Use this method to get your account's balance.

Code:
balance, err := client.GetBalance()
if err != nil {
   log.Fatal(err);
}

report
Use this method to report good or bad captcha answer.

Code:
err := client.Report(id, true) // solved correctly
err := client.Report(id, false) // solved incorrectly


Go to 2captcha.com
 
Last edited: