check root account access login and fail if used in the last day

This commit is contained in:
jonnyCodev
2020-02-06 11:10:10 +02:00
parent 4ecc9c929c
commit fe2d2b45bb

View File

@@ -16,6 +16,14 @@ CHECK_ALTERNATE_check101="check11"
check11(){
# "Avoid the use of the root account (Scored)."
COMMAND11=$(cat $TEMP_REPORT_FILE| grep '<root_account>' | cut -d, -f5,11,16 | sed 's/,/\ /g')
textInfo "Root account last accessed (password key_1 key_2): $COMMAND11"
MAX_DAYS=-1
last_login_date=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$5 }' |grep '<root_account>' | awk '{ print $2 }')
arn=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$2 }' |grep '<root_account>' | awk '{ print $2 }')
days_not_in_use=$(how_many_days_from_today ${last_login_date%T*})
if [ "$days_not_in_use" -gt "$MAX_DAYS" ];then
textFail "Root Account $arn last accessed was less then ${MAX_DAYS#-} day ago"
else
textPass "Root Account $arn last accessed was more then ${MAX_DAYS#-} day ago"
fi
}