|
Lines 6-15
Link Here
|
| 6 |
PATH=/sbin:/bin:/usr/bin |
6 |
PATH=/sbin:/bin:/usr/bin |
| 7 |
LC_ALL=C; export LC_ALL |
7 |
LC_ALL=C; export LC_ALL |
| 8 |
|
8 |
|
| 9 |
separator () { |
9 |
if [ -r /etc/defaults/periodic.conf ]; then |
| 10 |
echo '' |
10 |
. /etc/defaults/periodic.conf |
| 11 |
echo '' |
11 |
source_periodic_confs |
| 12 |
} |
12 |
fi |
| 13 |
|
13 |
|
| 14 |
sflag=FALSE ignore= |
14 |
sflag=FALSE ignore= |
| 15 |
while getopts ams c |
15 |
while getopts ams c |
|
Lines 24-38
Link Here
|
| 24 |
yesterday=`date -v-1d "+%b %e "` |
24 |
yesterday=`date -v-1d "+%b %e "` |
| 25 |
|
25 |
|
| 26 |
host=`hostname` |
26 |
host=`hostname` |
| 27 |
[ $sflag = FALSE ] && echo "Subject: ${host} security check output" |
27 |
[ $sflag = FALSE ] && |
|
|
28 |
periodic_print_message -0 "Subject: ${host} security check output" |
| 28 |
|
29 |
|
| 29 |
LOG=/var/log |
30 |
LOG=/var/log |
| 30 |
TMP=/var/run/_secure.$$ |
31 |
TMP=/var/run/_secure.$$ |
| 31 |
|
32 |
|
| 32 |
umask 027 |
33 |
umask 027 |
| 33 |
|
34 |
|
| 34 |
echo "checking setuid files and devices:" |
|
|
| 35 |
|
| 36 |
# Don't have ncheck, but this does the equivalent of the commented out block. |
35 |
# Don't have ncheck, but this does the equivalent of the commented out block. |
| 37 |
# Note that one of the original problems, the possibility of overrunning |
36 |
# Note that one of the original problems, the possibility of overrunning |
| 38 |
# the args to ls, is still here... |
37 |
# the args to ls, is still here... |
|
Lines 48-62
Link Here
|
| 48 |
done | xargs -0 -n 20 ls -liTd | sort +10 > ${TMP} |
47 |
done | xargs -0 -n 20 ls -liTd | sort +10 > ${TMP} |
| 49 |
|
48 |
|
| 50 |
if [ ! -f ${LOG}/setuid.today ]; then |
49 |
if [ ! -f ${LOG}/setuid.today ]; then |
| 51 |
separator |
50 |
periodic_print_message "no ${LOG}/setuid.today" |
| 52 |
echo "no ${LOG}/setuid.today" |
|
|
| 53 |
cp ${TMP} ${LOG}/setuid.today |
51 |
cp ${TMP} ${LOG}/setuid.today |
| 54 |
fi |
52 |
fi |
| 55 |
|
53 |
|
| 56 |
if ! cmp ${LOG}/setuid.today ${TMP} >/dev/null; then |
54 |
if ! cmp ${LOG}/setuid.today ${TMP} >/dev/null; then |
| 57 |
separator |
55 |
diff -w ${LOG}/setuid.today ${TMP} | |
| 58 |
echo "${host} setuid diffs:" |
56 |
periodic_maybe_print_message "${host} setuid diffs:" |
| 59 |
diff -w ${LOG}/setuid.today ${TMP} |
|
|
| 60 |
mv ${LOG}/setuid.today ${LOG}/setuid.yesterday |
57 |
mv ${LOG}/setuid.today ${LOG}/setuid.yesterday |
| 61 |
mv ${TMP} ${LOG}/setuid.today |
58 |
mv ${TMP} ${LOG}/setuid.today |
| 62 |
fi |
59 |
fi |
|
Lines 66-105
Link Here
|
| 66 |
[ -n "$ignore" ] && cmd="egrep -v ${ignore#|}" || cmd=cat |
63 |
[ -n "$ignore" ] && cmd="egrep -v ${ignore#|}" || cmd=cat |
| 67 |
if mount -p | $cmd > $TMP; then |
64 |
if mount -p | $cmd > $TMP; then |
| 68 |
if [ ! -f $LOG/mount.today ]; then |
65 |
if [ ! -f $LOG/mount.today ]; then |
| 69 |
separator |
66 |
periodic_print_message "no $LOG/mount.today" |
| 70 |
echo "no $LOG/mount.today" |
|
|
| 71 |
cp $TMP $LOG/mount.today |
67 |
cp $TMP $LOG/mount.today |
| 72 |
fi |
68 |
fi |
|
|
69 |
|
| 73 |
if ! cmp $LOG/mount.today $TMP >/dev/null 2>&1; then |
70 |
if ! cmp $LOG/mount.today $TMP >/dev/null 2>&1; then |
| 74 |
separator |
71 |
diff -b $LOG/mount.today $TMP | |
| 75 |
echo "$host changes in mounted filesystems:" |
72 |
periodic_maybe_print_message "$host changes in mounted filesystems:" |
| 76 |
diff -b $LOG/mount.today $TMP |
|
|
| 77 |
mv $LOG/mount.today $LOG/mount.yesterday |
73 |
mv $LOG/mount.today $LOG/mount.yesterday |
| 78 |
mv $TMP $LOG/mount.today |
74 |
mv $TMP $LOG/mount.today |
| 79 |
fi |
75 |
fi |
| 80 |
fi |
76 |
fi |
| 81 |
|
77 |
|
| 82 |
separator |
78 |
awk -F: '$3==0 {print $1,$3}' /etc/master.passwd | |
| 83 |
echo "checking for uids of 0:" |
79 |
periodic_maybe_print_message "checking for uids of 0:" |
| 84 |
awk -F: '$3==0 {print $1,$3}' /etc/master.passwd |
|
|
| 85 |
|
| 86 |
separator |
| 87 |
echo "checking for passwordless accounts:" |
| 88 |
awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}' /etc/master.passwd |
| 89 |
|
80 |
|
|
|
81 |
awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}' /etc/master.passwd | |
| 82 |
periodic_maybe_print_message "checking for passwordless accounts:" |
| 83 |
|
| 90 |
# Show denied packets |
84 |
# Show denied packets |
| 91 |
# |
85 |
# |
| 92 |
if ipfw -a l 2>/dev/null | egrep "deny|reset|unreach" > ${TMP}; then |
86 |
if ipfw -a l 2>/dev/null | egrep "deny|reset|unreach" > ${TMP}; then |
| 93 |
if [ ! -f ${LOG}/ipfw.today ]; then |
87 |
if [ ! -f ${LOG}/ipfw.today ]; then |
| 94 |
separator |
88 |
periodic_print_message "no ${LOG}/ipfw.today" |
| 95 |
echo "no ${LOG}/ipfw.today" |
|
|
| 96 |
cp ${TMP} ${LOG}/ipfw.today |
89 |
cp ${TMP} ${LOG}/ipfw.today |
| 97 |
fi |
90 |
fi |
| 98 |
|
91 |
|
| 99 |
if ! cmp ${LOG}/ipfw.today ${TMP} >/dev/null; then |
92 |
if ! cmp ${LOG}/ipfw.today ${TMP} >/dev/null; then |
| 100 |
separator |
93 |
diff -b ${LOG}/ipfw.today ${TMP} | egrep "^>" | |
| 101 |
echo "${host} denied packets:" |
94 |
periodic_maybe_print_message "${host} denied packets:" |
| 102 |
diff -b ${LOG}/ipfw.today ${TMP} | egrep "^>" |
|
|
| 103 |
mv ${LOG}/ipfw.today ${LOG}/ipfw.yesterday |
95 |
mv ${LOG}/ipfw.today ${LOG}/ipfw.yesterday |
| 104 |
mv ${TMP} ${LOG}/ipfw.today |
96 |
mv ${TMP} ${LOG}/ipfw.today |
| 105 |
fi |
97 |
fi |
|
Lines 110-136
Link Here
|
| 110 |
IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` |
102 |
IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` |
| 111 |
if [ $? -eq 0 -a "${IPFW_LOG_LIMIT}" -ne 0 ]; then |
103 |
if [ $? -eq 0 -a "${IPFW_LOG_LIMIT}" -ne 0 ]; then |
| 112 |
ipfw -a l | grep " log " | perl -n -e \ |
104 |
ipfw -a l | grep " log " | perl -n -e \ |
| 113 |
'/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > ${TMP} |
105 |
'/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' | |
| 114 |
if [ -s "${TMP}" ]; then |
106 |
periodic_print_message "ipfw log limit reached:" |
| 115 |
separator |
|
|
| 116 |
echo "ipfw log limit reached:" |
| 117 |
cat ${TMP} |
| 118 |
fi |
| 119 |
fi |
107 |
fi |
| 120 |
|
108 |
|
| 121 |
# Show kernel log messages |
109 |
# Show kernel log messages |
| 122 |
# |
110 |
# |
| 123 |
if dmesg 2>/dev/null > ${TMP}; then |
111 |
if dmesg 2>/dev/null > ${TMP}; then |
| 124 |
if [ ! -f ${LOG}/dmesg.today ]; then |
112 |
if [ ! -f ${LOG}/dmesg.today ]; then |
| 125 |
separator |
113 |
periodic_print_message "no ${LOG}/dmesg.today" |
| 126 |
echo "no ${LOG}/dmesg.today" |
|
|
| 127 |
cp ${TMP} ${LOG}/dmesg.today |
114 |
cp ${TMP} ${LOG}/dmesg.today |
| 128 |
fi |
115 |
fi |
| 129 |
|
116 |
|
| 130 |
if ! cmp ${LOG}/dmesg.today ${TMP} >/dev/null 2>&1; then |
117 |
if ! cmp ${LOG}/dmesg.today ${TMP} >/dev/null 2>&1; then |
| 131 |
separator |
118 |
diff -b ${LOG}/dmesg.today ${TMP} | egrep "^>" | |
| 132 |
echo "${host} kernel log messages:" |
119 |
periodic_maybe_print_message "${host} kernel log messages:" |
| 133 |
diff -b ${LOG}/dmesg.today ${TMP} | egrep "^>" |
|
|
| 134 |
mv ${LOG}/dmesg.today ${LOG}/dmesg.yesterday |
120 |
mv ${LOG}/dmesg.today ${LOG}/dmesg.yesterday |
| 135 |
mv ${TMP} ${LOG}/dmesg.today |
121 |
mv ${TMP} ${LOG}/dmesg.today |
| 136 |
fi |
122 |
fi |
|
Lines 138-151
Link Here
|
| 138 |
|
124 |
|
| 139 |
# Show login failures |
125 |
# Show login failures |
| 140 |
# |
126 |
# |
| 141 |
separator |
127 |
zcat -f $LOG/messages.0* $LOG/messages | |
| 142 |
echo "${host} login failures:" |
128 |
grep -i "^$yesterday.*login failure" | |
| 143 |
zcat -f $LOG/messages.0* $LOG/messages | grep -i "^$yesterday.*login failure" |
129 |
periodic_maybe_print_message "${host} login failures:" |
| 144 |
|
130 |
|
| 145 |
# Show tcp_wrapper warning messages |
131 |
# Show tcp_wrapper warning messages |
| 146 |
# |
132 |
# |
| 147 |
separator |
133 |
zcat -f $LOG/messages.0* $LOG/messages | |
| 148 |
echo "${host} refused connections:" |
134 |
grep -i "^$yesterday.*refused connect" | |
| 149 |
zcat -f $LOG/messages.0* $LOG/messages | grep -i "^$yesterday.*refused connect" |
135 |
periodic_maybe_print_message "${host} refused connections:" |
| 150 |
|
136 |
|
| 151 |
rm -f ${TMP} |
137 |
rm -f ${TMP} |