root/psad/tags/psad-2.1.2/psad.8

Revision 2150, 33.2 kB (checked in by mbr, 9 months ago)

minor contributor update

  • 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 PSAD 8 "Jun, 2006" Linux
5 .SH NAME
6 .B psad
7 \- The Port Scan Attack Detector
8 .SH SYNOPSIS
9 .B psad [options]
10 .SH DESCRIPTION
11
12 .B psad
13 makes use of iptables log messages to detect, alert, and (optionally) block
14 port scans and other suspect traffic.  For TCP scans psad analyzes TCP
15 flags to determine the scan type (syn, fin, xmas, etc.) and corresponding
16 command line options that could be supplied to nmap to generate such a scan.
17 In addition, psad makes use of many TCP, UDP, and ICMP signatures contained
18 within the Snort intrusion detection system (see http://www.snort.org/) to
19 detect suspicious network traffic such as probes for common backdoors, DDoS
20 tools, OS fingerprinting attempts, and more.  By default psad also provides
21 alerts for snort rules that are detected directly by iptables through the
22 use of a ruleset generated by
23 .B fwsnort
24 (http://www.cipherdyne.org/fwsnort/).  This enables psad to send alerts for
25 application layer attacks.
26 .B psad
27 features a set of highly configurable danger thresholds (with sensible
28 defaults provided) that allow the administrator to define what constitutes
29 a port scan or other suspect traffic.  Email alerts sent by psad contain the
30 scanning ip, number of packets sent to each port, any TCP, UDP, or ICMP
31 signatures that have been matched (e.g. "NMAP XMAS scan"), the scanned port
32 range, the current danger level (from 1 to 5), reverse dns info, and whois
33 information.
34 .B psad
35 also makes use of various packet header fields associated with TCP SYN packets
36 to passively fingerprint remote operating systems (in a manner similar to the
37 .B p0f
38 fingerprinter) from which scans originate.  This requires the use of the
39 .B --log-tcp-options
40 argument for iptables logging rules; if this option is not used,
41 .B psad
42 will fall back to a fingerprinting method that makes use of packet length,
43 TTL and TOS values, IP ID, and TCP window sizes.
44 .PP
45 .B psad
46 configures syslog to write all kern.info messages to a named pipe
47 .B /var/lib/psad/psadfifo
48 and then reads all messages out of the pipe that are matched by a string
49 designed to catch any packets that have been logged (and possibly dropped)
50 by the firewall.  In this way psad is supplied with a pure data stream
51 that exclusively contains packets that the firewall has deemed unfit to
52 enter the network. 
53 .B psad
54 consists of three daemons: psad, kmsgsd, and psadwatchd.
55 .B psad
56 is responsible for processing all packets that have been logged by the
57 firewall and applying the signature logic in order to determine what type
58 of scan has been leveraged against the machine and/or network.
59 .B kmsgsd
60 reads all messages that have been written to the
61 .B /var/lib/psad/psadfifo
62 named pipe and writes any message that matches a particular regular
63 expression (or string) to
64 .B /var/log/psad/fwdata.
65 .B psadwatchd
66 is a software watchdog that will restart any of the other two daemons should
67 a daemon die for any reason.
68 .SH OPTIONS
69 .TP
70 .BR \-A ", " \-\^\-Analyze-msgs
71 Analyze an iptables logfile for scans and exit.  This will generate email alerts
72 just as a normal running psad process would have for all logged scans.  By
73 default the psad data file
74 .B /var/log/psad/fwdata
75 is parsed for old scans, but any file can be specified through the use
76 of the --messages-file command line option.  For example it might be useful
77 to point psad at your
78 .B /var/log/messages
79 file.
80 .TP
81 .BR \-i "\fR,\fP " \-\^\-interface\ \<interface>
82 Specify the interface that
83 .B psad
84 will examine for iptables log messages.  This interface will be the
85 .B IN=
86 interface for packets that are logged in the
87 .B INPUT
88 and
89 .B FORWARD
90 chains, and the
91 .B OUT=
92 interface for packets logged in the
93 .B OUTPUT
94 chain.
95 .TP
96 .BR \-\^\-sig-update
97 Instruct
98 .B psad
99 to download the latest set of modified Snort signatures from
100 http://www.cipherdyne.org/psad/signatures so that psad can take advantage of
101 signature updates before a new release is made.
102 .TP
103 .BR \-D ", " \-\^\-Dump-conf
104 Dump the current psad config to STDOUT and exit.  Various pieces of information
105 such as the home network, alert email addresses, and DShield user id are removed
106 from the resulting output so it is safe to send to others.
107 .TP
108 .BR \-F ", " \-\^\-Flush
109 Remove any auto-generated firewall block rules if psad was configured
110 to automatically respond to scans (see the ENABLE_AUTO_IDS variable
111 in psad.conf).
112 .TP
113 .BR \-S ", " \-\^\-Status
114 Display the status of any psad processes that may or not be running.
115 The status output contains a listing of the number of packets that
116 have been processed by psad, along with all IP addresses and
117 corresponding danger levels that have scanned the network.
118 .TP
119 .BR \-\^\-status-ip\ \<ip>
120 Display status information associated with
121 .I ip
122 such as the protocol packet counters as well as the last 10 packets
123 logged by iptables.
124 .TP
125 .BR \-\^\-status-dl\ \<dl>
126 Display status information only for scans that have reached a danger
127 level of at least
128 .I dl
129 .TP
130 .BR \-\^\-status-summary
131 Instruct
132 .B psad
133 to omit detailed IP information from
134 .I --Status
135 and
136 .I --Analyze
137 modes.
138 .TP
139 .BR \-m "\fR,\fP " \-\^\-messages-file\ \<file>
140 This option is used to specify the file that will be parsed in analysis
141 mode (see the --Analyze-msgs option).  The default path is the psad
142 data file
143 .B /var/log/psad/fwdata.
144 .TP
145 .BR \-\^\-CSV
146 Instruct
147 .B psad
148 to parse iptables log messages out of
149 .I /var/log/messages
150 (by defult, but this path can be changed with the
151 .I -m
152 option), and print the packet fields on STDOUT in comma-separate value
153 format.  This is useful for graphing iptables log data with AfterGlow
154 (see http://afterglow.sourceforge.net/index.html).
155 .TP
156 .BR \-\^\-CSV-fields\ \<tokens>
157 Instruct
158 .B psad
159 to only include a specific set of iptables log message fields within the CSV
160 output.  AfterGlow accepts up to three fields for its graph data, so the most
161 common usage of this option is "src dst dp" to print the source and destination
162 IP addresses, and the destination port number.
163 .TP
164 .BR \-K ", " \-\^\-Kill
165 Kill the current psad process along with psadwatchd and kmsgsd.
166 This provides a quick and easy way to kill all psad processes without
167 having to look in the process table or appeal to the psad-init script.
168 .TP
169 .BR \-R ", " \-\^\-Restart
170 Restart the currently running psad processes.  This option will
171 preserve the command line options that were supplied to the original
172 psad process.
173 .TP
174 .BR \-U ", " \-\^\-USR1
175 Send a running psad process a USR1 signal.  This will cause psad to
176 dump the contents of the %Scan hash to the file "/var/log/psad/scan_hash.$$"
177 where "$$" represents the pid of the psad process.  This is mostly
178 useful for debugging purposes, but it also allows the administrator to
179 peer into the %Scan hash, which is the primary data structure used to
180 store scan data within system memory.
181 .TP
182 .BR \-H ", " \-\^\-HUP
183 Send all running psad daemons a HUP signal.  This will instruct the
184 daemons to re-read their respective configuration files without causing
185 scan data to be lost in the process.
186 .TP
187 .BR \-B ", " \-\^\-Benchmark
188 Run psad in benchmark mode.  By default benchmark mode will simulate
189 a scan of 10,000 packets (see the --packets option) and then report
190 the elapsed time.  This is useful to see how fast psad can process
191 packets on a specific machine.
192 .TP
193 .BR \-p "\fR,\fP " \-\^\-packets\ \<packets>
194 Specify the number of packets to use in benchmark mode.  The
195 default is 10,000 packets.
196 .TP
197 .BR \-d ", " \-\^\-debug
198 Run psad in debugging mode.  This will automatically prevent
199 psad from running as a daemon, and will print the contents
200 of the %Scan hash and a few other things on STDOUT at crucial
201 points as psad executes.
202 .TP
203
204 .BR \-c "\fR,\fP " \-\^\-config\ \<configuration-file>
205 By default all of the psad makes use of the configuration file
206 .B /etc/psad/psad.conf
207 for almost all configuration parameters.
208 .B psad
209 can be made to
210 override this path by specifying a different file on the command
211 line with the --config option.
212 .TP
213 .BR \-\^\-signatures\ \<signatures-file>
214 The iptables firewalling code included within the linux 2.4.x kernel
215 series has the ability to distinguish and log any of the TCP flags
216 present within TCP packets that traverse the firewall interfaces.
217 .B psad
218 makes use of this logging capability to detect several types of TCP scan
219 signatures included within
220 .B /etc/psad/signatures.
221 The signatures were
222 originally included within the snort intrusion detection
223 system.  New signatures can be included and modifications to existing
224 signatures can be made to the signature file and psad will import
225 the changes upon receiving a HUP signal (see the --HUP command line
226 option) without having to restart the psad process.
227 .B psad
228 also detects
229 many UDP and ICMP signatures that were originally included within snort.
230 .TP
231 .BR \-e ", " \-\^\-email-analysis
232 Send alert emails when run in --Analyze-msgs mode.  Depending on the size of
233 the iptables logfile, using the --email-analysis option could extend the runtime
234 of psad by quite a bit since normally both DNS and whois lookups will be issued
235 against each scanning IP address.  As usual these lookups can be disabled with
236 the --no-rdns and --no-whois options respectively.
237 .TP
238 .BR \-w ", " \-\^\-whois-analysis
239 By default
240 .B psad
241 does not issue whois lookups when running in --Analyze-msgs mode.  The
242 --whois-analysis option will override this behavior (when run in analysis mode)
243 and instruct psad to issue whois lookups against IP addresses from which scans
244 or other suspect traffic has originated.
245 .TP
246 .BR \-\^\-snort-type\ \<type>
247 Restrict the type of snort sids to
248 .I type.
249 Allowed types match the file names given to snort rules files such as
250 "ddos", "backdoor", and "web-attacks".
251 .TP
252 .BR \-\^\-snort-rdir\ \<snort-rules-directory>
253 Manually specify the directory where the snort rules files are located.
254 The default is
255 .B /etc/psad/snort_rules.
256 .TP
257 .BR \-\^\-passive-os-sigs\ \<passive-os-sigs-file>
258 Manually specify the path to the passive operating system fingerprinting
259 signatures file.  The default is
260 .B /etc/psad/posf.
261 .TP
262 .BR \-a "\fR,\fP " \-\^\-auto-dl\ \<auto-dl-file>
263 Occasionally certain IP addresses are repeat offenders and
264 should automatically be given a higher danger level than
265 would normally be assigned.  Additionally, some IP addresses
266 can always be ignored depending on your network configuration
267 (the loopback interface 127.0.0.1 might be a good candidate
268 for example).
269 .B /etc/psad/auto_dl
270 provides an interface for psad to automatically
271 increase/decrease/ignore scanning IP danger levels.  Modifications
272 can be made to auto_dl (installed by default in /etc/psad)
273 and psad will import them without having to restart the psad process.
274 .TP
275 .BR \-\^\-fw-search\ \<fw_search-file>
276 By default all of the psad makes use of the firewall search configuration
277 file
278 .B /etc/psad/fw_search.conf
279 for firewall search mode and search strings.
280 .B psad
281 can be made to
282 override this path by specifying a different file on the command
283 line with the --fw-search option.
284 .TP
285 .BR \-\^\-fw-list-auto
286 List all rules in iptables chains that are used by
287 .B psad
288 in auto-blocking mode.
289 .TP
290 .BR \-\^\-fw-analyze
291 Analyze the local iptables ruleset, send any alerts if errors are
292 discovered, and then exit.
293 .TP
294 .BR \-\^\-fw-del-chains
295 By default, if ENABLE_AUTO_IDS is set to "Y"
296 .B psad
297 will not delete the auto-generated iptables chains (see the IPT_AUTO_CHAIN
298 keywords in psad.conf) if the --Flush option is given.  The --fw-del-chains
299 option overrides this behavior and deletes the auto-blocking chains from a
300 running iptables firewall.
301 .TP
302 .BR \-\^\-fw-dump
303 Instruct
304 .B psad
305 to dump the contents of the iptables policy that is running on the local
306 system.  All IP addresses are removed from the resulting output, so it is
307 safe to post to the psad list, or communicate to others.  This option is
308 most often used with --Dump-conf.
309 .TP
310 .BR \-\^\-fw-block-ip\ \<ip>
311 Specify an IP address or network to add to the iptables controls that are
312 auto-generated by psad.  This allows psad to manage the rule timeouts.
313 .TP
314 .BR \-\^\-fw-rm-block-ip\ \<ip>
315 Specify an IP address or network to remove from the iptables controls that
316 are auto-generated by psad.
317 .TP
318 .BR \-\^\-fw-file\ \<policy-file>
319 Analyze the iptables ruleset contained within
320 .B policy-file
321 instead of the ruleset currently loaded on the local system.
322 .TP
323 .BR \-\^\-CSV-regex\ \<regex>
324 Instruct
325 .B psad
326 to only print CSV data that matches the supplied regex.  This regex is
327 used to match against each of the entire iptables log messages.
328 .TP
329 .BR \-\^\-CSV-neg-regex\ \<regex>
330 Instruct
331 .B psad
332 to only print CSV data that does not match the supplied regex.  This regex is
333 used to negatively match against each of the entire iptables log messages.
334 .TP
335 .BR \-\^\-CSV-uniq-lines
336 Instruct
337 .B psad
338 to only print unique CSV data.  That is, each line printed in
339 .I --CSV
340 mode will be unique.
341 .TP
342 .BR \-\^\-CSV-max-lines\ \<num>
343 Limit the number of CSV-formatted lines that
344 .B psad
345 generates on STDOUT.  This is useful to allow AfterGlow graphs to be
346 created that are not too cluttered.
347 .TP
348 .BR \-\^\-CSV-start-line\ \<num>
349 Specify the beginning line number to start parsing out of the iptables log
350 file in
351 .I --CSV
352 output mode.  This is useful for when the log file is extremely large, and you
353 want to begin parsing a specific place within the file.  The default is begin
354 parsing at the beginning of the file.
355 .TP
356 .BR \-\^\-CSV-end-line\ \<num>
357 Specify the ending line number to stop parsing the iptables log
358 file in
359 .I --CSV
360 output mode.  This is useful for when the log file is extremely large, and you
361 do not want
362 .B psad
363 to process the entire thing.
364 .TP
365 .BR \-\^\-gnuplot
366 Enter into Gnuplot mode whereby
367 .B psad
368 parses an iptables logfile and creates .gnu and .dat files that are suitable
369 for graphing with Gnuplot.  The various
370 .I --CSV
371 command line arguments apply to plotting iptables log with Gnuplot.
372 .TP
373 .BR \-\^\-gnuplot-template\ \<file>
374 Use a template file for all Gnuplot graphing directives (this is usually
375 a .gnu file by convention).  Normally
376 .B psad builds all of the graphing directives based on various --gnuplot
377 command line arguments, but the --gnuplot-template switch allows you to
378 override this behavior.
379 .TP
380 .BR \-\^\-gnuplot-file-prefix\ \<file>
381 Specify a prefix for the .gnu, .dat, and .png files that are generated in
382 .I --gnuplot
383 mode.  So, when visualizing attacks captured in an iptables logfile (let's
384 say you are interested in port scans), you could use this option to have
385 .B psad
386 create the two files portscan.dat, portscan.gnu, and Gnuplot will create
387 an additional file portscan.png when the portscan.gnu file is loaded.
388 .TP
389 .BR \-\^\-gnuplot-x-label\ \<label>
390 Set the label associated with the x-axis.
391 .TP
392 .BR \-\^\-gnuplot-x-range\ \<range>
393 Set the x-axis range.
394 .TP
395 .BR \-\^\-gnuplot-y-label\ \<label>
396 Set the label associated with the y-axis.
397 .TP
398 .BR \-\^\-gnuplot-y-range\ \<range>
399 Set the y-axis range.
400 .TP
401 .BR \-\^\-gnuplot-z-label\ \<label>
402 Set the label associated with the z-axis (only if
403 .I --gnuplot-3D
404 is used).
405 .TP
406 .BR \-\^\-gnuplot-z-range\ \<range>
407 Set the z-axis range. (only if
408 .I --gnuplot-3D
409 is used).
410 .TP
411 .BR \-\^\-gnuplot-3D
412 Generate a Gnuplot
413 .B splot
414 graph.  This produces a three-dimensional graph.
415 .TP
416 .BR \-\^\-gnuplot-view
417 Set the viewing angle when graphing data in
418 .I --gnuplot-3D
419 mode.
420 .TP
421 .BR \-\^\-gnuplot-title\ \<title>
422 Set the graph title for the Gnuplot graph.
423 .TP
424 .BR \-I "\fR,\fP " \-\^\-Interval\ \<seconds>
425 Specify the interval (in seconds) that psad should use to
426 check whether or not packets have been logged by the
427 firewall.
428 .B psad
429 will use the default of 15 seconds unless a
430 different value is specified.
431 .TP
432 .BR \-l ", " \-\^\-log-server
433 This option should be used if psad is being executed on a syslog
434 logging server.  Running psad on a logging server requires that
435 check_firewall_rules() and auto_psad_response() not be executed
436 since the firewall is probably not being run locally.
437 .TP
438 .BR \-V ", " \-\^\-Version
439 Print the psad version and exit.
440 .TP
441 .BR \-\^\-no-daemon
442 Do not run psad as a daemon.  This option will display scan
443 alerts on STDOUT instead of emailing them out.
444 .TP
445 .BR \-\^\-no-ipt-errors
446 Occasionally iptables messages written by syslog to
447 .B /var/lib/psad/psadfifo
448 or to
449 .B /var/log/messages
450 do not conform to the normal firewall logging format if the kernel
451 ring buffer used by klogd becomes full. 
452 .B
453 psad
454 will write these message to
455 .B /var/log/psad/errs/fwerrorlog
456 by default.  Passing the --no-ipt-errors option will make psad ignore
457 all such erroneous firewall messages.
458 .TP
459 .BR \-\^\-no-whois
460 By default psad will issue a whois query against any IP from which
461 a scan has originated, but this can be disabled with the --no-whois
462 command line argument.
463 .TP
464 .BR \-\^\-no-fwcheck
465 psad performs a rudimentary check of the firewall ruleset that
466 exists on the machine on which psad is deployed to determine
467 whether or not the firewall has a compatible configuration (i.e.
468 iptables has been configured to log packets).  Passing the
469 --no-fwcheck or --log-server options will disable this check.
470 .TP
471 .BR \-\^\-no-auto-dl
472 Disable auto danger level assignments.  This will instruct to not import
473 any IP addresses or networks from the file
474 .B /etc/psad/auto_dl.
475 .TP
476 .BR \-\^\-no-snort-sids
477 Disable snort sid processing mode.  This will instruct psad to not import
478 snort rules (for snort SID matching in a policy generated by
479 .B fwsnort
480 ).
481 .TP
482 .BR \-\^\-no-signatures
483 Disable psad signature processing.  Note that this is independent of
484 snort SID matching in iptables messages generated by
485 .B fwsnort
486 and also from the ICMP type/code validation routines.
487 .TP
488 .BR \-\^\-no-icmp-types
489 Disable ICMP type and code field validation.
490 .TP
491 .BR \-\^\-no-passive-os
492 By default psad will attempt to passively (i.e. without sending
493 any packets) fingerprint the remote operating system from which
494 a scan originates.  Passing the --no-passive-os option will
495 disable this feature.
496 .TP
497 .BR \-\^\-no-rdns
498 .B psad
499 normally attempts to find the name associated with a
500 scanning IP address, but this feature can be disabled with
501 the --no-rdns command line argument.
502 .TP
503 .BR \-\^\-no-kmsgsd
504 Disable startup of kmsgsd.  This option is most useful for debugging
505 with individual iptables messages so that new messages are not appended
506 to the
507 .B /var/log/psad/fwdata
508 file.
509 .TP
510 .BR \-\^\-no-netstat
511 By default for iptables firewalls psad will determine whether
512 or not your machine is listening on a port for which a TCP
513 signature has been matched.  Specifying --no-netstat
514 disables this feature.
515 .TP
516 .BR \-h ", " \-\^\-help
517 Print a page of usage information for psad and exit.
518 .SH FILES
519 .B /etc/psad/psad.conf
520 .RS
521 The main psad configuration file which contains configuration variables
522 mentioned in the section below.
523 .RE
524
525 .B /etc/psad/fw_search.conf
526 .RS
527 Used to configure the strategy both
528 .B psad
529 and
530 .B kmsgsd
531 employ to parse iptables messages.  Using configuration directive within
532 this file, psad can be configured to parse all iptables messages or only
533 those that match specific log prefix strings (see the --log-prefix option
534 to iptables).
535 .RE
536
537 .B /etc/psad/signatures
538 .RS
539 Contains the signatures
540 .B psad
541 uses to recognize nasty traffic.  The
542 signatures are written in a manner similar to the *lib signature
543 files used in the snort IDS.
544 .RE
545
546 .B /etc/psad/icmp_types
547 .RS
548 Contains all valid ICMP types and corresponding codes as defined by RFC 792.
549 By default, ICMP packets are validated against these values and an alert
550 will be generated if a non-matching ICMP packet is logged by iptables.
551 .RE
552
553 .B /etc/psad/snort_rules/*.rules
554 .RS
555 Snort rules files that are consulted by default unless the --no-snort-sids
556 commmand line argument is given.
557 .RE
558
559 .B /etc/psad/auto_dl
560 .RS
561 Contains a listing of any IP addresses that should be assigned
562 a danger level based on any traffic that is logged by the
563 firewall.  The syntax is "<IP address> <danger level>" where
564 <danger level> is an integer from 0 to 5, with 0 meaning to ignore
565 all traffic from <IP address>, and 5 is to assign the highest danger
566 level to <IP address>.
567 .RE
568
569 .B /etc/psad/posf
570 .RS
571 Contains a listing of all passive operating system fingerprinting
572 signatures.  These signatures include packet lengths, ttl, tos,
573 IP ID, and TCP window size values that are specific to various
574 operating systems.
575 .SH PSAD CONFIGURATION VARIABLES
576 This section describes what each of the more important
577 .B psad
578 configuration variables do and how they can be tuned to meet your
579 needs.  Most of the variables are located in the
580 .B psad
581 configuration file
582 .B /etc/psad/psad.conf
583 but the FW_SEARCH_ALL and FW_MSG_SEARCH variables are located in the
584 file
585 .B /etc/psad/fw_search.conf.
586 Each variable is assigned sensible defaults for most network
587 architectures during the install process.  More information on psad config
588 keywords may be found at:
589 .B http://www.cipherdyne.org/psad/config.html
590 .TP
591 .BR EMAIL_ADDRESSES
592 Contains a comma-separated list of email addresses to which email alerts
593 will be sent.  The default is "root@localhost".
594 .TP
595 .BR HOSTNAME
596 Defines the hostname of the machine on which
597 .B psad is running.  This will be
598 used in the email alerts generated by psad.
599 .TP
600 .BR HOME_NET
601 Define the internal network(s) that are connected to the local system.
602 This will be used in the signature matching code to determine whether traffic
603 matches snort rules, which invariably contain a source and destination
604 network.  Multiple networks are supported as a comma separated list, and
605 each network should be specified in CIDR notation.  Normally the network(s)
606 contained in the HOME_NET variable should be directly connected to the
607 machine that is running psad.
608 .TP
609 .BR IMPORT_OLD_SCANS
610 Preserve scan data across restarts of
611 .B psad
612 or even across reboots of the machine.  This is accomplished by importing
613 the data contained in the filesystem cache psad writes to during normal
614 operation back into memory as psad is started.  The filesystem cache data
615 in contained within the directory
616 .B /var/log/psad.
617 .TP
618 .BR FW_SEARCH_ALL
619 Defines the search mode
620 .B psad
621 uses to parse iptables messages.  By default FW_SEARCH_ALL is set to "Y"
622 since normally most people want all iptables log messages to be parsed for
623 scan activity.  However, if FW_SEARCH_ALL is set to "N", psad
624 will only parse those iptables log messages that match certain search
625 strings that appear in iptables logs with the --log-prefix option.  This is
626 useful for restricting psad to only operate on specific iptables chains or
627 rules.  The strings that will be searched for are defined with the FW_MSG_SEARCH
628 variable (see below).  The FW_SEARCH_ALL variable is defined in the file
629 .B /etc/psad/fw_search.conf
630 since it is referenced by both psad and kmsgsd.
631 .TP
632 .BR FW_MSG_SEARCH
633 Defines a set of search strings that
634 .B psad
635 uses to identify iptables messages that should be parsed for scan activity.
636 These search strings should match the log prefix strings specified
637 in the iptables ruleset with the --log-prefix option, and the default value
638 for FW_MSG_SEARCH is "DROP".  Note that
639 .B psad
640 normally parses all iptables messages, and so the FW_MSG_SEARCH variable
641 is only needed if FW_SEARCH_ALL (see above) is set to "N".  The FW_MSG_SEARCH
642 variable is referenced by both
643 .B psad
644 and
645 .B kmsgsd
646 so it lives in the file
647 .B /etc/psad/fw_search.conf.
648 .TP
649 .BR SYSLOG_DAEMON
650 Define the specific syslog daemon that
651 .B psad
652 should interface with.  Psad supports three syslog daemons:
653 .B syslogd,
654 .B syslog-ng,
655 and
656 .B metalog.
657 The default value of SYSLOG_DAEMON is
658 .B syslogd.
659 .TP
660 .BR IGNORE_PORTS
661 Specify a list of port ranges and/or individual ports and corresponding protocols
662 that
663 .B psad
664 should complete ignore.  This is particularly useful for ignore ports that are
665 used as a part of a port knocking scheme (such as
666 .B fwknop
667 http://www.cipherdyne.org/fwknop/) for network authentication since such log
668 messages generated by the knock sequence may otherwise be interpreted as a scan.
669 Multiple ports and/or port ranges may be specified as a comma-separated list, e.g.
670 "tcp/22, tcp/61000-61356, udp/53".
671 .TP
672 .BR ENABLE_PERSISTENCE
673 If "Y", psad will keep all scans in memory and not let them timeout.
674 This can help discover stealthy scans where an attacker tries to slip beneath
675 IDS thresholds by only scanning a few ports over a long period of time.
676 ENABLE_PERSISTENCE is set to "Y" by default.
677 .TP
678 .BR SCAN_TIMEOUT
679 If ENABLE_PERSISTENCE is "N" then psad will use the value set by SCAN_TIMEOUT
680 to remove packets from the scan threshold calculation.  The default is 3600
681 seconds (1 hour).
682 .TP
683 .BR DANGER_LEVEL{1,2,3,4,5}
684 psad uses a scoring system to keep track of the severity a scans reaches
685 (represented as a "danger level") over time.  The DANGER_LEVEL{n} variables
686 define the number of packets that must be dropped by the firewall before psad
687 will assign the respective danger level to the scan.  A scan may also be
688 assigned a danger level if the scan matches a particular signature contained
689 in the
690 .B signatures
691 file.  There are five
692 possible danger levels with one being the lowest and five the highest.
693 Note there are several factors that can influence how danger levels are
694 calculated: whether or not a scan matches a signature listed in
695 .B /etc/psad/signatures,
696 the value of PORT_RANGE_SCAN_THRESHOLD (see below), whether or not a scan comes
697 from an IP that is listed in the
698 .B /etc/psad/auto_dl
699 file, and finally whether or not scans are allowed to timeout
700 as determined by SCAN_TIMEOUT above.  If a signature is matched or the scanning
701 IP is listed in
702 .B /etc/psad/auto_dl,
703 then the corresponding danger level is automatically assigned to the scan.
704 .TP
705 .BR PORT_RANGE_SCAN_THRESHOLD
706 Defines the minimum difference between the lowest port and the highest port
707 scanned before an alert is sent (the default is 1 which means that at least
708 two ports must be scanned to generate an alert).  For example, suppose an ip
709 repeatedly scans a single port for which there is no special signature in
710 .B signatures.
711 Then if PORT_RANGE_SCAN_THRESHOLD=1, psad will never send
712 an alert for this "scan" no matter how many packets are sent to the port (i.e.
713 no matter what the value of DANGER_LEVEL1 is).  The reason for the default of
714 1 is that a "scan" usually means that at least two ports are probed, but if
715 you want psad to be extra paranoid you can set PORT_RANGE_SCAN_THRESHOLD=0
716 to alert on scans to single ports (as long as the number of packets also
717 exceeds DANGER_LEVEL1).
718 .TP
719 .BR SHOW_ALL_SIGNATURES
720 If "Y", psad will display all signatures detected from a single scanning
721 IP since a scan was first detected instead of just displaying newly-detected
722 signatures.  SHOW_ALL_SIGNATURES is set to "N" by default.  All signatures are
723 listed in the file
724 .B /etc/psad/signatures.
725 .TP
726 .BR SNORT_SID_STR
727 Defines the string kmsgsd will search for in iptables log messages that are
728 generated by iptables rules designed to detect snort rules.  The default is
729 "SID".  See
730 .B fwsnort
731 (http://www.cipherdyne.org/fwsnort/).
732 .TP
733 .BR ENABLE_DSHIELD_ALERTS
734 Enable dshield alerting mode.  This will send a parsed version of iptables log
735 messages to dshield.org which is a (free) distributed intrusion detection service.
736 For more information, see http://www.dshield.org/
737 .TP
738 .BR IGNORE_CONNTRACK_BUG_PKTS
739 If "Y", all TCP packets that have the ACK or RST flag bits set will be ignored
740 by psad since usually we see such packets being blocked as a result of the
741 iptables connection tracking bug.  Note there are no signatures that make use
742 of the RST flag and very few that use ACK flag.
743 .TP
744 .BR ALERT_ALL
745 If "Y", send email for all new bad packets instead of just when a danger
746 level increases.  ALERT_ALL is set to "Y" by default.
747 .TP
748 .BR PSAD_EMAIL_LIMIT
749 Defines the maximum number of emails that will be sent for a single scanning
750 IP (default is 50).  This variable gives you some protection from psad
751 sending countless alerts if an IP scans your machine constantly.
752 .B psad
753 will send a special alert if an IP has exceeded the email limit.  If
754 PSAD_EMAIL_LIMIT is set to zero, then psad will ignore the limit and send
755 alert emails indefinitely for any scanning ip.
756 .TP
757 .BR EMAIL_ALERT_DANGER_LEVEL
758 Defines the danger level a scan must reach before any alert is sent.
759 This variable is set to 1 by default.
760 .TP
761 .BR ENABLE_AUTO_IDS
762 .B psad
763 has the capability of dynamically blocking all traffic from an IP that
764 has reached a (configurable) danger level through modification of iptables
765 or tcpwrapper rulesets.
766 .B IMPORTANT:
767 This feature is disabled by default since it is possible for an attacker
768 to spoof packets from a well known (web)site in an effort to make it
769 look as though the site is scanning your machine, and then psad will
770 consequently block all access to it.  Also, psad works by parsing firewall
771 messages for packets the firewall has already dropped, so the "scans" are
772 unsuccessful anyway.  However, some administrators prefer to take this risk
773 anyway reasoning that they can always review which sites are being blocked
774 and manually remove the block if necessary (see the
775 .B --Flush
776 option).  Your mileage will vary.
777 .TP
778 .BR AUTO_IDS_DANGER_LEVEL
779 Defines the danger level a scan must reach before psad will automatically
780 block the IP (ENABLE_AUTO_IDS must be set to "Y").
781 .SH EXAMPLES
782 The following examples illustrate the command line arguments that could
783 be supplied to psad in a few situations:
784 .PP
785 Signature checking, passive OS fingerprinting, and automatic IP danger
786 level assignments are enabled by default without having to specify any
787 command line arguments (best for most situations):
788 .PP
789 .B # psad
790 .PP
791 Same as above, but this time we use the init script to start psad:
792 .PP
793 .B # /etc/init.d/psad start
794 .PP
795 Use psad as a forensics tool to analyze an old iptables logfile (psad defaults
796 to analyzing the
797 .B /var/log/messages
798 file if the -m option is not specified):
799 .PP
800 .B # psad -A -m <iptables logfile>
801 .PP
802 Run psad in forensics mode, but limit its operations to a specific IP
803 address "10.1.1.1":
804 .PP
805 .B # psad -A -m <iptables logfile> --analysis-fields "src:10.1.1.1"
806 .PP
807 Generate graphs of scan data using AfterGlow:
808 .PP
809 .B # psad --CSV --CSV-fields "src dst dp" --CSV-max 1000 -m <iptables logfile> | perl afterglow.pl -c color.properties | neato -Tgif -o netfilter_graph.gif
810 .PP
811 The
812 .B psad.conf,
813 .B signatures,
814 and
815 .B auto_dl
816 files are normally
817 located within the /etc/psad/ directory, but the paths to each of these
818 files can be changed:
819 .PP
820 .B # psad -c <config file> -s <signatures file> -a <auto ips file>
821 .PP
822 Disable the firewall check and the local port lookup subroutines; most useful
823 if psad is deployed on a syslog logging server:
824 .PP
825 .B # psad --log-server --no-netstat
826 .PP
827 Disable reverse dns and whois lookups of scanning IP addresses; most useful
828 if speed of psad is the main concern:
829 .PP
830 .B # psad --no-rdns --no-whois
831 .SH DEPENDENCIES
832 .B psad
833 requires that iptables is configured with a "drop and log" policy for any
834 traffic that is not explicitly allowed through.  This is consistent with a
835 secure network configuration since all traffic that has not been explicitly
836 allowed should be blocked by the firewall ruleset.  By default, psad attempts
837 to determine whether or not the firewall has been configured in this way.  This
838 feature can be disabled with the --no-fwcheck or --log-server options.  The
839 --log-server option is useful if psad is running on a syslog logging server
840 that is separate from the firewall.  For more information on compatible iptables
841 rulesets, see the
842 .B FW_EXAMPLE_RULES
843 file that is bundled with the psad source distribution.
844 .PP
845 .B psad
846 also requires that syslog be configured to write all kern.info messages to
847 the named pipe
848 \fB/var/lib/psad/psadfifo\fR.  A simple
849 .IP
850 .B echo -e 'kern.info\\\\t|/var/lib/psad/psadfifo' >> /etc/syslog.conf
851 .PP
852 will do.  Remember also to restart \fBsyslog\fR after the changes to
853 this file.
854 .SH DIAGNOSTICS
855 The --debug option can be used to display crucial information
856 about the psad data structures on STDOUT as a scan generates firewall
857 log messages.  --debug disables daemon mode execution.
858 .PP
859 Another more effective way to peer into the runtime execution of psad
860 is to send (as root) a USR1 signal to the psad process which will
861 cause psad to dump the contents of the %Scan hash to
862 .B /var/log/psad/scan_hash.$$
863 where
864 .B $$
865 represents the pid of the psad process.
866 .SH "SEE ALSO"
867 .BR iptables (8),
868 .BR kmsgsd (8),
869 .BR psadwatchd (8),
870 .BR fwsnort (8),
871 .BR snort (8),
872 .BR nmap (1),
873 .BR p0f (1),
874 .BR gnuplot (1)
875 .SH AUTHOR
876 Michael Rash <mbr@cipherdyne.org>
877 .SH CONTRIBUTORS
878 Many people who are active in the open source community have contributed to psad.
879 See the
880 .B CREDITS
881 file in the psad sources, or visit
882 .B http://www.cipherdyne.org/psad/docs/contributors.html
883 to view the online list of contributors.
884 .SH BUGS
885 Send bug reports to mbr@cipherdyne.org.  Suggestions and/or comments are
886 always welcome as well.
887 .PP
888 -For iptables firewalls as of Linux kernel version 2.4.26, if the ip_conntrack
889 module is loaded (or compiled into the kernel) and the firewall has been
890 configured to keep state of connections, occasionally packets that are supposed
891 to be part of normal TCP traffic will not be correctly identified due to a bug
892 in the firewall state timeouts and hence dropped.  Such packets will then be
893 interpreted as a scan by psad even though they are not part of any malicious
894 activity.  Fortunately, an interim fix for this problem is to simply extend the
895 TCP_CONNTRACK_CLOSE_WAIT timeout value in
896 linux/net/ipv4/netfilter/ip_conntrack_proto_tcp.c from 60 seconds to 2 minutes,
897 and a set of kernel patches is included within the patches/ directory in the
898 psad sources to change this.  (Requires a kernel recompile of course; see the
899 Kernel-HOWTO.)  Also, by default the IGNORE_CONNTRACK_BUG_PKTS variable is set
900 to "Y" in psad.conf which causes psad to ignore all TCP packets that have the
901 ACK bit set unless the packets match a specific signature.
902 .SH DISTRIBUTION
903 .B psad
904 is distributed under the GNU General Public License (GPL), and the latest
905 version may be downloaded from:
906 .B http://www.cipherdyne.org/
Note: See TracBrowser for help on using the browser.