Skip to content

Commit 8f96e01

Browse files
committed
Fix AttributeError in LDAPS channel binding check with Kerberos auth
1 parent 4fc571c commit 8f96e01

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ def check_ldaps_cbt(self):
233233
ldap_url = f"ldaps://{self.target}"
234234
try:
235235
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
236+
237+
# Check if the attribute exists before accessing it
238+
if not hasattr(ldap_connection, "_LDAPConnection__channel_binding_value"):
239+
self.logger.debug("LDAPConnection does not support channel binding value attribute")
240+
self.cbt_status = "Unknown"
241+
return
242+
236243
ldap_connection._LDAPConnection__channel_binding_value = None
237244
ldap_connection.login(user=" ", domain=self.domain)
238245
except ldap_impacket.LDAPSessionError as e:
@@ -242,6 +249,13 @@ def check_ldaps_cbt(self):
242249
# Login failed (wrong credentials). test if we get an error with an existing, but wrong CBT -> When supported
243250
elif str(e).find("data 52e") >= 0:
244251
ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
252+
253+
# Check if the attribute exists before accessing it
254+
if not hasattr(ldap_connection, "_LDAPConnection__channel_binding_value"):
255+
self.logger.debug("LDAPConnection does not support channel binding value attribute")
256+
self.cbt_status = "Unknown"
257+
return
258+
245259
new_cbv = bytearray(ldap_connection._LDAPConnection__channel_binding_value)
246260
new_cbv[15] = (new_cbv[3] + 1) % 256
247261
ldap_connection._LDAPConnection__channel_binding_value = bytes(new_cbv)

0 commit comments

Comments
 (0)