# eduaguixd/mtcaptcha-solver architecture

> Architecture diagram of the GitHub repository eduaguixd/mtcaptcha-solver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eduaguixd/mtcaptcha-solver
- Repository: https://github.com/eduaguixd/mtcaptcha-solver

## Overview

1. **Purpose and scope**
   - This repository is a proof-of-concept MTCaptcha audio solver.
   - The architecture centers on one workflow: fetch a challenge, satisfy MTCaptcha’s proof-of-work/fingerprint checks, transcribe the audio CAPTCHA, and submit the answer token.

2. **Entry point**
   - `main.py` is the CLI boundary.
   - It accepts `sitekey`, `hostname`, and optional `proxy`, then hands control to the solver pipeline.
   - This keeps user interaction separate from the network/ML logic.

3. **Core orchestration layer**
   - `solve_audio.py` is the main application engine.
   - It coordinates the end-to-end solve flow: challenge retrieval, fold computation, audio download, Whisper transcription, answer normalization, and final submission.
   - This file is where most of the integration logic lives.

4. **Challenge acquisition and submission boundary**
   - The solver talks to MTCaptcha’s backend at `service.mtcaptcha.com`.
   - That boundary includes fetching the challenge, handling the returned metadata, and submitting the final token.
   - The README indicates the protocol is reverse-engineered, so the code is effectively emulating a browser client rather than using a public API.

5. **Browser spoofing subsystem**
   - `spoofing.py` provides a pool of browser fingerprints across common browsers and OS combinations.
   - Its role is to shape outbound requests to resemble legitimate browser traffic, including header ordering and client-hint fields.
   - Architecturally, this is a request-morphing layer placed in front of the MTCaptcha network calls.

6. **Proof-of-work / fold challenge subsystem**
   - MTCaptcha may require a “fold” challenge before accepting an answer.
   - The repository implements this in two forms: the native C accelerator in `_fold_accel.c`, and a Python fallback when the native library is unavailable.
   - This subsystem is performance-sensitive but isolated from the rest of the solve pipeline.

7. **Native acceleration boundary**
   - `_fold_accel.c` is compiled at runtime and loaded through `ctypes`.
   - That creates a clear boundary between Python orchestration and low-level computation.
   - The C path is the preferred execution mode; the Python path preserves portability if no compiler is present.

8. **Audio recognition subsystem**
   - The audio CAPTCHA is transcribed using `faster-whisper`.
   - The model choice and CPU/int8 behavior are controlled in `config.py`.
   - After transcription, the solver applies a phonetic mapping so Whisper’s spoken letter outputs become the single-character response MTCaptcha expects.

9. **Configuration and tuning**
   - `config.py` centralizes runtime settings such as model selection, timeouts, and version metadata.
   - This keeps behavioral tuning separate from the solver logic and makes it easy to swap Whisper models or adjust operational parameters.

10. **Data flow through the system**
   - The overall flow is: CLI input → spoofed challenge request → optional fold computation → audio fetch → Whisper transcription → answer normalization → token submission.
   - The network path and the ML path are sequential, with the fold step acting as a prerequisite gate when present.
   - The solver’s success depends on both correct transcription and server-side acceptance of the spoofed client fingerprint/proxy origin.

11. **External dependencies that materially shape the architecture**
   - `faster-whisper` is the primary ML dependency and drives the compute profile of the project.
   - `rnet` is used for HTTP/network handling and likely supports the request construction/fingerprint behavior.
   - The optional C toolchain (GCC or MSVC) is part of the runtime environment because the accelerator can compile itself on first run.

12. **Operational constraints / architecture implications**
   - The README makes clear that IP reputation and fingerprint quality affect acceptance, so the solver is not purely a transcription problem.
   - Proxy support is therefore part of the architecture, not just a convenience feature.
   - The project is best understood as three cooperating subsystems: browser impersonation, challenge computation, and speech recognition.

Main entry points: [`solve_audio.py`](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/solve_audio.py) (solve_audio.py), [`spoofing.py`](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/spoofing.py) (spoofing.py), [`_fold_accel.c`](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/_fold_accel.c) (_fold_accel.c), [`main.py`](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/main.py) (main.py)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_cli["CLI"]
  node_node_main["main.py<br/>CLI entrypoint<br/>[main.py]"]
end

subgraph group_group_core["Solver core"]
  node_node_solve_audio["solve_audio.py<br/>orchestrator<br/>[solve_audio.py]"]
  node_node_config["config.py<br/>settings<br/>[config.py]"]
  node_node_phonetic["normalize<br/>postprocess"]
end

