|
Line 0
Link Here
|
|
|
1 |
#!/bin/sh - |
| 2 |
# |
| 3 |
# Show possible port scans detected by scanlogd. |
| 4 |
# |
| 5 |
# If you want to enable this script, place the following |
| 6 |
# into /etc/periodic.conf: |
| 7 |
# |
| 8 |
# security_status_scanlogd_enable="YES" |
| 9 |
# security_status_scanlogd_period="daily" |
| 10 |
# |
| 11 |
|
| 12 |
# If there is a global system configuration file, suck it in. |
| 13 |
# |
| 14 |
if [ -r /etc/defaults/periodic.conf ]; then |
| 15 |
. /etc/defaults/periodic.conf |
| 16 |
source_periodic_confs |
| 17 |
fi |
| 18 |
|
| 19 |
: ${security_status_scanlogd_period="daily"} |
| 20 |
|
| 21 |
security_daily_compat_var security_status_logdir |
| 22 |
security_daily_compat_var security_status_scanlogd_enable |
| 23 |
|
| 24 |
logdir="${security_status_logdir}" |
| 25 |
|
| 26 |
yesterday=`env LC_TIME=C date -v-1d "+%b %e "` |
| 27 |
|
| 28 |
catmsgs() { |
| 29 |
local logdir logfile mtime |
| 30 |
logdir="$1" |
| 31 |
logfile="$2" |
| 32 |
mtime="$3" |
| 33 |
|
| 34 |
find "$logdir" \( -name "$logfile" -o -name "$logfile.*" \) -mtime "$mtime" -print0 | |
| 35 |
xargs -0 ls -1tr | |
| 36 |
while read f; do |
| 37 |
case "$f" in |
| 38 |
*.gz) zcat -f "$f" ;; |
| 39 |
*.bz2) bzcat -f "$f" ;; |
| 40 |
*) cat "$f" ;; |
| 41 |
esac |
| 42 |
done |
| 43 |
} |
| 44 |
|
| 45 |
rc=0 |
| 46 |
|
| 47 |
if check_yesno_period security_status_scanlogd_enable; then |
| 48 |
echo "" |
| 49 |
echo "${host} possible port scans:" |
| 50 |
n=$(catmsgs "$logdir" messages "-2" | egrep -ia "^$yesterday.*scanlogd:" | tee /dev/stderr | wc -l) |
| 51 |
[ $n -gt 0 ] && rc=1 || rc=0 |
| 52 |
fi |
| 53 |
|
| 54 |
exit $rc |