博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

系统※网络技术实验室

System & Databses & Networking & Security & Services
evegl.cublog.cn
一个测试登陆的shell
#!/bin/sh

#BOOTUP=color
#RES_COL=60
#MOVE_TO_COL="echo -en \033[${RES_COL}G"
#SETCOLOR_SUCCESS="echo -en \033[1;32m"
#SETCOLOR_FAILURE="echo -en \033[1;31m"
#SETCOLOR_WARNING="echo -en \033[1;33m"
#SETCOLOR_NORMAL="echo -en \033[0;39m"

# source function library
. /etc/rc.d/init.d/functions

$ifpass
#set the variables to false

#ignore sign <CTRL-C>
trap "" 1 2 3 15
#
SAVEDSTTY=`stty -g`
echo -e "
	\033[1;32mYou Are Logging Into a Sensitive Area\033[0m
"
echo -e "\033[1;33m`cat <<EOF
##############################################################
       
	This script is checking user for login.

	Not checking passed user is do not login.

##############################################################
EOF`\033[0m
"
echo -n "Enter your name :"
read NAME
#hide the characters typed in
stty -echo
echo -n "Enter your password :"
read PASSWD

#back on agian
stty $SAVEDSTTY

echo -e "
"
#Check login name

if [ "$NAME" = "nobody" ] && [ "$PASSWD" = "123456" ] ; then

	echo -n $"Correct user id and password given";success $"$NAME success login";echo
        echo -e "`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
	#Connection to Mysql Server Auth
	check=`mysql -uadmin -p123456 -h root@localhost rlogin -e "select action from users where username='"$NAME"' and password=password('"$PASSWD"');" 2> /dev/null`
	if [ $? != 0 ] ; then
	echo -e "$HOSTNAME do not connection mysql.
" | mail -s "$HOSTNAME ifpass Wrong!" root@localhost
	fi
	
	if [ -n "$check" ] ; then
		echo -n $"Correct user id and password given";success $"$NAME success login";echo
		echo -e "User:$NAME loging success
`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
	else
        	echo -n $"System: Sorry wrong password or userid";failure $"$NAME failure login";echo
      		echo -e "User:$NAME password is wrong 
`date`
`w`
" | mail -s "$HOSTNAME Monitor" root@localhost
        	for pid in `ps|grep bash|awk '{print $1}'`
        	do
        	kill -9 $pid
        	done
		exit 1
	fi
fi
exit 0

发表于: 2006-12-22,修改于: 2006-12-22 13:02,已浏览171次,有评论0条 推荐 投诉

给我留言
版权所有 ChinaUnix.net 页面生成时间:0.04148