Skip to main content

Detects captive portals TLS Man-in-the-Middle attacks.

Project description

Captive Portal Detector

A Python utility to perform high-security network-integrity checks.
It reliably detects captive portals and can identify TLS Man-in-the-Middle (MITM) attacks using SPKI pinning against redundant, user-controlled endpoints.

Features

  • High-Security MITM Detection: Uses SPKI-pinning against redundant, user-controlled endpoints to detect sophisticated TLS interception.
  • Comprehensive Checks: Runs a suite of probes in parallel, including standard HTTP 204 checks, random domain requests, and IPv6 reachability tests.
  • Resilient by Design: The final verdict prioritizes security, trusting only a successful pinned connection to declare the internet "OK".
  • Fast and Lightweight: Concurrent probes provide a result in seconds with minimal overhead.

Usage

Install via pip:

pip install captive-portal-detector

CLI Usage

Simply run it with: capdet

Python Usage

from capdet.detector import NetworkProbe

status = NetworkProbe().network_health()
print(status)

Advanced Usage (with your own pinned servers)

The library's real power is using your own endpoints. You can override the PINNED dictionary by passing it to the constructor:

from capdet.detector import NetworkProbe
custom_pinned = {
    "c1": "sha256/your_custom_spki_hash1",
    "c2": "sha256/your_custom_spki_hash2"
}
network_probe = NetworkProbe(pinned=custom_pinned)
status = network_probe.network_health()
print(status)

Output

The network_health() method returns one of three clear verdicts:

OK: A trusted, pinned TLS connection was successful. Internet access is confirmed.
CAPTIVE: A definitive captive portal (redirect) or TLS pin mismatch (MITM attack) was detected.
NO_INTERNET: No definitive CAPTIVE state was found, but a trusted connection could not be established.

How It Works

The library runs multiple probes in parallel and makes a verdict based on a security-first principle:

  1. If any probe detects a captive portal (like an HTTP redirect or a TLS pin mismatch), the final verdict is immediately CAPTIVE.
  2. If no CAPTIVE state is found, it then checks if any of the high-security pinned probes returned OK. An "OK" from a simple public probe is not sufficient.
  3. If neither of the above conditions is met, the verdict is NO_INTERNET, as a trusted connection could not be established.

Security Model

This tool is designed for "zero trust" environments. Unlike simple checks, it does not trust a successful connection to a public website as proof of real internet access. The default PINNED servers (c1/c2.probecheck.fyi) provide a baseline but it's recommended you add your own for maximum security. This allows the tool to reliably detect most corporate and nation-state MITM interception attacks.

Donate

If you find this tool useful, consider supporting its development and server costs:
Buy Me a Coffee
Ethereum: 0x4E7cda0286b1B03116Ed9633B0264fc3f7Ab65De
Bitcoin: bc1ql60qjgv5dqy6mxwj2665xwwptzulrygtrte7we

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

captive_portal_detector-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

captive_portal_detector-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file captive_portal_detector-1.0.0.tar.gz.

File metadata

  • Download URL: captive_portal_detector-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for captive_portal_detector-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6405885cdd16c84984eadb442db4aa6735207ee0fdcd7ee3c70a999554e6a26f
MD5 b9e10fcab5c136f13f292f405e1b4d29
BLAKE2b-256 f12892c0f23cfbde3914e47bc2eb192ae700dc908cc761c4a5c7b5021cb8d684

See more details on using hashes here.

File details

Details for the file captive_portal_detector-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for captive_portal_detector-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7bfd288742d09f889ebb3cef147403714d4abfc7f6db462f3d5f8bccb89d9a9
MD5 2211beabfbe4931a43cd0ddd285af820
BLAKE2b-256 7157d19c55e06be6080bb76354d5e771454a0fc7d87c975775c4c94fd212bd71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page