From a6fc23909d9dc1f9b31c910d56c1d1878de93aa4 Mon Sep 17 00:00:00 2001 From: carnal0wnage Date: Fri, 23 Jun 2017 12:10:52 -0400 Subject: [PATCH] update config --- config/config.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/config/config.py b/config/config.py index 5aa8a4b..dcf873f 100644 --- a/config/config.py +++ b/config/config.py @@ -5,6 +5,7 @@ Config Library import boto3 import botocore import pprint +import sys pp = pprint.PrettyPrinter(indent=5, width=80) @@ -13,19 +14,22 @@ regions = ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2', 'ca-central-1', ' def describe_configuration_recorders(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region): - response = [] + response = {} try: client = boto3.client("config", aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY,region_name=region) response = client.describe_configuration_recorders() + #print response except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'InvalidClientTokenId': sys.exit("The AWS KEY IS INVALID. Exiting") + elif e.response['Error']['Code'] == 'UnrecognizedClientException': + sys.exit("The AWS KEY IS INVALID. Exiting") elif e.response['Error']['Code'] == 'AccessDenied': - print('%s : does not have config access. Did you check first?' % AWS_ACCESS_KEY_ID) + print('[-] {} : does not have config access. Did you check first?' .format(AWS_ACCESS_KEY_ID)) pass elif e.response['Error']['Code'] == 'AccessDeniedException': - print('%s : does not have config access. Did you check first?' % AWS_ACCESS_KEY_ID) + print('[-] {} : does not have config access. Did you check first?' .format(AWS_ACCESS_KEY_ID)) pass else: print "Unexpected error: %s" % e