refactor, tidy up, split out config

This commit is contained in:
cmc
2017-07-24 14:35:17 -07:00
parent eab4dc0131
commit b0aa204efe
18 changed files with 40 additions and 303 deletions

View File

@@ -2,23 +2,9 @@
example calling cloudwatch functions example calling cloudwatch functions
decribe alarms, describe alarm history, list metrics decribe alarms, describe alarm history, list metrics
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.cloudwatch import * from libs.cloudwatch import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
describe_alarms(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) describe_alarms(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
describe_alarm_history(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) describe_alarm_history(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
list_metrics(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_metrics(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,23 +1,8 @@
''' '''
data pipeline example data pipeline example
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.datapipeline import * from libs.datapipeline import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
list_pipelines(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
list_pipelines(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,23 +1,8 @@
''' '''
dynamoDB examples dynamoDB examples
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.dynamodb import * from libs.dynamodb import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
list_dynamodb_tables(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_dynamodb_tables(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
list_dynamodb_tables_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_dynamodb_tables_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,24 +1,7 @@
''' '''
This file is used to list ec2 instances This file is used to list ec2 instances
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.ec2 import * from libs.ec2 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
get_instance_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) get_instance_details(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,25 +1,8 @@
''' '''
This file is used to list volumes of ec2 instances This file is used to list volumes of ec2 instances
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.ec2 import * from libs.ec2 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
get_instance_volume_details(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) get_instance_volume_details2(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -2,23 +2,7 @@
''' '''
This file is used to list EBS volumes and whether or not they are encrypted. This is only for "in-use" (running) volumes. This file is used to list EBS volumes and whether or not they are encrypted. This is only for "in-use" (running) volumes.
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.ec2 import * from libs.ec2 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
review_encrypted_volumes(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) review_encrypted_volumes(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,28 +1,11 @@
''' '''
This file is used to perform some ElasticBeanstalk actions This file is used to perform some ElasticBeanstalk actions
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.elasticbeanstalk import * from libs.elasticbeanstalk import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
#describe_applications(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #describe_applications(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#describe_application_versions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #describe_application_versions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#describe_configuration_options(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #describe_configuration_options(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
describe_environments(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) describe_environments(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
describe_events(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) describe_events(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,25 +1,8 @@
''' '''
This file is used to perform some EMR actions This file is used to perform some EMR actions
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.emr import * from libs.emr import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
list_clusters(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_clusters(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,27 +1,9 @@
''' '''
if you have root or IAM access gather user info, manipulate access keys or passwords, make backdoor account if you have root or IAM access gather user info, manipulate access keys or passwords, make backdoor account
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.iam import * from libs.iam import *
from libs.sts import * from libs.sts import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 =''
get_accountid(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) check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@@ -31,4 +13,4 @@ get_password_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#change_user_console_password(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, 'pythons3', 'PS#EDCasd123456!@') #change_user_console_password(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, 'pythons3', 'PS#EDCasd123456!@')
#create_user(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax') #create_user(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax')
#make_admin(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax') #make_admin(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax')
#make_backdoor_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax','PS#EDCasd123456!@') #make_backdoor_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'leethax','PS#EDCasd123456!@')

View File

@@ -1,24 +1,8 @@
''' '''
This file is used to list lambda functions and event mappings This file is used to list lambda functions and event mappings
''' '''
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.aws_lambda import * from libs.aws_lambda import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#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 = ''
list_functions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_functions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
list_event_source_mappings(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) list_event_source_mappings(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -57,4 +57,4 @@ for region in regions:
ruleresponse = describe_configuration_recorders(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region) ruleresponse = describe_configuration_recorders(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, region)
print ruleresponse print ruleresponse
print_section_header_and_footer("END OF CONFIG SERVICE REVIEW", True) print_section_header_and_footer("END OF CONFIG SERVICE REVIEW", True)

View File

@@ -1,18 +1,4 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.opsworks import * from libs.opsworks import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID = '' describe_stacks(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
AWS_SECRET_ACCESS_KEY = ''
describe_stacks(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,20 +1,4 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
from libs.rds import * from libs.rds import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
pp = pprint.PrettyPrinter(indent=5, width=80)
#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 =''
describe_db_instances(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) describe_db_instances(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,20 +1,6 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.brute import * from libs.brute import *
from libs.s3 import * from libs.s3 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#insert AWS key, will figure out how to pull this in from a single file for all scripts
check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) check_root_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_acm_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_acm_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@@ -37,7 +23,7 @@ brute_cognitoidentity_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_cognitoidp_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_cognitoidp_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_cognitosync_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_cognitosync_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_configservice_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_configservice_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#brute_costandusagereportservice_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #Could not connect to the endpoint URL: "https://cur.us-west-2.amazonaws.com/" #brute_costandusagereportservice_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) #Could not connect to the endpoint URL: "https://cur.us-west-2.amazonaws.com/"
brute_datapipeline_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_datapipeline_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_devicefarm_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_devicefarm_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
brute_directconnect_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) brute_directconnect_permissions(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,21 +1,10 @@
import boto3 import sys
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.s3 import * from libs.s3 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#insert AWS key, will figure out how to pull this in from a single file for all scripts if len(sys.argv) < 2:
print "must specify bucket: {} <bucketname>".format(sys.argv[0])
sys.exit(-1)
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
#Attempt to list the contents of the bucket #Attempt to list the contents of the bucket
get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,'myfuckingbucket') get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, sys.argv[1])

View File

@@ -1,25 +1,11 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.s3 import * from libs.s3 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY =''
#open a list of possible buckets and attempt to list the contents #open a list of possible buckets and attempt to list the contents
f = open('test.txt', 'r') with open('bucket_list.txt', 'r') as f:
for line in f: for line in f:
line = line.strip() line = line.strip()
if not line: if not line:
continue continue
else: else:
get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,line) get_s3bucket_policy(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, line)

View File

@@ -1,20 +1,4 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.s3 import * from libs.s3 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#insert AWS key, will figure out how to pull this in from a single file for all scripts get_s3objects_for_account_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
#AWS_ACCESS_KEY_ID = ''
#AWS_SECRET_ACCESS_KEY =''
get_s3objects_for_account_detailed(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

View File

@@ -1,20 +1,4 @@
import boto3
import botocore
import json
import urllib
import logging
import sys,os
import pprint
pp = pprint.PrettyPrinter(indent=5, width=80)
from libs.s3 import * from libs.s3 import *
from config import AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
#insert AWS key, will figure out how to pull this in from a single file for all scripts get_s3objects_for_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY =''
get_s3objects_for_account(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)