How to Crack Sliding Puzzle Captchas with Simple Python Image Analysis
This article explores the security weaknesses of sliding puzzle captchas by collecting multiple samples, performing qualitative and quantitative image analysis, and presenting a Python script that automatically identifies the puzzle gap using pixel differences and statistical thresholds.
Abstract
Captchas serve as a tool to distinguish humans from bots, but traditional text-based captchas are no longer secure, leading to the rise of new formats such as the sliding puzzle captcha.
Content Overview
The sliding captcha was first introduced by a domestic security firm as a behavior-based verification method. Over the years, many variants have appeared, prompting the question of how secure these seemingly similar products truly are.
This article selects several sliding captchas from smaller vendors for experimental analysis, focusing solely on the image aspect due to the author's expertise in image processing. The goal is to provide knowledge for those familiar with automation techniques.
Research Object
A small website offers a sliding captcha from a minor vendor. Using a Python crawler, multiple captcha images are downloaded for inspection.
Repeated requests (e.g., 100 times) reveal that the captcha images follow a single, uniform pattern.
Qualitative Analysis
One representative image is examined, revealing three components related to the front‑end display: a position hint block (A), a small puzzle piece (B), and the complete background (C). The hint image A is simply a composition of B and C, indicating a lack of security expertise.
Two critical design flaws are identified:
No special processing applied to the images.
Excessive information exposed publicly.
These flaws make locating the puzzle piece trivially easy.
Quantitative Analysis
Using matplotlib, the image dimensions are measured (width: 240 px, height: 450 px) and divided into three equal vertical sections of 150 px each.
Solving the Image
By subtracting the pixel values of the first and third sections, the location of the missing piece becomes apparent. Summing the R‑channel values along the x‑axis yields a curve whose sharp change indicates the vertical position of the gap.
Computing the first derivative of this curve or detecting a sudden increase beyond a percentage of the maximum pixel value pinpoints the y‑coordinate of the leftmost gap.
Python Implementation
import numpy as np
def get_boundary(mask, axis, ratio=0.6):
"""Calculate boundary based on channel statistics"""
sum_along_axis = np.sum(mask, axis=axis)
max_value = np.max(sum_along_axis)
bound_value = max_value * ratio
bvalue = (sum_along_axis >= bound_value).astype('int8')
return np.where(bvalue != 0)[0][0]
def get_predict_ans(img):
"""Return the x‑position of the puzzle piece"""
nd_img = np.array(img)
w_pos = get_boundary(nd_img, 0)
return w_posConclusion
The described Python approach demonstrates how simple image‑processing techniques can automatically solve sliding puzzle captchas, highlighting the importance of proper image obfuscation in captcha design.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
