Skip to content

Commit

Permalink
massdns tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Feb 5, 2024
1 parent 57ea37e commit 15f4f48
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bbot/modules/massdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async def massdns(self, domain, subdomains):
subdomains = list(subdomains)

domain_wildcard_rdtypes = set()
for domain, rdtypes in (await self.helpers.is_wildcard_domain(domain)).items():
for _domain, rdtypes in (await self.helpers.is_wildcard_domain(domain)).items():
for rdtype, results in rdtypes.items():
if results:
domain_wildcard_rdtypes.add(rdtype)
Expand Down Expand Up @@ -385,10 +385,7 @@ def add_mutation(_domain_hash, m):
for s in _subdomains:
first_segment = s.split(".")[0]
# skip stuff with lots of numbers (e.g. PTRs)
digits = self.digit_regex.findall(first_segment)
excessive_digits = len(digits) > 2
long_digits = any(len(d) > 3 for d in digits)
if excessive_digits or long_digits:
if self.has_excessive_digits(first_segment):
continue
add_mutation(domain_hash, first_segment)
for word in self.helpers.extract_words(
Expand Down Expand Up @@ -454,3 +451,16 @@ def gen_random_subdomains(self, n=50):
yield subdomain
for _ in range(5):
yield self.helpers.rand_string(length=8, digits=False)

def has_excessive_digits(self, d):
"""
Identifies dns names with excessive numbers, e.g.:
- w1-2-3.evilcorp.com
- ptr1234.evilcorp.com
"""
digits = self.digit_regex.findall(d)
excessive_digits = len(digits) > 2
long_digits = any(len(d) > 3 for d in digits)
if excessive_digits or long_digits:
return True
return False

0 comments on commit 15f4f48

Please sign in to comment.