Giter Site home page Giter Site logo

imssm99 / illusion-captcha Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 559 KB

Applying optical illusion to CAPTCHA in order to improve usability for humans

License: MIT License

Python 73.90% JavaScript 6.21% HTML 19.02% Shell 0.88%
captcha fastapi opencv optical-illusion python

illusion-captcha's Introduction

Illusion CAPTCHA

illusion_captcha

Overview

You must have met annoying CAPTCHAs before. In general, optical illusions arise from the complex operation of the human brain, so they can be difficult for machines to distinguish.

This project applies optical illusion to CAPTCHA in order to improve usability for humans.

Getting Started

Prerequisites

  • Tested on Python 3.10, 3.11
  • run pip3 install -r requirements.txt to install dependencies
  • Or you can use poetry

Run Example

  • Run run_example.sh to start API and example server
  • You can get implemented example at http://localhost:8000
  • Or you can apply it yourself

CAPTCHA API Server

  • Set SERVER_URL in api/static/illusion-captcha.js to API server
  • uvicorn api:app --port=8001 to start server

Frontend Page

You can implement like other CAPTCHA providers (e.g. reCAPTCHA, hCAPTCHA) by simply adding div with id illusion_captcha and load script, and install it on div.

<div id="illusion_captcha"></div>

<script src="http://[API_SERVER]/static/illusion-captcha.js"></script>

function on_success(token) {
    location.href = "/protected?token=" + token;
}
illusion_captcha_install(300, on_success)

Backend Server

You can verify client with sending request API server with token.

Features

Illusions are generated dynamically and randomly with OpenCV.

Multiple Shapes

  • Delboeuf, simulaneous contrast can generate circle or rectangle
circle rectangle
delboeuf_circle delboeuf_rect

Number of Images

  • Currently it generates 2~4 images in delboeuf, ebbinghaus, simulaneous contrast
  • Other illusions generate 2 images
2 4
ebbinghaus_2 ebbinghaus_4

Random Colors

  • Randomize colors
  • In simulaneous contrast, generate color in HSV and adjust value (brightness)
contrast1 contrast2

Logic

  • Index page shows random Illusion CAPTCHA problems
  • You can't access /protected without solving CAPTCHA
  • If clicked image is correct, then you can access protected page
  • Token is invalidated after accessing protected page
Forbidden Page Protected Page Fail
forbidden protected failed

How this works

CAPTCHA

CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a type of security measure known as challenge-response authentication.

Optical Illusion

Optical Illusion is an illusion caused by the visual system and characterized by a visual percept that arguably appers to differ from reality.

Type Image Description
Delboeuf delboeuf Inner circle on the right looks bigger
Ebbinghaus ebbinghaus Inner circle on the left looks bigger
Müller-Lyer muller-lyer Line on the left looks longer
Ponzo ponzo Line on the left looks longer
Simulaneous Contrast contrast Inner rectangle on the right looks darker

Future Enhancements

  • Improve API server to use in-memory database like Redis
  • Add site key, secret check logic to verify client and server
  • Implement more optical illusions
  • Add post processing (image filters)

License

Distributed under the MIT License. See LICENSE for more information.

Dependencies

  • FastAPI for api server
  • OpenCV for generating illusion images
  • NumPy for numerical operations

References

illusion-captcha's People

Contributors

imssm99 avatar

Stargazers

Jooney Han avatar

Watchers

 avatar

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.