diff --git a/src/core/events/handler.py b/src/core/events/handler.py index dd6e6bc..652a257 100644 --- a/src/core/events/handler.py +++ b/src/core/events/handler.py @@ -79,7 +79,7 @@ class EventQueue(Queue, object): try: hook.execute() except Exception as ex: - logging.debug(ex.message) + logging.debug(ex) self.task_done() logging.debug("closing thread...") diff --git a/src/modules/discovery/hosts.py b/src/modules/discovery/hosts.py index 4bef152..3912ba1 100644 --- a/src/modules/discovery/hosts.py +++ b/src/modules/discovery/hosts.py @@ -74,18 +74,21 @@ class FromPodHostDiscovery(Hunter): self.event = event def execute(self): - # Discover master API server from in-pod environment variable. - - if self.is_azure_pod(): - subnets, cloud =self.azure_metadata_discovery() + # Scan any hosts that the user specified + if config.remote or config.cidr: + self.publish_event(HostScanEvent()) else: - subnets, cloud = self.traceroute_discovery() + # Discover cluster subnets, we'll scan all these hosts + if self.is_azure_pod(): + subnets, cloud = self.azure_metadata_discovery() + else: + subnets, cloud = self.traceroute_discovery() + for subnet in subnets: + logging.debug("From pod scanning subnet {0}/{1}".format(subnet[0], subnet[1])) + for ip in HostDiscoveryHelpers.generate_subnet(ip=subnet[0], sn=subnet[1]): + self.publish_event(NewHostEvent(host=ip, cloud=cloud)) - for subnet in subnets: - logging.debug("From pod scanning subnet {0}/{1}".format(subnet[0], subnet[1])) - for ip in HostDiscoveryHelpers.generate_subnet(ip=subnet[0], sn=subnet[1]): - self.publish_event(NewHostEvent(host=ip, cloud=cloud)) def is_azure_pod(self): try: @@ -116,7 +119,7 @@ class FromPodHostDiscovery(Hunter): logging.debug("From pod discovered subnet {0}/{1}".format(address, subnet if not config.quick else "24")) subnets.append([address,subnet if not config.quick else "24"]) - self.publish_event(AzureMetadataApi(cidr="{}/{}".format(address, subnet))) + self.publish_event(AzureMetadataApi(cidr="{}/{}".format(address, subnet))) return subnets, "Azure"