Skip to content

Commit 4767762

Browse files
committed
Rename ldapConnection to the new ldap_connection var
1 parent 4a8e702 commit 4767762

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(self, args, db, host):
134134
self.server_os = None
135135
self.os_arch = 0
136136
self.hash = None
137-
self.ldapConnection = None
137+
self.ldap_connection = None
138138
self.lmhash = ""
139139
self.nthash = ""
140140
self.baseDN = ""
@@ -302,8 +302,8 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
302302
proto = "ldaps" if (self.args.gmsa or self.port == 636) else "ldap"
303303
ldap_url = f"{proto}://{self.target}"
304304
self.logger.info(f"Connecting to {ldap_url} - {self.baseDN} - {self.host} [1]")
305-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
306-
self.ldapConnection.kerberosLogin(username, password, domain, self.lmhash, self.nthash, aesKey, kdcHost=kdcHost, useCache=useCache)
305+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
306+
self.ldap_connection.kerberosLogin(username, password, domain, self.lmhash, self.nthash, aesKey, kdcHost=kdcHost, useCache=useCache)
307307
if self.username == "":
308308
self.username = self.get_ldap_username()
309309

@@ -347,8 +347,8 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
347347
self.logger.extra["port"] = "636"
348348
ldaps_url = f"ldaps://{self.target}"
349349
self.logger.info(f"Connecting to {ldaps_url} - {self.baseDN} - {self.host} [2]")
350-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
351-
self.ldapConnection.kerberosLogin(username, password, domain, self.lmhash, self.nthash, aesKey, kdcHost=kdcHost, useCache=useCache)
350+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
351+
self.ldap_connection.kerberosLogin(username, password, domain, self.lmhash, self.nthash, aesKey, kdcHost=kdcHost, useCache=useCache)
352352
if self.username == "":
353353
self.username = self.get_ldap_username()
354354

@@ -404,8 +404,8 @@ def plaintext_login(self, domain, username, password):
404404
proto = "ldaps" if (self.args.gmsa or self.port == 636) else "ldap"
405405
ldap_url = f"{proto}://{self.target}"
406406
self.logger.info(f"Connecting to {ldap_url} - {self.baseDN} - {self.host} [3]")
407-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
408-
self.ldapConnection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
407+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldap_url, baseDN=self.baseDN, dstIp=self.host)
408+
self.ldap_connection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
409409
self.check_if_admin()
410410

411411
# Prepare success credential text
@@ -425,8 +425,8 @@ def plaintext_login(self, domain, username, password):
425425
self.logger.extra["port"] = "636"
426426
ldaps_url = f"ldaps://{self.target}"
427427
self.logger.info(f"Connecting to {ldaps_url} - {self.baseDN} - {self.host} [4]")
428-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
429-
self.ldapConnection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
428+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
429+
self.ldap_connection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
430430
self.check_if_admin()
431431

432432
# Prepare success credential text
@@ -490,8 +490,8 @@ def hash_login(self, domain, username, ntlm_hash):
490490
proto = "ldaps" if (self.args.gmsa or self.port == 636) else "ldap"
491491
ldaps_url = f"{proto}://{self.target}"
492492
self.logger.info(f"Connecting to {ldaps_url} - {self.baseDN} - {self.host}")
493-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
494-
self.ldapConnection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
493+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
494+
self.ldap_connection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
495495
self.check_if_admin()
496496

497497
# Prepare success credential text
@@ -511,8 +511,8 @@ def hash_login(self, domain, username, ntlm_hash):
511511
self.logger.extra["port"] = "636"
512512
ldaps_url = f"{proto}://{self.target}"
513513
self.logger.info(f"Connecting to {ldaps_url} - {self.baseDN} - {self.host}")
514-
self.ldapConnection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
515-
self.ldapConnection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
514+
self.ldap_connection = ldap_impacket.LDAPConnection(url=ldaps_url, baseDN=self.baseDN, dstIp=self.host)
515+
self.ldap_connection.login(self.username, self.password, self.domain, self.lmhash, self.nthash)
516516
self.check_if_admin()
517517

518518
# Prepare success credential text
@@ -605,12 +605,12 @@ def getUnixTime(self, t):
605605

606606
def search(self, searchFilter, attributes, sizeLimit=0) -> list:
607607
try:
608-
if self.ldapConnection:
608+
if self.ldap_connection:
609609
self.logger.debug(f"Search Filter={searchFilter}")
610610

611611
# Microsoft Active Directory set an hard limit of 1000 entries returned by any search
612612
paged_search_control = ldapasn1_impacket.SimplePagedResultsControl(criticality=True, size=1000)
613-
return self.ldapConnection.search(
613+
return self.ldap_connection.search(
614614
searchBase=self.baseDN,
615615
searchFilter=searchFilter,
616616
attributes=attributes,
@@ -1158,7 +1158,7 @@ def password_not_required(self):
11581158
searchFilter = "(userAccountControl:1.2.840.113556.1.4.803:=32)"
11591159
try:
11601160
self.logger.debug(f"Search Filter={searchFilter}")
1161-
resp = self.ldapConnection.search(
1161+
resp = self.ldap_connection.search(
11621162
searchBase=self.baseDN,
11631163
searchFilter=searchFilter,
11641164
attributes=[
@@ -1286,7 +1286,7 @@ def admin_count(self):
12861286
def gmsa(self):
12871287
self.logger.display("Getting GMSA Passwords")
12881288
search_filter = "(objectClass=msDS-GroupManagedServiceAccount)"
1289-
gmsa_accounts = self.ldapConnection.search(
1289+
gmsa_accounts = self.ldap_connection.search(
12901290
searchBase=self.baseDN,
12911291
searchFilter=search_filter,
12921292
attributes=[
@@ -1339,7 +1339,7 @@ def gmsa_convert_id(self):
13391339
else:
13401340
# getting the gmsa account
13411341
search_filter = "(objectClass=msDS-GroupManagedServiceAccount)"
1342-
gmsa_accounts = self.ldapConnection.search(
1342+
gmsa_accounts = self.ldap_connection.search(
13431343
searchBase=self.baseDN,
13441344
searchFilter=search_filter,
13451345
attributes=["sAMAccountName"],
@@ -1369,7 +1369,7 @@ def gmsa_decrypt_lsa(self):
13691369
gmsa_pass = gmsa[1]
13701370
# getting the gmsa account
13711371
search_filter = "(objectClass=msDS-GroupManagedServiceAccount)"
1372-
gmsa_accounts = self.ldapConnection.search(
1372+
gmsa_accounts = self.ldap_connection.search(
13731373
searchBase=self.baseDN,
13741374
searchFilter=search_filter,
13751375
attributes=["sAMAccountName"],

0 commit comments

Comments
 (0)