From 4dc0b50408d56662fe620f461915ad9eeb07acbe Mon Sep 17 00:00:00 2001 From: jonnyCodev Date: Wed, 5 Feb 2020 11:22:34 +0200 Subject: [PATCH 1/5] Check if root user have unused console login --- checks/check11 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/checks/check11 b/checks/check11 index a72c704c13..aa47cadbff 100644 --- a/checks/check11 +++ b/checks/check11 @@ -14,8 +14,15 @@ CHECK_SCORED_check11="SCORED" CHECK_TYPE_check11="LEVEL1" CHECK_ALTERNATE_check101="check11" +MAX_DAYS=-1 check11(){ # "Avoid the use of the root account (Scored)." - COMMAND11=$(cat $TEMP_REPORT_FILE| grep '' | 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 '' | awk '{ print $2 }') + days_not_in_use=$(how_many_days_from_today ${last_login_date%T*}) + if [ "$days_not_in_use" -lt "$MAX_DAYS" ];then + textFail "User root_account has not used console login for more then ${MAX_DAYS#-} days" + else + textPass "User root_account has used console login in the past ${MAX_DAYS#-} days" + fi } From 2b4bb6e12e6f15fff65220cf9d1af0785bd6b600 Mon Sep 17 00:00:00 2001 From: jonnyCodev Date: Wed, 5 Feb 2020 13:49:41 +0200 Subject: [PATCH 2/5] check root account access login and fail if used in the last day --- checks/check11 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/checks/check11 b/checks/check11 index aa47cadbff..837fdcfbf9 100644 --- a/checks/check11 +++ b/checks/check11 @@ -19,10 +19,11 @@ check11(){ # "Avoid the use of the root account (Scored)." MAX_DAYS=-1 last_login_date=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$5 }' |grep '' | awk '{ print $2 }') + arn=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$2 }' |grep '' | awk '{ print $2 }') days_not_in_use=$(how_many_days_from_today ${last_login_date%T*}) - if [ "$days_not_in_use" -lt "$MAX_DAYS" ];then - textFail "User root_account has not used console login for more then ${MAX_DAYS#-} days" - else - textPass "User root_account has used console login in the past ${MAX_DAYS#-} days" - fi + + textInfo "Root account last accessed (password key_1 key_2): $last_login_date" + if [ "$days_not_in_use" -gt "$MAX_DAYS" ];then + textFail "Root Account $arn last accessed was less then ${MAX_DAYS#-} days ago" + fi } From 10a30b34f24caea9cba3e51951bbdc71bed75b46 Mon Sep 17 00:00:00 2001 From: jonnyCodev Date: Wed, 5 Feb 2020 16:30:04 +0200 Subject: [PATCH 3/5] check root account access login and fail if used in the last day --- checks/check11 | 1 - 1 file changed, 1 deletion(-) diff --git a/checks/check11 b/checks/check11 index 837fdcfbf9..88770ece0b 100644 --- a/checks/check11 +++ b/checks/check11 @@ -14,7 +14,6 @@ CHECK_SCORED_check11="SCORED" CHECK_TYPE_check11="LEVEL1" CHECK_ALTERNATE_check101="check11" -MAX_DAYS=-1 check11(){ # "Avoid the use of the root account (Scored)." MAX_DAYS=-1 From af4c047896ad16bb09c9f43cccefaf3483fda462 Mon Sep 17 00:00:00 2001 From: jonnyCodev Date: Wed, 5 Feb 2020 17:21:17 +0200 Subject: [PATCH 4/5] check root account access login and fail if used in the last day --- checks/check11 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/checks/check11 b/checks/check11 index 88770ece0b..91199e27d9 100644 --- a/checks/check11 +++ b/checks/check11 @@ -21,8 +21,9 @@ check11(){ arn=$(cat $TEMP_REPORT_FILE|awk -F, '{ print $1,$2 }' |grep '' | awk '{ print $2 }') days_not_in_use=$(how_many_days_from_today ${last_login_date%T*}) - textInfo "Root account last accessed (password key_1 key_2): $last_login_date" if [ "$days_not_in_use" -gt "$MAX_DAYS" ];then textFail "Root Account $arn last accessed was less then ${MAX_DAYS#-} days ago" + else + textPass "Root Account $arn last accessed was more then ${MAX_DAYS#-} days ago" fi } From f833d6a948e4ba19d6045cb0210690634d8703b4 Mon Sep 17 00:00:00 2001 From: jonnyCodev Date: Wed, 5 Feb 2020 17:33:01 +0200 Subject: [PATCH 5/5] check root account access login and fail if used in the last day --- checks/check11 | 4 ++-- groups/group7_extras | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/checks/check11 b/checks/check11 index 91199e27d9..1150ac8b94 100644 --- a/checks/check11 +++ b/checks/check11 @@ -22,8 +22,8 @@ check11(){ 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#-} days ago" + 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#-} days ago" + textPass "Root Account $arn last accessed was more then ${MAX_DAYS#-} day ago" fi } diff --git a/groups/group7_extras b/groups/group7_extras index 5a36dbca30..84280f8e21 100644 --- a/groups/group7_extras +++ b/groups/group7_extras @@ -15,7 +15,7 @@ GROUP_ID[7]='extras' GROUP_NUMBER[7]='7.0' GROUP_TITLE[7]='Extras - [extras] **********************************************' GROUP_RUN_BY_DEFAULT[7]='Y' # run it when execute_all is called -GROUP_CHECKS[7]='extra71,extra72,extra73,extra74,extra75,extra76,extra77,extra78,extra79,extra710,extra711,extra712,extra713,extra714,extra715,extra716,extra717,extra718,extra719,extra720,extra721,extra722,extra723,extra724,extra725,extra726,extra727,extra728,extra729,extra730,extra731,extra732,extra733,extra734,extra735,extra736,extra737,extra738,extra739,extra740,extra741,extra742,extra743,extra744,extra745,extra746,extra747,extra748,extra749,extra750,extra751,extra752,extra753,extra754,extra755,extra756,extra757,extra758,extra761,extra762,extra763,extra764,extra765,extra767,extra768,extra769,extra770,extra771,extra772,extra773' +GROUP_CHECKS[7]='extra71,extra72,extra73,extra74,extra75,extra76,extra77,extra78,extra79,extra710,extra711,extra712,extra713,extra714,extra715,extra716,extra717,extra718,extra719,extra720,extra721,extra722,extra723,extra724,extra725,extra726,extra727,extra728,extra729,extra730,extra731,extra732,extra733,extra734,extra735,extra736,extra737,extra738,extra739,extra740,extra741,extra742,extra743,extra744,extra745,extra746,extra747,extra748,extra749,extra750,extra751,extra752,extra753,extra754,extra755,extra756,extra757,extra758,extra761,extra762,extra763,extra764,extra765,extra767,extra768,extra769,extra770,extra771,extra772,extra773,extra774' # Extras 759 and 760 (lambda variables and code secrets finder are not included) # to run detect-secrets use `./prowler -g secrets`