Skip to content

Commit c2cb752

Browse files
committed
Fix ldap query output for output containing special chars, e.g. german äöü
1 parent 98c4b15 commit c2cb752

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

nxc/protocols/ldap.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -990,19 +990,20 @@ def query(self):
990990
self.logger.debug(f"Querying LDAP server with filter: {search_filter} and attributes: {attributes}")
991991
try:
992992
resp = self.search(search_filter, attributes, 0)
993+
resp_parsed = parse_result_attributes(resp)
993994
except LDAPFilterSyntaxError as e:
994995
self.logger.fail(f"LDAP Filter Syntax Error: {e}")
995996
return
996-
for item in resp:
997-
if isinstance(item, ldapasn1_impacket.SearchResultEntry) is not True:
998-
continue
999-
self.logger.success(f"Response for object: {item['objectName']}")
1000-
for attribute in item["attributes"]:
1001-
attr = f"{attribute['type']}:"
1002-
vals = str(attribute["vals"]).replace("\n", "")
1003-
if "SetOf: " in vals:
1004-
vals = vals.replace("SetOf: ", "")
1005-
self.logger.highlight(f"{attr:<20} {vals}")
997+
for idx, entry in enumerate(resp_parsed):
998+
self.logger.success(f"Response for object: {resp[idx]['objectName']}")
999+
for attribute in entry:
1000+
if isinstance(entry[attribute], list) and entry[attribute]:
1001+
# Display first item in the same line as attribute
1002+
self.logger.highlight(f"{attribute:<20} {entry[attribute].pop(0)}")
1003+
for item in entry[attribute]:
1004+
self.logger.highlight(f"{'':<20} {item}")
1005+
else:
1006+
self.logger.highlight(f"{attribute:<20} {entry[attribute]}")
10061007

10071008
def find_delegation(self):
10081009
def printTable(items, header):

0 commit comments

Comments
 (0)