Skip to content

Commit

Permalink
nmap: accept IP_RANGEs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Dec 15, 2023
1 parent 8137736 commit 332194b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bbot/modules/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class nmap(BaseModule):
watched_events = ["IP_ADDRESS", "DNS_NAME"]
watched_events = ["IP_ADDRESS", "DNS_NAME", "IP_RANGE"]
produced_events = ["OPEN_TCP_PORT"]
flags = ["active", "portscan", "aggressive", "web-thorough"]
meta = {"description": "Execute port scans with nmap"}
Expand Down Expand Up @@ -32,6 +32,15 @@ async def setup(self):
self.timing = self.config.get("timing", "T4")
self.top_ports = self.config.get("top_ports", 100)
self.skip_host_discovery = self.config.get("skip_host_discovery", True)
self.ip_ranges = [e.host for e in self.scan.target.events if e.type == "IP_RANGE"]
return True

async def filter_event(self, event):
# skip IP_ADDRESSes if they are included in any of our target IP_RANGEs
if event.type == "IP_ADDRESS":
for net in self.helpers.ip_network_parents(event.data, include_self=True):
if net in self.ip_ranges:
return False, f"Skipping {event.host} because it is already included in {net}"
return True

async def handle_batch(self, *events):
Expand Down

0 comments on commit 332194b

Please sign in to comment.