def list_machines(self): instances = aws_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['State']['Name'] == 'running': instances_running = True response.append([ instance['Tags'][0]['Value'], instance['State']['Name'], instance['NetworkInterfaces'][0]['Association']['PublicIp'] ]) else: response.append( [instance['Tags'][0]['Value'], instance['State']['Name']]) print() print('Status EC2 Machines\n') if len(response) > 0: if instances_running: print( tabulate(response, headers=['Name', 'Status', 'IP Address'])) else: print(tabulate(response, headers=['Name', 'Status'])) else: print( "ERROR: Can't find configured EC2 Attack Range Instances in AWS." ) print()
def resume(self): if self.config['cloud_provider'] == 'aws': instances = aws_service.get_all_instances(self.config) aws_service.change_ec2_state(instances, 'running', self.log, self.config) elif self.config['cloud_provider'] == 'azure': azure_service.change_instance_state(self.config, 'running', self.log)
def list_machines(self): instances = aws_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['State']['Name'] == 'running': instances_running = True response.append([ instance['Tags'][0]['Value'], instance['State']['Name'], instance['NetworkInterfaces'][0]['Association']['PublicIp'] ]) else: response.append( [instance['Tags'][0]['Value'], instance['State']['Name']]) print() print('Status EC2 Machines\n') if len(response) > 0: if instances_running: print( tabulate(response, headers=['Name', 'Status', 'IP Address'])) else: print(tabulate(response, headers=['Name', 'Status'])) else: print( "ERROR: Can't find configured EC2 Attack Range Instances in AWS." ) print() if self.config['cloud_attack_range'] == '1': print() print('Status Serverless infrastructure\n') api_gateway_endpoint, error = aws_service.get_apigateway_endpoint( self.config) if not error: arr = [] arr.append([ api_gateway_endpoint['name'], str('https://' + api_gateway_endpoint['id'] + '.execute-api.' + self.config['region'] + '.amazonaws.com/prod/'), 'see Attack Range wiki for available REST API endpoints' ]) print(tabulate(arr, headers=['Name', 'URL', 'Note'])) print() else: print("ERROR: Can't find REST API Gateway.") if self.config['kubernetes'] == '1': print() print('Status Kubernetes\n') kubernetes_service.list_deployed_applications() print()
def list_machines(self): if self.config['cloud_provider'] == 'aws': instances = aws_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['State']['Name'] == 'running': instances_running = True response.append([ instance['Tags'][0]['Value'], instance['State']['Name'], instance['NetworkInterfaces'][0]['Association'] ['PublicIp'] ]) else: response.append([ instance['Tags'][0]['Value'], instance['State']['Name'] ]) elif self.config['cloud_provider'] == 'azure': instances = azure_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['vm_obj'].instance_view.statuses[ 1].display_status == "VM running": instances_running = True response.append([ instance['vm_obj'].name, instance['vm_obj']. instance_view.statuses[1].display_status, instance['public_ip'] ]) else: response.append([ instance['vm_obj'].name, instance['vm_obj']. instance_view.statuses[1].display_status ]) print() print('Status Virtual Machines\n') if len(response) > 0: if instances_running: print( tabulate(response, headers=['Name', 'Status', 'IP Address'])) else: print(tabulate(response, headers=['Name', 'Status'])) else: print("ERROR: Can't find configured Attack Range Instances") print()
def list_machines(self): if self.config['cloud_provider'] == 'aws': instances = aws_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['State']['Name'] == 'running': instances_running = True response.append([ instance['Tags'][0]['Value'], instance['State']['Name'], instance['NetworkInterfaces'][0]['Association'] ['PublicIp'] ]) else: response.append([ instance['Tags'][0]['Value'], instance['State']['Name'] ]) print() print('Status Virtual Machines\n') if len(response) > 0: if instances_running: print( tabulate(response, headers=['Name', 'Status', 'IP Address'])) else: print(tabulate(response, headers=['Name', 'Status'])) else: print("ERROR: Can't find configured Attack Range Instances") print() if self.config['kubernetes'] == '1': print() print('Status Kubernetes\n') kubernetes_service.list_deployed_applications() print()
def resume(self): instances = aws_service.get_all_instances(self.config) aws_service.change_ec2_state(instances, 'running', self.log)
def stop(self): instances = aws_service.get_all_instances(self.config) aws_service.change_ec2_state(instances, 'stopped', self.log)
def list_machines(self): if self.config['cloud_provider'] == 'aws': instances = aws_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['State']['Name'] == 'running': instances_running = True response.append([ instance['Tags'][0]['Value'], instance['State']['Name'], instance['NetworkInterfaces'][0]['Association'] ['PublicIp'] ]) else: response.append([ instance['Tags'][0]['Value'], instance['State']['Name'] ]) elif self.config['cloud_provider'] == 'azure': instances = azure_service.get_all_instances(self.config) response = [] instances_running = False for instance in instances: if instance['vm_obj'].instance_view.statuses[ 1].display_status == "VM running": instances_running = True response.append([ instance['vm_obj'].name, instance['vm_obj']. instance_view.statuses[1].display_status, instance['public_ip'] ]) else: response.append([ instance['vm_obj'].name, instance['vm_obj']. instance_view.statuses[1].display_status ]) print() print('Status Virtual Machines\n') if len(response) > 0: if instances_running: print( tabulate(response, headers=['Name', 'Status', 'IP Address'])) messages_to_print = self.show_message(response) for msg in messages_to_print: print(msg) else: print(tabulate(response, headers=['Name', 'Status'])) messages_to_print = self.show_message(response) for msg in messages_to_print: print(msg) else: print("ERROR: Can't find configured Attack Range Instances") # copy password into clipboard try: pyperclip.copy(self.config['attack_range_password']) print("* attack_range password has been copied to your clipboard") except Exception as e: self.log.error("not able to copy password to clipboard") print()