.\" Process this file with .\" groff -man -Tascii foo.1 .\" .TH PSAD 8 "March 2009" Linux .SH NAME .B psad \- The Port Scan Attack Detector .SH SYNOPSIS .B psad [options] .SH DESCRIPTION .B psad makes use of iptables log messages to detect, alert, and (optionally) block port scans and other suspect traffic. For TCP scans psad analyzes TCP flags to determine the scan type (syn, fin, xmas, etc.) and corresponding command line options that could be supplied to nmap to generate such a scan. In addition, psad makes use of many TCP, UDP, and ICMP signatures contained within the Snort intrusion detection system (see http://www.snort.org/) to detect suspicious network traffic such as probes for common backdoors, DDoS tools, OS fingerprinting attempts, and more. By default psad also provides alerts for snort rules that are detected directly by iptables through the use of a ruleset generated by .B fwsnort (http://www.cipherdyne.org/fwsnort/). This enables psad to send alerts for application layer attacks. .B psad features a set of highly configurable danger thresholds (with sensible defaults provided) that allow the administrator to define what constitutes a port scan or other suspect traffic. Email alerts sent by psad contain the scanning ip, number of packets sent to each port, any TCP, UDP, or ICMP signatures that have been matched (e.g. "NMAP XMAS scan"), the scanned port range, the current danger level (from 1 to 5), reverse dns info, and whois information. .B psad also makes use of various packet header fields associated with TCP SYN packets to passively fingerprint remote operating systems (in a manner similar to the .B p0f fingerprinter) from which scans originate. This requires the use of the .B --log-tcp-options argument for iptables logging rules; if this option is not used, .B psad will fall back to a fingerprinting method that makes use of packet length, TTL and TOS values, IP ID, and TCP window sizes. .PP .B psad reads all iptables log data by default from the .I /var/log/messages file. By parsing firewall log messages, psad is provided with data that represents packets that have been logged (and possibly dropped) by the running iptables policy. In this sense, psad is supplied with a pure data stream that exclusively contains packets that the firewall has deemed unfit to enter the network. .B psad consists of three daemons: psad, kmsgsd, and psadwatchd. .B psad is responsible for processing all packets that have been logged by the firewall and applying the signature logic in order to determine what type of scan has been leveraged against the machine and/or network. .B kmsgsd .B (deprecated) reads all messages that have been written to the .I /var/lib/psad/psadfifo named pipe and writes any message that matches a particular regular expression (or string) to .I /var/log/psad/fwdata. kmsgsd is only used if the .B ENABLE_SYSLOG_FILE variable is disabled in psad.conf. .B psadwatchd is a software watchdog that will restart any of the other two daemons should a daemon die for any reason. .SH OPTIONS .TP .BR \-A ", " \-\^\-Analyze-msgs Analyze an iptables logfile for scans and exit. This will generate email alerts just as a normal running psad process would have for all logged scans. By default the psad data file .I /var/log/psad/fwdata is parsed for old scans, but any file can be specified through the use of the \-\-messages-file command line option. For example it might be useful to point psad at your .I /var/log/messages file. .TP .BR \-\^\-analysis-fields\ \ In \-\-Analyze mode restrict analysis to iptables log messages that have specific values for particular fields. Examples include "SRC:1.2.3.4", "DST:10.0.0.0/24, and "TTL:64", and multiple fields are supported as a comma-separated list like "SRC:1.2.3.4, LEN:44, DST:10.0.0.0/24". .TP .BR \-i "\fR,\fP " \-\^\-interface\ \ Specify the interface that .B psad will examine for iptables log messages. This interface will be the .B IN= interface for packets that are logged in the .B INPUT and .B FORWARD chains, and the .B OUT= interface for packets logged in the .B OUTPUT chain. .TP .BR \-\^\-sig-update Instruct .B psad to download the latest set of modified Snort signatures from http://www.cipherdyne.org/psad/signatures so that psad can take advantage of signature updates before a new release is made. .TP .BR \-O "\fR,\fP " \-\^\-Override-config\ \ Override config variable values that are normally read from the /etc/psad/psad.conf file with values from the specified file. Multiple override config files can be given as a comma separated list. .TP .BR \-D ", " \-\^\-Dump-conf Dump the current psad config to STDOUT and exit. Various pieces of information such as the home network, alert email addresses, and DShield user id are removed from the resulting output so it is safe to send to others. .TP .BR \-F ", " \-\^\-Flush Remove any auto-generated firewall block rules if psad was configured to automatically respond to scans (see the ENABLE_AUTO_IDS variable in psad.conf). .TP .BR \-S ", " \-\^\-Status Display the status of any psad processes that may or not be running. The status output contains a listing of the number of packets that have been processed by psad, along with all IP addresses and corresponding danger levels that have scanned the network. .TP .BR \-\^\-status-ip\ \ Display status information associated with .I ip such as the protocol packet counters as well as the last 10 packets logged by iptables. .TP .BR \-\^\-status-dl\ \
Display status information only for scans that have reached a danger level of at least .I dl .TP .BR \-\^\-status-summary Instruct .B psad to omit detailed IP information from .I --Status and .I --Analyze modes. .TP .BR \-m "\fR,\fP " \-\^\-messages-file\ \ This option is used to specify the file that will be parsed in analysis mode (see the \-\-Analyze-msgs option). The default path is the psad data file .I /var/log/psad/fwdata. .TP .BR \-\^\-CSV Instruct .B psad to parse iptables log messages out of .I /var/log/messages (by default, but this path can be changed with the .I -m option), and print the packet fields on STDOUT in comma-separate value format. This is useful for graphing iptables log data with AfterGlow (see http://afterglow.sourceforge.net/index.html). .TP .BR \-\^\-stdin Acquire iptables log data from STDIN instead of the default .I /var/log/messages file. .TP .BR \-\^\-CSV-fields\ \ Instruct .B psad to only include a specific set of iptables log message fields within the CSV output. AfterGlow accepts up to three fields for its graph data, so the most common usage of this option is "src dst dp" to print the source and destination IP addresses, and the destination port number. .TP .BR \-K ", " \-\^\-Kill Kill the current psad process along with psadwatchd and kmsgsd. This provides a quick and easy way to kill all psad processes without having to look in the process table or appeal to the psad-init script. .TP .BR \-R ", " \-\^\-Restart Restart the currently running psad processes. This option will preserve the command line options that were supplied to the original psad process. .TP .BR \-U ", " \-\^\-USR1 Send a running psad process a USR1 signal. This will cause psad to dump the contents of the %Scan hash to the file "/var/log/psad/scan_hash.$$" where "$$" represents the pid of the psad process. This is mostly useful for debugging purposes, but it also allows the administrator to peer into the %Scan hash, which is the primary data structure used to store scan data within system memory. .TP .BR \-H ", " \-\^\-HUP Send all running psad daemons a HUP signal. This will instruct the daemons to re-read their respective configuration files without causing scan data to be lost in the process. .TP .BR \-B ", " \-\^\-Benchmark Run psad in benchmark mode. By default benchmark mode will simulate a scan of 10,000 packets (see the \-\-packets option) and then report the elapsed time. This is useful to see how fast psad can process packets on a specific machine. .TP .BR \-p "\fR,\fP " \-\^\-packets\ \ Specify the number of packets to analyze in \-\-Analyze mode or use in \-\-Benchmark mode. The default is 10,000 packets in \-\-Benchmark mode, and unlimited in \-\-Analyze mode. .TP .BR \-d ", " \-\^\-debug Run psad in debugging mode. This will automatically prevent psad from running as a daemon, and will print the contents of the %Scan hash and a few other things on STDOUT at crucial points as psad executes. .TP .BR \-c "\fR,\fP " \-\^\-config\ \ By default all of the psad makes use of the configuration file .I /etc/psad/psad.conf for almost all configuration parameters. .B psad can be made to override this path by specifying a different file on the command line with the \-\-config option. .TP .BR \-\^\-signatures\ \ The iptables firewalling code included within the linux 2.4.x kernel series has the ability to distinguish and log any of the TCP flags present within TCP packets that traverse the firewall interfaces. .B psad makes use of this logging capability to detect several types of TCP scan signatures included within .I /etc/psad/signatures. The signatures were originally included within the snort intrusion detection system. New signatures can be included and modifications to existing signatures can be made to the signature file and psad will import the changes upon receiving a HUP signal (see the \-\-HUP command line option) without having to restart the psad process. .B psad also detects many UDP and ICMP signatures that were originally included within snort. .TP .BR \-e ", " \-\^\-email-analysis Send alert emails when run in \-\-Analyze-msgs mode. Depending on the size of the iptables logfile, using the \-\-email-analysis option could extend the runtime of psad by quite a bit since normally both DNS and whois lookups will be issued against each scanning IP address. As usual these lookups can be disabled with the \-\-no-rdns and \-\-no-whois options respectively. .TP .BR \-w ", " \-\^\-whois-analysis By default .B psad does not issue whois lookups when running in \-\-Analyze-msgs mode. The \-\-whois-analysis option will override this behavior (when run in analysis mode) and instruct psad to issue whois lookups against IP addresses from which scans or other suspect traffic has originated. .TP .BR \-\^\-analysis-auto-block Enable auto-blocking responses when running in \-\-Analyze-msgs mode. This is mostly useful only for the .B psad test suite when auto-blocking responses are tested and verified. .TP .BR \-\^\-snort-type\ \ Restrict the type of snort sids to .I type. Allowed types match the file names given to snort rules files such as "ddos", "backdoor", and "web-attacks". .TP .BR \-\^\-snort-rdir\ \ Manually specify the directory where the snort rules files are located. The default is .I /etc/psad/snort_rules. .TP .BR \-\^\-passive-os-sigs\ \ Manually specify the path to the passive operating system fingerprinting signatures file. The default is .I /etc/psad/posf. .TP .BR \-\^\-auto-dl\ \ Occasionally certain IP addresses are repeat offenders and should automatically be given a higher danger level than would normally be assigned. Additionally, some IP addresses can always be ignored depending on your network configuration (the loopback interface 127.0.0.1 might be a good candidate for example). .I /etc/psad/auto_dl provides an interface for psad to automatically increase/decrease/ignore scanning IP danger levels. Modifications can be made to auto_dl (installed by default in /etc/psad) and psad will import them with 'psad \-H' or by restarting the psad process. .TP .BR \-\^\-fw-search\ \ By default all of the psad makes use of the firewall search configuration file .I /etc/psad/fw_search.conf for firewall search mode and search strings. .B psad can be made to override this path by specifying a different file on the command line with the \-\-fw-search option. .TP .BR \-\^\-fw-list-auto List all rules in iptables chains that are used by .B psad in auto-blocking mode. .TP .BR \-\^\-fw-analyze Analyze the local iptables ruleset, send any alerts if errors are discovered, and then exit. .TP .BR \-\^\-fw-del-chains By default, if ENABLE_AUTO_IDS is set to "Y" .B psad will not delete the auto-generated iptables chains (see the IPT_AUTO_CHAIN keywords in psad.conf) if the \-\-Flush option is given. The \-\-fw-del-chains option overrides this behavior and deletes the auto-blocking chains from a running iptables firewall. .TP .BR \-\^\-fw-dump Instruct .B psad to dump the contents of the iptables policy that is running on the local system. All IP addresses are removed from the resulting output, so it is safe to post to the psad list, or communicate to others. This option is most often used with \-\-Dump-conf. .TP .BR \-\^\-fw-block-ip\ \ Specify an IP address or network to add to the iptables controls that are auto-generated by psad. This allows psad to manage the rule timeouts. .TP .BR \-\^\-fw-rm-block-ip\ \ Specify an IP address or network to remove from the iptables controls that are auto-generated by psad. .TP .BR \-\^\-fw-file\ \ Analyze the iptables ruleset contained within .B policy-file instead of the ruleset currently loaded on the local system. .TP .BR \-\^\-CSV-regex\ \ Instruct .B psad to only print CSV data that matches the supplied regex. This regex is used to match against each of the entire iptables log messages. .TP .BR \-\^\-CSV-neg-regex\ \ Instruct .B psad to only print CSV data that does not match the supplied regex. This regex is used to negatively match against each of the entire iptables log messages. .TP .BR \-\^\-CSV-uniq-lines Instruct .B psad to only print unique CSV data. That is, each line printed in .I --CSV mode will be unique. .TP .BR \-\^\-CSV-max-lines\ \ Limit the number of CSV-formatted lines that .B psad generates on STDOUT. This is useful to allow AfterGlow graphs to be created that are not too cluttered. .TP .BR \-\^\-CSV-start-line\ \ Specify the beginning line number to start parsing out of the iptables log file in .I --CSV output mode. This is useful for when the log file is extremely large, and you want to begin parsing a specific place within the file. The default is begin parsing at the beginning of the file. .TP .BR \-\^\-CSV-end-line\ \ Specify the ending line number to stop parsing the iptables log file in .I --CSV output mode. This is useful for when the log file is extremely large, and you do not want .B psad to process the entire thing. .TP .BR \-\^\-gnuplot Enter into Gnuplot mode whereby .B psad parses an iptables logfile and creates .gnu and .dat files that are suitable for graphing with Gnuplot. The various .I --CSV command line arguments apply to plotting iptables log with Gnuplot. .TP .BR \-\^\-gnuplot-template\ \ Use a template file for all Gnuplot graphing directives (this is usually a .gnu file by convention). Normally .B psad builds all of the graphing directives based on various --gnuplot command line arguments, but the \-\-gnuplot-template switch allows you to override this behavior. .TP .BR \-\^\-gnuplot-file-prefix\ \ Specify a prefix for the .gnu, .dat, and .png files that are generated in .I --gnuplot mode. So, when visualizing attacks captured in an iptables logfile (let's say you are interested in port scans), you could use this option to have .B psad create the two files portscan.dat, portscan.gnu, and Gnuplot will create an additional file portscan.png when the portscan.gnu file is loaded. .TP .BR \-\^\-gnuplot-x-label\ \