Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/griffinmc22/gocaptcha

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/griffinmc22/gocaptcha

  • v0.0.0-20220126124404-0d4b2e220163
  • Source
  • Go
  • Socket score

Version published
Created
Source

gocaptcha

An API wrapper for popular captcha solvers such as AntiCaptcha and 2Captcha in Golang

Installation

Run the following command in your project folder: go get github.com/justhyped/gocaptcha

Support

Type2CaptchaAntiCaptchaCapMonster Cloud
RecaptchaV2
RecaptchaV3
Image Recaptcha
HCaptcha

Software like XEVil and CapMonster are also supported, but it gets a little trickier. Such software runs on a local ip:port so you must specify that with CustomServiceUrl (don't include the protocol as it defaults to http)

If you intend to use XEVil or CapMonster with this program you should check which API it supports (Either 2Captcha or AntiCaptcha). Don't forget to add firewall rules and host the captcha software on a public port when using XEVil or CapMonster between different machines.

Usage

RecaptchaV2

    payload := gocaptcha.RecaptchaV2Payload{
	EndpointUrl:   "https://www.google.com/recaptcha/api2/demo",
        EndpointKey:   "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
        ServiceApiKey: "key",
        ServiceName:   "2Captcha",
	}
	
    captcha, err := gocaptcha.SolveRecaptchaV2(&payload)
    
    // use captcha.ReportGoodRecaptcha() or captcha.ReportBadCaptcha() to help the provider improve their services.

These are all supported variables to use in RecaptchaV2Payload:

    	// This is the endpoint that has Recaptcha Protection
EndpointUrl string

// This is the Recaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string

// The API key for your captcha service
ServiceApiKey string

// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string

// Enable if endpoint has invisible Recaptcha V2
IsInvisibleCaptcha bool

// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string

// The time to wait before starting to poll result
InitialWaitTime int

// The time to wait between polling results
PollInterval int

// Max amount of poll attempts
MaxRetries int

RecaptchaV3

    payload := gocaptcha.RecaptchaV3Payload{
EndpointUrl:   "https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php",
EndpointKey:   "6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696",
ServiceApiKey: "key",
ServiceName:   "2Captcha",
Action:        "examples/v3scores",
}

captcha, err := gocaptcha.SolveRecaptchaV3(&payload)

// use captcha.ReportGoodRecaptcha() or captcha.ReportBadCaptcha() to help the provider improve their services.

These are all supported variables to use in RecaptchaV3Payload:

// This is the endpoint that has Recaptcha Protection
EndpointUrl string

// This is the Recaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string

// The API key for your captcha service
ServiceApiKey string

// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string

// The action name of the recaptcha, you can find it in source code of site
Action string

// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string

// Set to true if it's V3 Enterprise
IsEnterprise bool

// Defaults to 0.3, accepted values are 0.3, 0.6, 0.9
MinScore float32

// The time to wait before starting to poll result
InitialWaitTime int

// The time to wait between polling results
PollInterval int

// Max amount of poll attempts
MaxRetries int

HCaptcha

    payload := gocaptcha.HCaptchaPayload{
        EndpointUrl:   "https://www.hcaptcha.com/",
        EndpointKey:   "00000000-0000-0000-0000-000000000000",
        ServiceApiKey: "key",
        ServiceName:   "2Captcha",
    }

    captcha, err := gocaptcha.SolveHCaptcha(&payload)

    // use captcha.ReportGoodRecaptcha() or captcha.ReportBadCaptcha() to help the provider improve their services.

These are all supported variables to use in HCaptchaPayload:

// This is the endpoint that has Recaptcha Protection
EndpointUrl string

// This is the HCaptcha Key
// Can be found on the Endpoint URL page
EndpointKey string

// The API key for your captcha service
ServiceApiKey string

// The name of the captcha service
// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
ServiceName string

// Set this in case you're using a custom solver like CapMonster (not cloud)
CustomServiceUrl string

// The time to wait before starting to poll result
InitialWaitTime int

// The time to wait between polling results
PollInterval int

// Max amount of poll attempts
MaxRetries int

Image Captcha

payload := gocaptcha.ImageCaptchaPayload{
    ServiceApiKey: "key", // your api key
    ServiceName:   "2Captcha", // the provider, can be 2Captcha, AntiCaptcha or Capmonster Cloud
    Base64String:  imageBase64, // the image converted to a base64 string
}

captcha, err := gocaptcha.SolveImageCaptcha(&payload)

// don't mind the naming, this also works for image captcha's.
// use captcha.ReportGoodRecaptcha() or captcha.ReportBadCaptcha() to help the provider improve their services.

These are all supported variables to use in ImageCaptchaPayload:

    // This is the base64 that represents the image captcha
	Base64String string

	// The API key for your captcha service
	ServiceApiKey string

	// The name of the captcha service
	// Can be AntiCaptcha, 2Captcha or CapMonster Cloud
	ServiceName string

	// Set this in case you're using a custom solver like CapMonster (not cloud)
	CustomServiceUrl string

	// Set to true if captcha is case sensitive
	CaseSensitive bool

	// Set this if the human solver needs additional information
	// about how to solve the captcha
	InstructionsForSolver string

	// The time to wait before starting to poll result
	InitialWaitTime int

	// The time to wait between polling results
	PollInterval int

	// Max amount of poll attempts
	MaxRetries int

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

FAQs

Package last updated on 26 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc