DEV Community

Ravi Kumar
Ravi Kumar

Posted on

I Built a Motion CAPTCHA in Go That Is Harder for AI and Crawlers to Read

Traditional CAPTCHAs are becoming easier for automated systems to interpret. OCR, computer-vision tools, browser automation, and vision-language models can often process static visual challenges.

So I built Gotcha: an open-source, self-hosted motion CAPTCHA library for Go.

Repository: https://github.com/ravikumariitk/gotcha

How it works

Gotcha hides a numeric challenge inside moving visual noise.

A single frame looks like noise, while the answer becomes readable when the animation plays. This makes the challenge harder for basic OCR, single-frame analysis, and simple crawler automation to interpret.

Gotcha is designed to create friction for automated visual reading. It is not marketed as AI-proof, because determined attackers may still use vision models, optical-flow analysis, browser agents, or other techniques.

Features

  • Signed and expiring challenge tokens
  • Replay protection
  • Five-attempt challenge limit
  • MP4 rendering when ffmpeg is available
  • PNG-frame fallback when MP4 encoding is unavailable
  • Configurable colors and textures
  • Self-hosted deployment
  • No external CAPTCHA service required
  • Standard Go HTTP integration
  • MIT licensed

Installation

go get github.com/ravikumariitk/gotcha@v0.1.0
Enter fullscreen mode Exit fullscreen mode

Basic usage

package main

import gotcha "github.com/ravikumariitk/gotcha"

func main() {
    gotcha.ConfigureSecret("your-long-random-secret")

    challenge := gotcha.NewChallenge(
        5,
        "standard",
        gotcha.ParseAppearance(
            []string{"#0ea5e9", "#f8fafc"},
            "noise",
        ),
    )

    valid, latency, err := gotcha.VerifyCode(
        challenge.Token,
        "12345",
    )

    _, _, _ = valid, latency, err
}
Enter fullscreen mode Exit fullscreen mode

A real application normally exposes two endpoints:

GET  /challenge
POST /verify
Enter fullscreen mode Exit fullscreen mode

The browser receives the signed token and motion media from /challenge, keeps the token in memory, and submits the token with the user’s answer to /verify.

Important security note

Gotcha is a CAPTCHA and abuse-friction layer, not a complete authentication system.

For production applications, combine it with:

  • Rate limiting
  • MFA or step-up verification
  • Account lockout or throttling
  • Session security
  • Monitoring and alerting
  • Server-side authorization

Challenge state is stored in process memory, so distributed deployments should use request affinity or shared state.

Why open source?

The goal is to make the CAPTCHA mechanism transparent and controllable. Developers can inspect the token format, rendering behavior, verification rules, and fallback behavior instead of depending entirely on a third-party CAPTCHA service.

The motion-noise concept is related to the work documented in DrMikeMaik/GOTCHA, which explores motion-based human-versus-algorithm challenges and attack techniques.

Feedback is welcome—especially from Go developers and security researchers interested in testing the rendering approach and its resistance to automated visual analysis.

Try it

GOTCHA_SECRET="$(openssl rand -hex 32)" go run ./examples/login
Enter fullscreen mode Exit fullscreen mode

Then open:

http://localhost:8080
Enter fullscreen mode Exit fullscreen mode

GitHub: https://github.com/ravikumariitk/gotcha

Top comments (0)