PSAD(8)
๐ psad(8) ๐ โ The Port Scan Attack Detector ๐
okay so hi bestie, you've landed on the psad(8) page from the System Manager's Manual and honestly? you're about to have a great time. this is the port scan detective of your dreams and i'm gonna walk you through every single flag like we're texting at 2am. no skimming, no skipping, we're doing this properly. โจ
๐ NAME ๐
psad โ The Port Scan Attack Detector ๐ต๏ธโ๏ธ
๐ธ SYNOPSIS ๐ธ
psad [options]
that's it. that's the whole vibe. it's just psad plus whatever options you want. ๐ซถ
๐ฆ DESCRIPTION ๐ฆ
okay so here's the tea: psad eats iptables log messages for breakfast and uses them to detect, alert, and (optionally) block port scans and other sus traffic. ๐
for TCP scans, psad reads the TCP flags to figure out which type of scan it's looking at (syn, fin, xmas, etc.) and which corresponding command line options you'd hand to nmap to make such a scan happen. like, it can reverse-engineer the receipt. ๐ญ
plus, psad flexes a whole bunch of TCP, UDP, and ICMP signatures that live inside the Snort intrusion detection system (peep http://www.snort.org/) to catch sketchy network traffic โ probes for common backdoors, DDoS tools, OS fingerprinting attempts, and more. โจ
by default psad also throws alerts for snort rules that iptables detects directly, using a ruleset generated by fwsnort (http://www.cipherdyne.org/fwsnort/). this is the moment where psad can send alerts for application layer attacks. ate. ๐
psad ships with a set of highly configurable danger thresholds (with sensible defaults already set up for you, because she's thoughtful like that ๐) so the administrator gets to define what actually counts as a port scan or other suspect traffic.
the email alerts from psad contain:
- the scanning ip
- the 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
- whois information
psad also uses various packet header fields from TCP SYN packets to passively fingerprint remote operating systems โ in a manner similar to the p0f fingerprinter โ so it knows where scans are originating from. this needs the --log-tcp-options argument on your iptables logging rules. if you don't use that option, psad falls back to a fingerprinting method that uses packet length, TTL and TOS values, IP ID, and TCP window sizes. no cap. ๐ง
by default psad reads all iptables log data from the /var/log/messages file. by parsing firewall log messages, psad gets a data stream representing packets that have been logged (and possibly dropped) by the running iptables policy. which means psad is fed a pure data stream containing exclusively packets the firewall already deemed unfit to enter the network. iconic. ๐ฅ
psad is actually made of three daemons: psad, kmsgsd, and psadwatchd.
psadis responsible for processing all packets logged by the firewall and applying the signature logic to determine what type of scan has been leveraged against the machine and/or network.kmsgsd(deprecated! โ ๏ธ) reads all messages written to the/var/lib/psad/psadfifonamed pipe and writes any message matching a particular regular expression (or string) to/var/log/psad/fwdata.kmsgsdis only used if theENABLE_SYSLOG_FILEvariable is disabled inpsad.conf.psadwatchdis a software watchdog that restarts either of the other two daemons if one dies for any reason. she's the friend who checks on everyone. ๐ซถ
โจ OPTIONS โจ
-A,--Analyze-msgsโ analyze an iptables logfile for scans and exit. this generates email alerts just like a normal runningpsadprocess would have for all logged scans. by default the psad data file/var/log/psad/fwdatais parsed for old scans, but you can point it at any file with the--messages-filecommand line option. for example, it might be useful to pointpsadat your/var/log/messagesfile.--analysis-fields <search fields>โ in--Analyzemode, 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".-i,--interface <interface>โ specify the interface thatpsadwill examine for iptables log messages. this interface will be theIN=interface for packets logged in theINPUTandFORWARDchains, and theOUT=interface for packets logged in theOUTPUTchain. ๐--sig-updateโ instructpsadto download the latest set of modified Snort signatures from http://www.cipherdyne.org/psad/signatures sopsadcan take advantage of signature updates before a new release is even made. she stays ahead of the drop. ๐-O,--Override-config <file>โ override config variable values that are normally read from the/etc/psad/psad.conffile with values from the specified file. multiple override config files can be given as a comma separated list.-D,--Dump-confโ dump the current psad config toSTDOUTand exit. various pieces of info like the home network, alert email addresses, and DShield user id are removed from the resulting output, so it's safe to send to others. ๐ซถ-F,--Flushโ remove any auto-generated firewall block rules ifpsadwas configured to automatically respond to scans (see theENABLE_AUTO_IDSvariable inpsad.conf).-S,--Statusโ display the status of any psad processes that may or may not be running. the status output contains a listing of the number of packets processed bypsad, plus all IP addresses and corresponding danger levels that have scanned the network. ๐--status-ip <ip>โ display status information associated with ip, such as the protocol packet counters as well as the last 10 packets logged by iptables.--status-dl <dl>โ display status information only for scans that have reached a danger level of at least dl.--status-summaryโ instructpsadto omit detailed IP information from--Statusand--Analyzemodes.-m,--messages-file <file>โ this option specifies the file that will be parsed in analysis mode (see the--Analyze-msgsoption). the default path is the psad data file/var/log/psad/fwdata.--CSVโ instructpsadto parse iptables log messages out of/var/log/messages(by default, but this path can be changed with the-moption), and print the packet fields onSTDOUTin comma-separate value format. this is useful for graphing iptables log data with AfterGlow (see http://afterglow.sourceforge.net/index.html). ๐--stdinโ acquire iptables log data fromSTDINinstead of the default/var/log/messagesfile.--CSV-fields <tokens>โ instructpsadto 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.-K,--Killโ kill the currentpsadprocess along withpsadwatchdandkmsgsd. this is a quick and easy way to kill all psad processes without digging through the process table or appealing to the psad-init script. ๐-R,--Restartโ restart the currently running psad processes. this option preserves the command line options that were supplied to the originalpsadprocess.-U,--USR1โ send a runningpsadprocess aUSR1signal. this causespsadto dump the contents of the%Scanhash to the file/var/log/psad/scan_hash.$$where$$represents the pid of the psad process. mostly useful for debugging, but it also lets the administrator peer into the%Scanhash โ the primary data structure used to store scan data within system memory. ๐-H,--HUPโ send all running psad daemons aHUPsignal. this instructs the daemons to re-read their respective configuration files without causing scan data to be lost in the process.-B,--Benchmarkโ runpsadin benchmark mode. by default benchmark mode simulates a scan of 10,000 packets (see the--packetsoption) and then reports the elapsed time. useful to see how fastpsadcan process packets on a specific machine. ๐๏ธ-p,--packets <packets>โ specify the number of packets to analyze in--Analyzemode or use in--Benchmarkmode. the default is 10,000 packets in--Benchmarkmode, and unlimited in--Analyzemode.-d,--debugโ runpsadin debugging mode. this automatically preventspsadfrom running as a daemon, and prints the contents of the%Scanhash and a few other things onSTDOUTat crucial points aspsadexecutes. ๐-c,--config <configuration-file>โ by default all of the psad makes use of the configuration file/etc/psad/psad.conffor almost all configuration parameters.psadcan be made to override this path by specifying a different file on the command line with the--configoption.--signatures <signatures-file>โ 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.psadmakes use of this logging capability to detect several types of TCP scan signatures included within/etc/psad/signatures. these 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, andpsadwill import the changes upon receiving aHUPsignal (see the--HUPcommand line option) without having to restart the psad process.psadalso detects many UDP and ICMP signatures that were originally included within snort. ๐ง-e,--email-analysisโ send alert emails when run in--Analyze-msgsmode. depending on the size of the iptables logfile, using the--email-analysisoption could extend the runtime ofpsadby 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-rdnsand--no-whoisoptions respectively. ๐ญ-w,--whois-analysisโ by defaultpsaddoes not issue whois lookups when running in--Analyze-msgsmode. the--whois-analysisoption overrides this behavior (when run in analysis mode) and instructspsadto issue whois lookups against IP addresses from which scans or other suspect traffic has originated. ๐--analysis-auto-blockโ turns on auto-blocking responses while you're in--Analyze-msgsmode. ngl bestie, this one is basically for the psad test suite only, where auto-blocking responses get tested and verified. that's the whole vibe. ๐งช--snort-type <type>โ restricts which type of snort sids you're dealing with. the allowed types match the file names that get handed to snort rules files โ think"ddos","backdoor","web-attacks"and friends. ๐--snort-rdir <snort-rules-directory>โ you wanna hand-pick the directory where the snort rules files live? say it here. the default is/etc/psad/snort_rules. ๐--passive-os-sigs <passive-os-sigs-file>โ manually point at the path for the passive operating system fingerprinting signatures file. default?/etc/psad/posf. ๐--auto-dl <auto-dl-file>โ okay so sometimes certain IP addresses are repeat offenders and deserve a way higher danger level than they'd normally get. and also, some IP addresses can always be ignored depending on your network config (like the loopback interface127.0.0.1โ iconic candidate for ignoring, tbh)./etc/psad/auto_dlis the interface that lets psad automatically increase, decrease, or straight up ignore scanning IP danger levels. you can make edits toauto_dl(it's installed by default in/etc/psad) and psad will import them withpsad -Hor by restarting the psad process. ๐ฅ--fw-search <fw_search-file>โ by default, all of psad makes use of the firewall search config file/etc/psad/fw_search.conffor firewall search mode and search strings. but psad can override this path if you specify a different file on the command line with the--fw-searchoption. โจ--fw-list-autoโ lists every rule in iptables chains that psad uses in auto-blocking mode. ๐--fw-analyzeโ analyzes the local iptables ruleset, sends any alerts if errors are discovered, and then dips out (exits). ๐จ--fw-del-chainsโ by default, ifENABLE_AUTO_IDSis set to"Y", psad will not delete the auto-generated iptables chains (peep theIPT_AUTO_CHAINkeywords inpsad.conf) if the--Flushoption is given. the--fw-del-chainsoption overrides that behavior and deletes the auto-blocking chains from a running iptables firewall. ๐ค--fw-dumpโ tells psad to dump the contents of the iptables policy running on the local system. every IP address is stripped from the resulting output, so it's totally safe to post to the psad list or share with others. this option is most often used with--Dump-conf. ๐ซถ--fw-block-ip <ip>โ specify an IP address or network to add to the iptables controls that psad auto-generates. this lets psad manage the rule timeouts. ๐ซ--fw-rm-block-ip <ip>โ specify an IP address or network to remove from the iptables controls that psad auto-generates. bye felicia ๐--fw-file <policy-file>โ analyze the iptables ruleset contained within policy-file instead of the ruleset currently loaded on the local system. ๐--CSV-regex <regex>โ tells psad to only print CSV data that matches the regex you supply. this regex gets matched against each of the entire iptables log messages. ๐--CSV-neg-regex <regex>โ tells psad to only print CSV data that does not match the regex you supply. same deal, it negatively matches against each of the entire iptables log messages. ๐--CSV-uniq-linesโ tells psad to only print unique CSV data. so like, every single line printed in--CSVmode will be unique. no dupes, no repeats, periodt. ๐ฏ--CSV-max-lines <num>โ caps the number of CSV-formatted lines psad spits out on STDOUT. super useful when you want AfterGlow graphs that aren't too cluttered. ๐--CSV-start-line <num>โ picks the beginning line number to start parsing out of the iptables log file in--CSVoutput mode. great for when the log file is extremely large and you only wanna start parsing at a specific place inside it. the default is to begin parsing at the beginning of the file. โญ--CSV-end-line <num>โ picks the ending line number to stop parsing the iptables log file in--CSVoutput mode. also great for extremely large log files when you do not want psad to process the entire thing. ๐--gnuplotโ enters Gnuplot mode, where psad parses an iptables logfile and creates.gnuand.datfiles that are suitable for graphing with Gnuplot. the various--CSVcommand line arguments apply to plotting an iptables log with Gnuplot too. ๐--gnuplot-template <file>โ use a template file for all the Gnuplot graphing directives (conventionally a.gnufile). normally psad builds all the graphing directives based on various--gnuplotcommand line arguments, but the--gnuplot-templateswitch lets you override that behavior. ๐--gnuplot-file-prefix <file>โ sets a prefix for the.gnu,.dat, and.pngfiles generated in--gnuplotmode. so when you're visualizing attacks captured in an iptables logfile (say you're interested in port scans), you could use this option to have psad create the two filesportscan.dat,portscan.gnu, and Gnuplot will create an additional fileportscan.pngwhen theportscan.gnufile is loaded. chef's kiss ๐ฉโ๐ณ--gnuplot-x-label <label>โ sets the label associated with the x-axis. ๐--gnuplot-x-range <range>โ sets the x-axis range. ๐--gnuplot-y-label <label>โ sets the label associated with the y-axis. ๐ฆ--gnuplot-y-range <range>โ sets the y-axis range. ๐ธ--gnuplot-z-label <label>โ sets the label associated with the z-axis (only if--gnuplot-3Dis used). ๐ง--gnuplot-z-range <range>โ sets the z-axis range (only if--gnuplot-3Dis used). ๐--gnuplot-3Dโ generates a Gnuplot splot graph. this produces a three-dimensional graph, bestie. we're going 3D. ๐--gnuplot-viewโ sets the viewing angle when graphing data in--gnuplot-3Dmode. ๐ญ--gnuplot-title <title>โ sets the graph title for the Gnuplot graph. ๐-I,--Interval <seconds>โ specify the interval (in seconds) that psad should use to check whether or not packets have been logged by the firewall. psad uses a default of 15 seconds unless you specify a different value. โฑ๏ธ-l,--log-serverโ use this one if psad is being executed on a syslog logging server. running psad on a logging server requires thatcheck_firewall_rules()andauto_psad_response()not be executed, since the firewall probably isn't being run locally. ๐ฅ๏ธ-V,--Versionโ prints the psad version and exits. quick lil flex. ๐--no-daemonโ don't run psad as a daemon. this option will display scan alerts on STDOUT instead of emailing them out. ๐ฌ--no-ipt-errorsโ okay so occasionally iptables messages written by syslog to/var/log/messagesseem to not conform to the normal firewall logging format, if the kernel ring buffer used by klogd becomes full. psad will write these messages to/var/log/psad/errs/fwerrorlogby default. passing the--no-ipt-errorsoption makes psad ignore all such erroneous firewall messages. ๐ญ--no-whoisโ by default psad issues a whois query against any IP from which a scan has originated, but you can disable that with the--no-whoiscommand line argument. ๐ต๏ธ--no-fwcheckโ psad performs a rudimentary check of the firewall ruleset that exists on the machine where psad is deployed, to determine whether or not the firewall has a compatible configuration (i.e. iptables has been configured to log packets). passing--no-fwcheckor--log-serverwill disable this check. โ--no-auto-dlโ disables auto danger level assignments. this instructs psad to not import any IP addresses or networks from the file/etc/psad/auto_dl. ๐ฎ--no-snort-sidsโ disables snort sid processing mode. this instructs psad to not import snort rules (for snort SID matching in a policy generated byfwsnort). ๐--no-signaturesโ disables psad signature processing. note that this is independent of snort SID matching in iptables messages generated by fwsnort, and also independent from the ICMP type/code validation routines. ๐--no-icmp-typesโ disables ICMP type and code field validation. ๐--no-passive-osโ by default psad attempts to passively (i.e. without sending any packets) fingerprint the remote operating system from which a scan originates. passing the--no-passive-osoption disables this feature. ๐งฌ--no-rdnsโ psad normally attempts to find the name associated with a scanning IP address, but this feature can be disabled with the--no-rdnscommand line argument. ๐--no-kmsgsdโ disables startup ofkmsgsd. this option is most useful for debugging with individual iptables messages, so that new messages are not appended to the/var/log/psad/fwdatafile. ๐--no-netstatโ by default, for iptables firewalls, psad determines whether or not your machine is listening on a port for which a TCP signature has been matched. specifying--no-netstatdisables this feature. ๐ช-h,--helpโ prints a page of usage information for psad and exits. the classic. ๐ซถ
๐ FILES ๐
Okay bestie, here's the tea on every file psad is lowkey obsessed with. โ๐ No skipping, fr fr.
/etc/psad/psad.confโ This is the main psad configuration file, and it's where all those config variables mentioned in the section below live. ๐/etc/psad/fw_search.confโ Used to configure the strategy that both psad andkmsgsdemploy to parseiptablesmessages. Using a configuration directive within this file, psad can be configured to parse alliptablesmessages or only those that match specific log prefix strings (see the--log-prefixoption toiptables). โจ/etc/psad/signaturesโ Contains the signatures psad uses to recognize nasty traffic. The signatures are written in a manner similar to the*libsignature files used in the snort IDS. ๐จ/etc/psad/icmp_typesโ Contains all valid ICMP types and corresponding codes as defined by RFC 792. By default, ICMP packets are validated against these values, and an alert will be generated if a non-matching ICMP packet is logged byiptables. ๐ฆ/etc/psad/snort_rules/*.rulesโ Snort rules files that are consulted by default unless the--no-snort-sidscommand line argument is given. ๐/etc/psad/auto_dlโ Contains a listing of any IP addresses that should be assigned a danger level based on any traffic that is logged by the firewall. The syntax is"<IP address> <danger level>"where<danger level>is an integer from0to5, with0meaning to ignore all traffic from<IP address>, and5is to assign the highest danger level to<IP address>. ๐/etc/psad/posfโ Contains a listing of all passive operating system fingerprinting signatures. These signatures include packet lengths,ttl,tos,IP ID, andTCP window sizevalues that are specific to various operating systems. ๐
โจ PSAD CONFIGURATION VARIABLES โจ
okay bestie, this is the part where we go through the config variables one by one ๐ and honestly? this is where you get to make psad yours. Every one of these lives somewhere and does something, and most of them come pre-set with sensible defaults for most network architectures during the install process, so you don't have to touch them. But if you wanna tune, this is the menu.
Most of the variables hang out in the psad config file /etc/psad/psad.conf, except FW_SEARCH_ALL and FW_MSG_SEARCH, which live in /etc/psad/fw_search.conf instead (iykyk why in a sec).
Wanna read more about psad config keywords? There's more at: http://www.cipherdyne.org/psad/config.html
๐ EMAIL_ADDRESSES
Comma-separated list of email addresses where your alert emails get sent. Default is "root@localhost".
๐ HOSTNAME
The hostname of the machine psad is running on. This is what shows up in the email alerts psad generates, so make it a good one.
๐ HOME_NET
Defines the internal network(s) connected to the local system. This gets used in the signature matching code to figure out whether traffic matches snort rules โ and those rules invariably contain a source and destination network, so yeah, this matters. You can list multiple networks as a comma-separated list, and each network should be in CIDR notation. Normally, the network(s) in HOME_NET should be directly connected to the machine running psad.
๐ฆ IMPORT_OLD_SCANS
Keeps your scan data alive across restarts of psad, or even across reboots of the machine ๐ How? By importing the data in the filesystem cache that psad writes to during normal operation back into memory as psad starts up. That filesystem cache data lives in the directory /var/log/psad.
๐ FW_SEARCH_ALL
Sets the search mode psad uses to parse iptables messages. By default this is "Y" because, like, normally most people want all iptables log messages parsed for scan activity. But if you set it to "N", psad will only parse the iptables log messages that match certain search strings appearing in iptables logs via the --log-prefix option. Super useful if you wanna restrict psad to only operate on specific iptables chains or rules. The strings it searches for are defined by the FW_MSG_SEARCH variable (see below ๐). And this one lives in /etc/psad/fw_search.conf because it's referenced by both psad and kmsgsd.
๐ FW_MSG_SEARCH
A set of search strings psad uses to identify iptables messages that should be parsed for scan activity. These search strings should match the log prefix strings you specified in your iptables ruleset with the --log-prefix option, and the default value is "DROP". Note that psad normally parses all iptables messages, so FW_MSG_SEARCH is only needed if FW_SEARCH_ALL (above) is set to "N". This variable is referenced by both psad and kmsgsd, so it lives in /etc/psad/fw_search.conf.
๐ SYSLOG_DAEMON
Tells psad which specific syslog daemon it should interface with. psad supports three: syslogd, syslog-ng, and metalog. Default value is syslogd.
๐ IGNORE_PORTS
A list of port ranges and/or individual ports plus their corresponding protocols that psad should completely ignore. This is especially handy for ignoring ports that are part of a port knocking scheme (like fwknop โ http://www.cipherdyne.org/fwknop/) for network authentication, because otherwise those log messages generated by the knock sequence might get interpreted as a scan ๐ญ You can specify multiple ports and/or port ranges as a comma-separated list, e.g. "tcp/22, tcp/61000-61356, udp/53".
๐ง ENABLE_PERSISTENCE
If "Y", psad will keep all scans in memory and not let them timeout. This helps you catch stealthy scans where an attacker tries to slip beneath IDS thresholds by only scanning a few ports over a long period of time ๐ It's set to "Y" by default.
โณ SCAN_TIMEOUT
If ENABLE_PERSISTENCE is "N", then psad uses the value set by SCAN_TIMEOUT to remove packets from the scan threshold calculation. Default is 3600 seconds (1 hour).
๐จ DANGER_LEVEL{1,2,3,4,5}
psad uses a scoring system to keep track of how severe a scan gets (represented as a "danger level") over time. The DANGER_LEVEL{n} variables define the number of packets that must be dropped by the firewall before psad assigns the respective danger level to the scan. A scan can also get a danger level if it matches a particular signature contained in the signatures file. There are five possible danger levels, one being the lowest and five the highest.
Heads up though โ several factors can influence how danger levels are calculated:
- whether or not a scan matches a signature listed in
/etc/psad/signatures - the value of
PORT_RANGE_SCAN_THRESHOLD(see below) - whether or not a scan comes from an IP listed in the
/etc/psad/auto_dlfile - whether or not scans are allowed to timeout, as determined by
SCAN_TIMEOUTabove
If a signature is matched, or the scanning IP is listed in /etc/psad/auto_dl, then the corresponding danger level is automatically assigned to the scan.
๐ PORT_RANGE_SCAN_THRESHOLD
Defines the minimum difference between the lowest port and the highest port scanned before an alert is sent. Default is 1, which means at least two ports must be scanned to generate an alert.
Example time ๐ธ suppose an ip repeatedly scans a single port for which there is no special signature in signatures. Then if PORT_RANGE_SCAN_THRESHOLD=1, psad will never send an alert for this "scan" no matter how many packets are sent to the port (i.e. no matter what the value of DANGER_LEVEL1 is). The reason for the default of 1 is that a "scan" usually means at least two ports are probed. But if you want psad to be extra paranoid ๐ซฃ you can set PORT_RANGE_SCAN_THRESHOLD=0 to alert on scans to single ports โ as long as the number of packets also exceeds DANGER_LEVEL1.
๐ SHOW_ALL_SIGNATURES
If "Y", psad will display all signatures detected from a single scanning IP since a scan was first detected, instead of just displaying newly-detected signatures. It's set to "N" by default. All signatures are listed in the file /etc/psad/signatures.
๐ท SNORT_SID_STR
The string kmsgsd will search for in iptables log messages that are generated by iptables rules designed to detect snort rules. Default is "SID". See fwsnort (http://www.cipherdyne.org/fwsnort/).
๐ก๏ธ ENABLE_DSHIELD_ALERTS
Enables dshield alerting mode โจ This sends a parsed version of iptables log messages to dshield.org, which is a (free) distributed intrusion detection service. More info at http://www.dshield.org/
๐ IGNORE_CONNTRACK_BUG_PKTS
If "Y", all TCP packets that have the ACK or RST flag bits set will be ignored by psad, since usually we see such packets being blocked as a result of the iptables connection tracking bug. Note there are no signatures that make use of the RST flag, and very few that use the ACK flag.
๐ง ALERT_ALL
If "Y", send email for all new bad packets instead of just when a danger level increases. ALERT_ALL is set to "Y" by default.
๐ข PSAD_EMAIL_LIMIT
The maximum number of emails that will be sent for a single scanning IP โ default is 50. This variable gives you some protection from psad sending countless alerts if an IP scans your machine constantly. psad will send a special alert if an IP has exceeded the email limit. And if PSAD_EMAIL_LIMIT is set to zero, then psad will ignore the limit entirely and send alert emails indefinitely for any scanning ip ๐ญ
๐ฆ EMAIL_ALERT_DANGER_LEVEL
The danger level a scan must reach before any alert is sent. Set to 1 by default.
โ ๏ธ ENABLE_AUTO_IDS
psad has the capability of dynamically blocking all traffic from an IP that has reached a (configurable) danger level, by modifying iptables or tcpwrapper rulesets.
IMPORTANT: This feature is disabled by default ๐ค because it's possible for an attacker to spoof packets from a well known (web)site in an effort to make it look as though the site is scanning your machine โ and then psad will consequently block all access to it. Also, psad works by parsing firewall messages for packets the firewall has already dropped, so the "scans" are unsuccessful anyway. However, some administrators prefer to take this risk anyway, reasoning that they can always review which sites are being blocked and manually remove the block if necessary (see the --Flush option). Your mileage will vary.
๐ฏ AUTO_IDS_DANGER_LEVEL
Defines the danger level a scan must reach before psad will automatically block the IP (ENABLE_AUTO_IDS must be set to "Y").
๐ธ EXAMPLES ๐ธ
ok so here's the tea, bestie โ these are the actual command line arguments you could hand to psad in a few real-life situations ๐
โจ the no-notes, default-girlie run
Signature checking, passive OS fingerprinting, and automatic IP danger level assignments are enabled by default, no command line arguments needed. best for most situations, fr fr ๐ซถ
# psad
โจ same energy, but the init script does it
Same as above, but this time we use the init script to start psad:
# /etc/init.d/psad start
โจ forensics mode, let's investigate
Use psad as a forensics tool to analyze an old iptables logfile โ and just so you know, psad defaults to analyzing the /var/log/messages file if the -m option is not specified ๐
# psad -A -m <iptables logfile>
โจ forensics, but make it ONE ip only
Run psad in forensics mode, but limit its operations to a specific IP address "10.1.1.1":
# psad -A -m <iptables logfile> --analysis-fields src:10.1.1.1
โจ graph o'clock (AfterGlow era)
Generate graphs of scan data using AfterGlow ๐:
# psad --CSV --CSV-fields src dst dp --CSV-max 1000 -m <iptables
logfile> | perl afterglow.pl -c color.properties | neato -Tgif -o
iptables_graph.gif
โจ relocating the config files
The psad.conf, signatures, and auto_dl files are normally located within the /etc/psad/ directory, but the paths to each of these files can be changed ๐
# psad -c <config file> -s <signatures file> -a <auto ips file>
โจ syslog server life
Disable the firewall check and the local port lookup subroutines; most useful if psad is deployed on a syslog logging server:
# psad --log-server --no-netstat
โจ speed is the main character
Disable reverse dns and whois lookups of scanning IP addresses; most useful if speed of psad is the main concern ๐โโ๏ธ๐จ
# psad --no-rdns --no-whois
๐ง DEPENDENCIES ๐ง
ok so psad requires that iptables is configured with a "drop and log" policy for any traffic that is not explicitly allowed through. this is, like, the whole vibe of a secure network configuration โ because all traffic that has not been explicitly allowed should be blocked by the firewall ruleset, periodt ๐ฅ
By default, psad attempts to determine whether or not the firewall has been configured in this way. you can turn that feature off with the --no-fwcheck or --log-server options. and the --log-server option is super useful if psad is running on a syslog logging server that is separate from the firewall ๐
For more info on compatible iptables rulesets, check the FW_EXAMPLE_RULES file that is bundled with the psad source distribution ๐
also: psad by default parses the /var/log/messages file for all iptables log data.
๐ DIAGNOSTICS ๐
The --debug option can be used to display crucial information about the psad data structures on STDOUT as a scan generates firewall log messages. and btw, --debug disables daemon mode execution. noted ๐
Another, more effective way to peer into the runtime execution of psad is to send (as root) a USR1 signal to the psad process, which will cause psad to dump the contents of the %Scan hash to /var/log/psad/scan_hash.$$ where $$ represents the pid of the psad process ๐ซ
๐ SEE ALSO ๐
iptables(8), kmsgsd(8), psadwatchd(8), fwsnort(8), snort(8), nmap(1), p0f(1), gnuplot(1)
๐ AUTHOR ๐
Michael Rash <mbr@cipherdyne.org>
๐ซถ CONTRIBUTORS ๐ซถ
Many people who are active in the open source community have contributed to psad. See the CREDITS file in the psad sources, or visit http://www.cipherdyne.org/psad/docs/contributors.html to view the online list of contributors ๐
๐ BUGS ๐
Send bug reports to mbr@cipherdyne.org. Suggestions and/or comments are always welcome as well ๐
ok now for the big one, and it's giving chaos: for iptables firewalls as of Linux kernel version 2.4.26, if the ip_conntrack module is loaded (or compiled into the kernel) and the firewall has been configured to keep state of connections, occasionally packets that are supposed to be part of normal TCP traffic will not be correctly identified due to a bug in the firewall state timeouts โ and hence dropped ๐ญ Such packets will then be interpreted as a scan by psad even though they are not part of any malicious activity. false alarm energy, truly.
Fortunately, an interim fix for this problem is to simply extend theTCP_CONNTRACK_CLOSE_WAITtimeout value inlinux/net/ipv4/netfilter/ip_conntrack_proto_tcp.cfrom60 secondsto2 minutes, and a set of kernel patches is included within thepatches/directory in the psad sources to change this. (Requires a kernel recompile of course; see theKernel-HOWTO.) Also, by default theIGNORE_CONNTRACK_BUG_PKTSvariable is set to"Y"inpsad.confwhich causes psad to ignore all TCP packets that have the ACK bit set unless the packets match a specific signature.
๐ DISTRIBUTION ๐
psad is distributed under the GNU General Public License (GPL), and the latest version may be downloaded from: http://www.cipherdyne.org/ โ also, Snort is a registered trademark of Sourcefire, Inc. โข๏ธ
and that's the whole page, bestie, you made it to the end ๐ this one's from the Linux manual pages, March 2009, and it's page PSAD(8) โ slay, go read your logs, ily ๐๐ฆโจ
๐ฆ where this page comes from
- alpine 3.24: psad-doc 2.4.6-r4 ยท GPL-2.0-or-later
- debian bookworm: psad 2.4.6-3 ยท GPL-2.0-or-later
- debian trixie: psad 2.4.6-3+b1 ยท GPL-2.0-or-later
- fedora 43: psad 2.4.6-23.fc43 ยท GPL-2.0-or-later
- fedora 44: psad 2.4.6-24.fc44 ยท GPL-2.0-or-later
- ubuntu jammy: psad 2.4.6-2 ยท GPL-2.0-or-later
- ubuntu noble: psad 2.4.6-3 ยท GPL-2.0-or-later
- ubuntu questing: psad 2.4.6-3
- ubuntu resolute: psad 2.4.6-3build1 ยท GPL-2.0-or-later
- ubuntu stonking: psad 2.4.6-3build1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms