Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Created October 24, 2018 21:39
Show Gist options
  • Save ScriptAutomate/f5bc2b5d9bbfd11a3e76e90ef53ac53a to your computer and use it in GitHub Desktop.
Save ScriptAutomate/f5bc2b5d9bbfd11a3e76e90ef53ac53a to your computer and use it in GitHub Desktop.
[Python 3 / boto3 / AWS] List all S3 buckets, in the default region config, that have 'Public' permissions listed anywhere in the ACL
import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
for oh_noes in s3.BucketAcl(bucket.name).grants:
if oh_noes['Grantee']['Type'] == 'Group' and oh_noes['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers':
print(bucket)
@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