Example #1
0
    def handle(self):
        headers, table = [], []
        if self.cfg.type == 'sessions':
            headers = ['ID', 'Session', 'Type', 'State', 'IP', 'Uptime', 'Spot Price']
            for instance in aws.Ec2(self.cfg).get_instances():
                session_name = ''
                for tag in instance.tags:
                    if tag['Key'] == 'ec2hashcat':
                        session_name = tag['Value']
                        break
                table.append([instance.id,
                              session_name,
                              instance.instance_type,
                              instance.state.get('Name', ''),
                              instance.public_ip_address,
                              self._get_instance_uptime(instance),
                              '${}/h'.format(self._get_instance_price(instance))])
        elif self.cfg.type == 'prices':
            headers = ['Zone', 'Price (USD)']
            table = aws.Ec2(self.cfg).get_spot_prices()
        else:
            types = [self.cfg.type]
            if self.cfg.type == 'files':
                types = aws.S3Bucket.types
            headers = ['Filename', 'Size', 'Last Modified']
            for filetype in types:
                objects = aws.S3Bucket(self.cfg).get_objects(filetype)
                for obj in objects:
                    key = obj.key
                    if self.cfg.type != 'files':
                        key = os.path.basename(key)
                    table.append([key, obj.size, obj.last_modified])

        if headers and table:
            utils.print_table(table, headers)
Example #2
0
    def handle(self):
        headers, table = [], []
        if self.cfg.type == 'sessions':
            headers = [
                'ID', 'Session', 'Type', 'State', 'IP', 'Uptime', 'Spot Price'
            ]
            for instance in aws.Ec2(self.cfg).get_instances():
                session_name = ''
                for tag in instance.tags:
                    if tag['Key'] == 'ec2hashcat':
                        session_name = tag['Value']
                        break
                table.append([
                    instance.id, session_name, instance.instance_type,
                    instance.state.get('Name', ''), instance.public_ip_address,
                    self._get_instance_uptime(instance),
                    '${}/h'.format(self._get_instance_price(instance))
                ])
        elif self.cfg.type == 'prices':
            headers = ['Zone', 'Price (USD)']
            table = aws.Ec2(self.cfg).get_spot_prices()
        else:
            types = [self.cfg.type]
            if self.cfg.type == 'files':
                types = aws.S3Bucket.types
            headers = ['Filename', 'Size', 'Last Modified']
            for filetype in types:
                objects = aws.S3Bucket(self.cfg).get_objects(filetype)
                for obj in objects:
                    key = obj.key
                    if self.cfg.type != 'files':
                        key = os.path.basename(key)
                    table.append([key, obj.size, obj.last_modified])

        if headers and table:
            utils.print_table(table, headers)
Example #3
0
 def _show(self):
     table = [[mask] for mask in self.secgrp.get_masks()]
     utils.print_table(table, ['Mask'])
Example #4
0
 def _show(self):
     table = [[mask] for mask in self.secgrp.get_masks()]
     utils.print_table(table, ['Mask'])