Created
August 11, 2019 09:11
-
-
Save mauricioklein/57af2f643316ace70204cfcf32f0411d to your computer and use it in GitHub Desktop.
Script to check EBS snapshots vulnerability
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
#!/bin/bash | |
# | |
# RUN: | |
# AWS_PROFILE=[profile] AWS_REGION=[region] ./check-ebs-snapshots.sh | |
# | |
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account') | |
snapshots=$(aws ec2 describe-snapshots \ | |
--region $AWS_REGION \ | |
--owner-ids $AWS_ACCOUNT_ID \ | |
--filters "Name=status,Values=completed" \ | |
--output text \ | |
--query "Snapshots[*].SnapshotId" | tr "\t" "\n") | |
for ss in $snapshots; do | |
echo -n "Checking EBS snapshot '$ss': " | |
perms=$(aws ec2 describe-snapshot-attribute \ | |
--region $AWS_REGION \ | |
--snapshot-id $ss \ | |
--attribute createVolumePermission \ | |
--query 'CreateVolumePermissions[]') | |
[[ $perms =~ '"Group": "all"' ]] && echo "vulnerable!" || echo "secure!" | |
done | |
echo "All done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment