Skip to content

Instantly share code, notes, and snippets.

@aabed
Last active August 23, 2020 13:56
Show Gist options
  • Save aabed/88b740f06e39541dbbb9b9ffd8dea17f to your computer and use it in GitHub Desktop.
Save aabed/88b740f06e39541dbbb9b9ffd8dea17f to your computer and use it in GitHub Desktop.
dirty_sg_scanner
import boto3
response = ec2.describe_security_groups()
groups=set()
for sg in response.get('SecurityGroups'):
for rule in sg.get('IpPermissions'):
for cidr in rule.get('IpRanges'):
if cidr.get('CidrIp') == '0.0.0.0/0':
groups.add(sg.get('GroupId'))
print(groups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment