Skip to content

Commit c510373

Browse files
committed
Update aws_enum_services.py
1 parent 1b6b767 commit c510373

File tree

1 file changed

+199
-61
lines changed

1 file changed

+199
-61
lines changed

aws_service_enum/aws_enum_services.py

+199-61
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424

2525
json_body = {}
26-
# access_key = "AKIA3FT5IE3SKVIPQ7XW"
27-
# secret_key = "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"
28-
# session_token = ""
26+
2927
if args.thread:
3028
Thread_Count = int(args.thread)
3129
else:
@@ -119,6 +117,33 @@ def describe_instances(region):
119117

120118
print(crayons.green("[+] " + started, bold=True), "\r\n" ,tabulate(instance_data, headers=['Instance ID', 'Instance State', 'Instance Type', 'Launch Time', 'Region'], tablefmt='psql'))
121119

120+
def describe_vpcs():
121+
started = "List VPCs:"
122+
vpc_data = []
123+
124+
def describe_vpcs_in_region(region):
125+
ec2_client = get_client('ec2', region_name=region)
126+
response = ec2_client.describe_vpcs()
127+
vpcs = response['Vpcs']
128+
for vpc in vpcs:
129+
vpc_data.append([
130+
vpc['VpcId'],
131+
vpc['CidrBlock'],
132+
vpc['State'],
133+
region
134+
])
135+
136+
processes = []
137+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
138+
for region in regions:
139+
processes.append(executor.submit(describe_vpcs_in_region, region))
140+
141+
if vpc_data == []:
142+
print(crayons.yellow("[!] " + started + " (Empty!)", bold=True))
143+
return
144+
145+
print(crayons.green("[+] " + started, bold=True))
146+
print(tabulate(vpc_data, headers=['VPC ID', 'CIDR Block', 'State', 'Region'], tablefmt='psql'))
122147

123148

124149
def list_s3_buckets():
@@ -1302,8 +1327,9 @@ def list_change_sets(stack_name, region):
13021327
try:
13031328
response = cloudformation_client.list_change_sets(StackName=stack_name)
13041329
except ClientError as e:
1330+
#print(e)
13051331
error_message = e.response['Error']['Message']
1306-
print(crayons.red(f"Error retrieving change sets: {error_message} ({region})", bold=True))
1332+
#print(crayons.red(f"Error retrieving change sets: {error_message} ({region})", bold=True))
13071333
return
13081334

13091335

@@ -1427,72 +1453,184 @@ def process_region(region):
14271453
return
14281454
print(crayons.green("[+] " + started, bold=True), "\r\n", tabulate(container_data, headers=['Container Name', 'Status', 'Creation Time', 'Region'], tablefmt='psql'))
14291455

