日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 权限测试,linux下检测root权限的shell脚本

發布時間:2025/3/8 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 权限测试,linux下检测root权限的shell脚本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

個人心血來潮時寫的一個腳本,比較粗糙,功能也很簡單,大家有興趣的可以拿去改改。

本腳本之爭對系統中UID為0的用戶

#!/bin/bash????????????? ? #大家都知道

echo test my computer is or not safety?? ?#顯示“ test my computer is or not safety? ”

root_num=`awk -F: '{print $3}' /etc/passwd|grep "^0"|wc -l`??? #以“:”為分隔符,打印出/etc/passwd文件中第三個域的字段,并grep以“0”開頭的(意思是UID是0的用戶),然后計算行數(3行代表有3個UID為0的用戶,包括root),最終賦值給root_num.

if [ $root_num -eq 1 ];then? #如果$root_num的值為1,表示只有一個root用戶

echo your computer is safety #顯示“ your computer is safety ”

else???????? #否則

awk -F: '{print $3,$1}' /etc/passwd|grep "^0"|grep -v "root" >> hack1 #打印/etc/passwd中的第三個域(UID)和第一個域(用戶名),并且grep以“0”開頭的行,輸出到hack1的文件中

cat hack1|awk '{print $2}'>>hack????? #查看hack1文件的內容,并打印出第二個域的內容,輸出到hack文件中

for number in `cat hack`???? #查看hack的內容,并循環賦值給number

do

echo $number mybe created by hacker.? #顯示“?xxx mybe created by hacker.”

read -p "are you want to delete it? y or n? :" answer #顯示“are you want to delete it? y or n? :“

if [ $answer = "y" ]??????? #如果回答是”y“

then

userdel -r $numeber? #刪除xxx

echo $number is delete. #顯示”xxx is dele“

if [ $answer = "yes"]? #如果回答是”yes“

then

userdel -r $number

echo $number is delete.

fi

fi

done

fi

rm -f hack*? #刪除hack和hack1文件

有興趣的可以試試。功能很簡單,只為娛樂娛樂。

總結

以上是生活随笔為你收集整理的linux 权限测试,linux下检测root权限的shell脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。