Created
October 26, 2018 22:23
-
-
Save ScriptAutomate/c4f4feba54f0ddca2ce3b640d80a1847 to your computer and use it in GitHub Desktop.
[Bash Script / awscli / AWS] List all S3 buckets, in the default region config, that have 'Public' permissions listed anywhere in the ACL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Requires awcli | |
# pip install awscli --user --upgrade | |
# https://docs.aws.amazon.com/cli/latest/userguide/installing.html | |
BUCKETS=`aws s3api list-buckets --query 'Buckets[*].Name' --output text | tr " " "\n"` | |
for BUCKET in $BUCKETS | |
do | |
OH_NOES=`aws s3api get-bucket-acl --bucket $BUCKET | grep -e 'URI.*http\:\/\/acs\.amazonaws\.com\/groups\/global\/AllUsers\"'` | |
if [ ! -z "$OH_NOES" ] | |
then | |
echo "$BUCKET" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made a repo that includes each of the example gists: https://github.com/ScriptAutomate/s3nakedinpublic