diff --git a/ec2_get_instance_volumes.py b/ec2_get_instance_volumes.py deleted file mode 100644 index 56aba16..0000000 --- a/ec2_get_instance_volumes.py +++ /dev/null @@ -1,8 +0,0 @@ -''' -This file is used to list volumes of ec2 instances -''' -from libs.ec2 import * -from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY - -get_instance_volume_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) -get_instance_volume_details2(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) diff --git a/libs/brute.py b/libs/brute.py index 11030b0..7c7eda8 100644 --- a/libs/brute.py +++ b/libs/brute.py @@ -103,13 +103,13 @@ def generic_permission_bruteforcer(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, ser try: insert_reconservice_data(db_name, db_logger) except sqlite3.OperationalError as e: - print (e) - print ("You need to set up the database...exiting") + print(e) + print("You need to set up the database...exiting") sys.exit() - print ("\n") + print("\n") else: - print ("\n[-] No {} actions allowed [-]" .format(service)) - print ("\n") + print("\n[-] No {} actions allowed [-]" .format(service)) + print("\n") return actions def generic_method_bruteforcer(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, service, tests): diff --git a/libs/ec2.py b/libs/ec2.py index dcc008a..f2a2510 100644 --- a/libs/ec2.py +++ b/libs/ec2.py @@ -66,7 +66,10 @@ def get_instance_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): pp.pprint(i) except botocore.exceptions.ClientError as e: - print(e) + if e.response['Error']['Code'] == 'UnauthorizedOperation': + print('{} : (UnauthorizedOperation) when calling the DescribeInstances -- sure you have ec2 permissions?' .format(AWS_ACCESS_KEY_ID)) + else: + print(e) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -90,7 +93,10 @@ def get_instance_details_basic(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): print("InstanceID: {}, InstanceType: {}, State: {}, Launchtime: {}".format(instanceid, instancetype, state, launchtime)) except botocore.exceptions.ClientError as e: - print(e) + if e.response['Error']['Code'] == 'UnauthorizedOperation': + print('{} : (UnauthorizedOperation) when calling the DescribeInstances-- sure you have ec2 permissions?' .format(AWS_ACCESS_KEY_ID)) + else: + print(e) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -110,7 +116,10 @@ def get_instance_volume_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): pp.pprint(volumes) except botocore.exceptions.ClientError as e: - print(e) + if e.response['Error']['Code'] == 'UnauthorizedOperation': + print('{} : (UnauthorizedOperation) when calling the DescribeVolumes -- sure you have required ec2 permissions?' .format(AWS_ACCESS_KEY_ID)) + else: + print(e) except KeyboardInterrupt: print("CTRL-C received, exiting...") @@ -132,6 +141,9 @@ def get_instance_volume_details2(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY): print("\n") except botocore.exceptions.ClientError as e: - print(e) + if e.response['Error']['Code'] == 'UnauthorizedOperation': + print('{} : (UnauthorizedOperation) when calling the DescribeVolumes -- sure you have the required ec2 permissions?' .format(AWS_ACCESS_KEY_ID)) + else: + print(e) except KeyboardInterrupt: print("CTRL-C received, exiting...") diff --git a/modules/ec2.py b/modules/ec2.py index 33b4278..0a22674 100644 --- a/modules/ec2.py +++ b/modules/ec2.py @@ -1,13 +1,40 @@ ''' -This file is used to list ec2 instances +This file is used to perform various EC2 operations ''' from libs.ec2 import * from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY +''' +Basic info about each instance +''' + def step_ec2_get_instances_basic(): get_instance_details_basic(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) +''' +All info about each instance +''' + + def step_ec2_get_instances_detailed(): get_instance_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) + + +''' +show volumes sorted by instanceId ex: instanceID-->multiple volumes less detail than get_instance_volume_details2 +''' + + +def step_ec2_get_instance_volume_details(): + get_instance_volume_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) + + +''' +show volumes by instanceId but instanceID->volume1 of ID, instanceID->volume2 of ID but more details. +''' + + +def step_ec2_get_instance_volume_details2(): + get_instance_volume_details2(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)