knock client for various knocking techniques. WIP, vibe coded and untested.
- Python 100%
|
|
||
|---|---|---|
| debian | ||
| knock | ||
| man | ||
| README.md | ||
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)
- The client builds an 802.11 Probe Request management frame
with the target SSID in the
Dot11Eidfield. - It sends count copies of that frame on the monitor interface, spaced evenly across the window duration.
- The server's
KnockDetectorsees count probes from the same source MAC within its window and triggershostapd.
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
--macvalue must be present in the server'sallowed_macslist, 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.