| 1 |
.\" Process this file with |
|---|
| 2 |
.\" groff -man -Tascii foo.1 |
|---|
| 3 |
.\" |
|---|
| 4 |
.TH FWKNOP 8 "Jun, 2007" Linux |
|---|
| 5 |
.SH NAME |
|---|
| 6 |
.B fwknop |
|---|
| 7 |
\- Firewall Knock Operator |
|---|
| 8 |
.SH SYNOPSIS |
|---|
| 9 |
.B fwknop -A <ports> -D <host> [options] |
|---|
| 10 |
.SH DESCRIPTION |
|---|
| 11 |
|
|---|
| 12 |
.B fwknop |
|---|
| 13 |
implements an authorization scheme known as Single Packet Authorization (SPA) |
|---|
| 14 |
that requires only a single encrypted |
|---|
| 15 |
packet to communicate various pieces of information including desired access |
|---|
| 16 |
through an iptables policy and/or specific commands to execute on the target |
|---|
| 17 |
system. The main application of this program is to protect services such as |
|---|
| 18 |
.B SSH |
|---|
| 19 |
with an additional layer of security in order to make the exploitation of |
|---|
| 20 |
vulnerabilities (both 0-day and unpatched code) much more difficult. An |
|---|
| 21 |
authorization server |
|---|
| 22 |
.B fwknopd |
|---|
| 23 |
passively monitors authorization packets via |
|---|
| 24 |
.B libpcap |
|---|
| 25 |
and hence there is no "server" to which to connect in the traditional sense. |
|---|
| 26 |
Any service protected by fwknop is inaccessible (by using iptables to intercept |
|---|
| 27 |
packets within the Linux kernel) before authenticating; anyone scanning for |
|---|
| 28 |
the service will not be able to detect that it is even listening. Single Packet |
|---|
| 29 |
Authorization offers many advantages over port knocking, including non-replayability |
|---|
| 30 |
of SPA packets, ability to use asymmetric ciphers (such as Elgamal), and SPA cannot |
|---|
| 31 |
be broken by simply spoofing packets to duplicate ports within the knock sequence |
|---|
| 32 |
on the server to break port knocking authentication. SPA packets can easily be |
|---|
| 33 |
spoofed as well (this is a good thing in this context), and this makes it possible |
|---|
| 34 |
to make it appear as though, say, www.yahoo.com is trying to authenticate to a |
|---|
| 35 |
target system but in reality the actual connection will come from a seemingly |
|---|
| 36 |
unrelated IP. Although the default data collection method in Single Packet |
|---|
| 37 |
Authorization mode is to use libpcap to sniff packets off the wire, fwknop can also |
|---|
| 38 |
read packets out of a file that is written by the iptables |
|---|
| 39 |
. B ulogd |
|---|
| 40 |
pcap writer (or a separate sniffer process that is writing packet data to a file). |
|---|
| 41 |
.PP |
|---|
| 42 |
Authorization packets are either encrypted with the Rijndael block cipher |
|---|
| 43 |
or via GnuPG and associated asymmetric ciphers. If the symmetric encryption |
|---|
| 44 |
method is chosen, then the encryption key is shared between between the |
|---|
| 45 |
client and server (see the |
|---|
| 46 |
.I /etc/fwknop/access.conf |
|---|
| 47 |
file). If the GnuPG |
|---|
| 48 |
method is chosen, then the encryption keys are derived from GnuPG key |
|---|
| 49 |
rings. SPA packets generated by fwknop running as a client adhere |
|---|
| 50 |
to the following format (before they are encrypted): |
|---|
| 51 |
.PP |
|---|
| 52 |
random number (16 bytes) |
|---|
| 53 |
username |
|---|
| 54 |
timestamp |
|---|
| 55 |
software version |
|---|
| 56 |
mode (command mode (0) or access mode (1)) |
|---|
| 57 |
if command mode => command to execute |
|---|
| 58 |
else access mode => IP,proto,port |
|---|
| 59 |
MD5 sum |
|---|
| 60 |
.PP |
|---|
| 61 |
Each of the above fields are separated by a ":" character due to the |
|---|
| 62 |
variable length of several of the fields, and those that might contain |
|---|
| 63 |
":" characters are base64 encoded. The MD5 message sum allows the |
|---|
| 64 |
server to check message integrity after decryption, and the 16 bytes |
|---|
| 65 |
of random data ensures (with high probability) that no two messages are |
|---|
| 66 |
identical. For each packet coming from an |
|---|
| 67 |
.B fwknop |
|---|
| 68 |
client, the |
|---|
| 69 |
.B fwknopd |
|---|
| 70 |
server caches the MD5 sum calculated over the entire packet and compares against |
|---|
| 71 |
previous MD5 sums in order to detect attempted replay attacks. The MD5 sum |
|---|
| 72 |
cache file is located at |
|---|
| 73 |
.I /var/log/fwknop/md5sums |
|---|
| 74 |
and is not rotated so that the detection of duplicate SPA messages is maximized. |
|---|
| 75 |
Both syslog and email alerts are generated if a replay is detected (although |
|---|
| 76 |
this can be tuned via the |
|---|
| 77 |
.B ALERTING_METHODS |
|---|
| 78 |
variable in the |
|---|
| 79 |
.I /etc/fwknop/fwknop.conf |
|---|
| 80 |
file). By default, the |
|---|
| 81 |
.B fwknop |
|---|
| 82 |
client sends authorization packets over UDP |
|---|
| 83 |
port 62201, but this can be altered with the |
|---|
| 84 |
.B --Server-port |
|---|
| 85 |
argument. The server must first be configured to acquire the SPA data on |
|---|
| 86 |
the changed ptotocol-port. See |
|---|
| 87 |
.B fwknopd(8) |
|---|
| 88 |
for further details. See the |
|---|
| 89 |
.B EXAMPLES |
|---|
| 90 |
section for example invocations of the |
|---|
| 91 |
.B fwknop |
|---|
| 92 |
client. |
|---|
| 93 |
|
|---|
| 94 |
.SH REQUIRED ARGUMENTS |
|---|
| 95 |
|
|---|
| 96 |
.TP |
|---|
| 97 |
.BR \-D "\fR,\fP " \-\^\-target\ \<IP-address> |
|---|
| 98 |
Direct the |
|---|
| 99 |
.B fwknop |
|---|
| 100 |
client to authenticate with the |
|---|
| 101 |
.B fwknopd |
|---|
| 102 |
daemon/service at the destination address <IP> . The connection mode is discovered by the |
|---|
| 103 |
.B fwknopd |
|---|
| 104 |
daemon/service when it decrypts and parses the authentication packet. |
|---|
| 105 |
.TP |
|---|
| 106 |
.BR \-A "\fR,\fP " \-\^\-Access\ \<port\ list> |
|---|
| 107 |
Provide a list of ports and protocols to access on a remote computer running |
|---|
| 108 |
.B fwknopd. |
|---|
| 109 |
The format of this list is '<proto>/<port>...<proto>/<port>, |
|---|
| 110 |
e.g. "tcp/22,udp/53". |
|---|
| 111 |
.B NOTE: |
|---|
| 112 |
The vast majority of usages for |
|---|
| 113 |
.B fwknop |
|---|
| 114 |
require the -A argument, but sending full commands with the --Server-cmd |
|---|
| 115 |
argument via an SPA packet to be executed by |
|---|
| 116 |
.B fwknopd |
|---|
| 117 |
does not require this argument. |
|---|
| 118 |
|
|---|
| 119 |
.SH OPTIONS |
|---|
| 120 |
|
|---|
| 121 |
.TP |
|---|
| 122 |
.BR \-a "\fR,\fP " \-\^\-allow-ip\ \<allow-IP> |
|---|
| 123 |
Specify IP address that should be permitted through the destination |
|---|
| 124 |
.B fwknopd |
|---|
| 125 |
server firewall (this IP is encrypted within the SPA packet itself). This is |
|---|
| 126 |
useful to prevent a Man-In-The-Middle (MTIM) attack where an SPA packet can be |
|---|
| 127 |
intercepted en-route and sent from a different IP than the original. Hence, if |
|---|
| 128 |
the |
|---|
| 129 |
.B fwknopd |
|---|
| 130 |
server trusts the source address on the SPA packet IP header then the attacker |
|---|
| 131 |
gains access. The -a option puts the source address within the encrypted |
|---|
| 132 |
SPA packet, and so thwarts this attack. The -a option is also useful to specify |
|---|
| 133 |
the IP that will be granted access when SPA packet itself is spoofed with |
|---|
| 134 |
the --Spoof-src option. Another related option is -R (see below) which instructs |
|---|
| 135 |
the |
|---|
| 136 |
.B fwknop |
|---|
| 137 |
client to automatically resolve the externally routable IP address the local |
|---|
| 138 |
system is connected to by querying the |
|---|
| 139 |
.B http://www.whatismyip.com |
|---|
| 140 |
website. |
|---|
| 141 |
.TP |
|---|
| 142 |
.BR \-R "\fR,\fP " \-\^\-Resolve-external-IP |
|---|
| 143 |
This is an important option, and instructs the |
|---|
| 144 |
.B fwknop |
|---|
| 145 |
client and the |
|---|
| 146 |
.B fwknopd |
|---|
| 147 |
daemon/service to query |
|---|
| 148 |
.B http://www.whatismyip.com |
|---|
| 149 |
to determine the IP address that should be allowed through the iptables policy |
|---|
| 150 |
at the remote |
|---|
| 151 |
.B fwknopd |
|---|
| 152 |
server side. This is useful if the |
|---|
| 153 |
.B fwknop |
|---|
| 154 |
client is being used on a system that is behind an obscure NAT address. |
|---|
| 155 |
.TP |
|---|
| 156 |
.BR \-\^\-gpg-agent |
|---|
| 157 |
Instruct |
|---|
| 158 |
.B fwknop |
|---|
| 159 |
to acquire GnuPG key password from a running |
|---|
| 160 |
.B gpg-agent |
|---|
| 161 |
instance. |
|---|
| 162 |
.TP |
|---|
| 163 |
.BR \-\^\-gpg-agent-info\ \<connection\ \info> |
|---|
| 164 |
Specify the value of the GPG_AGENT_INFO environment variable as returned |
|---|
| 165 |
by the |
|---|
| 166 |
.B gpg-agent --daemon |
|---|
| 167 |
command. If the |
|---|
| 168 |
.B fwknop --gpg-agent |
|---|
| 169 |
command line argument is used instead of |
|---|
| 170 |
.B --gpg-agent-info, |
|---|
| 171 |
then fwknop assumes that the GPG_AGENT_INFO environment variable has already |
|---|
| 172 |
been set in the current shell. |
|---|
| 173 |
.TP |
|---|
| 174 |
.BR \-\^\-gpg-default-key |
|---|
| 175 |
Use the key that GnuPG defines as the default, i.e. the key that is specified |
|---|
| 176 |
by the |
|---|
| 177 |
.B default-key |
|---|
| 178 |
variable in |
|---|
| 179 |
.I ~/.gnupg/options. |
|---|
| 180 |
If the |
|---|
| 181 |
.B default-key |
|---|
| 182 |
variable is not defined |
|---|
| 183 |
within |
|---|
| 184 |
.I ~/.gnupg/options |
|---|
| 185 |
, then GnuPG tries to use the first suitable key on |
|---|
| 186 |
its key ring. If the user does not know the password for this key, then the |
|---|
| 187 |
standard password error will be thrown by GnuPG and reported back to the |
|---|
| 188 |
user. |
|---|
| 189 |
.TP |
|---|
| 190 |
.BR \-\^\-gpg-home-dir\ \<dir> |
|---|
| 191 |
Specify the path to the GnuPG directory; normally this path is derived from the |
|---|
| 192 |
home directory of the user that is running the |
|---|
| 193 |
.B fwknop |
|---|
| 194 |
client. This is useful when a 'root' user wishes to log into a remote machine |
|---|
| 195 |
whose |
|---|
| 196 |
.B sshd |
|---|
| 197 |
daemon/service does not permit 'root' login. |
|---|
| 198 |
.TP |
|---|
| 199 |
.BR \-\^\-gpg-recipient\ \<key\ \ID> |
|---|
| 200 |
Specify the GnuPG key ID, e.g. "1234ABCD" (see the output of "gpg --list-keys") |
|---|
| 201 |
of the recipient of the Single Packet Authorization message. This key is imported |
|---|
| 202 |
by the |
|---|
| 203 |
.B fwknopd |
|---|
| 204 |
server and the associated private key is used to decrypt the SPA packet. The |
|---|
| 205 |
recipient's key must first be imported into the client GnuPG key ring. |
|---|
| 206 |
.TP |
|---|
| 207 |
.BR \-\^\-gpg-signing-key\ \<key\ \ID> |
|---|
| 208 |
Specify the GnuPG key ID, e.g. "ABCD1234" (see the output of "gpg --list-keys") |
|---|
| 209 |
to use when signing the SPA message. The user is prompted for |
|---|
| 210 |
the associated GPG password to create the signature. This |
|---|
| 211 |
adds a cryptographically strong mechanism to allow the |
|---|
| 212 |
.B fwknopd |
|---|
| 213 |
daemon on the remote server to authenticate who created the SPA message. |
|---|
| 214 |
.TP |
|---|
| 215 |
.BR \-\^\-gpg-verbose |
|---|
| 216 |
Instruct |
|---|
| 217 |
.B fwknop |
|---|
| 218 |
to allow all output from the |
|---|
| 219 |
.B gpg |
|---|
| 220 |
process that is used by fwknop in GPG mode. This is primarily used for debugging |
|---|
| 221 |
purposes if it appears that the GPG encrypt/decrypt is not performing correctly. |
|---|
| 222 |
.TP |
|---|
| 223 |
.BR \-l "\fR,\fP " \-\^\-last-cmd |
|---|
| 224 |
Instruct |
|---|
| 225 |
.B fwknop |
|---|
| 226 |
client to run with the same command line arguments that were used in a previous execution. |
|---|
| 227 |
This option is useful because the clients' |
|---|
| 228 |
.B fwknop |
|---|
| 229 |
command line can be complex and difficult to recall. |
|---|
| 230 |
.TP |
|---|
| 231 |
.BR \-L "\fR,\fP " \-\^\-Last-host\ \<host> |
|---|
| 232 |
Instruct |
|---|
| 233 |
.B fwknop |
|---|
| 234 |
to use the same command line arguments that were used to authenticate to |
|---|
| 235 |
.B host. |
|---|
| 236 |
.TP |
|---|
| 237 |
.BR \-q "\fR,\fP " \-\^\-quiet |
|---|
| 238 |
This option instructs the |
|---|
| 239 |
.B fwknop |
|---|
| 240 |
to be as quiet as possible and only print absolutely necessary information to |
|---|
| 241 |
the terminal. |
|---|
| 242 |
.TP |
|---|
| 243 |
.BR \-s "\fR,\fP " \-\^\-source-ip |
|---|
| 244 |
Instruct the |
|---|
| 245 |
.B fwknop |
|---|
| 246 |
client to form an SPA packet that contains the special-case IP |
|---|
| 247 |
address "0.0.0.0" which will inform the destination |
|---|
| 248 |
.B fwknopd |
|---|
| 249 |
SPA server to use the source IP address from which the SPA packet originates as |
|---|
| 250 |
the IP that will be allowed through upon modification of the firewall ruleset. |
|---|
| 251 |
This option is useful if the fwknop client is deployed on a machine that is |
|---|
| 252 |
behind a NAT device. The permit-address options |
|---|
| 253 |
.B s |
|---|
| 254 |
(default), |
|---|
| 255 |
.B R |
|---|
| 256 |
and |
|---|
| 257 |
.B a |
|---|
| 258 |
are mutually exclusive. |
|---|
| 259 |
.TP |
|---|
| 260 |
.BR \-\^\-Server-port\ \<port> |
|---|
| 261 |
Specify the port number where |
|---|
| 262 |
.B fwknop |
|---|
| 263 |
accepts packets via libpcap or ulogd pcap writer. By default fwknop looks for |
|---|
| 264 |
authorization packets over UDP port 62201. |
|---|
| 265 |
.TP |
|---|
| 266 |
.BR \-\^\-Spoof-cmd\ \<cmd> |
|---|
| 267 |
Specify the path to the command |
|---|
| 268 |
.B knopspoof |
|---|
| 269 |
which is used by the |
|---|
| 270 |
.B fwknop |
|---|
| 271 |
client in |
|---|
| 272 |
.B --Spoof-src |
|---|
| 273 |
mode. This command is install by default at |
|---|
| 274 |
.I /usr/sbin/knopspoof. |
|---|
| 275 |
.TP |
|---|
| 276 |
.BR \-\^\-Spoof-file\ \<file> |
|---|
| 277 |
Specify the path to the cache file that |
|---|
| 278 |
.B knopspoof |
|---|
| 279 |
reads in order to correctly generate the authorization packet. |
|---|
| 280 |
This file defaults to |
|---|
| 281 |
.I /tmp/spoof.cache |
|---|
| 282 |
, and contains source and destination |
|---|
| 283 |
IP addresses, protocol and port numbers, and the encrypted authorization |
|---|
| 284 |
message. |
|---|
| 285 |
.TP |
|---|
| 286 |
.BR \-\^\-Spoof-src\ \<IP> |
|---|
| 287 |
Spoof the source address from which the |
|---|
| 288 |
.B fwknop |
|---|
| 289 |
client sends SPA packets. This requires root on the client side access since a raw socket |
|---|
| 290 |
is required to accomplish this. Note that the |
|---|
| 291 |
.B --Spoof-user |
|---|
| 292 |
argument can be given in this mode in order to pass any |
|---|
| 293 |
.B REQUIRE_USERNAME |
|---|
| 294 |
keyword that might |
|---|
| 295 |
be specified in |
|---|
| 296 |
.I /etc/fwknop/access.conf. |
|---|
| 297 |
.TP |
|---|
| 298 |
.BR \-\^\-Spoof-user\ \<user> |
|---|
| 299 |
Specify the username that is included within SPA packet. This allows |
|---|
| 300 |
the |
|---|
| 301 |
.B fwknop |
|---|
| 302 |
client to satisfy any non-root |
|---|
| 303 |
.B REQUIRE_USERNAME |
|---|
| 304 |
keyword on the |
|---|
| 305 |
.B fwknopd |
|---|
| 306 |
server ( |
|---|
| 307 |
.B --Spoof-src |
|---|
| 308 |
mode requires that the |
|---|
| 309 |
.B fwknop |
|---|
| 310 |
client is executed as root). |
|---|
| 311 |
.TP |
|---|
| 312 |
.BR \-T "\fR,\fP " \-\^\-TCP-sock |
|---|
| 313 |
Have the |
|---|
| 314 |
.B fwknop |
|---|
| 315 |
client send an SPA packet over an established TCP connection. This is not normally |
|---|
| 316 |
done, but is useful for compatibility with the Tor for strong anonymity; see |
|---|
| 317 |
.B http://tor.eff.org/. |
|---|
| 318 |
.TP |
|---|
| 319 |
.BR \-h "\fR,\fP " \-\^\-help |
|---|
| 320 |
Display usage information and exit. |
|---|
| 321 |
.TP |
|---|
| 322 |
.BR \-V "\fR,\fP " \-\^\-Version |
|---|
| 323 |
Display version information and exit. |
|---|
| 324 |
.TP |
|---|
| 325 |
.BR \-v "\fR,\fP " \-\^\-verbose |
|---|
| 326 |
Run the |
|---|
| 327 |
.B fwknop |
|---|
| 328 |
client in verbose mode. |
|---|
| 329 |
.TP |
|---|
| 330 |
.BR \-\^\-Server-cmd\ \<cmd> |
|---|
| 331 |
.B NOTE: |
|---|
| 332 |
This is for command mode only (i.e. when you want to send a command across |
|---|
| 333 |
to a system running |
|---|
| 334 |
.B fwknopd |
|---|
| 335 |
and have it execute the command). This option is not needed when trying to |
|---|
| 336 |
gain access to a service via the SPA mechanism. To use this feature, please |
|---|
| 337 |
ensure that ENABLE_CMD_EXEC; is set in the file |
|---|
| 338 |
.I /etc/fwknop/access.conf |
|---|
| 339 |
on the |
|---|
| 340 |
.B fwknopd |
|---|
| 341 |
server you are sending the command to. |
|---|
| 342 |
The --Server-cmd argument allows a complete command (e.g. "ping -c 1 www.yahoo.com", |
|---|
| 343 |
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") |
|---|
| 344 |
to be send to an |
|---|
| 345 |
.B fwknop |
|---|
| 346 |
server, which will execute the command as root. Command execution is enabled only |
|---|
| 347 |
if the |
|---|
| 348 |
.B ENABLE_CMD_EXEC keyword is given in |
|---|
| 349 |
.I /etc/fwknop/access.conf |
|---|
| 350 |
(note that commands can easily be restricted with the |
|---|
| 351 |
.B CMD_REGEX |
|---|
| 352 |
keyword as well). |
|---|
| 353 |
.TP |
|---|
| 354 |
|
|---|
| 355 |
.B Legacy Port-knock mode only |
|---|
| 356 |
|
|---|
| 357 |
All of the following options in this section are for the traditional port knocking |
|---|
| 358 |
mode mode. This is a legacy mode and is |
|---|
| 359 |
.B not |
|---|
| 360 |
the preferred or recommended mode next to Single Packet Authorization ( see |
|---|
| 361 |
.B http://www.cipherdyne.org/fwknop/docs/SPA.html |
|---|
| 362 |
for details on why). |
|---|
| 363 |
.RS |
|---|
| 364 |
.TP |
|---|
| 365 |
.BR \-\^\-offset\ \<port> |
|---|
| 366 |
Specify a port offset to use when running |
|---|
| 367 |
.B fwknop |
|---|
| 368 |
in encrypted knock mode. The default is 61000. |
|---|
| 369 |
.TP |
|---|
| 370 |
.BR \-r "\fR,\fP " \-\^\-rotate-proto |
|---|
| 371 |
Rotate the protocol across tcp and udp for |
|---|
| 372 |
encrypted sequences. This just adds one more additional layer of obfuscation |
|---|
| 373 |
to an encrypted sequence. |
|---|
| 374 |
.TP |
|---|
| 375 |
.BR \-\^\-Server-mode\ \<mode> |
|---|
| 376 |
This command line switch provides an interface to |
|---|
| 377 |
the old port knocking method if |
|---|
| 378 |
the mode argument is "knock". If the |
|---|
| 379 |
.B --Server-mode |
|---|
| 380 |
argument is not given then the |
|---|
| 381 |
.B fwknop |
|---|
| 382 |
client defaults to using the SPA method which provides much better |
|---|
| 383 |
security characteristics than port knocking (encrypted or not). |
|---|
| 384 |
.TP |
|---|
| 385 |
.BR \-t "\fR,\fP " \-\^\-time-delay\ \<seconds> |
|---|
| 386 |
Specify a time delay to introduce between successive |
|---|
| 387 |
connection attempts. This option is used by the |
|---|
| 388 |
.B fwknop |
|---|
| 389 |
client. On the server side, |
|---|
| 390 |
.B fwknopd |
|---|
| 391 |
uses the variables MIN_TIME_DIFF |
|---|
| 392 |
and MAX_TIME_DIFF to control whether the time delay actually means |
|---|
| 393 |
something (i.e. if the MIN_TIME_DIFF is 2 seconds for a SOURCE block, |
|---|
| 394 |
then the argument to the --time-delay option must be at least 2 at the |
|---|
| 395 |
client side). |
|---|
| 396 |
.TP |
|---|
| 397 |
.BR \-u "\fR,\fP " \-\^\-user-rc\ \<rc-file> |
|---|
| 398 |
The default connection rc file the |
|---|
| 399 |
.B fwknop |
|---|
| 400 |
client uses to know what shared port knocking sequence to send to a destination machine |
|---|
| 401 |
is defined in the file |
|---|
| 402 |
.I ~/.fwknoprc. |
|---|
| 403 |
The path to this file can be changed with the |
|---|
| 404 |
.B --user-rc |
|---|
| 405 |
command line option. |
|---|
| 406 |
.RE |
|---|
| 407 |
|
|---|
| 408 |
.SH FILES |
|---|
| 409 |
.TP |
|---|
| 410 |
.B ~/.fwknop.run |
|---|
| 411 |
Contains the last command line arguments that the |
|---|
| 412 |
.B fwknop |
|---|
| 413 |
client was invoked with. |
|---|
| 414 |
|
|---|
| 415 |
.TP |
|---|
| 416 |
.B ~/.fwknop.hosts |
|---|
| 417 |
Contains the last command line arguments for individual hosts that the |
|---|
| 418 |
.B fwknop |
|---|
| 419 |
client has been used to gain access to. By using the |
|---|
| 420 |
.B --Last-host |
|---|
| 421 |
switch, these arguments can be recalled and used. |
|---|
| 422 |
|
|---|
| 423 |
.SH ENVIRONMENT: |
|---|
| 424 |
|
|---|
| 425 |
.B GPG_AGENT_INFO |
|---|
| 426 |
(only used in --gpg-agent mode). |
|---|
| 427 |
|
|---|
| 428 |
.SH EXAMPLES: |
|---|
| 429 |
The following examples illustrate the command line arguments that could |
|---|
| 430 |
be supplied to the |
|---|
| 431 |
.B fwknop |
|---|
| 432 |
client in a few situations: |
|---|
| 433 |
|
|---|
| 434 |
.B Access mode examples |
|---|
| 435 |
.RS |
|---|
| 436 |
Packet contents printed to stdout at the |
|---|
| 437 |
.B fwknop |
|---|
| 438 |
client when creating a 'access mode' SPA packet: |
|---|
| 439 |
.PP |
|---|
| 440 |
Random data: 7457916043504181 |
|---|
| 441 |
Username: user_name |
|---|
| 442 |
Timestamp: 1185272057 |
|---|
| 443 |
Version: 1.8.1 |
|---|
| 444 |
Action: 1 (access mode) |
|---|
| 445 |
Access: NNN.NNN.NNN.NNN,tcp/22 |
|---|
| 446 |
MD5 sum: 35rdd5f8tZTavUy0MuEdqw |
|---|
| 447 |
.PP |
|---|
| 448 |
|
|---|
| 449 |
Use the Single Packet Authorization mode to gain access to tcp/22 (ssh) |
|---|
| 450 |
and udp/53 running on the system 10.0.0.123 from the IP 192.168.10.4: |
|---|
| 451 |
.PP |
|---|
| 452 |
.B $ fwknop -A 'tcp/22,udp/53' -a 192.168.10.4 -D 10.0.0.123 |
|---|
| 453 |
.PP |
|---|
| 454 |
Same as above example, but gain access from whatever source IP is seen |
|---|
| 455 |
by the fwknop server (useful if the fwknop client is behind a NAT device): |
|---|
| 456 |
.PP |
|---|
| 457 |
.B $ fwknop -A 'tcp/22,udp/53' -s -D 10.0.0.123 |
|---|
| 458 |
.PP |
|---|
| 459 |
Same as above example, but use the IP identification website http://www.whatismyip.com/ |
|---|
| 460 |
to derive the client IP address. This is a safer method of acquiring the client IP |
|---|
| 461 |
address than using the "-s" option because the source IP is put within the encrypted |
|---|
| 462 |
packet instead of having the |
|---|
| 463 |
.B fwknopd |
|---|
| 464 |
daemon grant the requested access from whatever IP address the SPA packet originates: |
|---|
| 465 |
.PP |
|---|
| 466 |
.B $ fwknop -A 'tcp/22,udp/53' -R -D 10.0.0.123 |
|---|
| 467 |
.PP |
|---|
| 468 |
Use the Single Packet Authorization mode to gain access to tcp/22 (ssh) |
|---|
| 469 |
and udp/53 running on the system 10.0.0.123, and use GnuPG keys to encrypt |
|---|
| 470 |
and decrypt: |
|---|
| 471 |
.PP |
|---|
| 472 |
.B $ fwknop -A 'tcp/22,udp/53' --gpg-sign ABCD1234 --gpg--recipient 1234ABCD -R -D 10.0.0.123 |
|---|
| 473 |
.PP |
|---|
| 474 |
Instruct the fwknop server running at 10.0.0.123 to allow 172.16.5.4 to |
|---|
| 475 |
connect to TCP/22, but spoof the authorization packet from an IP associated |
|---|
| 476 |
with www.yahoo.com: |
|---|
| 477 |
.PP |
|---|
| 478 |
.B # fwknop --Spoof-src 'www.yahoo.com' -A tcp/22 -a 172.16.5.4 -D 10.0.0.123 |
|---|
| 479 |
.PP |
|---|
| 480 |
.RE |
|---|
| 481 |
|
|---|
| 482 |
.B Command mode examples |
|---|
| 483 |
.RS |
|---|
| 484 |
.B NOTE: |
|---|
| 485 |
Please ensure that ENABLE_CMD_EXEC; is set in the file |
|---|
| 486 |
.I /etc/fwknop/access.conf |
|---|
| 487 |
on the |
|---|
| 488 |
.B fwknopd |
|---|
| 489 |
server you are attempting to connect to. |
|---|
| 490 |
Packet contents printed to stdout at the |
|---|
| 491 |
.B fwknop |
|---|
| 492 |
client when creating a 'command mode' SPA packet: |
|---|
| 493 |
.PP |
|---|
| 494 |
Random data: 1387393943305159 |
|---|
| 495 |
Username: user_name |
|---|
| 496 |
Timestamp: 1185349703 |
|---|
| 497 |
Version: 1.8.1 |
|---|
| 498 |
Action: 0 (command mode) |
|---|
| 499 |
Cmd: echo "The commands sent - minus quote charaters around the command" & sleep 10; echo "The End" |
|---|
| 500 |
MD5 sum: fJtQkAcK1A1XMRAHEG1UcA |
|---|
| 501 |
.PP |
|---|
| 502 |
Instruct the fwknop server running at 10.0.0.123 to send a single ICMP |
|---|
| 503 |
echo request to www.yahoo.com: |
|---|
| 504 |
.PP |
|---|
| 505 |
.B $ fwknop --Server-cmd 'ping -c 1 www.yahoo.com' -D 10.0.0.123 |
|---|
| 506 |
.PP |
|---|
| 507 |
.RE |
|---|
| 508 |
|
|---|
| 509 |
.B Port-knock mode (legacy) examples |
|---|
| 510 |
.RS |
|---|
| 511 |
This connection mode is a legacy mode and is |
|---|
| 512 |
.B not |
|---|
| 513 |
the preferred or recommended mode. |
|---|
| 514 |
|
|---|
| 515 |
Packet contents printed to stdout at the |
|---|
| 516 |
.B fwknop |
|---|
| 517 |
client when in 'port-knock mode': |
|---|
| 518 |
<TODO> |
|---|
| 519 |
|
|---|
| 520 |
Send an encrypted knock sequence to the IP "10.0.0.123" instructing the |
|---|
| 521 |
fwknop daemon running there to open tcp port 22 to source address |
|---|
| 522 |
192.168.10.4: |
|---|
| 523 |
.PP |
|---|
| 524 |
.B $ fwknop --Server-mode 'knock' -A tcp/22 -a 192.168.10.4 -D 10.0.0.123 |
|---|
| 525 |
.PP |
|---|
| 526 |
Same as above, but this time instruct the remote fwknop daemon to open |
|---|
| 527 |
tcp port 22 to whatever source address the encrypted sequence originates |
|---|
| 528 |
from (useful if the fwknop client is behind a NAT device): |
|---|
| 529 |
.PP |
|---|
| 530 |
.B $ fwknop --Server-mode 'knock' -A tcp/22 -s -D 10.0.0.123 |
|---|
| 531 |
.PP |
|---|
| 532 |
Same as above, but rotate the knock sequence through the tcp and udp |
|---|
| 533 |
protocols (remember that iptables must be configured to log both tcp and |
|---|
| 534 |
udp packets to the default port range of 61000-61255): |
|---|
| 535 |
.PP |
|---|
| 536 |
.B $ fwknop --Server-mode 'knock' -A tcp/22 -s -r -D 10.0.0.123 |
|---|
| 537 |
.PP |
|---|
| 538 |
Same as above, but change the base port for the encrypted sequence to |
|---|
| 539 |
55000 (the default is 61000): |
|---|
| 540 |
.PP |
|---|
| 541 |
.B $ fwknop --Server-mode 'knock' -A tcp/22 -s -r --offset 55000 -D 10.0.0.123 |
|---|
| 542 |
.PP |
|---|
| 543 |
Send a shared knock sequence to the IP 10.11.11.123. The fwknop client |
|---|
| 544 |
will read the sequence out of the file |
|---|
| 545 |
.B ~/.fwknoprc |
|---|
| 546 |
and the server will read the sequence out of |
|---|
| 547 |
.B /etc/fwknop/access.conf: |
|---|
| 548 |
.PP |
|---|
| 549 |
.B $ fwknop --Server-mode 'knock' -D 10.11.11.123 |
|---|
| 550 |
.RE |
|---|
| 551 |
|
|---|
| 552 |
.SH DEPENDENCIES |
|---|
| 553 |
.B fwknop |
|---|
| 554 |
requires perl. To take advantage of all of the authentication and access management features of the |
|---|
| 555 |
.B fwknopd |
|---|
| 556 |
daemon/service a functioning iptables firewall is required on the underlying |
|---|
| 557 |
operating system. If fwknop is being run in the legacy port knocking mode, |
|---|
| 558 |
then iptables must log packets via syslog, and ideally the |
|---|
| 559 |
.B --log-tcp-options |
|---|
| 560 |
argument will be specified in the iptables logging rule so that the |
|---|
| 561 |
.B fwknopd |
|---|
| 562 |
daemon/service will |
|---|
| 563 |
be able to use a strategy similar to |
|---|
| 564 |
.B p0f |
|---|
| 565 |
to passively fingerprint operating systems. |
|---|
| 566 |
|
|---|
| 567 |
.SH DIAGNOSTICS |
|---|
| 568 |
.B fwknop |
|---|
| 569 |
can be run in debug mode with the --debug command line option. This will |
|---|
| 570 |
disable daemon mode execution, and print verbose information to the screen |
|---|
| 571 |
on STDERR as packets are received. |
|---|
| 572 |
|
|---|
| 573 |
.SH "SEE ALSO" |
|---|
| 574 |
.BR fwknopd (8), |
|---|
| 575 |
.BR iptables (8), |
|---|
| 576 |
.BR gpg (1), |
|---|
| 577 |
.BR gpg-agent (1), |
|---|
| 578 |
.BR knopmd (8), |
|---|
| 579 |
.BR knopwatchd (8) |
|---|
| 580 |
.BR p0f (1), |
|---|
| 581 |
More information on the |
|---|
| 582 |
differences between port knocking and Single Packet Authorization can be found |
|---|
| 583 |
in the paper "Single Packet Authorization with fwknop" available here: |
|---|
| 584 |
.B http://www.cipherdyne.org/fwknop/docs/SPA.html |
|---|
| 585 |
|
|---|
| 586 |
.SH AUTHOR |
|---|
| 587 |
Michael Rash <mbr@cipherdyne.org> |
|---|
| 588 |
|
|---|
| 589 |
.SH CREDITS |
|---|
| 590 |
The phrase "Single Packet Authorization" was coined by MadHat, see: |
|---|
| 591 |
.B http://www.nmrc.org/ |
|---|
| 592 |
The term "port knocking" was coined by Martin Krzywinski, see: |
|---|
| 593 |
.B http://www.portknocking.org/ |
|---|
| 594 |
The original p0f passive OS fingerprinter was written by Michal Zalewski, and is |
|---|
| 595 |
available here: |
|---|
| 596 |
.B http://lcamtuf.coredump.cx/p0f.shtml |
|---|
| 597 |
|
|---|
| 598 |
.SH BUGS |
|---|
| 599 |
Send bug reports to mbr@cipherdyne.org. Suggestions and/or comments are |
|---|
| 600 |
always welcome as well. |
|---|
| 601 |
|
|---|
| 602 |
.SH DISTRIBUTION |
|---|
| 603 |
.B fwknop |
|---|
| 604 |
is distributed under the GNU General Public License (GPL), and the latest |
|---|
| 605 |
version may be downloaded from |
|---|
| 606 |
.B http://www.cipherdyne.org/ |
|---|
| 607 |
|
|---|
| 608 |
|
|---|