subgraph group_group_client["Client shaping"]
  node_node_spoofing["spoofing.py<br/>fingerprint pool<br/>[spoofing.py]"]
  node_node_network["HTTP client<br/>network layer"]
  node_node_service[("MTCaptcha service<br/>remote backend")]
end

subgraph group_group_runtime["Runtime engines"]
  node_node_fold_py["fold Python<br/>fallback compute"]
  node_node_fold_c["_fold_accel.c<br/>native accelerator<br/>[_fold_accel.c]"]
  node_node_whisper(("Whisper<br/>speech model"))
end

node_node_main -->|"starts"| node_node_solve_audio
node_node_solve_audio -->|"reads"| node_node_config
node_node_solve_audio -->|"selects"| node_node_spoofing
node_node_spoofing -->|"shapes"| node_node_network
node_node_solve_audio -->|"requests"| node_node_network
node_node_network -->|"talks to"| node_node_service
node_node_solve_audio -->|"prefers"| node_node_fold_c
node_node_solve_audio -->|"falls back to"| node_node_fold_py
node_node_fold_py -.->|"matches"| node_node_fold_c
node_node_solve_audio -->|"transcribes"| node_node_whisper
node_node_whisper -->|"feeds"| node_node_phonetic
node_node_phonetic -->|"submits"| node_node_network
node_node_solve_audio -.->|"depends on"| node_node_service

click node_node_main "https://github.com/eduaguixd/mtcaptcha-solver/blob/main/main.py"
click node_node_solve_audio "https://github.com/eduaguixd/mtcaptcha-solver/blob/main/solve_audio.py"
click node_node_config "https://github.com/eduaguixd/mtcaptcha-solver/blob/main/config.py"
click node_node_spoofing "https://github.com/eduaguixd/mtcaptcha-solver/blob/main/spoofing.py"
click node_node_fold_c "https://github.com/eduaguixd/mtcaptcha-solver/blob/main/_fold_accel.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_main toneBlue
class node_node_solve_audio,node_node_config,node_node_phonetic toneAmber
class node_node_spoofing,node_node_network,node_node_service toneMint
class node_node_fold_py,node_node_fold_c,node_node_whisper toneRose
```

## Components

### CLI

User entry and invocation boundary

- [main.py](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/main.py): CLI entrypoint · Parses sitekey, hostname, and proxy, then starts the solver · `main.py`

### Solver core

End-to-end solve orchestration

- [solve_audio.py](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/solve_audio.py): orchestrator · Coordinates challenge fetch, fold handling, audio transcription, normalization, and submission · `solve_audio.py`
- [config.py](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/config.py): settings · Central runtime tuning for models, timeouts, and version metadata · `config.py`
- **normalize**: postprocess · Maps transcription output into the single-character answer expected by MTCaptcha

### Client shaping

Fingerprinting and request construction

- [spoofing.py](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/spoofing.py): fingerprint pool · Provides browser and OS fingerprints plus request-shaping data · `spoofing.py`
- **HTTP client**: network layer · Handles outbound challenge, audio, and submission requests against MTCaptcha
- **MTCaptcha service**: remote backend · Challenge and token acceptance boundary at service.mtcaptcha.com

### Runtime engines

Native acceleration and speech recognition

- **fold Python**: fallback compute · Portable implementation of the proof-of-work fold challenge
- [_fold_accel.c](https://github.com/eduaguixd/mtcaptcha-solver/blob/main/_fold_accel.c): native accelerator · C accelerator compiled and loaded for fast fold computation · `_fold_accel.c`
- **Whisper**: speech model · Transcribes the audio CAPTCHA using faster-whisper

## Connections

- main.py → solve_audio.py: starts · CLI hands execution to the solver pipeline
- solve_audio.py → config.py: reads · Uses configured timeouts, model settings, and version metadata
- solve_audio.py → spoofing.py: selects · Chooses a browser fingerprint and request profile
- spoofing.py → HTTP client: shapes · Provides headers and client-hint ordering for requests
- solve_audio.py → HTTP client: requests · Fetches challenge data, audio, and submits the final token
- HTTP client → MTCaptcha service: talks to · Communicates with the MTCaptcha backend
- solve_audio.py → _fold_accel.c: prefers · Uses native acceleration when available for fold computation
- solve_audio.py → fold Python: falls back to · Uses the Python implementation if the native path is unavailable
- fold Python → _fold_accel.c: matches · Alternative implementations of the same fold challenge logic
- solve_audio.py → Whisper: transcribes · Runs speech recognition on downloaded audio CAPTCHA
- Whisper → normalize: feeds · Transcription is normalized into the expected answer token
- normalize → HTTP client: submits · Sends the final normalized answer back to the service
- solve_audio.py → MTCaptcha service: depends on · Success requires server acceptance of spoofed client state and submitted token
