当前位置: > shell编程 >

linux检测root权限shell脚本升级版

时间:2014-11-02 02:28来源:linux.it.net.cn 作者:it
linux下用于检测root权限的shell脚本,用shell检测用户是否有root权限,比较方便,用来研究shell编程以及awk等命令的用法也不错。

一个检测root权限的shell脚本,代码:
 

复制代码代码示例:

#!/bin/bash
#chk_root.sh
#

echo test your computer is or not safety.
sleep 1
root_num=`awk -F: '{print $3}' /etc/passwd|grep "\b0\b"|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 "\b0\b" >> 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*


(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容