knock client for various knocking techniques. WIP, vibe coded and untested.
Find a file
Your Name ea2db4a878 build: change source format to 3.0 (native)
Co-authored-by: aider (ollama/qwen3.8:27b) <aider@aider.chat>
2026-10-24 23:31:10 +02:00
debian build: change source format to 3.0 (native) 2026-10-24 23:31:10 +02:00
knock refactor: restructure client into knock package with wlan subcommand 2026-10-24 23:25:38 +02:00
man refactor: restructure client into knock package with wlan subcommand 2026-10-24 23:25:38 +02:00
README.md docs: add Debian package build and install instructions 2026-10-24 23:29:13 +02:00

knock

A generic pattern-knock client. Select a subcommand to choose the knock mechanism.

Subcommands

Subcommand Description
wlan Send 802.11 Probe Requests to trigger a hidden-SSID wireless server

Prerequisites

  • Linux with a wireless NIC that supports monitor mode (for wlan)

  • Python >= 3.10

  • scapy (for crafting and sending 802.11 management frames)

  • uv (optional, for dependency management)

    Install uv (if not already present)

    curl -LsSf https://astral.sh/uv/install.sh | sh

Project setup

# 1. Create a virtual environment
uv venv

# 2. Activate it
source .venv/bin/activate

# 3. Install dependencies
uv pip install scapy

Prepare the wireless interface (wlan)

The wlan subcommand sends raw 802.11 management frames, so the interface must be in monitor mode:

# Put wlan0 into monitor mode (example)
sudo ip link set wlan0 down
sudo iw dev wlan0 interface add wlan0mon type monitor
sudo ip link set wlan0mon up

Usage

sudo python -m knock wlan \
    --ssid "MyHiddenNetwork" \
    --iface wlan0mon \
    --count 3 \
    --window 5

wlan options

Flag Description
-s, --ssid SSID The hidden SSID the server is listening for (required)
-i, --iface IFACE Monitor-mode interface to send on (required)
-c, --count N Number of probes to send (default: 3)
-w, --window SECS Time window in seconds to spread probes across (default: 5.0)
-m, --mac AA:BB:CC:DD:EE:FF Source MAC to spoof (optional)
-v, --verbose Enable debug logging

Examples

# Basic knock (3 probes over 5 s)
sudo python -m knock wlan -s "SecretNet" -i wlan0mon

# 5 probes over 2 s, spoofing a specific MAC
sudo python -m knock wlan -s "SecretNet" -i wlan0mon \
    -c 5 -w 2 -m aa:bb:cc:dd:ee:ff

# Verbose output
sudo python -m knock wlan -s "SecretNet" -i wlan0mon -v

How it works (wlan)

  1. The client builds an 802.11 Probe Request management frame with the target SSID in the Dot11Eid field.
  2. It sends count copies of that frame on the monitor interface, spaced evenly across the window duration.
  3. The server's KnockDetector sees count probes from the same source MAC within its window and triggers hostapd.

Cleanup

sudo ip link set wlan0mon down
sudo iw dev wlan0mon del
sudo ip link set wlan0 up

Debian package

The repository includes a debian/ directory with all the files needed to build a standard Debian binary package.

Build dependencies

sudo apt-get install debhelper python3-scapy

Build the .deb

dpkg-buildpackage -us -uc -b

The resulting binary package will be placed in the parent directory:

../knock_1.0-1_all.deb

Build a source package (.dsc + .tar.xz)

dpkg-buildpackage -us -uc

Install locally

sudo dpkg -i ../knock_1.0-1_all.deb

What gets installed

Path Description
/usr/bin/knock Console script (entry point)
/usr/lib/python3/dist-packages/knock/ Python package
/usr/share/man/man1/knock.1 Man page for knock
/usr/share/man/man1/knock-wlan.1 Man page for knock wlan

Lintian

To check the package for policy violations:

lintian ../knock_1.0-1_all.deb

Notes

  • The client must run as root (or with CAP_NET_RAW) to send raw 802.11 frames.
  • The --mac value must be present in the server's allowed_macs list, or the server will ignore the knock.
  • No association or authentication is performed by the client; it only sends the probe pattern. Actual network access still requires valid credentials (WPA2-PSK / 802.1X) on the server side.