From d4a9e0e8cc23726beaca5fcd1384bedd98a2c3eb Mon Sep 17 00:00:00 2001 From: TheTechromancer Date: Wed, 20 Dec 2023 07:23:12 -0500 Subject: [PATCH] improve speculate OPEN_TCP_PORT logic, yield to event loop in asset_inventory.report() --- bbot/modules/internal/speculate.py | 3 ++- bbot/modules/output/asset_inventory.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bbot/modules/internal/speculate.py b/bbot/modules/internal/speculate.py index 27766bc56b..a420209615 100644 --- a/bbot/modules/internal/speculate.py +++ b/bbot/modules/internal/speculate.py @@ -33,7 +33,8 @@ class speculate(BaseInternalModule): _priority = 4 async def setup(self): - self.open_port_consumers = any(["OPEN_TCP_PORT" in m.watched_events for m in self.scan.modules.values()]) + scan_modules = [m for m in self.scan.modules.values() if m._type == "scan"] + self.open_port_consumers = any(["OPEN_TCP_PORT" in m.watched_events for m in scan_modules]) self.portscanner_enabled = any(["portscan" in m.flags for m in self.scan.modules.values()]) self.emit_open_ports = self.open_port_consumers and not self.portscanner_enabled self.range_to_ip = True diff --git a/bbot/modules/output/asset_inventory.py b/bbot/modules/output/asset_inventory.py index 56e94aaa29..db9fcd9468 100644 --- a/bbot/modules/output/asset_inventory.py +++ b/bbot/modules/output/asset_inventory.py @@ -36,9 +36,6 @@ class asset_inventory(CSV): async def setup(self): self.assets = {} - self.open_port_producers = "httpx" in self.scan.modules or any( - ["portscan" in m.flags for m in self.scan.modules.values()] - ) self.use_previous = self.config.get("use_previous", False) self.summary_netmask = self.config.get("summary_netmask", 16) self.emitted_contents = False @@ -136,6 +133,8 @@ async def finish(self): with open(self.output_file, newline="") as f: c = csv.DictReader(f) for row in c: + # yield to event loop to make sure we don't hold up the scan + await self.helpers.sleep(0) host = row.get("Host", "").strip() ips = row.get("IP(s)", "") if not host or not ips: