Created
October 10, 2018 23:01
-
-
Save relotnek/073569144ab5a7c4bde75a65c5283e8a to your computer and use it in GitHub Desktop.
Quick script to enumerate assumable roles in an AWS Account
This file contains 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
import boto3 | |
client = boto3.client('iam', region_name="us-east-1") | |
response = client.list_roles() | |
roles = response.get("Roles") | |
for role in roles: | |
if "AWS" in role["AssumeRolePolicyDocument"]["Statement"][0]["Principal"]: | |
print(role["RoleId"] + " " + role["RoleName"]) | |
print(role["AssumeRolePolicyDocument"]["Statement"][0]["Principal"]["AWS"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment