'\" t .\" Title: fwknopd .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 08/06/2018 .\" Manual: Fwknop Server .\" Source: Fwknop Server .\" Language: English .\" .TH "FWKNOPD" "8" "08/06/2018" "Fwknop Server" "Fwknop Server" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" fwknopd \- Firewall Knock Operator Daemon .SH "SYNOPSIS" .sp \fBfwknopd\fR [\fIoptions\fR] .SH "DESCRIPTION" .sp \fBfwknopd\fR is the server component for the FireWall Knock Operator, and is responsible for monitoring and processing Single Packet Authorization (SPA) packets that are generated by \fBfwknop\fR clients, modifying a firewall or ACL policy to allow the desired access after authenticating and decrypting a valid SPA packet (in that order), and removing access after a configurable timeout\&. .sp The main application of this program is to conceal services such as \fISSH\fR with an additional layer of security in order to make the exploitation of vulnerabilities (both 0\-day and unpatched code) much more difficult\&. In addition, services that are concealed in this fashion naturally cannot be scanned for with \fINmap\fR or \fIShodan\fR\&. .sp The main configuration for \fBfwknopd\fR is maintained within two files: \fIfwknopd\&.conf\fR and \fIaccess\&.conf\fR\&. The default location for these files is determined at package configuration (typically \fI/etc/fwknop\fR)\&. The configuration variables within these files are described below\&. .sp Additional information may be found in the tutorial \(lqSingle Packet Authorization: A Comprehensive Guide to Strong Service Concealment with fwknop\(rq available online (see: \fIhttp://www\&.cipherdyne\&.org/fwknop/docs/fwknop\-tutorial\&.html\fR)\&. .SH "COMMAND\-LINE OPTIONS" .PP \fB\-i, \-\-interface\fR=\fI\fR .RS 4 Manually specify interface on which to sniff, e\&.g\&. \(lq\-i eth0\(rq\&. This option is not usually needed because the \(lqPCAP_INTF\(rq keyword in the \fIfwknopd\&.conf\fR file defines the sniffing interface\&. .RE .PP \fB\-f, \-\-foreground\fR .RS 4 Run \fBfwknopd\fR in the foreground instead of becoming a daemon\&. When run in the foreground, message that would go to the log would instead be sent to stderr\&. This mode is usually used when testing and/or debugging\&. .RE .PP \fB\-\-fw\-list\fR .RS 4 List only firewall rules that any running \fBfwknopd\fR daemon has created and then exit\&. .RE .PP \fB\-a, \-\-access\-file\fR=\fI\fR .RS 4 Specify the location of the \fIaccess\&.conf\fR file\&. If this option is not given, \fIfwknopd\fR will use the compile\-time default location (typically \fI/etc/fwknop/access\&.conf\fR)\&. .RE .PP \fB\-\-access\-folder\fR=\fI\fR .RS 4 Specify the location of the \fIaccess\&.conf\fR folder\&. If this option is given, rather than load a single access\&.conf file, all the \&.conf files in the given folders are processed\&. .RE .PP \fB\-c, \-\-config\fR=\fI\fR .RS 4 Specify the location of the \fIfwknopd\&.conf\fR file\&. If this option is not given, \fIfwknopd\fR will use the default location (typically \fI/etc/fwknop/fwknopd\&.conf\fR\&. .RE .PP \fB\-C, \-\-packet\-limit\fR=\fI\fR .RS 4 Specify the number of candidate SPA packets to process and exit when this limit is reached\&. .RE .PP \fB\-d, \-\-digest\-file\fR=\fI\fR .RS 4 Specify the location of the \fIdigest\&.cache\fR file\&. If this option is not given, \fIfwknopd\fR will use the compile\-time default location (typically \fI@runstatedir@/fwknop/digest\&.cache\fR)\&. .RE .PP \fB\-D, \-\-dump\-config\fR .RS 4 Dump the configuration values that \fBfwknopd\fR derives from the \fI/etc/fwknop/fwknopd\&.conf\fR (or override files) and \fI/etc/fwknop/access\&.conf\fR on stderr\&. .RE .PP \fB\-\-dump\-serv\-err\-codes\fR .RS 4 Dump all possible \fBfwknopd\fR error codes to stdout and exit\&. This option is rarely needed in practice, and was added to assist with test coverage\&. .RE .PP \fB\-\-fault\-injection\-tag\fR=\fI\fR .RS 4 This option is only used for fault injection testing when \fBfwknop\fR is compiled to support the libfiu library (see: \fIhttp://blitiri\&.com\&.ar/p/libfiu/\fR)\&. Under normal circumstances this option is not used, and any packaged version of fwknop will not have code compiled in so this capability is not enabled at run time\&. It is documented here for completeness\&. version of fwknop will not have code compiled in to enable this capability at run time\&. It is documented here for completeness\&. .RE .PP \fB\-A, \-\-afl\-fuzzing\fR .RS 4 Instruct \fBfwknopd\fR to acquire SPA packets directly from stdin in support of fuzzing operations from the \fIAmerican Fuzzy Lop\fR (AFL) fuzzer written by Michal Zalewski\&. This requires that \fBfwknop\fR is compiled with the \fI\-\-enable\-afl\-fuzzing\fR argument to the \fBconfigure\fR script as this allows encryption/digest short circuiting in a manner necessary for AFL to function properly\&. The benefit of this strategy is that AFL can fuzz the SPA packet decoding routines implemented by \fBlibfko\fR\&. .RE .PP \fB\-\-fw\-list\-all\fR .RS 4 List all firewall rules including those that have nothing to do with \fBfwknopd\fR\&. .RE .PP \fB\-\-fw\-flush\fR .RS 4 Flush any firewall rules created by a running \fBfwknopd\fR process\&. This option allows the used to easily delete \fBfwknopd\fR firewall rules without having to wait for them to be timed out\&. .RE .PP \fB\-K, \-\-kill\fR .RS 4 Kill the current \fBfwknopd\fR process\&. This provides a quick and easy way to stop \fBfwknopd\fR without having to look in the process table\&. .RE .PP \fB\-\-exit\-parse\-config\fR .RS 4 Parse config files (\fI/etc/fwknop/fwknopd\&.conf\fR, and \fI/etc/fwknop/access\&.conf\fR) and then exit\&. This provides a way to test whether the config files are properly structured without having to start processing network traffic\&. .RE .PP \fB\-\-exit\-parse\-digest\-cache\fR .RS 4 Parse the digest cache file \fI@runstatedir@/fwknop/digest\&.cache\fR and exit\&. This validates the structure of the digest cache file without having to start processing network traffic\&. Note that the standard configuration files are also parsed in this mode\&. .RE .PP \fB\-l, \-\-locale\fR=\fI\fR .RS 4 Set/override the system default locale setting\&. .RE .PP \fB\-\-no\-ipt\-check\-support\fR .RS 4 Disable the usage of the iptables \fI\-C\fR option\&. This is not normally needed, and is only useful on older Linux distributions where iptables does not have \fI\-C\fR support\&. .RE .PP \fB\-O, \-\-override\-config\fR=\fI\fR .RS 4 Override config variable values that are normally read from the \fI/etc/fwknop/fwknopd\&.conf\fR file with values from the specified file\&. Multiple override config files can be given as a comma\-separated list\&. .RE .PP \fB\-\-key\-gen\fR .RS 4 Have \fBfwknopd\fR generate both Rijndael and HMAC keys that can be used for SPA packet encryption and authentication\&. These keys are derived from /dev/urandom and then base64 encoded before being printed to stdout, and are meant to be manually included in a stanza within the \fI/etc/fwknop/access\&.conf\fR file\&. Such keys are generally more secure than passphrases\&. .RE .PP \fB\-\-key\-gen\-file\fR=\fI\fR .RS 4 Write generated keys to the specified file\&. Note that the file is overwritten if it already exists\&. If this option is not given, then \fB\-\-key\-gen\fR writes the keys to stdout\&. .RE .PP \fB\-\-key\-len\fR=\fI\fR .RS 4 Specify the number of bytes for a generated Rijndael key\&. The maximum size is currently 128 bytes\&. .RE .PP \fB\-\-hmac\-key\-len\fR=\fI\fR .RS 4 Specify the number of bytes for a generated HMAC key\&. The maximum size is currently 128 bytes\&. .RE .PP \fB\-p, \-\-pid\-file\fR=\fI\fR .RS 4 Specify the location of the \fIfwknopd\&.pid\fR file\&. If this option is not given, \fIfwknopd\fR will use the compile\-time default location (typically \fI@runstatedir@/fwknop/fwknopd\&.pid\fR)\&. .RE .PP \fB\-P, \-\-pcap\-filter\fR=\fI\fR .RS 4 Specify a Berkeley packet filter statement on the \fBfwknopd\fR command line\&. This overrides the value of the PCAP_FILTER variable taken from the \fI/etc/fwknop/fwknopd\&.conf\fR file\&. .RE .PP \fB\-\-pcap\-file\fR=\fI\fR .RS 4 This option instructs \fBfwknopd\fR to read packet data from a pcap file instead of sniffing an interface directly\&. This mode is usually used for debugging purposes, and will disable SPA packet age checking unless it is manually enabled in the \fI/etc/fwknop/fwknopd\&.conf\fR file\&. .RE .PP \fB\-\-pcap\-any\-direction\fR .RS 4 Allow \fBfwknopd\fR to sniff SPA packets regardless of whether they are received on the sniffing interface or sent from the sniffing interface\&. In the later case, this can be useful to have fwknopd sniff SPA packets that are forwarded through a system and destined for a different network\&. If the sniffing interface is the egress interface for such packets (and hence SPA packets are sent by this interface instead of received), then this option will need to used in order for \fBfwknopd\fR to see them\&. The default is to only sniff packets that are received on the sniffing interface\&. Note that this setting is independent of promiscuous mode\&. .RE .PP \fB\-R, \-\-restart\fR .RS 4 Restart the currently running \fBfwknopd\fR processes\&. This option will preserve the command line options that were supplied to the original \fBfwknopd\fR process but will force \fBfwknopd\fR to re\-read the \fIfwknopd\&.conf\fR and \fI/etc/fwknop/access\&.conf\fR files\&. This will also force a flush of the current \(lqFWKNOP\(rq iptables chain(s)\&. .RE .PP \fB\-\-rotate\-digest\-cache\fR .RS 4 Rotate the digest cache file by renaming it to \(lq\-old\(rq, and starting a new one\&. The digest cache file is typically found in \fI@runstatedir@/fwknop/digest\&.cache\fR\&. .RE .PP \fB\-r, \-\-run\-dir\fR=\fI\fR .RS 4 Specify the directory where \fBfwknopd\fR writes run time state files\&. The default is \fI@runstatedir@\fR\&. .RE .PP \fB\-S, \-\-status\fR .RS 4 Display the status of any \fBfwknopd\fR processes that may or not be running\&. If there is an existing fwknopd process then 0 is returned for the exit status and 1 is returned otherwise\&. .RE .PP \fB\-\-syslog\-enable\fR .RS 4 Allow messages to be sent to syslog even if the foreground mode is set\&. .RE .PP \fB\-t, \-\-test\fR .RS 4 Run \fBfwknopd\fR in test mode\&. This instructs \fBfwknopd\fR to acquire and process SPA packets, but not manipulate firewall rules or execute commands that are provided by SPA clients\&. This option is mostly useful for the fuzzing tests in the test suite to ensure broad code coverage under adverse conditions\&. .RE .PP \fB\-U, \-\-udp\-server\fR .RS 4 Run \fBfwknopd\fR in UDP server mode so that SPA packets are acquired via a UDP socket directly without having to use libpcap\&. See the discussion of the \(lqENABLE_UDP_SERVER\(rq configuration variable below for more information\&. .RE .PP \fB\-v, \-\-verbose\fR .RS 4 Run \fBfwknopd\fR in verbose mode\&. This can option can be specified multiple times to increase the verbosity of the output to the system log file (or to the screen if running in the foreground)\&. .RE .PP \fB\-h, \-\-help\fR .RS 4 Display usage information and exit\&. .RE .PP \fB\-V, \-\-Version\fR .RS 4 Display version information and exit\&. .RE .SH "FWKNOPD CONFIG AND ACCESS VARIABLES" .sp \fBfwknopd\fR references the \fI/etc/fwknop/fwknopd\&.conf\fR file for configuration variables to define operational parameters (what network interface and port to sniff, what features to enable/disable, etc\&.)\&. The \fIfwknopd\&.conf\fR file does not define any access control directives or set any encryption or authentication keys\&. .sp The access control directives are contained in the \fI/etc/fwknop/access\&.conf\fR file\&. Access control directives define encryption keys and level of access that is granted to an fwknop client that has generated the appropriate encrypted SPA message\&. .SS "FWKNOPD\&.CONF VARIABLES" .sp This section list the more prominent configuration variables used by \fBfwknopd\fR\&. You will want to make sure to check these to make sure they have appropriate values, but sensible defaults are provided for most systems\&. See the \fI/etc/fwknop/fwknopd\&.conf\fR file for additional details\&. .PP \fBPCAP_INTF\fR \fI\fR .RS 4 Specify the ethernet interface on which \fBfwknopd\fR will sniff packets\&. .RE .PP \fBENABLE_PCAP_PROMISC\fR \fI\fR .RS 4 By default \fBfwknopd\fR puts the pcap interface into promiscuous mode\&. Set this to \(lqN\(rq to disable that behavior (non\-promiscuous)\&. .RE .PP \fBPCAP_FILTER\fR \fI\fR .RS 4 Define the filter used for \fIPCAP\fR modes; \fBfwknopd\fR defaults to UDP port 62201\&. However, if an \fBfwknop\fR client uses the \fB\-\-rand\-port\fR option to send the SPA packet over a random port, then this variable should be updated to something like \(lqudp dst portrange 10000\-65535\(rq\&. .RE .PP \fBENABLE_SPA_PACKET_AGING\fR \fI\fR .RS 4 This instructs \fBfwknopd\fR to not honor SPA packets that have an old time stamp\&. The value for \(lqold\(rq is defined by the \(lqMAX_SPA_PACKET_AGE\(rq variable\&. If \(lqENABLE_SPA_PACKET_AGING\(rq is set to \(lqN\(rq, \fBfwknopd\fR will not use the client time stamp at all\&. .RE .PP \fBMAX_SPA_PACKET_AGE\fR \fI\fR .RS 4 Defines the maximum age (in seconds) that an SPA packet will be accepted\&. This requires that the client system is in relatively close time synchronization with the \fBfwknopd\fR server system (NTP is good)\&. The default age is 120 seconds (two minutes)\&. .RE .PP \fBENABLE_DIGEST_PERSISTENCE\fR \fI\fR .RS 4 Track digest sums associated with previous SPA packets processed by \fBfwknopd\fR\&. This allows digest sums to remain persistent across executions of \fBfwknopd\fR\&. The default is \(lqY\(rq\&. If set to \(lqN\(rq, \fBfwknopd\fR will not check incoming SPA packet data against any previously save digests\&. It is a good idea to leave this feature on to reduce the possibility of being vulnerable to a replay attack\&. .RE .PP \fBRULES_CHECK_THRESHOLD\fR \fI\fR .RS 4 Defines the number of times firewall rule expiration times must be checked before a "deep" check is run\&. This allows \fBfwknopd\fR to remove rules that contain a proper \fI\fIexp\fR\fR\fI