Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix connection issue with socks ldap #530

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions nxc/protocols/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def proto_logger(self):
)

def create_conn_obj(self):
target = ""
target_domain = ""
base_dn = ""
try:
proto = "ldaps" if (self.args.gmsa or self.port == 636) else "ldap"
ldap_url = f"{proto}://{self.host}"
Expand All @@ -187,9 +190,6 @@ def create_conn_obj(self):
for item in resp:
if isinstance(item, ldapasn1_impacket.SearchResultEntry) is not True:
continue
target = None
target_domain = None
base_dn = None
try:
for attribute in item["attributes"]:
if str(attribute["type"]) == "defaultNamingContext":
Expand All @@ -205,8 +205,9 @@ def create_conn_obj(self):
except Exception as e:
self.logger.debug("Exception:", exc_info=True)
self.logger.info(f"Skipping item, cannot process due to error {e}")
except OSError:
return False
except OSError as e:
self.logger.error(f"Error getting ldap info {e}")

self.logger.debug(f"Target: {target}; target_domain: {target_domain}; base_dn: {base_dn}")
self.target = target
self.targetDomain = target_domain
Expand All @@ -229,7 +230,7 @@ def get_ldap_username(self):

def enum_host_info(self):
self.baseDN = self.args.base_dn if self.args.base_dn else self.baseDN # Allow overwriting baseDN from args
self.hostname = self.target.split(".")[0].upper()
self.hostname = self.target.split(".")[0].upper() if "." in self.target else self.target
self.remoteName = self.target
self.domain = self.targetDomain

Expand Down
Loading