FWKNOPD(8) Fwknop Server FWKNOPD(8) NAME fwknopd - Firewall Knock Operator Daemon SYNOPSIS fwknopd [options] DESCRIPTION fwknopd 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 fwknop 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. The main application of this program is to conceal services such as SSH 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 Nmap or Shodan. The main configuration for fwknopd is maintained within two files: fwknopd.conf and access.conf. The default location for these files is determined at package configuration (typically /etc/fwknop). The configuration variables within these files are described below. Additional information may be found in the tutorial "Single Packet Authorization: A Comprehensive Guide to Strong Service Concealment with fwknop" available online (see: http://www.cipherdyne.org/fwknop/docs/fwknop-tutorial.html). COMMAND-LINE OPTIONS -i, --interface= Manually specify interface on which to sniff, e.g. "-i eth0". This option is not usually needed because the "PCAP_INTF" keyword in the fwknopd.conf file defines the sniffing interface. -f, --foreground Run fwknopd 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. --fw-list List only firewall rules that any running fwknopd daemon has created and then exit. -a, --access-file= Specify the location of the access.conf file. If this option is not given, fwknopd will use the compile-time default location (typically /etc/fwknop/access.conf). --access-folder= Specify the location of the access.conf folder. If this option is given, rather than load a single access.conf file, all the .conf files in the given folders are processed. -c, --config= Specify the location of the fwknopd.conf file. If this option is not given, fwknopd will use the default location (typically /etc/fwknop/fwknopd.conf. -C, --packet-limit= Specify the number of candidate SPA packets to process and exit when this limit is reached. -d, --digest-file= Specify the location of the digest.cache file. If this option is not given, fwknopd will use the compile-time default location (typically /var/fwknop/digest.cache). -D, --dump-config Dump the configuration values that fwknopd derives from the /etc/fwknop/fwknopd.conf (or override files) and /etc/fwknop/access.conf on stderr. --dump-serv-err-codes Dump all possible fwknopd error codes to stdout and exit. This option is rarely needed in practice, and was added to assist with test coverage. --fault-injection-tag= This option is only used for fault injection testing when fwknop is compiled to support the libfiu library (see: http://blitiri.com.ar/p/libfiu/). 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. -A, --afl-fuzzing Instruct fwknopd to acquire SPA packets directly from stdin in support of fuzzing operations from the American Fuzzy Lop (AFL) fuzzer written by Michal Zalewski. This requires that fwknop is compiled with the --enable-afl-fuzzing argument to the configure 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 libfko. --fw-list-all List all firewall rules including those that have nothing to do with fwknopd. --fw-flush Flush any firewall rules created by a running fwknopd process. This option allows the used to easily delete fwknopd firewall rules without having to wait for them to be timed out. -K, --kill Kill the current fwknopd process. This provides a quick and easy way to stop fwknopd without having to look in the process table. --exit-parse-config Parse config files (/etc/fwknop/fwknopd.conf, and /etc/fwknop/access.conf) and then exit. This provides a way to test whether the config files are properly structured without having to start processing network traffic. --exit-parse-digest-cache Parse the digest cache file /var/fwknop/digest.cache 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. -l, --locale= Set/override the system default locale setting. --no-ipt-check-support Disable the usage of the iptables -C option. This is not normally needed, and is only useful on older Linux distributions where iptables does not have -C support. -O, --override-config= Override config variable values that are normally read from the /etc/fwknop/fwknopd.conf file with values from the specified file. Multiple override config files can be given as a comma-separated list. --key-gen Have fwknopd 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 /etc/fwknop/access.conf file. Such keys are generally more secure than passphrases. --key-gen-file= Write generated keys to the specified file. Note that the file is overwritten if it already exists. If this option is not given, then --key-gen writes the keys to stdout. --key-len= Specify the number of bytes for a generated Rijndael key. The maximum size is currently 128 bytes. --hmac-key-len= Specify the number of bytes for a generated HMAC key. The maximum size is currently 128 bytes. -p, --pid-file= Specify the location of the fwknopd.pid file. If this option is not given, fwknopd will use the compile-time default location (typically /var/fwknop/fwknopd.pid). -P, --pcap-filter= Specify a Berkeley packet filter statement on the fwknopd command line. This overrides the value of the PCAP_FILTER variable taken from the /etc/fwknop/fwknopd.conf file. --pcap-file= This option instructs fwknopd 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 /etc/fwknop/fwknopd.conf file. --pcap-any-direction Allow fwknopd 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 fwknopd 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. -R, --restart Restart the currently running fwknopd processes. This option will preserve the command line options that were supplied to the original fwknopd process but will force fwknopd to re-read the fwknopd.conf and /etc/fwknop/access.conf files. This will also force a flush of the current "FWKNOP" iptables chain(s). --rotate-digest-cache Rotate the digest cache file by renaming it to "-old", and starting a new one. The digest cache file is typically found in /var/fwknop/digest.cache. -r, --run-dir= Specify the directory where fwknopd writes run time state files. The default is /var. -S, --status Display the status of any fwknopd 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. --syslog-enable Allow messages to be sent to syslog even if the foreground mode is set. -t, --test Run fwknopd in test mode. This instructs fwknopd 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. -U, --udp-server Run fwknopd 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 "ENABLE_UDP_SERVER" configuration variable below for more information. -v, --verbose Run fwknopd 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). -h, --help Display usage information and exit. -V, --Version Display version information and exit. FWKNOPD CONFIG AND ACCESS VARIABLES fwknopd references the /etc/fwknop/fwknopd.conf file for configuration variables to define operational parameters (what network interface and port to sniff, what features to enable/disable, etc.). The fwknopd.conf file does not define any access control directives or set any encryption or authentication keys. The access control directives are contained in the /etc/fwknop/access.conf 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. FWKNOPD.CONF VARIABLES This section list the more prominent configuration variables used by fwknopd. 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 /etc/fwknop/fwknopd.conf file for additional details. PCAP_INTF Specify the ethernet interface on which fwknopd will sniff packets. ENABLE_PCAP_PROMISC By default fwknopd puts the pcap interface into promiscuous mode. Set this to "N" to disable that behavior (non-promiscuous). PCAP_FILTER Define the filter used for PCAP modes; fwknopd defaults to UDP port 62201. However, if an fwknop client uses the --rand-port option to send the SPA packet over a random port, then this variable should be updated to something like "udp dst portrange 10000-65535". ENABLE_SPA_PACKET_AGING This instructs fwknopd to not honor SPA packets that have an old time stamp. The value for "old" is defined by the "MAX_SPA_PACKET_AGE" variable. If "ENABLE_SPA_PACKET_AGING" is set to "N", fwknopd will not use the client time stamp at all. MAX_SPA_PACKET_AGE 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 fwknopd server system (NTP is good). The default age is 120 seconds (two minutes). ENABLE_DIGEST_PERSISTENCE Track digest sums associated with previous SPA packets processed by fwknopd. This allows digest sums to remain persistent across executions of fwknopd. The default is "Y". If set to "N", fwknopd 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. RULES_CHECK_THRESHOLD Defines the number of times firewall rule expiration times must be checked before a "deep" check is run. This allows fwknopd to remove rules that contain a proper exp