This article is a continuation of my attempts to create an original captcha.
In the last article (
link ), I wanted to rely on neural networks to recognize patterns from users, and realized the frontend captcha: the actual ability to draw.
But judging by the two comments of the previous article, which gained the maximum number of pluses:
roman_tik +44
“Drawing several figures with a mouse is a crap for a real person ...”
knine +44
"Mona Lisa"
I concluded that my idea was a fiasco, besides, the server part of the script devoured many resources, and the neural network had to be trained for a long time before use. But the desire to invent a bicycle did not disappear anywhere, and (less than a week) I had a new idea for captcha.
A bit of theory.
The approach of modern captchas is to solve such a problem that a person can easily solve, but the machine will not solve (although, in the end, the “true” AI, having passed the Turing test, will still solve this problem). But instead, the main part of captcha generates symbols that a person supposedly must recognize, but the machine does not recognize. Modern technology with ease performs the reverse task (OCR) to complicate the work of the “recognizer”, they make noise in the captcha, distort simols, thereby worsening the recognizability indices by man.
Here, for example, captcha symbols: كلمة الت - they are not in the picture and they are not distorted, but without knowing this language a person will not understand that this will not pass the test, for a machine it is just an exact set of characters. What is it for? In addition, the word “car” is one thing, and the car itself is another. The word “car” for a car is familiar, but the concept of a car for it does not exist.
How does a person learn? We show him a car and explain that it is a “car”, show him a horse and tell him that it is a horse (as well as an animal, an artiodactyl, a living creature, etc.). For a machine, such a task is also partially subservient. And yet, that the car, that the horse is a means of transportation - for human thinking, this conclusion will be obvious.
So, it is worthwhile to force the machine to operate not with symbols, but, for example, with images that the machine does not “understand”. It would seem that there is a difference, and the difference is that the characters in the alphabet are always a finite number (even of hieroglyphs), and the images are infinite. Although it may seem that there are as many images as there are words, this is not so. For example:

- this is the key;

- and this is the key;

- again the key;

- they beat the keys again (why would they beat the keys - it would be better to open the doors with them).

- there is no such word in Russian at all.
Idea
Combining this theory, with the developments from the first article, I came to the conclusion to display pictures and give the user to find the necessary using figurative thinking.
But stop, this idea is not new - such captcha already exists. But they have a disadvantage in order not to succumb to cracking through brute force, there must be a large number of pictures on the server.
I decided to limit myself to a small number of pictures. To this end, in order to eliminate brute force, I decided to superimpose pictures on each other. Can you tell the car from the back of a horse? I think yes.
It remains to think of sticking all the pictures into one and sending coordinates to the server instead of the picture number (hence, expanding the range of possible response values) of the correct picture.
')
Implementation
For the day after scribbling the code, I got this pretty captcha:

It is quite simple to generate such a captcha, in my version there are only 10 types of objects with 3 variations of the subject of each type.
When creating a picture of random items, we remember the coordinates of the correct answers and voila; when checking the user's answer, we check the occurrence of the marked coordinates in the original ones.
<?php if (isset($_POST['check']) && isset($_POST['answer']) && $_POST['check'] == 1){ $answerUser = json_decode($_POST['answer']); $answerCaptcha = unserialize($_SESSION['nncaptcha']); echo json_encode(array('checked'=>$answerCaptcha->checked($answerUser) )); exit(); } ?>
That's the whole test.
In the live captcha you can look
here . (carefully weak hosting!)
This is the simplest captcha from this area, you can easily increase the number of images (both on captcha and in the system), you can not resize the mini-pictures in the same way, rotate pictures to different angles, do the same with the text.
Practically all this is already implemented in this captcha. The script uses the usual GD, you can rewrite it on imagick - there will be even more possibilities (for example, in GD there is no regular functionality to rotate at a certain angle of the picture). If, suddenly, to whom it will be interesting, in the next article I can lay out the source code with explanations (PHP 5.3).
UPD1:Passage statistics:
- 50.9% - Successfully passed
- 1.2% - Time Out
- 47.9% - Wrong
Total samples (for now): 12627
Unique visitors: about 6000
Soon I will update the captcha on the advice of commentators (
for example, this one ) - then I will reset the statistics.