Skip to content

Commit f981215

Browse files
authored
Merge pull request Pennyw0rth#952 from Pennyw0rth/neff-fix-bh-stacktrace
Catch dns resolver issue when domain can't be resolved
2 parents 1f04ce2 + bc5e842 commit f981215

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,7 @@ def bloodhound(self):
16091609
self.logger.fail("Or if you installed with pipx:")
16101610
self.logger.fail("pipx runpip netexec uninstall -y bloodhound")
16111611
self.logger.fail("pipx inject netexec bloodhound-ce --force")
1612-
return False
1612+
return
16131613

16141614
elif not use_bhce and is_ce:
16151615
self.logger.fail("⚠️ Configuration Issue Detected ⚠️")
@@ -1623,7 +1623,7 @@ def bloodhound(self):
16231623
self.logger.fail("Or if you installed with pipx:")
16241624
self.logger.fail("pipx runpip netexec uninstall -y bloodhound-ce")
16251625
self.logger.fail("pipx inject netexec bloodhound --force")
1626-
return False
1626+
return
16271627

16281628
auth = ADAuthentication(
16291629
username=self.username,
@@ -1644,11 +1644,15 @@ def bloodhound(self):
16441644
)
16451645
collect = resolve_collection_methods("Default" if not self.args.collection else self.args.collection)
16461646
if not collect:
1647-
return None
1647+
return
16481648
self.logger.highlight("Resolved collection methods: " + ", ".join(list(collect)))
16491649

16501650
self.logger.debug("Using DNS to retrieve domain information")
1651-
ad.dns_resolve(domain=self.domain)
1651+
try:
1652+
ad.dns_resolve(domain=self.domain)
1653+
except (resolver.LifetimeTimeout, resolver.NoNameservers):
1654+
self.logger.fail("Bloodhound-python failed to resolve domain information, try specifying the DNS server.")
1655+
return
16521656

16531657
if self.args.kerberos:
16541658
self.logger.highlight("Using kerberos auth without ccache, getting TGT")
@@ -1661,16 +1665,21 @@ def bloodhound(self):
16611665
bloodhound = BloodHound(ad, self.hostname, self.host, self.port)
16621666
bloodhound.connect()
16631667

1664-
bloodhound.run(
1665-
collect=collect,
1666-
num_workers=10,
1667-
disable_pooling=False,
1668-
timestamp=timestamp,
1669-
fileNamePrefix=self.output_filename.split("/")[-1],
1670-
computerfile=None,
1671-
cachefile=None,
1672-
exclude_dcs=False,
1673-
)
1668+
try:
1669+
bloodhound.run(
1670+
collect=collect,
1671+
num_workers=10,
1672+
disable_pooling=False,
1673+
timestamp=timestamp,
1674+
fileNamePrefix=self.output_filename.split("/")[-1],
1675+
computerfile=None,
1676+
cachefile=None,
1677+
exclude_dcs=False,
1678+
)
1679+
except Exception as e:
1680+
self.logger.fail(f"BloodHound collection failed: {e.__class__.__name__} - {e}")
1681+
self.logger.debug(f"BloodHound collection failed: {e.__class__.__name__} - {e}", exc_info=True)
1682+
return
16741683

16751684
self.output_filename += f"_{timestamp}"
16761685

0 commit comments

Comments
 (0)