Coder Social home page Coder Social logo

2captcha / 2captcha-go Goto Github PK

View Code? Open in Web Editor NEW
93.0 3.0 38.0 49 KB

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

Home Page: https://2captcha.com

License: MIT License

Go 100.00%
captcha-solving captcha-breaking anticaptcha 2captcha anti-captcha bypass-invisible-recaptcha bypass-on-captcha-recaptcha bypass-recaptcha-v2 bypasscaptcha captcha-bypass

2captcha-go's Issues

Solve method doesn't return id of captcha task.

If you call client.Solve(req), you recieve token or error.
If you have desire to report captcha task - you have to use callback parameter to receive id of each task.
Simple solution would be to return id from this method too.

My implementation of this solution:

type SolveResult struct {
	ID    string
	Token string
}

func (c *Client) Solve(req Request) (SolveResult, error) {
	if c.Callback != "" {
		_, ok := req.Params["pingback"]
		if !ok {
			// set default pingback
			req.Params["pingback"] = c.Callback
		}
	}

	pingback, hasPingback := req.Params["pingback"]
	if pingback == "" {
		delete(req.Params, "pingback")
		hasPingback = false
	}

	_, ok := req.Params["soft_id"]
	if c.SoftId != 0 && !ok {
		req.Params["soft_id"] = strconv.FormatInt(int64(c.SoftId), 10)
	}

	id, err := c.Send(req)
	if err != nil {
		return SolveResult{}, err
	}

	// don't wait for result if Callback is used
	if hasPingback {
		return SolveResult{
			ID: id,
		}, nil
	}

	timeout := c.DefaultTimeout
	if req.Params["method"] == "userrecaptcha" {
		timeout = c.RecaptchaTimeout
	}

	result, resultErr := c.WaitForResult(id, timeout, c.PollingInterval)
	return SolveResult{ID: id, Token: result}, resultErr
}

strconv.FormatInt base is 64? really?

panic info:

	panic: strconv: illegal AppendInt/FormatInt base

code

	if c.Rows != 0 {
		req.Params["recaptcharows"] = strconv.FormatInt(int64(c.Rows), 64)
	}
	if c.Cols != 0 {
		req.Params["recaptchacols"] = strconv.FormatInt(int64(c.Cols), 64)
	}
	if c.PreviousId != 0 {
		req.Params["previousID"] = strconv.FormatInt(int64(c.PreviousId), 64)
	}

base64 encoded images for normal captcha not working

base64 encoded image is not working, I keep getting a error stating no image was sent to the API. I made sure to leave the Image parameter blank and only leave the base64 parameter but I still get this error.

Turnstile method appears to be broken.

Hello,
When attempting to use the cloudflare turnstile method to solve standalone turnstile captchas, it seems to always return an API error on the current version of the package.

for example, take the below code.

func handleTurnstileCaptcha() {
	cap := api2captcha.CloudflareTurnstile{SiteKey: "0x4AAAAAAADnPIDROrmt1Wwj", Url: "https://account.jagex.com"}
	solver := api2captcha.NewClient("CENSORED_API_KEY")
	solution, err := solver.Send(cap.ToRequest())
	if err != nil {
		zl.ErrorErr("Failed to solve captcha: ", err)
		log.Print(err)
		log.Print(cap.ToRequest())
		log.Print(solution)
	}
	if solution != "" {
		zl.Info("Got captcha solution: " + solution)
	}
}

This will always return api2captcha.ErrApi

2024/05/01 04:05:43 api2captcha: API error
2024/05/01 04:05:43 {map[method:turnstile pageurl:account.jagex.com sitekey:0x4AAAAAAADnPIDROrmt1Wwj] map[]}

When emulating the request this code sends in a http client we can see more details on the resulting error.

POST https://api.2captcha.com/createTask
Accept: application/json

{
    "clientKey":"CENSORED_API_KEY",
    "task": {
        "type":"TurnstileTaskProxyless",
        "websiteURL":"https://account.jagex.com",
        "websiteKey":"0x4AAAAAAADnPIDROrmt1Wwj"
    }
}
---
{
  "errorId": 110,
  "errorCode": "ERROR_BAD_PARAMETERS",
  "errorDescription": "The required captcha parameters in your reques are missing or have incorrect format. Please make sure your request payload has proper format for selected task type."
}

It seems the 2captcha api is expecting additional parameters, that the CloudflareTurnstile struct does not currently contain.

release is not actual

code have more actual version that release. For example method base64 for Normal captcha not found in release, but exist into last git commit !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.