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.
- Tested on Python 3.10, 3.11
- run
pip3 install -r requirements.txt
to install dependencies - Or you can use poetry
- 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
- Set
SERVER_URL
inapi/static/illusion-captcha.js
to API server uvicorn api:app --port=8001
to start server
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)
You can verify client with sending request API server with token.
Illusions are generated dynamically and randomly with OpenCV.
- Delboeuf, simulaneous contrast can generate circle or rectangle
circle | rectangle |
---|---|
- Currently it generates 2~4 images in delboeuf, ebbinghaus, simulaneous contrast
- Other illusions generate 2 images
2 | 4 |
---|---|
- Randomize colors
- In simulaneous contrast, generate color in HSV and adjust value (brightness)
- 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 |
---|---|---|
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 is an illusion caused by the visual system and characterized by a visual percept that arguably appers to differ from reality.
- 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)
Distributed under the MIT License. See LICENSE
for more information.
- What is CAPTCHA?
- Optical illusion
- hCAPTCHA
- Pyllusion (PIP implementation of illusions)