linuxshell:在LinuxShell程序中进行身份验证

来源:http://www.hutuworm.org

.缘起   

  Linux系统管理员常常碰到头痛问题是在确定系统没有被入侵前提下不知道哪个人不小心运行了某个特定用途Shell把系统搞得塌糊涂而且系统记录显示该人使用是公用帐号(root或者admin)你无法知道这个人在现实生活中具体对应是哪   

   2.开场  

  针对以上问题解决方案有 2:其追查时间和ip根据时间和ip可以追查到该人是从哪里出来这套解决方案只能确定以某人为首群可疑人大家都是通过代理连服务器那除了one by _disibledevent=>http://cr.yp.to/checkpwd/checkpassword-0.90.tar.gz  

  2. 安装:

  tar xvfz checkpassword-0.90.tar.gz

  cd checkpassword-0.90

  make

  make up check  

  3. 如果可执行文件checkpassword没有在/bin下出现goto 1   

  再加上下面这段就大功告成了:   

  --------------------------------

  #!/bin/sh

  #

  # Filename: auth.sh

  # Author: hutuworm

  # @Copyleft 2003 hutuworm.org

  #

  function auth_failed {

  echo "你耍我啊?"

  exit 1

  }

  echo "※※※※※※※※※※※"

  echo "※猪圈重地 闲人莫入※"

  echo "※※※※※※※※※※※"

  prf "请输入帐号:"

  read ACCOUNT

   [ $ACCOUNT = 'admin' -o $ACCOUNT = 'root' ]

  then

  echo "本圈不欢迎admin&root!"

  exit 1

  fi

  prf "请输入密码:"

  stty -echo

  read PASSWORD

  stty echo

  echo ""

  prf "$ACCOUNT\0$PASSWORD\0Y123456\0"   /bin/checkpassword logger "$ACCOUNT used auth.sh" 3<&0    auth_failed

  echo "欢迎光临糊涂馋寺附属斋堂的猪圈! :P"

  --------------------------------  

   4.验收   

  $ chmod +x auth.sh

  $

  $ ./auth.sh

  ※※※※※※※※※※※

  ※猪圈重地 闲人莫入※

  ※※※※※※※※※※※

  请输入帐号:hutuworm

  请输入密码:

  你耍我啊?

  $

  $ ./auth.sh

  ※※※※※※※※※※※

  ※猪圈重地 闲人莫入※

  ※※※※※※※※※※※

  请输入帐号:admin

  请输入密码:

  本圈不欢迎admin&root!

  $

  $ ./auth.sh

  ※※※※※※※※※※※

  ※猪圈重地 闲人莫入※

  ※※※※※※※※※※※

  请输入帐号:hutuworm

  请输入密码:

  欢迎光临糊涂馋寺附属斋堂的猪圈! :P

  $

  $ tail -1 /var/log/messages

  May 5 13:51:45 hutuworm.org 5月 5 13:51:45 logger: hutuworm used auth.sh

Tags:  linuxshellif linuxshell命令 linuxshell编程 linuxshell

延伸阅读

最新评论

发表评论