Skip to main content

UDP port knocking suite with HMAC-PSK authentication

Project description

pyknock

UDP port knocking suite with HMAC-PSK authentication. Once it receives valid packet signed with valid pre-shared key, it runs command to open or close access. Commands should be specified by user via server command line. Server allows use of substitution placeholders in configured commands:

  • $ip - IP address mentioned in signed packet
  • $af - IP address type: inet or inet6
  • $cmd - requested action: open or close

See Usage for examples.

Main Idea

In this application UDP datagrams are choosen for a reason. Typical configuration of firewalled machine allows only packets to some public ports and drops packets to all other ports. With UDP external observer can't distinguish between accepted packet and packet dropped by firewall. Therefore, if firewall configuration drops all UDP packets except packets to pyknock port, external observer can't even detect there is something awaiting for magic packet. So, it may be used to hide machine completely from network for unauthenticated peers. Also, it may be used as classical port-knocking solution, adding another protection layer to sensitive network application.

Features

  • Uses cryptographically authenticated messages.
  • Resistant to replay attacks.
  • Post-quantum ready cryptography (HMAC-PSK with SHA-256).
  • Works completely in user-space. May run even as unprivileged user.

Requirements

Only Python 2.6+ required. Python 3 is also supported.

Installation

Place file anywhere you want and run. Or use pip install pyknock to install it as python package into your system. Scripts shall become available at standard binary paths.

Usage

Server example:

pyknock-server MySecretPSK 'ipset add -exist myallowedset $ip timeout 3600' 'ipset del -exist myallowedset $ip'

Client example:

pyknock-client open my-protected-host.com MySecretPSK

Client behind NAT example:

pyknock-client -S $(curl -s https://canihazip.com/s) open my-protected-host.com MySecretPSK

See help for more options.

Project details


Download files

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

Files for pyknock, version 0.4.2
Filename, size File type Python version Upload date Hashes
Filename, size pyknock-0.4.2-py2.py3-none-any.whl (6.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pyknock-0.4.2.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page