Skip to content

Instantly share code, notes, and snippets.

@tiagocordeiro
Forked from ScriptAutomate/S3NakedInPublic.py
Created June 29, 2019 03:45
Show Gist options
  • Save tiagocordeiro/e5af3fe257c59f097a12123662b01533 to your computer and use it in GitHub Desktop.
Save tiagocordeiro/e5af3fe257c59f097a12123662b01533 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment