root/fwknop/tags/fwknop-0.9.7-pre1/fwknop.8

Revision 464, 16.8 kB (checked in by mbr, 3 years ago)

man page formatting fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 .\" Process this file with
2 .\" groff -man -Tascii foo.1
3 .\"
4 .TH FWKNOP 8 "May, 2005" Linux
5 .SH NAME
6 .B fwknop
7 \- Firewall Knock Operator
8 .SH SYNOPSIS
9 .B fwknop [-u
10 .I user-rc file
11 .B ] [-k
12 .I knock-dst
13 .B ] [-a
14 .I allow-IP
15 .B ] [--gpg-signing-key
16 .I keyID
17 .B ] [--gpg-recipient
18 .I keyID
19 .B ] [--gpg-verbose] [--gpg-home-dir
20 .I GnuPG dir
21 .B ] [--Server-port
22 .I port
23 .B ] [--Server-mode
24 .I mode
25 .B ] [--Server-cmd
26 .I command
27 .B ] [--Spoof-src
28 .I IP
29 .B ] [--Spoof-cmd
30 .I command
31 .B ] [--Spoof-file
32 .I file
33 .B ] [--Spoof-user
34 .I user
35 .B ] [--no-save-args] [-d] [-e] [-s] [-r] [-w] [-K] [-R] [-A] [-t
36 .I time-delay
37 .B ] [-g
38 .I key-file
39 .B ] [--offset
40 .I port-offset
41 .B ] [-H
42 .I homedir
43 .B ] [--Status] [-l] [-v] [-V] [-h]
44 .SH DESCRIPTION
45
46 .B fwknop
47 implements an authorization scheme known as Single Packet Authorization (SPA)
48 that requires only a single encrypted
49 packet to communicate various pieces of information including desired access
50 through a Netfilter policy and/or specific commands to execute on the target
51 system.  The main application of this program is to protect services such as
52 .B SSH
53 with an additional layer of security in order to make the exploitation of
54 vulnerabilities (both 0-day and unpatched code) much more difficult.  The
55 authorization server passively monitors authorization packets via
56 .B libpcap
57 and hence there is no "server" to which to connect in the traditional sense.
58 Any service protected by fwknop
59 is inaccessible (by using Netfilter to intercept packets within the Linux
60 kernel) before authenticating; anyone scanning for the service will not be
61 able to detect that it is even listening.  This authorization scheme offers
62 many advantages over port knocking, include being non-replayable, much more
63 data can be communicated, and the scheme cannot be broken by simply
64 connecting to extraneous ports on the server in an effort to break
65 knock sequences.  The authorization packets can easily be spoofed as
66 well, and this makes it possible to make it appear as though, say, www.yahoo.com
67 is trying to authenticate to a target system but in reality the actual
68 connection will come from a seemingly unrelated IP.  Although the default
69 data collection method is to use libpcap to sniff packets off the wire,
70 fwknop can also read packets out of a file that is written by the Netfilter
71 . B ulogd
72 pcap writer (or a separate sniffer process that is writing to a file).
73 .PP
74 Authorization packets are either encrypted with the Rijndael block cipher
75 or via GnuPG and associated asymmetric ciphers.  If the symmetric encryption
76 method is chosen, then the encryption key is shared between between the
77 client and server (see the file /etc/fwknop/access.conf).  If the GnuPG
78 method is chosen, then the encryption keys are derived from GnuPG key
79 rings.  Authorization packets generated by fwknop running as a client adhere
80 to the following format before being encrypted:
81 .PP
82     random number (16 bytes)
83     username
84     timestamp
85     software version
86     mode (command mode (0) or access mode (1))
87     if command mode => command to execute
88     else access mode  => IP,proto,port
89     MD5 sum
90 .PP
91 Each of the above fields are separated by a ":" character due to the
92 variable length of several of the fields, and those that might contain
93 ":" characters are base64 encoded.  The MD5 message sum allows the
94 server to check message integrity after decryption, and the 16 bytes
95 of random data ensures (with high probability) that no two messages are
96 identical.  For each packet coming from an fwknop client, the server
97 caches the MD5 sum calculated over the entire packet and compares against
98 previous MD5 sums in order to detect attempted replay attacks.  Both
99 syslog and email alerts are (optionally) generated if a replay is
100 attempted.  By default, fwknop sends authorization packets over UDP
101 port 62201, but this can be altered with the --Server-port argument.
102 The fwknop server is not limited to acquiring authorization packets
103 over any particular port or protocol, but the PCAP_FILTER and
104 ULOG_PCAP_FILTER keywords in /etc/fwknop/fwknop.conf limit the server
105 to inspecting traffic over the default UDP port 62201.  See the EXAMPLES
106 section for example invocations of fwknop in client mode, and see the
107 FWKNOP CONFIG section for an explanation of server configuration
108 keywords.
109 .PP
110 A note about the interaction between
111 .B fwknop
112 and Netfilter; fwknop maintains a strict separation between dynamically
113 generated rules and any existing Netfilter policy by adding all rules
114 to a custom chain "FWKNOP_INPUT".  Packets are jumped to this chain from
115 the INPUT chain.  Interaction with the FORWARD chain can be accomplished
116 by altering the IPT_AUTO_CHAIN{n} keywords in
117 .B /etc/fwknop/fwknop.conf.
118 .PP
119 In addition to the Single Packet Authorization method, fwknop maintains
120 the ability to generate encrypted port knocking sequences and combine
121 them with passive OS fingerprinting, but this mode is not enabled by
122 default.  This scheme is based around log
123 messages generated by the Netfilter firewall in the Linux kernel.
124 .B fwknop
125 supports both shared and encrypted port knock sequences, passive OS fingerprinting,
126 multi-protocol knock sequences (tcp, udp, and icmp), firewall access across
127 multiple ports and protocols, firewall access timeouts, relative timeouts between
128 knock packets, and more.
129 .PP
130 The server component of fwknop is the
131 .B fwknopd
132 daemon which normally sniffs the wire directly or monitors a pcap file for SPA
133 packets generated by fwknop clients.  If run in legacy port knocking mode, fwknopd
134  watches iptables log messages as they are written via syslog to a named pipe
135 .B /var/lib/fwknop/fwknopfifo.
136 If a valid knock sequence is seen, then fwknop will modify the iptables ruleset to
137 grant the appropriate access to the originating IP address.  Knock sequence parameters
138 are defined in the file
139 .B /etc/fwknop/access.conf.
140 When run in client mode, fwknop generates either an encrypted knock sequence (see
141 the
142 .B EXAMPLES
143 section below), or a shared knock sequence.  Shared knock sequences are defined in
144 the file
145 .B ~/.fwknoprc
146 (this file is not used for encrypted sequences).
147
148 See the
149 .B fwknopd (8)
150 man page for more information.
151
152 .SH OPTIONS
153 .TP
154 .BR \-A "\fR,\fP " \-\^\-Access\ \<port\ list>
155 Provide a list of ports and protocols to access via a remote
156 .B fwknop
157 server. The format of this list is "<proto>/<port>...<proto>/<port>",
158 e.g. "tcp/22,udp/53".
159 .TP
160 .BR \-\^\-gpg-signing-key\ \<key ID>
161 Specify the GnuPG key ID, e.g. "ABCD1234" (see the output of "gpg --list-keys")
162 to use to sign a Single Packet Authorization message.  The user prompted for the
163 associated GPG password which is required for creating the signature.  This
164 .TP
165 .BR \-\^\-gpg-recipient\ \<key ID>
166 Specify the GnuPG key ID, e.g. "1234ABCD" (see the output of "gpg --list-keys")
167 of the recipient of the Single Packet Authorization message.  This key is imported
168 by the
169 .B fwknopd
170 server and the associated private key is used to decrypt the SPA packet.  The
171 recipient's key must be imported into the client GnuPG key ring.
172 .TP
173 .BR \-\^\-gpg-home-dir\ \<dir>
174 Specify the path to the GnuPG directory; normally this path is derived from the
175 home directory of the user that is running the
176 .B fwknop
177 client.
178 .TP
179 .BR \-\^\-gpg-verbose
180 Instruct
181 .B fwknop
182 to allow all output from the
183 .B gpg
184 process that is used by fwknop in GPG mode.  This is primarily used for debugging
185 purposes if it appears that the GPG encrypt/decrypt is not performing correctly.
186 .TP
187 .BR \-\^\-Server-port\ \<port>
188 Specify the port number where
189 .B fwknop
190 accepts packets via libpcap or ulogd pcap writer.  By default fwknop looks for
191 authorization packets over UDP port 62201.
192 .TP
193 .BR \-\^\-Server-cmd\ \<cmd>
194 The --Server-cmd argument allows a complete command (e.g. "ping -c 1 www.yahoo.com",
195 or "iptables -t nat -A PREROUTING -p tcp -s 65.x.x.x --dport 443 -i eth0 -j DNAT --to 192.168.10.20:443")
196 to be send to an
197 .B fwknop
198 server, which will execute the command as root.  Command execution is enabled only
199 if the ENABLE_CMD_EXEC keyword is given in /etc/fwknop/access.conf (note that
200 commands can easily be restricted with the CMD_REGEX keyword as well).
201 .TP
202 .BR \-u "\fR,\fP " \-\^\-user-rc\ \<rc-file>
203 The default connection rc file
204 .B fwknop
205 uses to know what shared port knocking sequence to send to a destination machine
206 is defined in the file
207 .B ~/.fwknoprc.
208 The path to this file can be changed with the
209 .B --user-rc
210 command line option.
211 .TP
212 .BR \-k "\fR,\fP " \-\^\-knock-dst\ \<IP>
213 Run
214 .B fwknop
215 in port knocking mode against the destination IP address.  The specific port
216 knock sequence that is sent to the destination will either be encrypted (if
217 .B --encrypt
218 is passed on the command line) or read out of the file
219 .B ~/.fwknoprc.
220 .TP
221 .BR \-a "\fR,\fP " \-\^\-allow-ip\ \<allow-IP>
222 Specify a third-party IP address (can be the local machine) to allow
223 through the destination knock server firewall.  This option is only used
224 when
225 .B fwknop
226 is being run in
227 .B --encrypt
228 encrypted knock mode.
229 .TP
230 .BR \-s "\fR,\fP " \-\^\-source-ip
231 Instruct
232 .B fwknop
233 to form an encrypted knock sequence that will contain the special-case IP
234 address "0.0.0.0" which will inform the destination knock server to use
235 the source IP address from which an encrypted knock sequence originates as
236 the IP that will be allowed through upon modification of the firewall ruleset.
237 This option is useful if the fwknop client is deployed on a machine that is
238 behind a NAT device.  This option is only used in
239 .B --encrypt
240 encrypted knock mode.
241 .TP
242 .BR \-\^\-Spoof-src\ \<IP>
243 Spoof the source address from which
244 .B fwknop
245 sends authorization packets.  This requires root access since a raw socket
246 is required to accomplish this.  Note that the --Spoof-user argument can be
247 given in this mode in order to pass any REQUIRE_USERNAME keyword that might
248 be specified in /etc/fwknop/access.conf.
249 .TP
250 .BR \-\^\-Spoof-cmd\ \<cmd>
251 Specify the path to the command
252 .B knopspoof
253 which is used by
254 .B fwknop
255 in --Spoof-src mode.  This command is install by default at /usr/sbin/knopspoof.
256 .TP
257 .BR \-\^\-Spoof-user\ \<user>
258 Specify the username that is included within authorization messages.  This allows
259 the client to satisfy any non-root REQUIRE_USERNAME keyword on the
260 .B fwknop
261 server (--Spoof-src mode requires that fwknop is executed as root).
262 .TP
263 .BR \-\^\-Spoof-file\ \<file>
264 Specify the path to the cache file that
265 .B knopspoof
266 reads in order to correctly generate the authorization packet.  This
267 file defaults to /tmp/spoof.cache, and contains source and destination
268 IP addresses, protocol and port numbers, and the encrypted authorization
269 message.
270 .TP
271 .BR \-\^\-offset\ \<port>
272 Specify a port offset to use when running
273 .B fwknop
274 in encrypted knock mode.  The default is 61000.
275 .TP
276 .BR \-r "\fR,\fP " \-\^\-rotate-proto
277 Rotate the protocol across tcp and udp for encrypted sequences.  This just
278 adds one more additional layer of obfuscation to an encrypted sequence.
279 .TP
280 .BR \-t "\fR,\fP " \-\^\-time-delay\ \<seconds>
281 Specify a time delay to introduce between successive connection attempts.
282 This option is only used when
283 .B fwknop
284 is run in client mode.  On the server side, the variables MIN_TIME_DIFF
285 and MAX_TIME_DIFF will control whether the time delay actually means
286 something (i.e. if the MIN_TIME_DIFF is 2 seconds for a SOURCE block,
287 then the argument to the --time-delay option must be at least 2 at the
288 client side).
289 .TP
290 .BR \-\^\-Server-mode\ \<mode>
291 This command line switch provides an interface to the old port knocking method if
292 the mode argument is "knock".  If the --Server-mode argument is not given then
293 .B fwknop
294 defaults to the Single Packet Authorization method which provides much better
295 security characteristics than port knocking (encrypted or not).
296 .TP
297 .BR \-g "\fR,\fP " \-\^\-get-key\ \<file>
298 Get encryption key from
299 .B <file>
300 instead of from STDIN.  This option can only be specified when running
301 .B fwknop
302 in encrypted knock mode against a system running a fwknop server.
303 .TP
304 .BR \-l "\fR,\fP " \-\^\-last-cmd
305 Run
306 .B fwknop
307 with the command line arguments given for the previous execution.  This
308 makes it easy to run the same fwknop command over and over without having
309 to remember complicated command line args.
310 .TP
311 .BR \-\^\-no-save-args
312 Instruct
313 .B fwknop
314 to not save the command line arguments it was invoked with.  This is useful to
315 test fwknop with new command line args that should not be saved to disk, and
316 this leaves existing saved arguments from a previous fwknop execution intact.
317 .TP
318 .BR \-H "\fR,\fP " \-\^\-Home-dir\ \<directory>
319 Manually specify the home directory associated with the current user (useful
320 if fwknop is unable to automatically determine the home directory).
321 .TP
322 .BR \-v "\fR,\fP " \-\^\-verbose
323 Run fwknop in verbose mode.
324 .TP
325 .BR \-h "\fR,\fP " \-\^\-help
326 Display usage information and exit.
327 .TP
328 .BR \-V "\fR,\fP " \-\^\-Version
329 Display version information and exit.
330 .SH EXAMPLES
331 The following examples illustrate the command line arguments that could
332 be supplied to fwknop in a few situations:
333 .PP
334 Use the Single Packet Authorization mode to gain access to tcp/22 (ssh)
335 and udp/53 running on the system 10.0.0.123 from the IP 192.168.10.4:
336 .PP
337 .B $ fwknop -A "tcp/22,udp/53" -a 192.168.10.4 -k 10.0.0.123
338 .PP
339 Same as above example, but gain access from whatever source IP is seen
340 by the fwknop server (useful if the fwknop client is behind a NAT device):
341 .PP
342 .B $ fwknop -A "tcp/22,udp/53" -s -k 10.0.0.123
343 .PP
344 Same as above example, but use the IP identification website http://www.whatismyip.com
345 to derive the client IP address.  This is a safer method of acquiring the client IP
346 address than using the "-s" option because the IP is put within the encrypted packet
347 (a man-in-the-middle attack becomes infeasible against this).
348 .PP
349 .B $ fwknop -A "tcp/22,udp/53" -w -k 10.0.0.123
350 .PP
351 Use the Single Packet Authorization mode to gain access to tcp/22 (ssh)
352 and udp/53 running on the system 10.0.0.123, and use GnuPG keys to encrypt
353 and decrypt:
354 .PP
355 .B $ fwknop -A "tcp/22,udp/53" --gpg-sign ABCD1234 --gpg--recipient 1234ABCD -w -k 10.0.0.123
356 .PP
357 Instruct the fwknop server running at 10.0.0.123 to send a single ICMP
358 echo request to www.yahoo.com:
359 .PP
360 .B $ fwknop --Server-cmd "ping -c 1 www.yahoo.com" -k 10.0.0.123
361 .PP
362 Instruct the fwknop server running at 10.0.0.123 to allow 172.16.5.4 to
363 connect to TCP/22, but spoof the authorization packet from an IP associated
364 with www.yahoo.com:
365 .PP
366 .B # fwknop --Spoof-src "www.yahoo.com" -A tcp/22 -a 172.16.5.4 -k 10.0.0.123
367 .PP
368 LEGACY: Send an encrypted knock sequence to the IP "10.0.0.123" instructing the
369 fwknop daemon running there to open tcp port 22 to source address
370 192.168.10.4:
371 .PP
372 .B $ fwknop --Server-mode "knock" -A tcp/22 -a 192.168.10.4 -k 10.0.0.123
373 .PP
374 LEGACY: Same as above, but this time instruct the remote fwknop daemon to open
375 tcp port 22 to whatever source address the encrypted sequence originates
376 from (useful if the fwknop client is behind a NAT device):
377 .PP
378 .B $ fwknop --Server-mode "knock" -A tcp/22 -s -k 10.0.0.123
379 .PP
380 LEGACY: Same as above, but rotate the knock sequence through the tcp and udp
381 protocols (remember that iptables must be configured to log both tcp and
382 udp packets to the default port range of 61000-61255):
383 .PP
384 .B $ fwknop --Server-mode "knock" -A tcp/22 -s -r -k 10.0.0.123
385 .PP
386 LEGACY: Same as above, but change the base port for the encrypted sequence to
387 55000 (the default is 61000):
388 .PP
389 .B $ fwknop --Server-mode "knock" -A tcp/22 -s -r --offset 55000 -k 10.0.0.123
390 .PP
391 LEGACY: Send a shared knock sequence to the IP 10.11.11.123.  The fwknop client
392 will read the sequence out of the file
393 .B ~/.fwknoprc
394 and the server will read the sequence out of
395 .B /etc/fwknop/access.conf:
396 .PP
397 .B $ fwknop --Server-mode "knock" -k 10.11.11.123
398 .SH DEPENDENCIES
399 .B fwknop
400 requires perl.  To take advantage of all of the features in fwknop when run
401 in server mode a functioning Netfilter firewall is required on the underlying
402 operating system.  If fwknop is being run in the legacy port knocking mode,
403 then Netfilter must log packets via syslog, and ideally the --log-tcp-options
404 argument will be specified in the iptables logging rule so that fwknop will
405 be able to use a strategy similar to
406 .B p0f
407 to passively fingerprint operating systems.
408 .SH DIAGNOSTICS
409 .B fwknop
410 can be run in debug mode with the --debug command line option.  This will
411 disable daemon mode execution, and print verbose information to the screen
412 on STDERR as packets are received.
413 .SH "SEE ALSO"
414 .BR fwknopd (8),
415 .BR iptables (8),
416 .BR p0f (1),
417 .BR knopmd (8),
418 .BR knopwatchd (8)
419 .SH AUTHOR
420 Michael Rash <mbr@cipherdyne.org>
421 .SH CREDITS
422 The phrase "Single Packet Authorization" was coined by MadHat, see:
423 .B http://www.nmrc.org/
424 The term "port knocking" was coined by Martin Krzywinski, see:
425 .B http://www.portknocking.org/
426  The original p0f passive OS fingerprinter was written by Michal Zalewski, and is
427 available here:
428 .B http://lcamtuf.coredump.cx/p0f.shtml
429 .SH BUGS
430 Send bug reports to mbr@cipherdyne.org.  Suggestions and/or comments are
431 always welcome as well.
432 .SH DISTRIBUTION
433 .B fwknop
434 is distributed under the GNU General Public License (GPL), and the latest
435 version may be downloaded from
436 .B http://www.cipherdyne.org/
Note: See TracBrowser for help on using the browser.