Skip to content

Commit

Permalink
fix dnszonetransfer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Dec 25, 2023
1 parent a78b992 commit 93fa655
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions bbot/core/configurator/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def parse_args(self, *args, **kwargs):
if ret.silent:
ret.yes = True
ret.modules = chain_lists(ret.modules)
ret.exclude_modules = chain_lists(ret.exclude_modules)
ret.output_modules = chain_lists(ret.output_modules)
ret.targets = chain_lists(ret.targets, try_files=True, msg="Reading targets from file: {filename}")
ret.whitelist = chain_lists(ret.whitelist, try_files=True, msg="Reading whitelist from file: {filename}")
ret.blacklist = chain_lists(ret.blacklist, try_files=True, msg="Reading blacklist from file: {filename}")
ret.flags = chain_lists(ret.flags)
ret.exclude_flags = chain_lists(ret.exclude_flags)
ret.require_flags = chain_lists(ret.require_flags)
for m in ret.modules:
if m not in module_choices and not self._dummy:
Expand Down
6 changes: 4 additions & 2 deletions bbot/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ async def _handle_batch(self):
self.debug(f"Handling batch of {len(events):,} events")
submitted = True
async with self.scan._acatch(f"{self.name}.handle_batch()"):
await self.handle_batch(*events)
handle_batch_task = asyncio.create_task(self.handle_batch(*events))
await handle_batch_task
self.debug(f"Finished handling batch of {len(events):,} events")
if finish:
context = f"{self.name}.finish()"
Expand Down Expand Up @@ -605,7 +606,8 @@ async def _worker(self):
self.scan.stats.event_consumed(event, self)
self.debug(f"Handling {event}")
async with self.scan._acatch(context), self._task_counter.count(context):
await self.handle_event(event)
handle_event_task = asyncio.create_task(self.handle_event(event))
await handle_event_task
self.debug(f"Finished handling {event}")
else:
self.debug(f"Not accepting {event} because {reason}")
Expand Down
10 changes: 6 additions & 4 deletions bbot/modules/dnszonetransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ async def handle_event(self, event):
break
try:
self.debug(f"Attempting zone transfer against {nameserver} for domain {domain}")
xfr_answer = await self.scan.run_in_executor(
dns.query.xfr, nameserver, domain, timeout=self.timeout, lifetime=self.timeout
)
zone = dns.zone.from_xfr(xfr_answer)
zone = await self.scan.run_in_executor(self.zone_transfer, nameserver, domain)
except Exception as e:
self.debug(f"Error retrieving zone for {domain}: {e}")
continue
Expand All @@ -64,3 +61,8 @@ async def handle_event(self, event):
self.emit_event(child_event)
else:
self.debug(f"No data returned by {nameserver} for domain {domain}")

def zone_transfer(self, nameserver, domain):
xfr_answer = dns.query.xfr(nameserver, domain, timeout=self.timeout, lifetime=self.timeout)
zone = dns.zone.from_xfr(xfr_answer)
return zone

0 comments on commit 93fa655

Please sign in to comment.