Skip to content

Commit a651678

Browse files
committed
Add exception handling if no TLS cert is available
1 parent 8fb6334 commit a651678

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,23 @@ def get_ldap_username(self):
237237
def check_ldap_signing(self):
238238
self.signing_required = False
239239
ldap_url = f"ldap://{self.target}"
240-
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host, signing=False)
241240
try:
241+
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host, signing=False)
242242
ldap_connection.login(domain=self.domain)
243243
self.logger.debug(f"LDAP signing is not enforced on {self.host}")
244244
except ldap_impacket.LDAPSessionError as e:
245245
if str(e).find("strongerAuthRequired") >= 0:
246246
self.logger.debug(f"LDAP signing is enforced on {self.host}")
247247
self.signing_required = True
248+
else:
249+
raise
248250

249251
def check_ldaps_cbt(self):
250252
self.cbt_status = "Never"
251253
ldap_url = f"ldaps://{self.target}"
252-
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
253-
ldap_connection._LDAPConnection__channel_binding_value = None
254254
try:
255+
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
256+
ldap_connection._LDAPConnection__channel_binding_value = None
255257
ldap_connection.login(user=" ", domain=self.domain)
256258
except ldap_impacket.LDAPSessionError as e:
257259
if str(e).find("data 80090346") >= 0:
@@ -266,6 +268,15 @@ def check_ldaps_cbt(self):
266268
except ldap_impacket.LDAPSessionError as e:
267269
if str(e).find("data 80090346") >= 0:
268270
self.cbt_status = "When Supported" # CBT is When Supported
271+
else:
272+
raise
273+
except SysCallError as e:
274+
self.logger.debug(f"Received SysCallError when trying to enumerate channel binding support: {e!s}")
275+
if e.args[1] == "ECONNRESET":
276+
self.cbt_status = "No TLS cert"
277+
else:
278+
raise
279+
269280

270281
def enum_host_info(self):
271282
self.hostname = self.target.split(".")[0].upper() if "." in self.target else self.target

0 commit comments

Comments
 (0)