Example #1
0
 def get_services(self):
     services_lock.acquire()
     services_data = [{
         "service":
         service.get_name(),
         "location":
         "{}:{}{}".format(service.host, service.port, service.get_path()),
         "description":
         service.explain()
     } for service in services]
     services_lock.release()
     return services_data
Example #2
0
 def get_nodes(self):
     nodes = list()
     node_locations = set()
     services_lock.acquire()
     for service in services:
         node_location = str(service.host)
         if node_location not in node_locations:
             nodes.append({
                 "type": "Node/Master",
                 "location": str(service.host)
             })
             node_locations.add(node_location)
     services_lock.release()
     return nodes
Example #3
0
 def services_table(self):
     services_table = PrettyTable(["Service", "Location", "Description"], hrules=ALL)
     services_table.align = "l"
     services_table.max_width = MAX_TABLE_WIDTH
     services_table.padding_width = 1
     services_table.sortby = "Service"
     services_table.reversesort = True
     services_table.header_style = "upper"
     services_lock.acquire()
     for service in services:
         services_table.add_row([service.get_name(), "{}:{}{}".format(service.host, service.port, service.get_path()), service.explain()])
     detected_services_ret = "\nDetected Services\n{}\n".format(services_table)
     services_lock.release()
     return detected_services_ret
Example #4
0
 def nodes_table(self):
     nodes_table = PrettyTable(["Type", "Location"], hrules=ALL)
     nodes_table.align = "l"
     nodes_table.max_width = MAX_TABLE_WIDTH
     nodes_table.padding_width = 1
     nodes_table.sortby = "Type"
     nodes_table.reversesort = True
     nodes_table.header_style = "upper"
     # TODO: replace with sets
     id_memory = list()
     services_lock.acquire()
     for service in services:
         if service.event_id not in id_memory:
             nodes_table.add_row(["Node/Master", service.host])
             id_memory.append(service.event_id)
     nodes_ret = "\nNodes\n{}\n".format(nodes_table)
     services_lock.release()
     return nodes_ret
Example #5
0
    def get_report(self):
        """generates report tables"""
        output = ""

        vulnerabilities_lock.acquire()
        vulnerabilities_len = len(vulnerabilities)
        vulnerabilities_lock.release()

        services_lock.acquire()
        services_len = len(services)
        services_lock.release()

        if services_len:
            output += self.nodes_table()
            if not config.mapping:
                output += self.services_table()
                if vulnerabilities_len:
                    output += self.vulns_table()
                else:
                    output += "\nNo vulnerabilities were found"
        else:
            print("\nKube Hunter couldn't find any clusters")
            # print("\nKube Hunter couldn't find any clusters. {}".format("Maybe try with --active?" if not config.active else ""))
        return output