Révision b5ce1d00
Add port scan detection plugin (psad)
psad is a cyber defense tool that monitors for incoming port scans
and can optionally blacklist/block attackers.
Both these options can be charted with this plugin.
- Port scans detected (per hour)
- Attackers blocked (per hour)
| plugins/network/psad | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# -*- sh -*- |
|
| 3 |
|
|
| 4 |
: << =cut |
|
| 5 |
|
|
| 6 |
=head1 NAME |
|
| 7 |
|
|
| 8 |
psad - Plugin to monitor the number of port scans detected by psad. |
|
| 9 |
|
|
| 10 |
=head1 CONFIGURATION |
|
| 11 |
|
|
| 12 |
The following environment variables are used by this plugin |
|
| 13 |
|
|
| 14 |
psad - Path to psad binary - defaults to psad in PATH |
|
| 15 |
psad_log - Path to the log where psad entries are logged. defaults to /var/log/messages |
|
| 16 |
wc - wc program to use |
|
| 17 |
awk - awk program to use |
|
| 18 |
|
|
| 19 |
=head1 APPLICABLE SYSTEMS |
|
| 20 |
|
|
| 21 |
Any system using psad for intrusion detection. |
|
| 22 |
psad is a port scan detection tool. Using this plugin will allow munin to |
|
| 23 |
graph its effectiveness for you so you can easily track network security |
|
| 24 |
compromise or other trends. |
|
| 25 |
|
|
| 26 |
=head2 CONFIGURATION EXAMPLES |
|
| 27 |
|
|
| 28 |
There should be no configuration needed for a standard install. |
|
| 29 |
|
|
| 30 |
For the sake of example, the following configuration could be used |
|
| 31 |
for psad installation with non-standard logfile location (/var/log/psad/psad.log): |
|
| 32 |
|
|
| 33 |
[psad] |
|
| 34 |
env.psad_log /var/log/psad/psad.log |
|
| 35 |
|
|
| 36 |
=head1 AUTHOR |
|
| 37 |
|
|
| 38 |
Copyright (C) 2013 Dave Driesen <dave.driesen@honeypot.pandemonium.be> |
|
| 39 |
|
|
| 40 |
=head1 LICENSE |
|
| 41 |
|
|
| 42 |
This program is free software; you can redistribute it and/or modify |
|
| 43 |
it under the terms of the GNU General Public License as published by |
|
| 44 |
the Free Software Foundation; version 2 dated June, 1991. |
|
| 45 |
|
|
| 46 |
This program is distributed in the hope that it will be useful, but |
|
| 47 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 48 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 49 |
General Public License for more details. |
|
| 50 |
|
|
| 51 |
You should have received a copy of the GNU General Public License |
|
| 52 |
along with this program; if not, write to the Free Software |
|
| 53 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
| 54 |
02110-1301 USA. |
|
| 55 |
|
|
| 56 |
=head1 MAGIC MARKERS |
|
| 57 |
|
|
| 58 |
#%# family=auto contrib |
|
| 59 |
#%# capabilities=autoconf |
|
| 60 |
|
|
| 61 |
=cut |
|
| 62 |
|
|
| 63 |
psad_log_default=/var/log/messages |
|
| 64 |
|
|
| 65 |
[ $awk ] || awk="awk" |
|
| 66 |
[ $wc ] || wc="wc" |
|
| 67 |
[ $psad ] || psad="psad" |
|
| 68 |
[ $psad_log ] || psad_log="$psad_log_default" |
|
| 69 |
|
|
| 70 |
case $1 in |
|
| 71 |
autoconf) |
|
| 72 |
if [ -f ${psad} ] ; then
|
|
| 73 |
echo yes |
|
| 74 |
else |
|
| 75 |
echo no |
|
| 76 |
fi |
|
| 77 |
exit 0;; |
|
| 78 |
|
|
| 79 |
config) |
|
| 80 |
cat <<'EOM' |
|
| 81 |
graph_title Port scans detected |
|
| 82 |
graph_vlabel Events per hour |
|
| 83 |
graph_info This graph shows the number of port scans detected per hour |
|
| 84 |
graph_category network |
|
| 85 |
graph_period minute |
|
| 86 |
|
|
| 87 |
attacks_logged.label Scans detected per hour |
|
| 88 |
attacks_logged.draw LINE1 |
|
| 89 |
attacks_logged.warning 10 |
|
| 90 |
attacks_logged.critical 20 |
|
| 91 |
attacks_logged.type COUNTER |
|
| 92 |
attacks_logged.cdef attacks_logged,12,* |
|
| 93 |
|
|
| 94 |
autoblocks_logged.label Auto-blocks per hour |
|
| 95 |
autoblocks_logged.draw LINE1 |
|
| 96 |
autoblocks_logged.type COUNTER |
|
| 97 |
autoblocks_logged.cdef autoblocks_logged,12,* |
|
| 98 |
|
|
| 99 |
EOM |
|
| 100 |
exit 0;; |
|
| 101 |
esac |
|
| 102 |
|
|
| 103 |
grep "psad: scan detected" "$psad_log" | $wc -l | $awk '{
|
|
| 104 |
print "attacks_logged.value " $1 |
|
| 105 |
}' |
|
| 106 |
|
|
| 107 |
grep "psad: added iptables auto-block against " "$psad_log" | $wc -l | $awk '{
|
|
| 108 |
print "autoblocks_logged.value " $1 |
|
| 109 |
}' |
|
Formats disponibles : Unified diff