1456+
def describe_snapshots():
1457+
started = "List EBS Snapshots:"
1458+
snapshot_data = []
1459+
1460+
def describe_snapshots_in_region(region):
1461+
ec2_client = get_client('ec2', region_name=region)
1462+
response = ec2_client.describe_snapshots(OwnerIds=['self'])
1463+
snapshots = response['Snapshots']
1464+
1465+
for snapshot in snapshots:
1466+
snapshot_data.append([
1467+
snapshot['SnapshotId'],
1468+
snapshot['VolumeId'],
1469+
snapshot['StartTime'],
1470+
snapshot['State'],
1471+
region
1472+
])
1473+
1474+
processes = []
1475+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
1476+
for region in regions:
1477+
processes.append(executor.submit(describe_snapshots_in_region, region))
1478+
1479+
if snapshot_data == []:
1480+
print(crayons.yellow("[!] " + started + " (Empty!)", bold=True))
1481+
return
1482+
1483+
print(crayons.green("[+] " + started, bold=True))
1484+
print(tabulate(snapshot_data, headers=['Snapshot ID', 'Volume ID', 'Start Time', 'State', 'Region'], tablefmt='psql'))
1485+
1486+
1487+
def describe_subnets():
1488+
started = "List Subnets:"
1489+
subnet_data = []
1490+
1491+
def describe_subnets_in_region(region):
1492+
ec2_client = get_client('ec2', region_name=region)
1493+
response = ec2_client.describe_subnets()
1494+
subnets = response['Subnets']
1495+
1496+
for subnet in subnets:
1497+
subnet_data.append([
1498+
subnet['SubnetId'],
1499+
subnet['VpcId'],
1500+
subnet['CidrBlock'],
1501+
subnet['AvailabilityZone'],
1502+
region
1503+
])
1504+
1505+
processes = []
1506+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
1507+
for region in regions:
1508+
processes.append(executor.submit(describe_subnets_in_region, region))
1509+
1510+
if subnet_data == []:
1511+
print(crayons.yelow("[!] " + started + " (Empty!)", bold=True))
1512+
return
1513+
1514+
headers = ['Subnet ID', 'VPC ID', 'CIDR Block', 'Availability Zone', 'Region']
1515+
print(crayons.green("[+] " + started, bold=True))
1516+
print(tabulate(subnet_data, headers=headers, tablefmt='psql'))
1517+
1518+
1519+
def describe_volumes():
1520+
started = "List EBS Volumes:"
1521+
volume_data = []
1522+
1523+
def describe_volumes_in_region(region):
1524+
ec2_client = boto3.client('ec2', region_name=region)
1525+
response = ec2_client.describe_volumes()
1526+
volumes = response['Volumes']
1527+
1528+
for volume in volumes:
1529+
volume_data.append([
1530+
volume['VolumeId'],
1531+
volume['Size'],
1532+
volume['AvailabilityZone'],
1533+
volume['State'],
1534+
region
1535+
])
1536+
processes = []
1537+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
1538+
for region in regions:
1539+
processes.append(executor.submit(describe_volumes_in_region, region))
1540+
1541+
if volume_data == []:
1542+
print(crayons.yellow("[!] " + started + " (Empty!)", bold=True))
1543+
return
1544+
1545+
headers = ['Volume ID', 'Size (GiB)', 'Availability Zone', 'State', 'Region']
1546+
print(crayons.green("[+] " + started, bold=True))
1547+
print(tabulate(volume_data, headers=headers, tablefmt='psql'))
1548+
1549+
def describe_amis():
1550+
started = "List AMIs:"
1551+
ami_data = []
1552+
1553+
def describe_amis_in_region(region):
1554+
1555+
ec2_client = get_client('ec2', region_name=region)
1556+
response = ec2_client.describe_images(Owners=['self'])
1557+
amis = response['Images']
1558+
1559+
for ami in amis:
1560+
ami_data.append([
1561+
ami['ImageId'],
1562+
ami['Name'],
1563+
ami['CreationDate'],
1564+
region
1565+
])
1566+
1567+
processes = []
1568+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
1569+
for region in regions:
1570+
processes.append(executor.submit(describe_amis_in_region, region))
1571+
1572+
if ami_data == []:
1573+
print(crayons.yellow("[!] " + started + " (Empty!)", bold=True))
1574+
return
1575+
1576+
headers = ['AMI ID', 'Name', 'Creation Date', 'Region']
1577+
print(crayons.green("[+] " + started, bold=True))
1578+
print(tabulate(ami_data, headers=headers, tablefmt='psql'))
1579+
1580+
def describe_security_groups():
1581+
started = "List Security Groups:"
1582+
group_data = []
1583+
1584+
def describe_security_groups_in_region(region):
1585+
ec2_client = get_client('ec2', region_name=region)
1586+
response = ec2_client.describe_security_groups()
1587+
security_groups = response['SecurityGroups']
1588+
1589+
for group in security_groups:
1590+
group_data.append([
1591+
group['GroupId'],
1592+
group['GroupName'],
1593+
group['Description'],
1594+
region
1595+
])
1596+
1597+
processes = []
1598+
with ThreadPoolExecutor(max_workers=Thread_Count) as executor:
1599+
for region in regions:
1600+
processes.append(executor.submit(describe_security_groups_in_region, region))
1601+
1602+
if group_data == []:
1603+
print(crayons.yellow("[!] " + started + " (Empty!)", bold=True))
1604+
return
1605+
1606+
headers = ['Group ID', 'Group Name', 'Description', 'Region']
1607+
print(crayons.green("[+] " + started, bold=True))
1608+
print(tabulate(group_data, headers=headers, tablefmt='psql'))
14301609

14311610

