Skip to content

Commit 7296e3c

Browse files
committed
fix connection issue with socks ldap
1 parent 131e29e commit 7296e3c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def proto_logger(self):
162162
)
163163

164164
def create_conn_obj(self):
165+
target = ""
166+
target_domain = ""
167+
base_dn = ""
165168
try:
166169
proto = "ldaps" if (self.args.gmsa or self.port == 636) else "ldap"
167170
ldap_url = f"{proto}://{self.host}"
@@ -187,9 +190,6 @@ def create_conn_obj(self):
187190
for item in resp:
188191
if isinstance(item, ldapasn1_impacket.SearchResultEntry) is not True:
189192
continue
190-
target = None
191-
target_domain = None
192-
base_dn = None
193193
try:
194194
for attribute in item["attributes"]:
195195
if str(attribute["type"]) == "defaultNamingContext":
@@ -205,9 +205,9 @@ def create_conn_obj(self):
205205
except Exception as e:
206206
self.logger.debug("Exception:", exc_info=True)
207207
self.logger.info(f"Skipping item, cannot process due to error {e}")
208-
except OSError:
209-
return False
210-
self.logger.debug(f"Target: {target}; target_domain: {target_domain}; base_dn: {base_dn}")
208+
except OSError as e:
209+
self.logger.error(f"Error getting ldap info { str(e) }")
210+
211211
self.target = target
212212
self.targetDomain = target_domain
213213
self.baseDN = base_dn
@@ -229,7 +229,7 @@ def get_ldap_username(self):
229229

230230
def enum_host_info(self):
231231
self.baseDN = self.args.base_dn if self.args.base_dn else self.baseDN # Allow overwriting baseDN from args
232-
self.hostname = self.target.split(".")[0].upper()
232+
self.hostname = self.target.split(".")[0].upper() if "." in self.target else self.target
233233
self.remoteName = self.target
234234
self.domain = self.targetDomain
235235

0 commit comments

Comments
 (0)