一个检测root权限的shell/ target=_blank class=infotextkey>shell脚本,代码:
#!/bin/bash
#chk_root.sh
#
echo test your computer is or not safety.
sleep 1
root_num=`linuxjishu/13830.html target=_blank class=infotextkey>awk -F: '{print $3}' /etc/passwd|grep "b0b"|wc -l`
case $root_num in
0)
echo your system dont have root.
;;
1)
echo your system is safety.
;;
*)
echo your system mybe cracked.
awk -F: '{print $1,$3}' /etc/passwd|grep "b0b" >> hack1
cat hack1|awk '{print $1}'|grep -v "root" >> hack2
for hacker in `cat hack2`
do
read -p "$hacker mybe created by hacker. Do you want to kill it ?" answer
case $answer in
y)
userdel $hacker
echo $hacker is killed.
;;
yes)
userdel $hacker
echo $hacker is killed.
;;
n)
;;
no)
;;
*)
;;
esac
done
esac
rm -f hack*