From ea5ed636d77982803465d087c279aae44f158bc0 Mon Sep 17 00:00:00 2001 From: cktricky Date: Thu, 5 Apr 2018 18:59:00 -1000 Subject: [PATCH] I have decided to temporarily just fix all the print statements since it did not take long with some atom/regex fu --- libs/datapipeline.py | 8 ++--- libs/dynamodb.py | 45 ++++++++++++------------ libs/dynamodbstreams.py | 6 ++-- libs/ecr.py | 6 ++-- libs/elasticbeanstalk.py | 34 +++++++++--------- libs/emr.py | 12 +++---- libs/iam.py | 22 ++++++------ libs/opsworks.py | 10 +++--- libs/route53.py | 6 ++-- logging_list_monitoring_configuration.py | 2 +- s3_list_bucket_contents.py | 2 +- 11 files changed, 76 insertions(+), 77 deletions(-) diff --git a/libs/datapipeline.py b/libs/datapipeline.py index 39cc3fc..0307586 100644 --- a/libs/datapipeline.py +++ b/libs/datapipeline.py @@ -21,21 +21,21 @@ def list_pipelines(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): response = client.list_pipelines() print"### {} Data Pipelines ###" .format(region) if response.get('pipelineIdList') is None: - print "{} likely does not have Data Pipeline permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have Data Pipeline permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['pipelineIdList']) <= 0: - print "[-] ListPipelines allowed for {} but no results [-]" .format(region) + print("[-] ListPipelines allowed for {} but no results [-]" .format(region)) else: print"### {} Data Pipelines ###" .format(region) for pipes in response['pipelineIdList']: pp.pprint(pipes) print("\n") - + 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...") diff --git a/libs/dynamodb.py b/libs/dynamodb.py index bdaee76..ee8ee94 100644 --- a/libs/dynamodb.py +++ b/libs/dynamodb.py @@ -20,22 +20,22 @@ def list_dynamodb_tables(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): response = client.list_tables() if response.get('TableNames') is None: - print "{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['TableNames']) <= 0: - print "[-] ListTables allowed for {} but no results [-]" .format(region) + print("[-] ListTables allowed for {} but no results [-]" .format(region)) else: print"### {} DynamoDB Tables ###" .format(region) for tables in response['TableNames']: pp.pprint(tables) print("\n") - + 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('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -47,55 +47,54 @@ def list_dynamodb_tables_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): response = client.list_tables() if response.get('TableNames') is None: - print "{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['TableNames']) <= 0: - print "[-] ListTables allowed for {} but no results [-]" .format(region) + print("[-] ListTables allowed for {} but no results [-]" .format(region)) else: print"### {} DynamoDB Tables ###" .format(region) for tables in response['TableNames']: #pp.pprint(tables) describe_table(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, tables, region) print("\n") - + 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('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") def describe_table(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, table, region): - print "### Describing DynamoDB Table: {} ###" .format(table) + print("### Describing DynamoDB Table: {} ###" .format(table)) try: client = boto3.client('dynamodb', aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region_name=region) response = client.describe_table(TableName=table) if response.get('Table') is None: - print "{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Table']) <= 0: - print "[-] DescribeTable allowed for {} but no results [-]" .format(region) + print("[-] DescribeTable allowed for {} but no results [-]" .format(region)) else: - print "TableArn: {}" .format(response['Table']['TableArn']) - print "AttributeDefinitions: {}" .format(response['Table']['AttributeDefinitions']) - print "ProvisionedThroughput: {}" .format(response['Table']['ProvisionedThroughput']) - print "TableSizeBytes: {}" .format(response['Table']['TableSizeBytes']) - print "TableName: {}" .format(response['Table']['TableName']) - print "TableStatus: {}" .format(response['Table']['TableStatus']) - print "KeySchema: {}" .format(response['Table']['KeySchema']) - print "ItemCount: {}" .format(response['Table']['ItemCount']) - print "CreationDateTime: {}" .format(response['Table']['CreationDateTime']) + print("TableArn: {}" .format(response['Table']['TableArn'])) + print("AttributeDefinitions: {}" .format(response['Table']['AttributeDefinitions'])) + print("ProvisionedThroughput: {}" .format(response['Table']['ProvisionedThroughput'])) + print("TableSizeBytes: {}" .format(response['Table']['TableSizeBytes'])) + print("TableName: {}" .format(response['Table']['TableName'])) + print("TableStatus: {}" .format(response['Table']['TableStatus'])) + print("KeySchema: {}" .format(response['Table']['KeySchema'])) + print("ItemCount: {}" .format(response['Table']['ItemCount'])) + print("CreationDateTime: {}" .format(response['Table']['CreationDateTime'])) print("\n") - + 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('{} : Does not have the required permissions' .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/dynamodbstreams.py b/libs/dynamodbstreams.py index 11dde44..cf7a3a8 100644 --- a/libs/dynamodbstreams.py +++ b/libs/dynamodbstreams.py @@ -21,9 +21,9 @@ def list_dynamodbstreams(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): response = client.list_streams() if response.get('Streams') is None: - print "{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have DynamoDB permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Streams']) <= 0: - print "[-] ListStreams allowed for {} but no results [-]" .format(region) + print("[-] ListStreams allowed for {} but no results [-]" .format(region)) else: print"### {} DynamoDB Streams ###" .format(region) for streams in response['Streams']: @@ -36,6 +36,6 @@ def list_dynamodbstreams(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") \ No newline at end of file diff --git a/libs/ecr.py b/libs/ecr.py index e90c172..82cc1f1 100644 --- a/libs/ecr.py +++ b/libs/ecr.py @@ -23,9 +23,9 @@ def describe_repositories(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('repositories') is None: - print "{} likely does not have ECR permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ECR permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['repositories']) <= 0: - print "[-] DescribeRepositories allowed for {} but no results [-]" .format(region) + print("[-] DescribeRepositories allowed for {} but no results [-]" .format(region)) else: print"### {} ECR Repositories ###" .format(region) for tables in response['repositories']: @@ -38,6 +38,6 @@ def describe_repositories(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .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/elasticbeanstalk.py b/libs/elasticbeanstalk.py index 79a7d9c..8483523 100644 --- a/libs/elasticbeanstalk.py +++ b/libs/elasticbeanstalk.py @@ -23,9 +23,9 @@ def describe_applications(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('Applications') is None: - print "{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Applications']) <= 0: - print "[-] DescribeApplications allowed for {} but no results [-]" .format(region) + print("[-] DescribeApplications allowed for {} but no results [-]" .format(region)) else: print"### {} ElasticBeanstalk Applications ###" .format(region) for app in response['Applications']: @@ -38,7 +38,7 @@ def describe_applications(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -53,9 +53,9 @@ def describe_application_versions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('ApplicationVersions') is None: - print "{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['ApplicationVersions']) <= 0: - print "[-] DescribeApplicationVersions allowed for {} but no results [-]" .format(region) + print("[-] DescribeApplicationVersions allowed for {} but no results [-]" .format(region)) else: print"### {} ElasticBeanstalk Application Versions ###" .format(region) for app in response['ApplicationVersions']: @@ -68,7 +68,7 @@ def describe_application_versions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -83,17 +83,17 @@ def describe_configuration_options(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('Options') is None: - print "{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Options']) <= 0: - print "[-] DescribeConfigurationOptions allowed for {} but no results [-]" .format(region) + print("[-] DescribeConfigurationOptions allowed for {} but no results [-]" .format(region)) else: print"### {} ElasticBeanstalk Configuration Options ###" .format(region) #if response['PlatformArn'] is None: # pass #else: - # print "PlatformArn: {}" .format(response['PlatformArn']) + # print("PlatformArn: {}" .format(response['PlatformArn'])) - print "SolutionStackName: {}" .format(response['SolutionStackName']) + print("SolutionStackName: {}" .format(response['SolutionStackName'])) pp.pprint( "Options: {}" .format(response['Options'])) print("\n") @@ -103,7 +103,7 @@ def describe_configuration_options(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -118,9 +118,9 @@ def describe_environments(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('Environments') is None: - print "{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Environments']) <= 0: - print "[-] DescribeEnvironments allowed for {} but no results [-]" .format(region) + print("[-] DescribeEnvironments allowed for {} but no results [-]" .format(region)) else: print"### {} ElasticBeanstalk Environments ###" .format(region) for enviro in response['Environments']: @@ -133,7 +133,7 @@ def describe_environments(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -148,9 +148,9 @@ def describe_events(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('Events') is None: - print "{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have ElasticBeanstalk permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Events']) <= 0: - print "[-] DescribeEvents allowed for {} but no results [-]" .format(region) + print("[-] DescribeEvents allowed for {} but no results [-]" .format(region)) else: print"### {} ElasticBeanstalk Events ###" .format(region) for events in response['Events']: @@ -163,7 +163,7 @@ def describe_events(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .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/emr.py b/libs/emr.py index 9d8c1be..f405214 100644 --- a/libs/emr.py +++ b/libs/emr.py @@ -23,9 +23,9 @@ def list_clusters(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('Clusters') is None: - print "{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Clusters']) <= 0: - print "[-] ListClusters allowed for {} but no results [-]" .format(region) + print("[-] ListClusters allowed for {} but no results [-]" .format(region)) else: print"### {} EMR Clusters ###" .format(region) for app in response['Clusters']: @@ -38,7 +38,7 @@ def list_clusters(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .format(AWS_ACCESS_KEY_ID)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -53,9 +53,9 @@ def list_security_configurations(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('SecurityConfigurations') is None: - print "{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['SecurityConfigurations']) <= 0: - print "[-] ListSecurityConfigurations allowed for {} but no results [-]" .format(region) + print("[-] ListSecurityConfigurations allowed for {} but no results [-]" .format(region)) else: print"### {} EMR Security Configuration ###" .format(region) for app in response['SecurityConfigurations']: @@ -68,7 +68,7 @@ def list_security_configurations(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .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/iam.py b/libs/iam.py index 1611866..6044679 100644 --- a/libs/iam.py +++ b/libs/iam.py @@ -44,7 +44,7 @@ def check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): 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': @@ -52,7 +52,7 @@ def check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): if 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...") @@ -69,7 +69,7 @@ def change_user_console_password(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, usern elif e.response['Error']['Code'] == 'NoSuchEntity': print("[-]: User likely doesnt have console access") else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -87,7 +87,7 @@ def create_user_console_password(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, usern elif e.response['Error']['Code'] == 'NoSuchEntity': print("[-]: User likely doesnt have console access") else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -100,7 +100,7 @@ def get_password_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): print("Account Password Policy:") pp.pprint(pass_policy['PasswordPolicy']) except botocore.exceptions.ClientError as e: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -117,7 +117,7 @@ def create_user(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username): if e.response['Error']['Code'] == 'EntityAlreadyExists': print("ERROR: The provided user: {} already exists" .format(username)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -129,7 +129,7 @@ def create_access_key(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username): print("Creating a new access key for: {}" .format(username)) pp.pprint(create_access_key['AccessKey']) except botocore.exceptions.ClientError as e: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -144,7 +144,7 @@ def delete_access_key(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username, access if e.response['Error']['Code'] == 'NoSuchEntity': print("ERROR: The provided AccessKey doesnt exist") else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -159,7 +159,7 @@ def delete_mfa_device(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username, mfaser if e.response['Error']['Code'] == 'NoSuchEntity': print("ERROR: The provided AccessKey doesnt exist") else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -176,7 +176,7 @@ def make_admin(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username): if e.response['Error']['Code'] == 'AccessDenied': print("ERROR: Account does not have permissions to add the policy") else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -191,6 +191,6 @@ def make_backdoor_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, username, pa create_access_key(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,username) except botocore.exceptions.ClientError as e: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") diff --git a/libs/opsworks.py b/libs/opsworks.py index 4632462..f2203ef 100644 --- a/libs/opsworks.py +++ b/libs/opsworks.py @@ -24,21 +24,21 @@ def describe_stacks(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #debug print response if response.get('Stacks') is None: - print "{} likely does not have Lambda permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have Lambda permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['Stacks']) <= 0: - print "[-] DescribeStacks allowed for {} but no results (everyone seems to have this permission) [-]\n" .format(region) + print("[-] DescribeStacks allowed for {} but no results (everyone seems to have this permission) [-]\n" .format(region)) else: #THIS PART IS UNTESTED for r in response['Stacks']: pp.pprint(r) except botocore.exceptions.EndpointConnectionError as e: - 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'] == 'EndpointConnectionError': - print "[-] Cant connect to the {} endpoint [-]" .format(region) + print("[-] Cant connect to the {} endpoint [-]" .format(region)) else: - print "Unexpected error: {}" .format(e) + print("Unexpected error: {}" .format(e)) except KeyboardInterrupt: print("CTRL-C received, exiting...") diff --git a/libs/route53.py b/libs/route53.py index b241fa2..c7b6163 100644 --- a/libs/route53.py +++ b/libs/route53.py @@ -26,9 +26,9 @@ def list_geolocations(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): #print response if response.get('GeoLocationDetailsList') is None: - print "{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have EMR permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['GeoLocationDetailsList']) <= 0: - print "[-] ListGeoLocations allowed for {} but no results [-]" .format(region) + print("[-] ListGeoLocations allowed for {} but no results [-]" .format(region)) else: print"### {} Route53 GeoLocations ###" .format(region) for app in response['GeoLocationDetailsList']: @@ -41,7 +41,7 @@ def list_geolocations(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): elif e.response['Error']['Code'] == 'AccessDenied': print('{} : Does not have the required permissions' .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/logging_list_monitoring_configuration.py b/logging_list_monitoring_configuration.py index a0fb1be..6ef909d 100644 --- a/logging_list_monitoring_configuration.py +++ b/logging_list_monitoring_configuration.py @@ -44,7 +44,7 @@ for region in regions: print_config_text(config_service_text) if response.get('ConfigurationRecorders') is None: - print "{} likely does not have Config permissions\n" .format(AWS_ACCESS_KEY_ID) + print("{} likely does not have Config permissions\n" .format(AWS_ACCESS_KEY_ID)) elif len(response['ConfigurationRecorders']) <= 0: print("NO CONFIGURATION DETECTED") else: diff --git a/s3_list_bucket_contents.py b/s3_list_bucket_contents.py index 21e3757..3ce0cea 100644 --- a/s3_list_bucket_contents.py +++ b/s3_list_bucket_contents.py @@ -3,7 +3,7 @@ from libs.s3 import * from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY if len(sys.argv) < 2: - print "must specify bucket: {} ".format(sys.argv[0]) + print("must specify bucket: {} ".format(sys.argv[0])) sys.exit(-1) #Attempt to list the contents of the bucket