diff --git a/libs/brute.py b/libs/brute.py index dfe1db1..4368787 100644 --- a/libs/brute.py +++ b/libs/brute.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import boto3 import botocore import json @@ -54,23 +56,23 @@ def check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): try: profile = client.get_login_profile(UserName=user['UserName']) if profile: - print('User {} likely has console access and the password can be reset :-)' .format(user['UserName'])) - print("Checking for MFA on account") + print ('User {} likely has console access and the password can be reset :-)' .format(user['UserName'])) + print ("Checking for MFA on account") mfa = client.list_mfa_devices(UserName=user['UserName']) - print mfa['MFADevices'] + print (mfa['MFADevices']) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'NoSuchEntity': print("[-]: user '{}' likely doesnt have console access" .format(user['UserName'])) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID)) elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Is NOT a root key' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -120,7 +122,7 @@ def generic_method_bruteforcer(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, service method(*args, **kwargs) #print method --wont return anything on dryrun except botocore.exceptions.EndpointConnectionError as e: - print e + print (e) continue except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -133,7 +135,7 @@ def generic_method_bruteforcer(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, service actions.append(api_action) else: - print e + print (e) continue else: print('{} IS allowed' .format(api_action)) diff --git a/libs/s3.py b/libs/s3.py index c67b7d7..1aec960 100644 --- a/libs/s3.py +++ b/libs/s3.py @@ -25,7 +25,7 @@ def get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket): print('[+] '+ key['Key'].encode('utf-8').strip()) #print(key['Key']) #first 100 results except KeyError as e: - print "KeyError havent tracked down reason yet" + print ("KeyError havent tracked down reason yet") except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'AccessDenied': print('{} : cant list s3 bucket [AccessDenied]' .format(AWS_ACCESS_KEY_ID)) @@ -34,7 +34,7 @@ def get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket): elif e.response['Error']['Code'] == 'AllAccessDisabled': print('{} : cant list s3 bucket [AllAccessDisabled]' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -55,7 +55,7 @@ def get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket): elif e.response['Error']['Code'] == 'AllAccessDisabled': print('{} : cant list s3 bucket policy [AllAccessDisabled]' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) try: acl = client.get_bucket_acl(Bucket=bucket) @@ -74,7 +74,7 @@ def get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket): elif e.response['Error']['Code'] == 'AllAccessDisabled': print('{} : cant list s3 bucket acl [AllAccessDisabled]' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': @@ -82,7 +82,7 @@ def get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket): elif e.response['Error']['Code'] == 'NotSignedUp': print('{} : doesnt have s3 access' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -100,7 +100,7 @@ def get_s3object_acl(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket, myfile): myobject = myfile print('#### Trying to enumate s3 ACL for {}:{} ####\n '.format(bucket, myfile)) acl = client.get_object_acl(Bucket=bucket,Key=myfile) - print acl + print (acl) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': @@ -108,7 +108,7 @@ def get_s3object_acl(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, bucket, myfile): elif e.response['Error']['Code'] == 'NotSignedUp': print('{} : doesnt have s3 access' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -134,7 +134,7 @@ def get_s3objects_for_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'NotSignedUp': print('{} : doesnt have s3 access' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -159,6 +159,6 @@ def get_s3objects_for_account_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) elif e.response['Error']['Code'] == 'NotSignedUp': print('{} : doesnt have s3 access' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print ("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") diff --git a/libs/sql.py b/libs/sql.py index be102f8..e2d609b 100644 --- a/libs/sql.py +++ b/libs/sql.py @@ -8,8 +8,8 @@ def create_table(db_name,table_name,sql): result = cursor.fetchall() keep_table = True if len(result) == 1: - #python 2 - response = raw_input("The table {} already exists, do you wish to recreate it? (y/n): ".format(table_name)) + #python 3 + response = input("The table {} already exists, do you wish to recreate it? (y/n): ".format(table_name)) if response == "y": keep_table = False print("The {} table will be recreated - all existing data will be lost".format(table_name)) diff --git a/recon_find_all_permissions.py b/recon_find_all_permissions.py index 448be51..cc9d6eb 100644 --- a/recon_find_all_permissions.py +++ b/recon_find_all_permissions.py @@ -1,3 +1,5 @@ +from __future__ import print_function + from libs.brute import * from libs.s3 import *