Skip to content

Siltaz/captcha-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Captcha Solver Service

This is a captcha solver service that takes an image URL, downloads it, and returns the recognized captcha from the image. It can also solves mathematical captcha as well. It uses Tesseract.js, a JavaScript library for optical character recognition (OCR), to recognize the text in the captcha image.

Prerequisites

Before running the service, make sure you have the following prerequisites installed:

  • Node.js (version 10 or higher)
  • NPM (Node Package Manager) or Yarn

Installation

  1. Clone the repository or download the source code.

  2. Navigate to the project directory.

  3. Install the dependencies by running the following command:

    npm install

    or

    yarn install

Configuration

The service uses environment variables for configuration. Create a .env file in the project directory and provide the following variables:

  • NODE_ENV (optional): Specifies the environment (e.g., development, production). If not specified, it defaults to development.
  • APP_PORT (optional): Specifies the port number on which the service should listen. If not specified, it defaults to 3000.

Usage

  1. Start the service by running the following command:

    npm start

    or

    yarn start
  2. Once the service is running, you can make a request to the /solve_captcha endpoint with the following query parameters:

    • uri: The URL of the captcha image to be solved.

    Example request:

    GET http://localhost:3000/solve_captcha?uri=https://raw.githubusercontent.com/Siltaz/captcha-solver/master/sample/mathematical_captcha.png
    
    Normal Captcha Mathematical Captcha

    The service will download the image, perform OCR using Tesseract.js, and return the recognized captcha in the response.

    Example response:

    {
      "result": "2"
    }

    Note: The example code provided assumes that the captcha is in the format of a mathematical expression that can be evaluated using eval(). You may need to modify the code according to your specific captcha format.

Error Handling

If any errors occur during the captcha solving process, the service will return an error response with the corresponding HTTP status code and error message.

Example error response:

{
  "error": "Failed to download image"
}

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! If you find any issues or want to enhance the functionality, feel free to open a pull request.

Credits

This service was created using the following libraries:

  • Express - Fast, unopinionated, minimalist web framework for Node.js.
  • Tesseract.js - JavaScript library for OCR (optical character recognition).
  • cors - Express middleware for enabling Cross-Origin Resource Sharing (CORS).
  • helmet - Express middleware for securing HTTP headers.
  • hpp - Express middleware for preventing HTTP parameter pollution attacks.

Contact

If you have any questions or suggestions, feel free to contact the project maintainer at [email protected].

About

Mathematical & Simple Captcha solver service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published