14321611
services_list = {
1433-
"ec2": "describe_ec2_instances","s3": "list_s3_buckets","rds": "describe_rds_instances","lambda": "list_lambda_functions","cloudfront": "list_cloudfront_distributions","dynamodb": "list_dynamodb_tables","iam": "list_iam_users","sns": "list_sns_topics","sqs": "list_sqs_queues","ecr": "describe_ecr_repositories","elasticbeanstalk": "describe_elasticbeanstalk_applications","route53": "list_route53_hosted_zones","cloudwatch": "describe_cloudwatch_alarms","codepipeline": "list_codepipeline_pipelines","sagemaker": "list_sagemaker_notebooks","secretsmanager": "list_secretsmanager_secrets","glue": "list_glue_data_catalogs","stepfunctions": "list_stepfunctions_state_machines","eks": "list_eks_clusters","cloudtrail": "describe_cloudtrail_trails",
1434-
"kinesis": "list_kinesis_streams","redshift": "describe_redshift_clusters","elasticache": "describe_elasticache_clusters","apigateway": "list_apigateway_apis","cloudformation": "list_cloudformation_stacks","appsync": "list_appsync_apis","ssm": "list_ssm_documents","elastictranscoder": "list_elastictranscoder_pipelines","datapipeline": "list_datapipeline_pipelines","mediaconvert": "list_mediaconvert_jobs","storagegateway": "list_storagegateway_gateways","workspaces": "describe_workspaces","cloud9": "list_cloud9_environments","lex-models": "list_lex_bots","iot": "list_iot_things","medialive": "list_medialive_channels","datasync": "list_datasync_tasks","emr": "list_emr_clusters",
1435-
"athena": "list_athena_workgroups","pinpoint": "list_pinpoint_applications","efs": "list_efs_file_systems","mediapackage": "list_mediapackage_channels","mq": "list_mq_brokers","organizations": "list_organizations_accounts","detective": "list_detective_graphs","opsworks": "list_opsworks_stacks","codecommit": "list_codecommit_repositories","appmesh": "list_appmesh_meshes","backup": "list_backup_plans","mediapackage-vod": "list_mediapackage_vod_assets","mediastore": "list_mediastore_containers"
1612+
"ec2": "describe_ec2_instances","vpc":"describe_vpcs","s3": "list_s3_buckets","rds": "describe_rds_instances","lambda": "list_lambda_functions","cloudfront": "list_cloudfront_distributions","dynamodb": "list_dynamodb_tables","iam": "list_iam_users","sns": "list_sns_topics",
1613+
"sqs": "list_sqs_queues","ecr": "describe_ecr_repositories","elasticbeanstalk": "describe_elasticbeanstalk_applications","route53": "list_route53_hosted_zones","cloudwatch": "describe_cloudwatch_alarms","codepipeline": "list_codepipeline_pipelines","sagemaker": "list_sagemaker_notebooks",
1614+
"secretsmanager": "list_secretsmanager_secrets","glue": "list_glue_data_catalogs","stepfunctions": "list_stepfunctions_state_machines","eks": "list_eks_clusters","cloudtrail": "describe_cloudtrail_trails","kinesis": "list_kinesis_streams","redshift": "describe_redshift_clusters",
1615+
"elasticache": "describe_elasticache_clusters","apigateway": "list_apigateway_apis","cloudformation": "list_cloudformation_stacks","appsync": "list_appsync_apis","ssm": "list_ssm_documents","elastictranscoder": "list_elastictranscoder_pipelines","datapipeline": "list_datapipeline_pipelines",
1616+
"mediaconvert": "list_mediaconvert_jobs","storagegateway": "list_storagegateway_gateways","workspaces": "describe_workspaces","cloud9": "list_cloud9_environments","lex-models": "list_lex_bots","iot": "list_iot_things","medialive": "list_medialive_channels","datasync": "list_datasync_tasks",
1617+
"emr": "list_emr_clusters","athena": "list_athena_workgroups","pinpoint": "list_pinpoint_applications","efs": "list_efs_file_systems","mediapackage": "list_mediapackage_channels","mq": "list_mq_brokers","organizations": "list_organizations_accounts","detective": "list_detective_graphs",
1618+
"opsworks": "list_opsworks_stacks","codecommit": "list_codecommit_repositories","appmesh": "list_appmesh_meshes","backup": "list_backup_plans","mediapackage-vod": "list_mediapackage_vod_assets","mediastore": "list_mediastore_containers","Snapshots":"describe_snapshots","Subnet":"describe_subnets",
1619+
"Volumes":"describe_volumes","ami":"describe_amis","SecurityGroups":"describe_security_groups"
14361620
}
14371621

