| 1 |
.\" Process this file with |
|---|
| 2 |
.\" groff -man -Tascii foo.1 |
|---|
| 3 |
.\" |
|---|
| 4 |
.TH FWKNOPD 8 "Jun, 2007" Linux |
|---|
| 5 |
.SH NAME |
|---|
| 6 |
.B fwknopd |
|---|
| 7 |
\- Firewall Knock Operator (server component) |
|---|
| 8 |
.SH SYNOPSIS |
|---|
| 9 |
.B fwknopd [options] |
|---|
| 10 |
.SH DESCRIPTION |
|---|
| 11 |
|
|---|
| 12 |
.B fwknopd |
|---|
| 13 |
is the server component for the FireWall Knock Operator, and is responsible |
|---|
| 14 |
for monitoring Single Packet Authorization (SPA) packets that are generated by |
|---|
| 15 |
.B fwknop |
|---|
| 16 |
clients, modifying a Netfilter policy to allow the desired access after decrypting |
|---|
| 17 |
a valid SPA packet, and removing access after a configurable timeout. The main |
|---|
| 18 |
application of this program is to protect services such as SSH with an additional |
|---|
| 19 |
layer of security in order to make the exploitation of vulnerabilities (both 0-day |
|---|
| 20 |
and unpatched code) much more difficult. |
|---|
| 21 |
.PP |
|---|
| 22 |
The main configuration for |
|---|
| 23 |
.B fwknopd |
|---|
| 24 |
is maintained within two files: |
|---|
| 25 |
.B fwknop.conf |
|---|
| 26 |
and |
|---|
| 27 |
.B access.conf |
|---|
| 28 |
within the |
|---|
| 29 |
.B /etc/fwknop |
|---|
| 30 |
directory, and configuration variables within these files are desribed below. |
|---|
| 31 |
.SH OPTIONS |
|---|
| 32 |
.TP |
|---|
| 33 |
.BR \-c "\fR,\fP " \-\^\-config\ \<config-file> |
|---|
| 34 |
When run in server mode |
|---|
| 35 |
.B fwknop |
|---|
| 36 |
references the file |
|---|
| 37 |
.B /etc/fwknop/fwknop.conf |
|---|
| 38 |
for various run-time configuration |
|---|
| 39 |
variables. The path to this file can be changed through the use of the |
|---|
| 40 |
.B --config |
|---|
| 41 |
command line option. |
|---|
| 42 |
.TP |
|---|
| 43 |
.BR \-i "\fR,\fP " \-\^\-intf\ \<interface> |
|---|
| 44 |
Manually specify interface on which to sniff, e.g. "-i eth0". This option |
|---|
| 45 |
is not usually needed because the PCAP_INTF keyword in /etc/fwknop/fwknop.conf |
|---|
| 46 |
file defines the sniffing interface. |
|---|
| 47 |
.TP |
|---|
| 48 |
.BR \-\^\-fw-list |
|---|
| 49 |
List all active rules in the FWKNOP Netfilter chain(s). |
|---|
| 50 |
.TP |
|---|
| 51 |
.BR \-\^\-fw-flush |
|---|
| 52 |
Flush all active rules in the FWKNOP Netfilter chain(s). |
|---|
| 53 |
.TP |
|---|
| 54 |
.BR \-o "\fR,\fP " \-\^\-os |
|---|
| 55 |
Parse Netfilter logs and fingerprint operating systems from which tcp SYN |
|---|
| 56 |
packets have been logged. |
|---|
| 57 |
.TP |
|---|
| 58 |
.BR \-\^\-fw-log\ \<file> |
|---|
| 59 |
Specify the path to the Netfilter log file that is parsed when running in |
|---|
| 60 |
--os mode. |
|---|
| 61 |
.TP |
|---|
| 62 |
.BR \-K "\fR,\fP " \-\^\-Kill |
|---|
| 63 |
Kill the current fwknop process along with knopwatchd and knopmd. This |
|---|
| 64 |
provides a quick and easy way to stop all fwknop processes without having |
|---|
| 65 |
to look in the process table or appeal to the fwknop init script. |
|---|
| 66 |
.TP |
|---|
| 67 |
.BR \-R "\fR,\fP " \-\^\-Restart |
|---|
| 68 |
Restart the currently running fwknop processes. This option will preserve |
|---|
| 69 |
the command line options that were supplied to the original fwknop process. |
|---|
| 70 |
.TP |
|---|
| 71 |
.BR \-\^\-Status |
|---|
| 72 |
Display the status of any fwknop processes that may or not be running. |
|---|
| 73 |
.TP |
|---|
| 74 |
.BR \-v "\fR,\fP " \-\^\-verbose |
|---|
| 75 |
Run fwknop in verbose mode. |
|---|
| 76 |
.TP |
|---|
| 77 |
.BR \-h "\fR,\fP " \-\^\-help |
|---|
| 78 |
Display usage information and exit. |
|---|
| 79 |
.TP |
|---|
| 80 |
.BR \-V "\fR,\fP " \-\^\-Version |
|---|
| 81 |
Display version information and exit. |
|---|
| 82 |
.SH FILES |
|---|
| 83 |
.B /etc/fwknop/fwknop.conf |
|---|
| 84 |
.RS |
|---|
| 85 |
The main configuration file for |
|---|
| 86 |
.B fwknop. |
|---|
| 87 |
.RE |
|---|
| 88 |
|
|---|
| 89 |
.B /etc/fwknop/access.conf |
|---|
| 90 |
.RS |
|---|
| 91 |
Defines all knock sequences and access control directives. |
|---|
| 92 |
.RE |
|---|
| 93 |
|
|---|
| 94 |
.B /etc/fwknop/pf.os |
|---|
| 95 |
.RS |
|---|
| 96 |
Defines p0f signatures used by fwknop. |
|---|
| 97 |
.RE |
|---|
| 98 |
.SH FWKNOP CONFIG AND ACCESS VARIABLES |
|---|
| 99 |
.B fwknop |
|---|
| 100 |
references the file |
|---|
| 101 |
.B /etc/fwknop/fwknop.conf |
|---|
| 102 |
for configuration variables such as the path to the firewall logfile, |
|---|
| 103 |
the sleep interval fwknop uses to check for new log messages, and |
|---|
| 104 |
paths to system binaries, etc. The |
|---|
| 105 |
.B fwknop |
|---|
| 106 |
config file does not define any access control directives; they are |
|---|
| 107 |
located in the file |
|---|
| 108 |
.B /etc/fwknop/access.conf. |
|---|
| 109 |
Access control directives define encryption keys and level of access that |
|---|
| 110 |
is granted to an fwknop client that has generated the appropriate encrypted |
|---|
| 111 |
message. This file is referenced for this information when run in either |
|---|
| 112 |
the single packet authorization mode, or the legacy port knocking mode. |
|---|
| 113 |
.TP |
|---|
| 114 |
.B SOURCE: <IP,..,IP/NET,..,NET/ANY> |
|---|
| 115 |
This defines the source address from which an authorization packet (or |
|---|
| 116 |
legacy knock sequence) will be accepted. The string "ANY" is also |
|---|
| 117 |
accepted if a valid authorization packet should be honored from any source |
|---|
| 118 |
IP. Every authorization stanza in |
|---|
| 119 |
.B /etc/fwknop/access.conf |
|---|
| 120 |
definition must start with the SOURCE keyword. Networks can be |
|---|
| 121 |
specified in either CIDR (e.g. "192.168.10.0/24") or regular (e.g. |
|---|
| 122 |
"192.168.10.0/255.255.255.0") notation, and individual IP addresses |
|---|
| 123 |
can be specified as well. Also, multiple IP's and/or networks can |
|---|
| 124 |
be defined as a comma separated list (e.g. "192.168.10.0/24, 10.1.1.123") |
|---|
| 125 |
.TP |
|---|
| 126 |
.B DATA_COLLECT_MODE: PCAP|FILE_PCAP|ULOG_PCAP|ENCRYPT_SEQUENCE |
|---|
| 127 |
If DATA_COLLECT_MODE is set to "PCAP", |
|---|
| 128 |
.B fwknop |
|---|
| 129 |
sniffs the wire directly via libpcap to capture authorization packets. |
|---|
| 130 |
If set to "FILE_PCAP", fwknop reads a pcap-formatted file (defined by |
|---|
| 131 |
the PCAP_PKT_FILE keyword in the fwknop.conf file) that is written |
|---|
| 132 |
to by a separate sniffer process. If set to "ULOG_PCAP", fwknop collects |
|---|
| 133 |
packets via the Netfilter ulogd pcap writer. This requires that packets |
|---|
| 134 |
are logged via the ULOG target in the Netfilter policy. If set to |
|---|
| 135 |
ENCRYPT_SEQUENCE, fwknop falls back to the legacy port knocking method |
|---|
| 136 |
of network authorization. |
|---|
| 137 |
.TP |
|---|
| 138 |
.B ENABLE_CMD_EXEC |
|---|
| 139 |
This instructs |
|---|
| 140 |
.B fwknop |
|---|
| 141 |
to accept complete commands that are contained within an authorization |
|---|
| 142 |
packet. Any such command will be executed as root by the |
|---|
| 143 |
.B fwknop server. |
|---|
| 144 |
.TP |
|---|
| 145 |
.B CMD_REGEX: <regex> |
|---|
| 146 |
If ENABLE_CMD_EXEC is specified, the CMD_REGEX keyword instructs |
|---|
| 147 |
.B fwknop |
|---|
| 148 |
to restrict command execution to only those command that match the |
|---|
| 149 |
given regular expression. |
|---|
| 150 |
.TP |
|---|
| 151 |
.B KEY: <8 or more chars> |
|---|
| 152 |
Define the encryption key for an ENCRYPT_SEQUENCE block. This variable |
|---|
| 153 |
is required for all encrypted sequences (each encrypted sequence may |
|---|
| 154 |
have its own unique key), and must be provided at execution to an |
|---|
| 155 |
.B fwknop |
|---|
| 156 |
client attempting to gain access. When run in client mode, fwknop will |
|---|
| 157 |
prompt the user for the encryption key, or a path to the key may be |
|---|
| 158 |
provided on the command line with |
|---|
| 159 |
.B --get-key <file>. |
|---|
| 160 |
.TP |
|---|
| 161 |
.B OPEN_PORTS: <proto/port>, ..., <proto/port> |
|---|
| 162 |
Define a set of ports and protocols (tcp or udp) that will be opened |
|---|
| 163 |
if a valid knock sequence is seen. This variable is required for |
|---|
| 164 |
shared knock sequences since the port information is not sent within |
|---|
| 165 |
the sequence, and optional for encrypted knock sequences which can |
|---|
| 166 |
include the port and protocol within the sequence. |
|---|
| 167 |
.TP |
|---|
| 168 |
.B GPG_DECRYPT_ID: <keyID> |
|---|
| 169 |
Define a GnuPG key ID to use for decrypting SPA messages that have been |
|---|
| 170 |
encrypted by an |
|---|
| 171 |
.B fwknop |
|---|
| 172 |
client. This keyword is required for authentication that is based on |
|---|
| 173 |
.B gpg |
|---|
| 174 |
keys. |
|---|
| 175 |
The gpg key ring on the client must have imported and signed the |
|---|
| 176 |
.B fwknopd |
|---|
| 177 |
server key, and vice versa. It is ok to use a sensitive personal gpg key |
|---|
| 178 |
on the client, but each fwknopd server should have its own gpg key that is |
|---|
| 179 |
generated specifically for fwknop communications. The reason for this is |
|---|
| 180 |
that the decryption password for the server key must be placed within the |
|---|
| 181 |
.B /etc/fwknop/access.conf |
|---|
| 182 |
file for fwknopd to function (it has to be able to decrypt SPA messages that |
|---|
| 183 |
have been encrypted with the server's public key). For more information on |
|---|
| 184 |
using fwknop with GnuPG keys, see the following link: |
|---|
| 185 |
.B http://www.cipherdyne.org/fwknop/docs/gpghowto.html |
|---|
| 186 |
.TP |
|---|
| 187 |
.B GPG DECRYPT_PW: <decrypt password> |
|---|
| 188 |
Specify the decryption password for the |
|---|
| 189 |
.B gpg |
|---|
| 190 |
key defined by the |
|---|
| 191 |
.B GPG_DECRYPT_ID |
|---|
| 192 |
above. This is a required field for gpg-based authentication. |
|---|
| 193 |
.TP |
|---|
| 194 |
.B GPG_REMOTE_ID: <keyID,...,keyID> |
|---|
| 195 |
Define a list of |
|---|
| 196 |
.B gpg |
|---|
| 197 |
key ID's that are required to have signed any incoming SPA message that |
|---|
| 198 |
has been encrypted with the |
|---|
| 199 |
.B fwknopd |
|---|
| 200 |
server key. This ensures that the verification of the remote user is accomplished |
|---|
| 201 |
via a strong cryptographic mechanism. |
|---|
| 202 |
.TP |
|---|
| 203 |
.B GPG_HOME_DIR: <path> |
|---|
| 204 |
Define the path to the GnuPG directory to be used by the |
|---|
| 205 |
.B fwknopd |
|---|
| 206 |
server. If this keyword is not specified within |
|---|
| 207 |
.B /etc/fwknop/access.conf |
|---|
| 208 |
then fwknopd will default to using the /root/.gnupg directory for the server key(s). |
|---|
| 209 |
.TP |
|---|
| 210 |
.B FW_ACCESS_TIMEOUT: <seconds> |
|---|
| 211 |
Define the length of time access will be granted by fwknop through |
|---|
| 212 |
the firewall after a valid knock sequence from a source IP address. |
|---|
| 213 |
If FW_ACCESS_TIMEOUT is not set then the default timeout of 300 |
|---|
| 214 |
seconds (5 minutes) will automatically be set. |
|---|
| 215 |
.TP |
|---|
| 216 |
.B REQUIRE_USERNAME: <username> |
|---|
| 217 |
Require a specific username from the client system. This username is |
|---|
| 218 |
sent across the network in an encrypted knock sequence to the fwknop |
|---|
| 219 |
server. If there are multiple users on the client system, only a knock |
|---|
| 220 |
sequence that is initiated by the required username will be honored. |
|---|
| 221 |
This variable is optional and is only valid with an encrypted sequence |
|---|
| 222 |
definition. |
|---|
| 223 |
.TP |
|---|
| 224 |
.B REQUIRE_SOURCE_ADDRESS |
|---|
| 225 |
Force all SPA packets to contain a real IP address within the encrypted |
|---|
| 226 |
data. This makes it impossible to use the -s command line argument on |
|---|
| 227 |
the |
|---|
| 228 |
.B fwknop |
|---|
| 229 |
command line, so either -R has to be used to automatically resolve the |
|---|
| 230 |
external address (if the client behind a NAT) or the client must know |
|---|
| 231 |
the external IP. |
|---|
| 232 |
.TP |
|---|
| 233 |
.B REQUIRE_OS: <operating system> |
|---|
| 234 |
Require a specific operating system fingerprint match (e.g. |
|---|
| 235 |
"Linux:2.4::Linux 2.4/2.6" or "OpenBSD:3.0-3.5::OpenBSD 3.0-3.5" |
|---|
| 236 |
before a knock sequence will be accepted. The fingerprints are listed |
|---|
| 237 |
in |
|---|
| 238 |
.B /etc/fwknop/pf.os. |
|---|
| 239 |
Note that the corresponding knock sequence must utilize the tcp protocol |
|---|
| 240 |
(this is only be an issue for shared sequences since encrypted sequences |
|---|
| 241 |
use tcp by default) since OS fingerprinting requires tcp syn packets. |
|---|
| 242 |
This variable is optional, and is not applicable in SPA mode. |
|---|
| 243 |
.TP |
|---|
| 244 |
.B REQUIRE_OS_REGEX: <regex> |
|---|
| 245 |
Require an operating system fingerprint that matches <regex>, e.g. |
|---|
| 246 |
"linux" or "*bsd". Note that the regex will be matched case in- |
|---|
| 247 |
sensitively. This variable is optional, and is not applicable in SPA |
|---|
| 248 |
mode. |
|---|
| 249 |
.TP |
|---|
| 250 |
.B ENCRYPT_SEQUENCE |
|---|
| 251 |
Expect that all port knock sequences originating from the SOURCE will |
|---|
| 252 |
be encrypted. Fwknop will try to decrypt all such sequences. |
|---|
| 253 |
ENCRYPT_SEQUENCE does not accept any arguments. Either this variable |
|---|
| 254 |
or the "SHARED_SEQUENCE" variable is required for each SOURCE block. |
|---|
| 255 |
.TP |
|---|
| 256 |
.B SHARED_SEQUENCE: <proto/port>, ..., <proto/port> |
|---|
| 257 |
Define the sequence of ports (together with their associated |
|---|
| 258 |
protocol; tcp or udp) that will be sent to the destination knock |
|---|
| 259 |
server. This sequence is not encrypted, and source IP will be |
|---|
| 260 |
allowed to connect through the destination firewall ruleset to a set |
|---|
| 261 |
of tcp or udp ports (defined by the OPEN_PORTS variable). Using |
|---|
| 262 |
an encrypted sequence is much more secure. Either this variable or |
|---|
| 263 |
the "ENCRYPT_SEQUENCE" variable above is required for each SOURCE |
|---|
| 264 |
block. |
|---|
| 265 |
.TP |
|---|
| 266 |
.B KNOCK_INTERVAL: <seconds> |
|---|
| 267 |
Define the interval of time in which a port knock sequence will be |
|---|
| 268 |
honored. I.e. the number of seconds after the first connection |
|---|
| 269 |
attempt the last connection attempt in the sequence must be received |
|---|
| 270 |
for the knock sequence to be accepted by the destination fwknop |
|---|
| 271 |
daemon. If a KNOCK_INTERVAL is not specified then the default |
|---|
| 272 |
interval of 60 seconds will automatically be set. |
|---|
| 273 |
.TP |
|---|
| 274 |
.B KNOCK_LIMIT: <number> |
|---|
| 275 |
Define the maximum number of times a knock sequence will be honored. |
|---|
| 276 |
Note that repetitive access to the fwknop server will eventually be |
|---|
| 277 |
restricted if this option is used. |
|---|
| 278 |
.TP |
|---|
| 279 |
.B PORT_OFFSET: <offset> |
|---|
| 280 |
Encrypted knock sequences take place over a range of 256 ports |
|---|
| 281 |
starting at a default port of 61000. This value can be changed |
|---|
| 282 |
through the use of the PORT_OFFSET variable. The PORT_OFFSET |
|---|
| 283 |
is optional and will be set to 61000 by fwknop if it is not specified |
|---|
| 284 |
in /etc/fwknop/access.conf. |
|---|
| 285 |
.TP |
|---|
| 286 |
.B MIN_TIME_DIFF: <seconds> |
|---|
| 287 |
Set the minimum number of seconds that must pass between successive |
|---|
| 288 |
connection attempts in a shared knock sequence. This variable is |
|---|
| 289 |
optional. |
|---|
| 290 |
.TP |
|---|
| 291 |
.B MAX_TIME_DIFF: <seconds> |
|---|
| 292 |
Set the maximum number of seconds that must pass between successive |
|---|
| 293 |
connection attempts in a shared knock sequence. This variable is |
|---|
| 294 |
optional. |
|---|
| 295 |
.SH DEPENDENCIES |
|---|
| 296 |
.B fwknopd |
|---|
| 297 |
requires perl. To take advantage of all of the features in fwknop when run |
|---|
| 298 |
in server mode a functioning Netfilter firewall is required on the underlying |
|---|
| 299 |
operating system. If fwknop is being run in the legacy port knocking mode, |
|---|
| 300 |
then Netfilter must log packets via syslog, and ideally the --log-tcp-options |
|---|
| 301 |
argument will be specified in the iptables logging rule so that fwknop will |
|---|
| 302 |
be able to use a strategy similar to |
|---|
| 303 |
.B p0f |
|---|
| 304 |
to passively fingerprint operating systems. |
|---|
| 305 |
.SH DIAGNOSTICS |
|---|
| 306 |
.B fwknop |
|---|
| 307 |
can be run in debug mode with the --debug command line option. This will |
|---|
| 308 |
disable daemon mode execution, and print verbose information to the screen |
|---|
| 309 |
on STDERR as packets are received. |
|---|
| 310 |
.SH "SEE ALSO" |
|---|
| 311 |
.BR fwknop (8), |
|---|
| 312 |
.BR iptables (8), |
|---|
| 313 |
.BR gpg (1), |
|---|
| 314 |
.BR gpg-agent (1), |
|---|
| 315 |
.BR knopmd (8), |
|---|
| 316 |
.BR knopwatchd (8) |
|---|
| 317 |
.BR p0f (1), |
|---|
| 318 |
.SH AUTHOR |
|---|
| 319 |
Michael Rash <mbr@cipherdyne.org> |
|---|
| 320 |
.SH CREDITS |
|---|
| 321 |
The phrase "Single Packet Authorization" was coined by MadHat, see: |
|---|
| 322 |
.B http://www.nmrc.org/ |
|---|
| 323 |
The term "port knocking" was coined by Martin Krzywinski, see: |
|---|
| 324 |
.B http://www.portknocking.org/ |
|---|
| 325 |
The original p0f passive OS fingerprinter was written by Michal Zalewski, and is |
|---|
| 326 |
available here: |
|---|
| 327 |
.B http://lcamtuf.coredump.cx/p0f.shtml |
|---|
| 328 |
.SH BUGS |
|---|
| 329 |
Send bug reports to mbr@cipherdyne.org. Suggestions and/or comments are |
|---|
| 330 |
always welcome as well. |
|---|
| 331 |
.SH DISTRIBUTION |
|---|
| 332 |
.B fwknop |
|---|
| 333 |
is distributed under the GNU General Public License (GPL), and the latest |
|---|
| 334 |
version may be downloaded from |
|---|
| 335 |
.B http://www.cipherdyne.org/ |
|---|