Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Target for Event Correlation in Massdns #748

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bbot/core/helpers/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def clean_old_scans(self):
_filter = lambda x: x.is_dir() and self.regexes.scan_name_regex.match(x.name)
self.clean_old(self.scans_dir, keep=self.keep_old_scans, filter=_filter)

def make_target(self, events):
def make_target(self, *events):
return Target(self.scan, *events)

@property
Expand Down
2 changes: 1 addition & 1 deletion bbot/modules/deadly/nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def setup(self):
return True

async def handle_batch(self, *events):
temp_target = self.helpers.make_target(events)
temp_target = self.helpers.make_target(*events)
nuclei_input = [str(e.data) for e in events]
async for severity, template, host, url, name, extracted_results in self.execute_nuclei(nuclei_input):
# this is necessary because sometimes nuclei is inconsistent about the data returned in the host field
Expand Down
15 changes: 3 additions & 12 deletions bbot/modules/massdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class massdns(crobat):
async def setup(self):
self.found = dict()
self.mutations_tried = set()
self.source_events = dict()
self.source_events = self.helpers.make_target()
self.subdomain_file = await self.helpers.wordlist(self.config.get("wordlist"))
self.max_resolvers = self.config.get("max_resolvers", 1000)
self.max_mutations = self.config.get("max_mutations", 500)
Expand Down Expand Up @@ -94,9 +94,7 @@ async def filter_event(self, event):

async def handle_event(self, event):
query = self.make_query(event)
h = hash(query)
if not h in self.source_events:
self.source_events[h] = event
self.source_events.add_target(event)

self.info(f"Brute-forcing subdomains for {query} (source: {event.data})")
for hostname in await self.massdns(query, self.helpers.read_file(self.subdomain_file)):
Expand Down Expand Up @@ -354,7 +352,7 @@ def add_mutation(_domain_hash, m):
self.info(f"Trying {len(mutations):,} mutations against {domain} ({i+1}/{len(found)})")
results = list(await self.massdns(query, mutations))
for hostname in results:
source_event = self.get_source_event(hostname)
source_event = self.source_events.get(hostname)
if source_event is None:
self.warning(f"Could not correlate source event from: {hostname}")
source_event = self.scan.root_event
Expand Down Expand Up @@ -395,10 +393,3 @@ def gen_random_subdomains(self, n=50):
yield subdomain
for _ in range(5):
yield self.helpers.rand_string(length=8, digits=False)

def get_source_event(self, hostname):
for p in self.helpers.domain_parents(hostname):
try:
return self.source_events[hash(p)]
except KeyError:
continue
2 changes: 1 addition & 1 deletion bbot/modules/nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def setup(self):
return True

async def handle_batch(self, *events):
target = self.helpers.make_target(events)
target = self.helpers.make_target(*events)
targets = list(set(str(e.data) for e in events))
command, output_file = self.construct_command(targets)
try:
Expand Down