14381622

14391623
functions = [
1440-
describe_ec2_instances,
1441-
list_s3_buckets,
1442-
describe_rds_instances,
1443-
list_lambda_functions,
1444-
list_cloudfront_distributions,
1445-
list_dynamodb_tables,
1446-
list_iam_users,
1447-
list_sns_topics,
1448-
list_sqs_queues,
1449-
describe_ecr_repositories,
1450-
describe_elasticbeanstalk_applications,
1451-
list_route53_hosted_zones,
1452-
describe_cloudwatch_alarms,
1453-
list_codepipeline_pipelines,
1454-
list_sagemaker_notebooks,
1455-
list_secretsmanager_secrets,
1456-
list_glue_data_catalogs,
1457-
list_stepfunctions_state_machines,
1458-
list_eks_clusters,
1459-
describe_cloudtrail_trails,
1460-
list_kinesis_streams,
1461-
describe_redshift_clusters,
1462-
describe_elasticache_clusters,
1463-
list_apigateway_apis,
1464-
list_cloudformation_stacks,
1465-
list_appsync_apis,
1466-
list_ssm_documents,
1467-
list_elastictranscoder_pipelines,
1468-
list_datapipeline_pipelines,
1469-
list_mediaconvert_jobs,
1470-
list_storagegateway_gateways,
1471-
describe_workspaces,
1472-
list_cloud9_environments,
1473-
list_lex_bots,
1474-
list_iot_things,
1475-
list_medialive_channels,
1476-
list_datasync_tasks,
1477-
list_emr_clusters,
1478-
list_athena_workgroups,
1479-
list_pinpoint_applications,
1480-
list_efs_file_systems,
1481-
list_glue_crawlers,
1482-
list_datasync_locations,
1483-
list_mediapackage_channels,
1484-
list_mq_brokers,
1485-
list_organizations_accounts,
1486-
list_detective_graphs,
1487-
list_opsworks_stacks,
1488-
list_codecommit_repositories,
1489-
list_cloudformation_change_sets,
1490-
list_appmesh_meshes,
1491-
list_backup_plans,
1492-
list_mediapackage_vod_assets,
1493-
list_mediastore_containers
1624+
describe_ec2_instances,describe_vpcs,list_s3_buckets,describe_rds_instances,list_lambda_functions,list_cloudfront_distributions,list_dynamodb_tables,list_iam_users,list_sns_topics,list_sqs_queues,describe_ecr_repositories,describe_elasticbeanstalk_applications,list_route53_hosted_zones,
1625+
describe_cloudwatch_alarms,list_codepipeline_pipelines,list_sagemaker_notebooks,list_secretsmanager_secrets,list_glue_data_catalogs,list_stepfunctions_state_machines,list_eks_clusters,describe_cloudtrail_trails,list_kinesis_streams,describe_redshift_clusters,
1626+
describe_elasticache_clusters,list_apigateway_apis,list_cloudformation_stacks,list_appsync_apis,list_ssm_documents,list_elastictranscoder_pipelines,list_datapipeline_pipelines,list_mediaconvert_jobs,list_storagegateway_gateways,describe_workspaces,list_cloud9_environments,
1627+
list_lex_bots,list_iot_things,list_medialive_channels,list_datasync_tasks,list_emr_clusters,list_athena_workgroups,list_pinpoint_applications,list_efs_file_systems,list_glue_crawlers,list_datasync_locations,list_mediapackage_channels,list_mq_brokers,list_organizations_accounts,
1628+
list_detective_graphs,list_opsworks_stacks,list_codecommit_repositories,list_cloudformation_change_sets,list_appmesh_meshes,list_backup_plans,list_mediapackage_vod_assets,list_mediastore_containers,describe_snapshots,
1629+
describe_subnets,describe_volumes,describe_amis,describe_security_groups
14941630
]
14951631

1632+
1633+
14961634
def get_profile():
14971635
profile = get_client("sts", region_name=None)
14981636
try:

0 commit comments

Comments
 (0)