3 # @(#)security 5.3 (Berkeley) 5/28/91
4 # $Id: security,v 1.29 1999/01/10 11:18:59 danny Exp $
6 PATH=/sbin:/bin:/usr/bin
7 LC_ALL=C; export LC_ALL
15 echo "Subject: $host security check output"
18 TMP=/var/run/_secure.$$
22 echo "checking setuid files and devices:"
24 # don't have ncheck, but this does the equivalent of the commented out block.
25 # note that one of the original problem, the possibility of overrunning
26 # the args to ls, is still here...
28 MP=`mount -t ufs | grep -v " nosuid" | sed 's;/dev/;&r;' | awk '{ print $3 }'`
30 while test $# -ge 1; do
33 find $mount -xdev -type f \
34 \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
35 \( -perm -u+s -or -perm -g+s \) -print0
36 done | xargs -0 -n 20 ls -lTd | sort +9 > $TMP
38 if [ ! -f $LOG/setuid.today ] ; then
40 echo "no $LOG/setuid.today"
41 cp $TMP $LOG/setuid.today
43 if cmp $LOG/setuid.today $TMP >/dev/null; then :; else
45 echo "$host setuid diffs:"
46 diff -b $LOG/setuid.today $TMP
47 mv $LOG/setuid.today $LOG/setuid.yesterday
48 mv $TMP $LOG/setuid.today
52 echo "checking for uids of 0:"
53 awk -F: '$3==0 {print $1,$3}' /etc/master.passwd
56 echo "checking for passwordless accounts:"
57 awk -F: '$1 !~ /^\+/ && $2=="" {print $0}' /etc/master.passwd
60 if ipfw -a l 2>/dev/null | egrep "deny|reset|unreach" > $TMP; then
61 if [ ! -f $LOG/ipfw.today ] ; then
63 echo "no $LOG/ipfw.today"
64 cp $TMP $LOG/ipfw.today
66 if cmp $LOG/ipfw.today $TMP >/dev/null; then :; else
68 echo "$host denied packets:"
69 diff -b $LOG/ipfw.today $TMP | egrep "^>"
70 mv $LOG/ipfw.today $LOG/ipfw.yesterday
71 mv $TMP $LOG/ipfw.today
75 # show ipfw rules which have reached the log limit
76 IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null`
77 if [ $? -eq 0 ] && [ $IPFW_LOG_LIMIT -ne 0 ]; then
78 ipfw -a l | grep " log " | perl -n -e \
79 '/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > $TMP
82 echo "ipfw log limit reached:"
87 # show kernel log messages
88 if dmesg 2>/dev/null > $TMP; then
89 if [ ! -f $LOG/dmesg.today ] ; then
91 echo "no $LOG/dmesg.today"
92 cp $TMP $LOG/dmesg.today
94 if cmp $LOG/dmesg.today $TMP >/dev/null 2>&1; then :; else
96 echo "$host kernel log messages:"
97 diff -b $LOG/dmesg.today $TMP | egrep "^>"
98 mv $LOG/dmesg.today $LOG/dmesg.yesterday
99 mv $TMP $LOG/dmesg.today
103 # show login failures
105 echo "$host login failures:"
106 grep -i "login failure" $LOG/messages
108 # show tcp_wrapper warning messages
110 echo "$host refused connections:"
111 grep -i "refused connect" $LOG/messages