BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: root root ¸ð´ÏÅÍ Á¶È¸¼ö: 7344


#!/bin/ksh

###
## rootmonitor
## Root Login Script
##
## Monitors root logins via the su command and
## directly at the console.
## Notifies via email.
##
## Usage: Execute from crontab every 15 minutes
## 14,29,44,59 * * * * /opt/admin/scripts/rtlgn.sh > /dev/null
##
## Dependencies: None
## Outputs: Email
##
## Submitter: Gideon Rasmussen
## Submitter Email: gideon@infostruct.net
## *************************************************************
PATH=/usr/bin:/usr/sbin:/usr/ucb:/bin
SRVNM=`uname -n`
DATE=`date '+%m/%d'`
DAY=`date '+%d'`
HOUR=`date '+%H'`
MONTH=`date '+%m'`
MIN=`date '+%M'`

LOGDIR=/var/adm/log/rtlgn
DATFILE=$LOGDIR/rtlgn.dat

if [ ! -d $LOGDIR ] ; then
mkdir -p $LOGDIR
touch $DATFILE
fi

# Clean out the dat file each day

if [ $HOUR -eq "00" ]; then

if [ $MIN -lt "15" ]; then
> $DATFILE
fi

fi


# The next variable can be set for multiple addresses
# (i.e. jsmith@yahoo.com,jsmith@hotmail.com)
MAILADD=monitor

# Check for remote root login (should never happen)
# Check on tctest
#who

# Check for recent root console login
# Determine if notification has been sent this hour
if [ `grep -c "$DATE $HOUR CONSOLE" $DATFILE` -eq 0 ]
then
if [ `last root console | grep -c "$MONTH $DAY $HOUR" ` -gt 0 ]
then

mail $MAILADD <<EOF
From: $0
To: $MAILADD
Subject: Root Console Login $SRVNM

A root console login has occurred:

`last root console | grep "$MONTH $DAY $HOUR"`

EOF

# Ensure notification only occurs once per hour
print "$DATE $HOUR CONSOLE" >> $DATFILE

fi
fi

# Check for recent su to root
# Determine if notification has been sent this hour
if [ `grep -c "$DATE $HOUR SU" $DATFILE ` -lt 1 ]
then

if [ `grep "$DATE $HOUR" /var/adm/sulog | grep -v root- | grep root |
grep -c "+" ` -gt 0 ]
then

mail $MAILADD <<EOF
From: $0
To: $MAILADD
Subject: Root Access on $SRVNM

The following root login has occurred:

`grep "$DATE $HOUR" /var/adm/sulog | grep root | grep "+"`

EOF

# Ensure notification only occurs once per hour
print "$DATE $HOUR SU" >> $DATFILE

fi
fi

exit 0


°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2002/08/28 18:37 from 210.121.188.5

  ½Ã½ºÅÛÁ¤º¸ ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ ÀüÈ­¹øÈ£ºÎ  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