phpKnockClient
Dec 11th, 2009 by paolo
synopsis
knock.php [options] <host> <port[:proto]> [port[:proto]] ...
description
A port-knocking client implementation in PHP inspired by the knockd C implementation made by Judd Vinet.
Port knocking is a way of surreptitiously offering services on a server without advertising the fact. By delivering a special sequence of “port knocks”, a user can open up access to a port for his IP only, and close it again when he’s done.
For more information, see the port knocking website or this article that is an introduction to how, using the port-knocking technic, trusted users can manipulate firewall rules to transmit information across closed ports.
download
options
- -u
- make all ports hits use UDP (default is TCP)
- -v
- be verbose
- -h
- Syntax help.
examples
- knocks a server on 192.168.1.13 on four tcp ports: 6754, 8437, 84754, 8845.
$ knock.php 192.168.1.13 6754 8437 84754 8845
- knocks a server on myhost.mydomain.com on five ports using different protocols:
$ knock.php myhost.mydomain.com 3478:tcp 8574:udp 650:udp 3293:udp 77790:tcp
author
Written by Paolo Casarini.
reporting bugs
Report bugs to <paolo@casarini.org>.
copyright
Copyright © 2009 Paolo Casarini – License GPLv2: GNU GPL version 2 or later <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html> – This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Hi,
Is that possible to have an implementation example ?
Like a php or html form, cause I would like to use phpKnockClient for my personnal monitoring NAS webpage.
Thanks a lot for your futur response ^^
Bye, WikiJM
In the download section of this page there is the php implementation. It’s a tarball with the php script described in this page. Is it enough for you?
Hi,
Thanks for this quick response.
I’m more a system and network tech than a PHP developper (in other words, I’m a PHP noob ^^).
More details : I have a Synology NAS with a port redirection for the SSH protocol, and that I want to do is a simple form include on an PHP or html webpage. I imagine a form with possibility to enter between 3 to 5 ports, choose the type (TCP or UDP) and, of course, enter the destination.
Moreover, when I use your PHP file, I have some errors :
- Warning: array_shift() expects parameter 1 to be array, null given in …
- Warning: reset() expects parameter 1 to be array, null given in …
- Warning: Variable passed to each() is not an array or object in …
Hope answers to this questions gonna help other people than me.
Have a nice week-end and thanks for your time
P.S : Sorry for my english, I’m a french guy.
I want to know how I can prevent replay attack by port knocking
thank you
I want to help me how I can prevent replay attack by port knocking
thank you