📜 ⬆️ ⬇️

MintEye CAPTCHA solution in 23 lines of code

As an avid reader of HAD, I was interested in this post describing how to break the MintEye audio captcha . The graphic version also looked quite interesting, so I thought it would be fun to hack it.

Here is one example of the MintEye graphic captcha:



For the solution you just need to move the slider and choose the undistorted version of the image. In the comments on HAD there were some rather naive in my opinion proposals for captcha solutions based on the search for straight lines. However, such options do not work with examples similar to the one indicated above (i.e., containing a small number of straight lines).
')
After some thought, I found a good, reliable and, surprisingly, simple way to solve a captcha. Here is the entire implementation of it in Python:

import cv2 import sys import numpy as np import os import matplotlib.pyplot as plt if __name__ == '__main__': for dir in range(1,14): dir = str(dir) total_images = len(os.listdir(dir))+1 points_sob = [] for i in range(1,total_images): img = cv2.imread(dir+'/'+str(i)+'.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) sob = cv2.Sobel(gray, -1, 1, 1) points_sob.append(np.sum(sob)) x = range(1,total_images) res = np.argmin(points_sob)+1 print res plt.plot(res,points_sob[res-1], marker='o', color='r', ls='') plt.plot(x, points_sob) plt.savefig(dir+'.png') plt.show() 


(Please note that most of the code relates to the opening of the image and the construction of the schedule. Such functions as automatic analysis of images and returning the finished result will be left to spammers as homework).

The essence of the method is as follows: the larger the image is “twisted”, the longer the border. This can be seen in the picture above, but there is a more obvious example:



Note the increase in the length of the black rectangle. In order to use this, we need to calculate the sum of the lengths of the borders of the image. The simplest way to do this is to take a derivative of the image (in the proposed implementation, the Sobel operator is used) and add the results (we recommend reading the article on how the Sobel operator works). Then we simply select the image with the smallest "length of borders" - it will be the right answer.

The results are impressive, 13 of 13 I downloaded captcha were solved correctly in this way. These graphs show the number of the image on the X axis and the “border length” on the Y axis. The red dot indicates the correct answer.


Interestingly, often completely undistorted image on the graph is displayed as a peak. This usually means that we have missed with the correct answer to one picture left or right (which, however, is accepted by MintEye as the correct answer). This usually happens because in some places the undistorted image looks clearer and the borders stand out more precisely, which affects the final sum of lengths.

In conclusion, I would like to say that this CAPTCHA in its architecture is not resistant to cracking. A simple “twisting” of an image can always be easily noticed by the method described above, regardless of the original image.

Source: https://habr.com/ru/post/166307/


All Articles