diff --git a/README.md b/README.md index c1bbfdbc9d..8ce7773e25 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ This script has been written in bash using AWS-CLI and it works in Linux and OSX ./prowler -M mono | aws s3 cp - s3://bucket-name/prowler-report.txt ``` -1. To perform an assessment based on CIS Profile Definitions you can use cislevel1 or cislevel2 with `-c` flag, more information about this [here, page 8](https://d0.awsstatic.com/whitepapers/compliance/AWS_CIS_Foundations_Benchmark.pdf): +1. To perform an assessment based on CIS Profile Definitions you can use cislevel1 or cislevel2 with `-g` flag, more information about this [here, page 8](https://d0.awsstatic.com/whitepapers/compliance/AWS_CIS_Foundations_Benchmark.pdf): ```sh ./prowler -g cislevel1 diff --git a/checks/check26 b/checks/check26 index 41281b5646..18d92545d6 100644 --- a/checks/check26 +++ b/checks/check26 @@ -27,7 +27,7 @@ check26(){ if [[ $CLOUDTRAILBUCKET ]];then bucket=$CLOUDTRAILBUCKET - if [ "$CLOUDTRAIL_ACCOUNT_ID" == "$ACCOUNT_ID" ];then + if [ "$CLOUDTRAIL_ACCOUNT_ID" == "$ACCOUNT_NUM" ];then CLOUDTRAILBUCKET_LOGENABLED=$($AWSCLI s3api get-bucket-logging --bucket $bucket $PROFILE_OPT --region $REGION --query 'LoggingEnabled.TargetBucket' --output text|grep -v None) if [[ $CLOUDTRAILBUCKET_LOGENABLED ]];then textPass "Bucket access logging enabled in CloudTrail S3 bucket $bucket for $trail" diff --git a/checks/check_extra770 b/checks/check_extra770 new file mode 100644 index 0000000000..f39de56471 --- /dev/null +++ b/checks/check_extra770 @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Prowler - the handy cloud security tool (copyright 2018) by Toni de la Fuente +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +CHECK_ID_extra770="7.70" +CHECK_TITLE_extra770="[extra770] Check for internet facing EC2 instances with Instance Profiles attached (Not Scored) (Not part of CIS benchmark)" +CHECK_SCORED_extra770="NOT_SCORED" +CHECK_TYPE_extra770="EXTRA" +CHECK_ALTERNATE_check770="extra770" + +extra770(){ + # "Check for internet facing EC2 Instances (Not Scored) (Not part of CIS benchmark)" + textInfo "Looking for instances in all regions... " + for regx in $REGIONS; do + LIST_OF_PUBLIC_INSTANCES_WITH_INSTANCE_PROFILES=$($AWSCLI ec2 describe-instances $PROFILE_OPT --region $regx --query 'Reservations[*].Instances[?((IamInstanceProfile!=`null` && PublicIpAddress!=`null`))].[InstanceId,PublicIpAddress,IamInstanceProfile.Arn]' --output text) + if [[ $LIST_OF_PUBLIC_INSTANCES_WITH_INSTANCE_PROFILES ]];then + while read -r instance;do + INSTANCE_ID=$(echo $instance | awk '{ print $1; }') + PUBLIC_IP=$(echo $instance | awk '{ print $2; }') + INSTANCE_PROFILE=$(echo $instance | awk '{ print $3; }') + textFail "$regx: Instance: $INSTANCE_ID at IP: $PUBLIC_IP is internet-facing with Instance Profile $INSTANCE_PROFILE" "$regx" + done <<< "$LIST_OF_PUBLIC_INSTANCES_WITH_INSTANCE_PROFILES" + else + textPass "$regx: no Internet Facing EC2 Instances with Instance Profiles found" "$regx" + fi + done +} diff --git a/groups/group7_extras b/groups/group7_extras index c9eaa5ad63..12afb988ee 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,extra766,extra767,extra768,extra769' +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,extra766,extra767,extra768,extra769,extra770,extra771' # Extras 759 and 760 (lambda variables and code secrets finder are not included) # to run detect-secrets use `./prowler -g secrets` diff --git a/iam/prowler-additions-policy.json b/iam/prowler-additions-policy.json index c706b6f487..c95b05f202 100644 --- a/iam/prowler-additions-policy.json +++ b/iam/prowler-additions-policy.json @@ -3,6 +3,7 @@ "Statement": [ { "Action": [ + "access-analyzer:List*", "apigateway:get*", "apigatewayv2:get*", "aws-marketplace:viewsubscriptions", @@ -103,4 +104,4 @@ "Resource": "*" } ] -} \ No newline at end of file +} diff --git a/prowler b/prowler index fb60a32f41..437b72941c 100755 --- a/prowler +++ b/prowler @@ -74,12 +74,13 @@ USAGE: -b do not print Prowler banner -V show version number & exit -s show scoring report + -x specify external directory with custom checks (i.e. /my/own/checks, files must start by "check") -h this help " exit } -while getopts ":hlLkp:r:c:g:f:m:M:E:enbVs" OPTION; do +while getopts ":hlLkp:r:c:g:f:m:M:E:enbVsx:" OPTION; do case $OPTION in h ) usage @@ -136,6 +137,9 @@ while getopts ":hlLkp:r:c:g:f:m:M:E:enbVs" OPTION; do s ) SCORING=1 ;; + x ) + EXTERNAL_CHECKS_PATH=$OPTARG + ;; : ) echo "" echo "$OPTRED ERROR!$OPTNORMAL -$OPTARG requires an argument" @@ -185,6 +189,13 @@ for checks in $(ls $PROWLER_DIR/checks/check*|grep -v check_sample); do . "$checks" done +# include checks if external folder is specified +if [[ $EXTERNAL_CHECKS_PATH ]]; then + for checks in $(ls $EXTERNAL_CHECKS_PATH/check*); do + . "$checks" + done +fi + # Function to show the title of the check # using this way instead of arrays to keep bash3 (osx) and bash4(linux) compatibility show_check_title() {