diff --git a/iam_pwn.py b/iam_pwn.py index e82ee63..a867706 100644 --- a/iam_pwn.py +++ b/iam_pwn.py @@ -14,14 +14,15 @@ import pprint pp = pprint.PrettyPrinter(indent=5, width=80) from libs.iam import * +from libs.sts import * #insert AWS key, will figure out how to pull this in from a single file for all scripts -#AWS_ACCESS_KEY_ID = '' -#AWS_SECRET_ACCESS_KEY ='' - +AWS_ACCESS_KEY_ID = '' +AWS_SECRET_ACCESS_KEY ='' +get_accountid(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) get_password_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #create_access_key(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'pythons3') diff --git a/libs/iam.py b/libs/iam.py index bf6bb5b..1611866 100644 --- a/libs/iam.py +++ b/libs/iam.py @@ -153,8 +153,8 @@ def delete_mfa_device(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username, mfaser client = boto3.client('iam', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region_name=region) try: delete_mfa = client.deactivate_mfa_device(UserName=username, SerialNumber=mfaserial) - print("Deleting a MFA device: {} for: {}" .format(mfaserial, username)) - print('Response to delete MFA devices was: {}' .format(delete_mfa['ResponseMetadata']['HTTPStatusCode'])) + print("Deleting a MFA device: {} for: {}" .format(mfaserial, username)) + print('Response to delete MFA devices was: {}' .format(delete_mfa['ResponseMetadata']['HTTPStatusCode'])) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'NoSuchEntity': print("ERROR: The provided AccessKey doesnt exist") diff --git a/libs/sts.py b/libs/sts.py index 3660c6e..faa7b1a 100644 --- a/libs/sts.py +++ b/libs/sts.py @@ -9,9 +9,10 @@ regions = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'ca-central-1', ' def get_accountid(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): try: - client = boto3.client("sts", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY) - account_id = client.get_caller_identity()["Account"] - print account_id - except KeyboardInterrupt: - print("CTRL-C received, exiting...") - return account_id \ No newline at end of file + client = boto3.client("sts", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY) + account_id = client.get_caller_identity()["Account"] + print("Account Id: {}" .format(account_id)) + except KeyboardInterrupt: + print("CTRL-C received, exiting...") + + return account_id \ No newline at end of file