Explainers

Math and Logic CAPTCHA Types Explained

Math CAPTCHAs present arithmetic problems like "What is 7 + 3?" or "Solve: 15 – 8" as a challenge. Logic CAPTCHAs extend this with word-based questions like "What color is the sky?" or "Type the largest number: 5, 12, 3." These challenges were among the earliest CAPTCHA types and remain common on WordPress sites, contact forms, and legacy applications. If your automation encounters a text field asking you to solve a simple equation, you are dealing with a math or logic CAPTCHA.


Types of math and logic CAPTCHAs

1. Basic arithmetic CAPTCHAs

Present a simple addition, subtraction, or multiplication problem.

Examples:

  • "What is 3 + 5?"
  • "12 – 4 = ?"
  • "6 × 7 = ?"

Implementation: The question is either rendered as plain text (easily parsed) or embedded in an image (requires OCR).

2. Text-rendered math CAPTCHAs

The equation is rendered as an image to prevent simple text parsing.

Examples:

  • An image showing "14 + 23 = ?" in distorted font
  • A CAPTCHA image with colored numbers and noise background

Implementation: Requires OCR to read the equation from the image, then computation to produce the answer.

3. Word-based math CAPTCHAs

Numbers are written as words instead of digits.

Examples:

  • "What is seven plus three?"
  • "Type the result of twelve minus five"

Implementation: Requires NLP parsing to convert words to numbers, then computation.

4. Logic questions

Non-arithmetic questions that require common knowledge.

Examples:

  • "What color is grass?"
  • "How many legs does a dog have?"
  • "Is fire hot or cold?"

Implementation: Requires a knowledge base or language model. These are typically drawn from a fixed question bank.

5. Sequential or pattern CAPTCHAs

Present a number sequence and ask for the next value.

Examples:

  • "What comes next: 2, 4, 6, 8, ?"
  • "Complete the pattern: 1, 1, 2, 3, 5, ?"

Implementation: Requires pattern recognition logic.


How math CAPTCHAs work technically

Text-based math CAPTCHA flow

Server generates random equation (e.g., "7 + 3")
    ↓
Stores answer (10) in server-side session
    ↓
Renders equation as HTML text or image
    ↓
User submits answer via form field
    ↓
Server compares submitted answer to stored answer
    ↓
Match → Form submitted     Mismatch → Error shown

Image-based math CAPTCHA flow

Server generates random equation
    ↓
Renders equation into a distorted image (noise, lines, color shifts)
    ↓
Image served to client via <img> tag
    ↓
User reads image, computes answer, types in form field
    ↓
Server validates submitted answer

Detecting math CAPTCHAs in automation

Python detection

import requests
from bs4 import BeautifulSoup
import re

def detect_math_captcha(url):
    """Detect common math CAPTCHA patterns on a page."""
    response = requests.get(url, timeout=10)
    soup = BeautifulSoup(response.text, "html.parser")
    html = response.text.lower()

    indicators = {
        "text_math": False,
        "image_math": False,
        "logic_question": False,
    }

    # Check for text-based math questions
    math_patterns = [
        r"what is \d+\s*[\+\-\×\*]\s*\d+",
        r"\d+\s*[\+\-\×\*]\s*\d+\s*=\s*\?",
        r"solve:\s*\d+",
        r"type the (result|answer|sum)",
    ]
    for pattern in math_patterns:
        if re.search(pattern, html):
            indicators["text_math"] = True
            break

    # Check for CAPTCHA images near math-related labels
    captcha_images = soup.find_all("img", attrs={
        "alt": re.compile(r"captcha|math|verify", re.I)
    })
    if captcha_images:
        indicators["image_math"] = True

    # Check for logic questions
    logic_patterns = [
        r"what color is",
        r"how many legs",
        r"what comes next",
        r"is .+ hot or cold",
    ]
    for pattern in logic_patterns:
        if re.search(pattern, html):
            indicators["logic_question"] = True
            break

    return indicators

result = detect_math_captcha("https://example.com/contact")
print(result)

Node.js detection

const axios = require("axios");
const cheerio = require("cheerio");

async function detectMathCaptcha(url) {
    const { data: html } = await axios.get(url, { timeout: 10000 });
    const $ = cheerio.load(html);
    const lower = html.toLowerCase();

    const indicators = {
        textMath: false,
        imageMath: false,
        logicQuestion: false,
    };

    // Text-based math patterns
    const mathPatterns = [
        /what is \d+\s*[+\-×*]\s*\d+/,
        /\d+\s*[+\-×*]\s*\d+\s*=\s*\?/,
        /solve:\s*\d+/,
        /type the (result|answer|sum)/,
    ];

    for (const pattern of mathPatterns) {
        if (pattern.test(lower)) {
            indicators.textMath = true;
            break;
        }
    }

    // Check for CAPTCHA images
    $("img").each((_, el) => {
        const alt = ($(el).attr("alt") || "").toLowerCase();
        if (/captcha|math|verify/.test(alt)) {
            indicators.imageMath = true;
        }
    });

    return indicators;
}

detectMathCaptcha("https://example.com/contact").then(console.log);

Solving math CAPTCHAs with OCR

When math CAPTCHAs render the equation as an image, OCR extracts the text and a simple parser computes the answer.

Using CaptchaAI for image-based math CAPTCHAs

import requests
import time
import re

API_KEY = "YOUR_API_KEY"
CAPTCHA_IMAGE_URL = "https://example.com/captcha.png"

# Download the CAPTCHA image
image_data = requests.get(CAPTCHA_IMAGE_URL).content

# Submit to CaptchaAI OCR
import base64
b64_image = base64.b64encode(image_data).decode()

submit = requests.post("https://ocr.captchaai.com/in.php", data={
    "key": API_KEY,
    "method": "base64",
    "body": b64_image,
    "json": 1,
})

task_id = submit.json().get("request")

# Poll for result
for _ in range(30):
    time.sleep(3)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY,
        "action": "get",
        "id": task_id,
        "json": 1,
    })
    data = result.json()
    if data.get("status") == 1:
        ocr_text = data["request"]  # e.g., "7 + 3"
        print(f"OCR result: {ocr_text}")

        # Parse and compute the answer
        match = re.match(r"(\d+)\s*([+\-*/×])\s*(\d+)", ocr_text)
        if match:
            a, op, b = int(match.group(1)), match.group(2), int(match.group(3))
            ops = {"+": a + b, "-": a - b, "*": a * b, "×": a * b, "/": a // b}
            answer = ops.get(op)
            print(f"Answer: {answer}")
        break
    elif "CAPCHA_NOT_READY" in str(data):
        continue

Math CAPTCHAs vs other CAPTCHA types

Feature Math CAPTCHAs reCAPTCHA v2 hCaptcha Slider CAPTCHAs
User friction Low (quick mental math) Medium (image selection) Medium (image selection) Low (single drag)
Bot resistance Very low High High Medium
Accessibility Good (text-based versions) Poor (vision-dependent) Poor (vision-dependent) Poor (motor-dependent)
Cost Free (self-hosted) Free tier available Free tier available Varies
Common use WordPress, contact forms Login, signup Login, signup E-commerce, Asia

Why math CAPTCHAs are still used

  1. Simplicity — No external API dependencies, no JavaScript SDKs
  2. WordPress plugins — Plugins like "Math CAPTCHA" and "Really Simple CAPTCHA" are widely installed
  3. Low friction — Users find simple math faster than image selection
  4. Accessibility — Text-based math CAPTCHAs work with screen readers (unlike image CAPTCHAs)
  5. Legacy systems — Older applications that predate modern CAPTCHA services

Frequently asked questions

Are math CAPTCHAs effective against bots?

Plain-text math CAPTCHAs are trivially bypassed by any bot that can parse HTML. Image-based math CAPTCHAs are slightly harder but easily solved with OCR. Math CAPTCHAs are effective only against the most basic spam bots. For serious bot protection, use a behavioral CAPTCHA system like reCAPTCHA or Cloudflare Turnstile.

How do I solve image-based math CAPTCHAs in automation?

Use an OCR service like CaptchaAI to extract the equation from the image, then parse and compute the answer programmatically. CaptchaAI supports 27,500+ image CAPTCHA types including math equation images.

Can text-based math CAPTCHAs be solved without OCR?

Yes. If the equation is rendered as HTML text (not an image), you can parse it directly from the page source using regex or DOM parsing. No OCR is needed for text-based math CAPTCHAs.

What is the best replacement for math CAPTCHAs?

Cloudflare Turnstile is the best replacement if you want low friction with strong bot detection. It runs invisibly and requires no user interaction. For higher security, reCAPTCHA v3 with score-based assessment is effective.


Summary

Math and logic CAPTCHAs are the simplest challenge type, commonly found on WordPress contact forms and legacy systems. Text-based versions can be parsed directly from HTML. Image-based versions require OCR to read the equation, then simple arithmetic to compute the answer. For image-based math CAPTCHAs, use the CaptchaAI Image OCR API to extract and solve the equation. While easy to bypass, math CAPTCHAs remain popular due to their simplicity and accessibility advantages.

Discussions (0)

No comments yet.

Related Posts

Reference CAPTCHA Token Injection Methods Reference
Complete reference for injecting solved CAPTCHA tokens into web pages.

Complete reference for injecting solved CAPTCHA tokens into web pages. Covers re CAPTCHA, Turnstile, and Cloud...

Automation Python reCAPTCHA v2
Apr 08, 2026
Tutorials Pytest Fixtures for CaptchaAI API Testing
Build reusable pytest fixtures to test CAPTCHA-solving workflows with Captcha AI.

Build reusable pytest fixtures to test CAPTCHA-solving workflows with Captcha AI. Covers mocking, live integra...

Automation Python reCAPTCHA v2
Apr 08, 2026
Reference Browser Session Persistence for CAPTCHA Workflows
Manage browser sessions, cookies, and storage across CAPTCHA-solving runs to reduce repeat challenges and maintain authenticated state.

Manage browser sessions, cookies, and storage across CAPTCHA-solving runs to reduce repeat challenges and main...

Automation Python reCAPTCHA v2
Feb 24, 2026
Integrations Browser Profile Isolation + CaptchaAI Integration
Browser profile isolation tools create distinct browser environments with unique fingerprints per session.

Browser profile isolation tools create distinct browser environments with unique fingerprints per session. Com...

Automation Python reCAPTCHA v2
Feb 21, 2026
Comparisons WebDriver vs Chrome DevTools Protocol for CAPTCHA Automation
Compare Web Driver and Chrome Dev Tools Protocol (CDP) for CAPTCHA automation — detection, performance, capabilities, and when to use each with Captcha AI.

Compare Web Driver and Chrome Dev Tools Protocol (CDP) for CAPTCHA automation — detection, performance, capabi...

Automation Python reCAPTCHA v2
Mar 27, 2026
Tutorials CAPTCHA Handling in Flask Applications with CaptchaAI
Integrate Captcha AI into Flask applications for automated CAPTCHA solving.

Integrate Captcha AI into Flask applications for automated CAPTCHA solving. Includes service class, API endpoi...

Automation Cloudflare Turnstile
Mar 17, 2026
Use Cases Event Ticket Monitoring with CAPTCHA Handling
Build an event ticket availability monitor that handles CAPTCHAs using Captcha AI.

Build an event ticket availability monitor that handles CAPTCHAs using Captcha AI. Python workflow for checkin...

Automation Python reCAPTCHA v2
Jan 17, 2026
Use Cases CAPTCHA Solving in Ticket Purchase Automation
How to handle CAPTCHAs on ticketing platforms Ticketmaster, AXS, and event sites using Captcha AI for automated purchasing workflows.

How to handle CAPTCHAs on ticketing platforms Ticketmaster, AXS, and event sites using Captcha AI for automate...

Automation Python reCAPTCHA v2
Feb 25, 2026
Tutorials Caching CAPTCHA Tokens for Reuse
Cache and reuse CAPTCHA tokens with Captcha AI to reduce API calls and costs.

Cache and reuse CAPTCHA tokens with Captcha AI to reduce API calls and costs. Covers token lifetimes, cache st...

Automation Python reCAPTCHA v2
Feb 15, 2026
Explainers How BLS CAPTCHA Works: Grid Logic and Image Selection
Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how Captcha AI processes BLS challenges.

Deep dive into BLS CAPTCHA grid logic — how images are arranged, how instructions map to selections, and how C...

Automation BLS CAPTCHA
Apr 09, 2026
Explainers Browser Fingerprinting and CAPTCHA: How Detection Works
How browser fingerprinting affects CAPTCHA challenges, what signals trigger CAPTCHAs, and how to reduce detection with Captcha AI.

How browser fingerprinting affects CAPTCHA challenges, what signals trigger CAPTCHAs, and how to reduce detect...

reCAPTCHA v2 Cloudflare Turnstile reCAPTCHA v3
Mar 23, 2026
Explainers GeeTest v3 Challenge-Response Workflow: Technical Deep Dive
A technical deep dive into Gee Test v 3's challenge-response workflow — the registration API, challenge token exchange, slider verification, and how Captcha AI...

A technical deep dive into Gee Test v 3's challenge-response workflow — the registration API, challenge token...

Automation Testing GeeTest v3
Mar 02, 2026