142328Sbostic#!/bin/sh - 242328Sbostic# 3*53184Sbostic# @(#)security 5.22 (Berkeley) 04/17/92 442328Sbostic# 553105Sbostic 652578SbosticPATH=/sbin:/usr/sbin:/bin:/usr/bin 742328Sbostic 853130Sbosticumask 077 952215Sbostic 1053098SbosticERR=/tmp/_secure1.$$ 1153098SbosticTMP1=/tmp/_secure2.$$ 1253098SbosticTMP2=/tmp/_secure3.$$ 1353130SbosticTMP3=/tmp/_secure4.$$ 1453130SbosticLIST=/tmp/_secure5.$$ 1553130SbosticOUTPUT=/tmp/_secure6.$$ 1652578Sbostic 1753130Sbostictrap 'rm -f $ERR $TMP1 $TMP2 $TMP3 $LIST $OUTPUT' 0 1852578Sbostic 19*53184Sbostic# Check the master password file syntax. 2053130SbosticMP=/etc/master.passwd 2153130Sbosticawk -F: '{ 2253130Sbostic if ($0 ~ /^[ ]*$/) { 2353130Sbostic printf("Line %d is a blank line.\n", NR); 2453130Sbostic next; 2553130Sbostic } 2653130Sbostic if (NF != 10) 2753130Sbostic printf("Line %d has the wrong number of fields.\n", NR); 2853155Sbostic if ($1 !~ /^[A-Za-z0-9]*$/) 2953130Sbostic printf("Login %s has non-numeric characters.\n", $1); 3053130Sbostic if (length($1) > 8) 3153130Sbostic printf("Login %s has more than 8 characters.\n", $1); 3253130Sbostic if ($2 == "") 3353130Sbostic printf("Login %s has no password.\n", $1); 3453130Sbostic if (length($2) != 13 && ($10 ~ /.*sh$/ || $10 == "")) 3553130Sbostic printf("Login %s is off but still has a valid shell.\n", $1); 3653130Sbostic if ($3 == 0 && $1 != "root" && $1 != "toor") 3753130Sbostic printf("Login %s has a user id of 0.\n", $1); 3853130Sbostic if ($3 < 0) 3953130Sbostic printf("Login %s has a negative user id.\n", $1); 4053130Sbostic if ($4 < 0) 4153155Sbostic printf("Login %s has a negative group id.\n", $1); 4253130Sbostic}' < $MP > $OUTPUT 4353130Sbosticif [ -s $OUTPUT ] ; then 4453130Sbostic printf "\nChecking the $MP file:\n" 4553130Sbostic cat $OUTPUT 4653130Sbosticfi 4742328Sbostic 4853130Sbosticawk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT 4953130Sbosticif [ -s $OUTPUT ] ; then 5053130Sbostic printf "\n$MP has duplicate user names.\n" 5153130Sbostic column $OUTPUT 5253130Sbosticfi 5352573Sbostic 5453130Sbosticawk -F: '{ print $1 " " $3 }' $MP | sort -n +1 | tee $TMP1 | 5553130Sbosticuniq -d -f 1 | awk '{ print $2 }' > $TMP2 5653130Sbosticif [ -s $TMP2 ] ; then 5753130Sbostic printf "\n$MP has duplicate user id's.\n" 5853130Sbostic while read uid; do 5953130Sbostic grep -w $uid $TMP1 6053130Sbostic done < $TMP2 | column 6153130Sbosticfi 6253104Sbostic 6353130Sbostic# Check the group file syntax. 6453130SbosticGRP=/etc/group 6553130Sbosticawk -F: '{ 6653130Sbostic if ($0 ~ /^[ ]*$/) { 6753130Sbostic printf("Line %d is a blank line.\n", NR); 6853130Sbostic next; 6953130Sbostic } 7053130Sbostic if (NF != 4) 7153130Sbostic printf("Line %d has the wrong number of fields.\n", NR); 7253159Sbostic if ($1 !~ /^[A-za-z0-9]*$/) 7353130Sbostic printf("Group %s has non-numeric characters.\n", $1); 7453130Sbostic if (length($1) > 8) 7553130Sbostic printf("Group %s has more than 8 characters.\n", $1); 7653130Sbostic if ($3 !~ /[0-9]*/) 7753155Sbostic printf("Login %s has a negative group id.\n", $1); 7853130Sbostic}' < $GRP > $OUTPUT 7953130Sbosticif [ -s $OUTPUT ] ; then 8053130Sbostic printf "\nChecking the $GRP file:\n" 8153130Sbostic cat $OUTPUT 8253130Sbosticfi 8353130Sbostic 8453130Sbosticawk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT 8553130Sbosticif [ -s $OUTPUT ] ; then 8653130Sbostic printf "\n$GRP has duplicate group names.\n" 8753130Sbostic column $OUTPUT 8853130Sbosticfi 8953130Sbostic 9053130Sbostic# Check for root paths, umask values in startup files. 91*53184Sbostic# The check for the root paths is problematical -- it's likely to fail 92*53184Sbostic# in other environments. Once the shells have been modified to warn 93*53184Sbostic# of '.' in the path, the path tests should go away. 9453130Sbostic> $OUTPUT 9553130Sbosticrhome=/root 9653130Sbosticumaskset=no 9753130Sbosticlist="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login" 9853130Sbosticfor i in $list ; do 9953130Sbostic if [ -f $i ] ; then 10053130Sbostic if egrep umask $i > /dev/null ; then 10153130Sbostic umaskset=yes 10253104Sbostic fi 10353130Sbostic egrep umask $i | 10453130Sbostic awk '$2 % 100 < 20 \ 10553130Sbostic { print "Root umask is group writeable" } 10653130Sbostic $2 % 10 < 2 \ 10753130Sbostic { print "Root umask is other writeable" }' >> $OUTPUT 10853130Sbostic /bin/csh -f -s << end-of-csh > /dev/null 2>&1 10953130Sbostic unset path 11053130Sbostic source $i 11153130Sbostic /bin/ls -ldgT \$path > $TMP1 11253130Sbosticend-of-csh 11353130Sbostic awk '{ 11453159Sbostic if ($10 ~ /^\.$/) { 11553130Sbostic print "The root path includes ."; 11653130Sbostic next; 11753130Sbostic } 11853130Sbostic } 11953130Sbostic $1 ~ /^d....w/ \ 12053130Sbostic { print "Root path directory " $10 " is group writeable." } \ 12153130Sbostic $1 ~ /^d.......w/ \ 12253130Sbostic { print "Root path directory " $10 " is other writeable." }' \ 12353130Sbostic < $TMP1 >> $OUTPUT 12453130Sbostic fi 12553130Sbosticdone 12653130Sbosticif [ $umaskset = "no" -o -s $OUTPUT ] ; then 12753130Sbostic printf "\nChecking root csh paths, umask values:\n$list\n" 12853130Sbostic if [ -s $OUTPUT ]; then 12953130Sbostic cat $OUTPUT 13053130Sbostic fi 13153130Sbostic if [ $umaskset = "no" ] ; then 13253130Sbostic printf "\nRoot csh startup files do not set the umask.\n" 13353130Sbostic fi 13453130Sbosticfi 13553104Sbostic 13653130Sbostic> $OUTPUT 13753130Sbosticrhome=/root 13853130Sbosticumaskset=no 13953130Sbosticlist="${rhome}/.profile" 14053130Sbosticfor i in $list; do 14153130Sbostic if [ -f $i ] ; then 14253130Sbostic if egrep umask $i > /dev/null ; then 14353130Sbostic umaskset=yes 14453130Sbostic fi 14553130Sbostic egrep umask $i | 14653130Sbostic awk '$2 % 100 < 20 \ 14753130Sbostic { print "Root umask is group writeable" } \ 14853130Sbostic $2 % 10 < 2 \ 14953130Sbostic { print "Root umask is other writeable" }' >> $OUTPUT 15053130Sbostic /bin/sh << end-of-sh > /dev/null 2>&1 15153130Sbostic PATH= 15253130Sbostic . $i 15353130Sbostic list=\`echo \$PATH | /usr/bin/sed -e 's/:/ /g'\` 15453130Sbostic /bin/ls -ldgT \$list > $TMP1 15553130Sbosticend-of-sh 15653130Sbostic awk '{ 15753159Sbostic if ($10 ~ /^\.$/) { 15853130Sbostic print "The root path includes ."; 15953130Sbostic next; 16053130Sbostic } 16153130Sbostic } 16253130Sbostic $1 ~ /^d....w/ \ 16353130Sbostic { print "Root path directory " $10 " is group writeable." } \ 16453130Sbostic $1 ~ /^d.......w/ \ 16553130Sbostic { print "Root path directory " $10 " is other writeable." }' \ 16653130Sbostic < $TMP1 >> $OUTPUT 16753130Sbostic 16853130Sbostic fi 16953130Sbosticdone 17053130Sbosticif [ $umaskset = "no" -o -s $OUTPUT ] ; then 17153130Sbostic printf "\nChecking root sh paths, umask values:\n$list\n" 17253130Sbostic if [ -s $OUTPUT ]; then 17353130Sbostic cat $OUTPUT 17453130Sbostic fi 17553130Sbostic if [ $umaskset = "no" ] ; then 17653130Sbostic printf "\nRoot sh startup files do not set the umask.\n" 17753130Sbostic fi 17853130Sbosticfi 17953130Sbostic 18053130Sbostic# Root and uucp should both be in /etc/ftpusers. 18153130Sbosticif egrep root /etc/ftpusers > /dev/null ; then 18253130Sbostic : 18353130Sbosticelse 18453130Sbostic printf "\nRoot not listed in /etc/ftpusers file.\n" 18553130Sbosticfi 18653130Sbosticif egrep uucp /etc/ftpusers > /dev/null ; then 18753130Sbostic : 18853130Sbosticelse 18953130Sbostic printf "\nUucp not listed in /etc/ftpusers file.\n" 19053130Sbosticfi 19153130Sbostic 192*53184Sbostic# Uudecode should not be in the /etc/aliases file. 19353130Sbosticif grep -w uudecode /etc/aliases; then 19453130Sbostic printf "\nThere is an entry for uudecode in the /etc/aliases file.\n" 19553130Sbosticfi 19653130Sbostic 197*53184Sbostic# There should be no plus signs in /etc/hosts.equiv. 19853130Sbosticif egrep '\+|^$' /etc/hosts.equiv > /dev/null ; then 19953130Sbostic printf "\nEmpty line or + in /etc/hosts.equiv file.\n" 20053130Sbosticfi 20153130Sbostic 20253130Sbostic# Check for special users with .rhosts files. Only root and toor should 20353130Sbostic# have a .rhosts files. Also, .rhosts files should not have blank lines 20453130Sbostic# or plus signs. 20553130Sbosticawk -F: '$1 != "root" && $1 != "toor" && \ 20653130Sbostic ($3 < 100 || $1 == "ftp" || $1 == "uucp") \ 20753130Sbostic { print $1 " " $6 }' /etc/passwd | 20853130Sbosticwhile read uid homedir; do 20953130Sbostic if [ -f ${homedir}/.rhosts ] ; then 21053130Sbostic rhost=`ls -ldgT ${homedir}/.rhosts` 21153130Sbostic printf "$uid: $rhost\n" 21253130Sbostic fi 21353130Sbosticdone > $OUTPUT 21453130Sbosticif [ -s $OUTPUT ] ; then 21553130Sbostic printf "\nChecking for special users with .rhosts files.\n" 21653130Sbostic cat $OUTPUT 21753130Sbosticfi 21853130Sbostic 21953130Sbosticawk -F: '{ print $1 " " $6 }' /etc/passwd | \ 22053130Sbosticwhile read uid homedir; do 22153130Sbostic if [ -f ${homedir}/.rhosts ] && \ 22253130Sbostic egrep '\+|^$' ${homedir}/.rhosts > /dev/null ; then 22353130Sbostic printf "$uid: empty line or + in .rhosts file.\n" 22453130Sbostic fi 22553130Sbosticdone > $OUTPUT 22653130Sbosticif [ -s $OUTPUT ] ; then 22753130Sbostic printf "\nChecking .rhosts files syntax.\n" 22853130Sbostic cat $OUTPUT 22953130Sbosticfi 23053130Sbostic 231*53184Sbostic# Check home directories. Directories should not be owned by someone else 232*53184Sbostic# or writeable. 23353130Sbosticawk -F: '{ print $1 " " $6 }' /etc/passwd | \ 23453105Sbosticwhile read uid homedir; do 23553105Sbostic if [ -d ${homedir}/ ] ; then 23653105Sbostic file=`ls -ldgT ${homedir}` 23753130Sbostic printf "$uid $file\n" 23853105Sbostic fi 23953130Sbosticdone | 24053130Sbosticawk '$1 != $4 && $4 != "root" \ 24153130Sbostic { print "user " $1 " home directory is owned by " $4 } 24253130Sbostic $2 ~ /^-....w/ \ 24353130Sbostic { print "user " $1 " home directory is group writeable" } 24453130Sbostic $2 ~ /^-.......w/ \ 24553130Sbostic { print "user " $1 " home directory is other writeable" }' > $OUTPUT 24653130Sbosticif [ -s $OUTPUT ] ; then 24753130Sbostic printf "\nChecking home directories.\n" 24853130Sbostic cat $OUTPUT 24953130Sbosticfi 25053105Sbostic 25153104Sbostic# Files that should not be owned by someone else or readable. 25253130Sbosticlist=".netrc .rhosts" 25353130Sbosticawk -F: '{ print $1 " " $6 }' /etc/passwd | \ 25453104Sbosticwhile read uid homedir; do 25553130Sbostic for f in $list ; do 25653130Sbostic file=${homedir}/${f} 25753130Sbostic if [ -f $file ] ; then 25853130Sbostic printf "$uid $f `ls -ldgT $file`\n" 25953130Sbostic fi 26053130Sbostic done 26153130Sbosticdone | 26253130Sbosticawk '$1 != $5 && $5 != "root" \ 26353130Sbostic { print "user " $1 " " $2 " file is owned by " $5 } 26453130Sbostic $3 ~ /^-...r/ \ 26553130Sbostic { print "user " $1 " " $2 " file is group readable" } 26653130Sbostic $3 ~ /^-......r/ \ 26753130Sbostic { print "user " $1 " " $2 " file is other readable" } 26853130Sbostic $3 ~ /^-....w/ \ 26953130Sbostic { print "user " $1 " " $2 " file is group writeable" } 27053130Sbostic $3 ~ /^-.......w/ \ 27153130Sbostic { print "user " $1 " " $2 " file is other writeable" }' > $OUTPUT 27253104Sbostic 27353104Sbostic# Files that should not be owned by someone else or writeable. 27453130Sbosticlist=".bashrc .cshrc .emacsrc .exrc .forward .klogin .login .logout \ 27553130Sbostic .profile .tcshrc" 27653130Sbosticawk -F: '{ print $1 " " $6 }' /etc/passwd | \ 27753104Sbosticwhile read uid homedir; do 27853130Sbostic for f in $list ; do 27953130Sbostic file=${homedir}/${f} 28053130Sbostic if [ -f $file ] ; then 28153130Sbostic printf "$uid $f `ls -ldgT $file`\n" 28253130Sbostic fi 28353130Sbostic done 28453130Sbosticdone | 28553130Sbosticawk '$1 != $5 && $5 != "root" \ 28653130Sbostic { print "user " $1 " " $2 " file is owned by " $5 } 28753130Sbostic $3 ~ /^-....w/ \ 28853130Sbostic { print "user " $1 " " $2 " file is group writeable" } 28953130Sbostic $3 ~ /^-.......w/ \ 29053130Sbostic { print "user " $1 " " $2 " file is other writeable" }' >> $OUTPUT 29153130Sbosticif [ -s $OUTPUT ] ; then 29253130Sbostic printf "\nChecking dot files.\n" 29353130Sbostic cat $OUTPUT 29453130Sbosticfi 29553104Sbostic 296*53184Sbostic# Mailboxes should be owned by user and unreadable. 29753130Sbosticls -l /var/mail | sed 1d | \ 29853130Sbosticawk '$3 != $9 \ 29953130Sbostic { print "user " $9 " mailbox is owned by " $3 } 30053130Sbostic $1 != "-rw-------" \ 30153130Sbostic { print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT 30253130Sbosticif [ -s $OUTPUT ] ; then 30353130Sbostic printf "\nChecking mailbox ownership.\n" 30453130Sbostic cat $OUTPUT 30553130Sbosticfi 30653104Sbostic 307*53184Sbostic# File systems should not be globally exported. 30853105Sbosticawk '{ 30953105Sbostic readonly = 0; 31053105Sbostic for (i = 2; i <= NF; ++i) { 31153105Sbostic if ($i ~ /-ro/) 31253105Sbostic readonly = 1; 31353105Sbostic else if ($i !~ /^-/) 31453105Sbostic next; 31553105Sbostic } 31653105Sbostic if (readonly) 31753105Sbostic print "File system " $1 " globally exported, read-only." 31853105Sbostic else 31953105Sbostic print "File system " $1 " globally exported, read-write." 32053130Sbostic}' < /etc/exports > $OUTPUT 32153130Sbosticif [ -s $OUTPUT ] ; then 32253130Sbostic printf "\nChecking for globally exported file systems.\n" 32353130Sbostic cat $OUTPUT 32453130Sbosticfi 32553105Sbostic 326*53184Sbostic# Display any changes in setuid files and devices. 32753130Sbosticprintf "\nChecking setuid files and devices:\n" 32853130Sbostic(find / ! -fstype local -a -prune -o \ 32953130Sbostic \( -perm -u+s -o -perm -g+s -o ! -type d -a ! -type f -a ! -type l -a \ 33053130Sbostic ! -type s \) | \ 33153130Sbosticsort | sed -e 's/^/ls -ldgT /' | sh > $LIST) 2> $OUTPUT 33242328Sbostic 33353098Sbostic# Display any errors that occurred during system file walk. 33453130Sbosticif [ -s $OUTPUT ] ; then 33553130Sbostic printf "Setuid/device find errors:\n" 33653130Sbostic cat $OUTPUT 33753130Sbostic printf "\n" 33842328Sbosticfi 33942328Sbostic 34053098Sbostic# Display any changes in the setuid file list. 34153130Sbosticegrep -v '^[bc]' $LIST > $TMP1 34253130Sbosticif [ -s $TMP1 ] ; then 34353130Sbostic # Check to make sure uudecode isn't setuid. 34453130Sbostic if grep -w uudecode $TMP1 > /dev/null ; then 34553130Sbostic printf "\nUudecode is setuid.\n" 34653130Sbostic fi 34753130Sbostic 34853130Sbostic CUR=/var/backups/setuid.current 34953130Sbostic BACK=/var/backups/setuid.backup 35053130Sbostic 35153098Sbostic if [ -s $CUR ] ; then 35253130Sbostic if cmp -s $CUR $TMP1 ; then 35352573Sbostic : 35452573Sbostic else 35553130Sbostic > $TMP2 35653130Sbostic join -110 -210 -v2 $CUR $TMP1 > $OUTPUT 35753130Sbostic if [ -s $OUTPUT ] ; then 35853130Sbostic printf "Setuid additions:\n" 35953130Sbostic tee -a $TMP2 < $OUTPUT 36053130Sbostic printf "\n" 36152573Sbostic fi 36252573Sbostic 36353130Sbostic join -110 -210 -v1 $CUR $TMP1 > $OUTPUT 36453130Sbostic if [ -s $OUTPUT ] ; then 36553130Sbostic printf "Setuid deletions:\n" 36653130Sbostic tee -a $TMP2 < $OUTPUT 36753130Sbostic printf "\n" 36852573Sbostic fi 36952573Sbostic 37053130Sbostic sort +9 $TMP2 $CUR $TMP1 | \ 37153130Sbostic sed -e 's/[ ][ ]*/ /g' | uniq -u > $OUTPUT 37253130Sbostic if [ -s $OUTPUT ] ; then 37353130Sbostic printf "Setuid changes:\n" 37453130Sbostic column -t $OUTPUT 37553130Sbostic printf "\n" 37652573Sbostic fi 37752573Sbostic 37853130Sbostic cp $CUR $BACK 37953130Sbostic cp $TMP1 $CUR 38052573Sbostic fi 38152573Sbostic else 38253130Sbostic printf "Setuid additions:\n" 38353140Sbostic column -t $TMP1 38453130Sbostic printf "\n" 38553130Sbostic cp $TMP1 $CUR 38652573Sbostic fi 38752215Sbosticfi 38852215Sbostic 389*53184Sbostic# Check for block and character disk devices that are readable or writeable 39053140Sbostic# or not owned by root.operator. 39153130Sbosticegrep '^b' $LIST > $TMP1 39253130Sbosticegrep '^c.*/rdk[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39353130Sbosticegrep '^c.*/rfd[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39453130Sbosticegrep '^c.*/rhd[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39553130Sbosticegrep '^c.*/rhk[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39653130Sbosticegrep '^c.*/rhp[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39753130Sbosticegrep '^c.*/rjb[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39853130Sbosticegrep '^c.*/rkra[0-9][0-9]*[a-h]$' $LIST >> $TMP1 39953130Sbosticegrep '^c.*/rra[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40053130Sbosticegrep '^c.*/rrb[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40153130Sbosticegrep '^c.*/rrd[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40253130Sbosticegrep '^c.*/rrl[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40353130Sbosticegrep '^c.*/rrx[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40453130Sbosticegrep '^c.*/rrz[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40553130Sbosticegrep '^c.*/rsd[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40653130Sbosticegrep '^c.*/rup[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40753130Sbosticegrep '^c.*/rwd[0-9][0-9]*[a-h]$' $LIST >> $TMP1 40853105Sbostic 40953140Sbosticawk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \ 41053140Sbostic { printf("Disk %s is user %s, group %s, permissions %s.\n", \ 41153140Sbostic $11, $3, $4, $1); }' < $TMP1 > $OUTPUT 41253130Sbosticif [ -s $OUTPUT ] ; then 41353130Sbostic printf "\nChecking disk ownership and permissions.\n" 41453130Sbostic cat $OUTPUT 41553130Sbostic printf "\n" 41653130Sbosticfi 41753105Sbostic 418*53184Sbostic# Display any changes in the device file list. 41953140Sbosticegrep '^[bc]' $LIST | sort +10 > $TMP1 42053130Sbosticif [ -s $TMP1 ] ; then 42153130Sbostic CUR=/var/backups/device.current 42253130Sbostic BACK=/var/backups/device.backup 42353098Sbostic 42453098Sbostic if [ -s $CUR ] ; then 42553130Sbostic if cmp -s $CUR $TMP1 ; then 42653098Sbostic : 42753098Sbostic else 42853130Sbostic > $TMP2 42953130Sbostic join -111 -211 -v2 $CUR $TMP1 > $OUTPUT 43053130Sbostic if [ -s $OUTPUT ] ; then 43153130Sbostic printf "Device additions:\n" 43253130Sbostic tee -a $TMP2 < $OUTPUT 43353130Sbostic printf "\n" 43453098Sbostic fi 43553098Sbostic 43653130Sbostic join -111 -211 -v1 $CUR $TMP1 > $OUTPUT 43753130Sbostic if [ -s $OUTPUT ] ; then 43853130Sbostic printf "Device deletions:\n" 43953130Sbostic tee -a $TMP2 < $OUTPUT 44053130Sbostic printf "\n" 44153098Sbostic fi 44253098Sbostic 44353140Sbostic # Report any block device change. Ignore character 44453140Sbostic # devices, only the name is significant. 44553140Sbostic cat $TMP2 $CUR $TMP1 | \ 44653140Sbostic sed -e '/^c/d' | \ 44753140Sbostic sort +10 | \ 44853130Sbostic sed -e 's/[ ][ ]*/ /g' | \ 44953140Sbostic uniq -u > $OUTPUT 45053130Sbostic if [ -s $OUTPUT ] ; then 45153140Sbostic printf "Block device changes:\n" 45253130Sbostic column -t $OUTPUT 45353130Sbostic printf "\n" 45453098Sbostic fi 45553098Sbostic 45653130Sbostic cp $CUR $BACK 45753130Sbostic cp $TMP1 $CUR 45853098Sbostic fi 45953098Sbostic else 46053130Sbostic printf "Device additions:\n" 46153140Sbostic column -t $TMP1 46253130Sbostic printf "\n" 46353130Sbostic cp $TMP1 $CUR 46453098Sbostic fi 46553098Sbosticfi 46653098Sbostic 46753142Sbostic# Check special files. 46853142Sbostic# Check system binaries. 46953142Sbostic# 47052578Sbostic# Create the mtree tree specifications using: 47152578Sbostic# 47253130Sbostic# mtree -cx -pDIR -kcksum,gid,mode,nlink,size,link,time,uid > DIR.secure 47353130Sbostic# chown root.wheel DIR.SECURE 47453130Sbostic# chmod 600 DIR.SECURE 47552578Sbostic# 47652578Sbostic# Note, this is not complete protection against Trojan horsed binaries, as 47752578Sbostic# the hacker can modify the tree specification to match the replaced binary. 47852578Sbostic# For details on really protecting yourself against modified binaries, see 47952578Sbostic# the mtree(8) manual page. 48052578Sbosticif cd /etc/mtree; then 48153130Sbostic mtree -e -p / -f /etc/mtree/special > $OUTPUT 48253130Sbostic if [ -s $OUTPUT ] ; then 48353130Sbostic printf "\nChecking special files and directories.\n" 48453130Sbostic cat $OUTPUT 48553130Sbostic fi 48653130Sbostic 48753130Sbostic > $OUTPUT 48852578Sbostic for file in *.secure; do 48952578Sbostic tree=`sed -n -e '3s/.* //p' -e 3q $file` 49053130Sbostic mtree -f $file -p $tree > $TMP1 49153130Sbostic if [ -s $TMP1 ]; then 49253130Sbostic printf "\nChecking $tree:\n" >> $OUTPUT 49353130Sbostic cat $TMP1 >> $OUTPUT 49453130Sbostic fi 49552578Sbostic done 49653130Sbostic if [ -s $OUTPUT ] ; then 49753130Sbostic printf "\nChecking system binaries:\n" 49853130Sbostic cat $OUTPUT 49953130Sbostic fi 50052578Sbosticfi 501