Skip to content

Commit fb96e78

Browse files
authored
Merge pull request Pennyw0rth#530 from Pennyw0rth/ldap_socks
fix connection issue with socks ldap
2 parents 56e9222 + 3ec787c commit fb96e78

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 7 additions & 6 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,8 +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
208+
except OSError as e:
209+
self.logger.error(f"Error getting ldap info {e}")
210+
210211
self.logger.debug(f"Target: {target}; target_domain: {target_domain}; base_dn: {base_dn}")
211212
self.target = target
212213
self.targetDomain = target_domain
@@ -229,7 +230,7 @@ def get_ldap_username(self):
229230

230231
def enum_host_info(self):
231232
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()
233+
self.hostname = self.target.split(".")[0].upper() if "." in self.target else self.target
233234
self.remoteName = self.target
234235
self.domain = self.targetDomain
235236

0 commit comments

Comments
 (0)