Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Created October 26, 2018 22:23
Show Gist options
  • Save ScriptAutomate/c4f4feba54f0ddca2ce3b640d80a1847 to your computer and use it in GitHub Desktop.
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
#!/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
@ScriptAutomate
Copy link
Author

I made a repo that includes each of the example gists: https://github.com/ScriptAutomate/s3nakedinpublic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment