Skip to content

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

License

Notifications You must be signed in to change notification settings

imssm99/illusion-captcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published