amazoncaptcha

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 15 Imported by: 0

README

Amazon Captcha Solver

AmazonCaptcha is a Go library that provides a simple and easy-to-use API for solving text captchas used by Amazon. This library simplifies the process of captcha resolution and enables fast integration into your applications, making it a powerful tool for your development needs.

Installation

To use this library, you need to have Go installed on your system. You can then install it using the following command:

go get github.com/gopkg-dev/amazoncaptcha

Usage

Using this library is simple:

package main

import (
	"fmt"
	"os"
	"github.com/gopkg-dev/amazoncaptcha"
)

func main() {
	file, err := os.Open("captcha.jpg")
	if err != nil {
		fmt.Printf("Error opening captcha file: %v", err)
		return
	}
	defer file.Close()

	result, err := amazoncaptcha.Solve(file)
	if err != nil {
		fmt.Printf("Error solving captcha: %v", err)
		return
	}

	fmt.Printf("Captcha solution: %s\n", result)
}

In this example, we load a captcha image from a file ("captcha.jpg") and solve it using the default solver provided by this library. The result is printed to the console.

Training

Training

This library also includes a custom training tool for solving simple captchas. Our tool is designed to simplify the process of training machine learning models for captcha solving, by automating the collection and extraction of relevant features from large datasets.

With our training tool, you can:

  • Automatically collect large volumes of captcha images from multiple sources
  • Extract and preprocess relevant features from these images
  • Train and optimize your own machine learning models

By using this tool, you can quickly create custom captcha solvers optimized for your specific use case.

Note: The use of our tool to exploit or misuse captchas in any way may be against the terms of service of websites that use them, and is not endorsed by this library or its developers.

Testing

This project provides a set of tests to solve Amazon CAPTCHA problems. It includes the following tests:

  1. TestDownloadCaptchaImages: Downloads CAPTCHAs from the Amazon CAPTCHA service and saves them to disk if the letters haven't appeared in the dataset before.
  2. TestSplitAndSaveCaptchaByLetter: Splits multiple Amazon CAPTCHAs stored in a directory into individual letters and saves them to separate directories for subsequent machine learning modeling.
  3. TestExtractFeatures: Calculates image features for each letter extracted from split images, then saves those features to JSON files for further use.
  4. TestSolveBatch: Performs batch testing on multiple Amazon CAPTCHAs stored in a directory. Each CAPTCHA is solved using the Solve function and compared against the expected answer to determine its accuracy.
=== RUN   TestSolveBatch
    amazoncaptcha_test.go:79: Processing 15316 files with 50 workers...
    amazoncaptcha_test.go:118: Processing file AAYFJR.jpg... success rate: 100.00%, progress: 0.01%
    amazoncaptcha_test.go:118: Processing file AAPTPP.jpg... success rate: 100.00%, progress: 0.01%
    amazoncaptcha_test.go:118: Processing file AAHXBP.jpg... success rate: 100.00%, progress: 0.02%
    amazoncaptcha_test.go:118: Processing file AAGMCR.jpg... success rate: 100.00%, progress: 0.03%
    amazoncaptcha_test.go:118: Processing file AAHNGN.jpg... success rate: 100.00%, progress: 0.03%
    ................
    amazoncaptcha_test.go:118: Processing file YYRBLN.jpg... success rate: 99.54%, progress: 99.98%
    amazoncaptcha_test.go:118: Processing file YYRMEU.jpg... success rate: 99.54%, progress: 99.99%
    amazoncaptcha_test.go:118: Processing file YYRCNK.jpg... success rate: 99.55%, progress: 99.99%
    amazoncaptcha_test.go:118: Processing file YYYTEM.jpg... success rate: 99.55%, progress: 100.00%
    amazoncaptcha_test.go:125: Processed 15386 files with success rate: 15316/15386 (99.55%)
    amazoncaptcha_test.go:128: Failed to solve captcha in the following files:
    amazoncaptcha_test.go:130: captchas/AGYHRF.jpg -> AGYHR-
    amazoncaptcha_test.go:130: captchas/AJBLFX.jpg -> AJBL-X
    amazoncaptcha_test.go:130: captchas/AJLRFY.jpg -> AJLR-Y
    amazoncaptcha_test.go:130: captchas/APNGHF.jpg -> APNGH-
    ................
--- PASS: TestSolveBatch (15.28s)
PASS

Notes

  • This project aims to provide a set of testing tools to solve Amazon CAPTCHA problems but does not guarantee the accuracy of the test results.
  • When using this project, please be respectful of Amazon's terms of service and privacy policy.

Acknowledgments

We would like to thank the open-source community for providing inspiration and resources for this project, including a-maliarov/amazoncaptcha which served as a reference for our development. We are grateful for their contributions to the field of captcha solving, and we hope that our library can help further advance this technology.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

View Source
const MaximumLetterLength = 33

MaximumLetterLength Define a constant MaximumLetterLength with a value of 33, representing the maximum width of a single letter.

View Source
const MinimumLetterLength = 14

MinimumLetterLength Define a constant MinimumLetterLength with a value of 14, representing the minimum width of the first letter. If the width of the first letter is less than this value, all letters will be replaced with blank letters.

View Source
const MonoWeight = 1

MonoWeight Define a constant MonoWeight with a value of 1, representing the threshold used to convert grayscale images to binary images.

Variables

This section is empty.

Functions

func CutTheWhite

func CutTheWhite(img *image.Gray) *image.Gray

CutTheWhite removes the white border from a grayscale image by cropping it.

func ExtractFeatures

func ExtractFeatures(img *image.Gray) (string, error)

ExtractFeatures extracts image features and returns a binary string.

func FindLetterBoxes

func FindLetterBoxes(img *image.Gray, maxLength int) []image.Rectangle

FindLetterBoxes finds and segments characters in a captcha image. The maxLength parameter specifies the maximum allowed width of a single character.

func FindLetters

func FindLetters(r io.Reader) ([]*image.Gray, error)

FindLetters attempts to locate the letters in a captcha image and returns a slice of grayscale letter images. It takes an io.Reader as input, which should contain a valid captcha image. It returns a slice of grayscale letter images and an error if the letter extraction process fails.

func Grayscale

func Grayscale(img image.Image) *image.Gray

Grayscale generates a grayscale version of an image.

func MergeHorizontally

func MergeHorizontally(img1, img2 *image.Gray) (*image.Gray, error)

MergeHorizontally merges two grayscale images horizontally. It returns the merged image and an error if the input images are not compatible.

func MonoChrome

func MonoChrome(img *image.Gray, threshold uint8) *image.Gray

MonoChrome generates a monochrome (binary) version of a grayscale image. The threshold parameter is used to determine which pixels are converted to black and which are converted to white.

func SaveGrayToPNG

func SaveGrayToPNG(fileName string, img *image.Gray) error

SaveGrayToPNG saves a grayscale image to a PNG file.

func Solve

func Solve(r io.Reader) (string, error)

Solve attempts to solve a captcha image and returns a list of character images.

func SolveFromImageFile added in v1.0.1

func SolveFromImageFile(filepath string) (string, error)

SolveFromImageFile takes a file path of an image file as input, opens the file, and processes the data from the image file using the Solve function. It returns the processed result as a string and an error if any error occurs during the process.

func SolveFromURL added in v1.0.1

func SolveFromURL(url string) (string, error)

SolveFromURL takes a URL string as input, makes an HTTP request to the given URL, and processes the data from the URL using the Solve function. It returns the processed result as a string and an error if any error occurs during the process.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL