gpt4 book ai didi

linux - Bash 脚本 : How to check if there's is only one root id?

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:27 25 4
gpt4 key购买 nike

<分区>

如何编辑我的脚本以检查是否只有一个根 ID?

预期输出

Audit criteria: There is only one root id

Vulnerability: Yes

Details: See below


root:!:0:0::/:/usr/bin/bash

jdoe:*:0:1:John Doe:/home/jdoe:/usr/bin/bash

脚本

#!/bin/bash

isVulnerable="No"
isVulnerable="Yes"

cat /etc/passwd | cut -f3 -d":" | sort -n | /usr/bin/uniq -c | while read x ;
do
[ -z "${x}" ] && break
set - $x

if [ "$1" -gt 1 ]; then
users=`/bin/gawk -F: '($3 == n) { print $1 }' n=$2 /etc/passwd | /usr/bin/xargs`

echo "Audit Criteria: Duplicate UID ($2): ${users}"
echo "Vulnerability: ${isVulnerable}"
echo "Details: see below"
echo
grep "x:0:" /etc/passwd

else

echo "All user id are unique"
fi

done

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com