Skip to content

Commit 7e2a75e

Browse files
committed
Parse ldap response instead of manual iteration
1 parent f8293d1 commit 7e2a75e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

nxc/protocols/ldap.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,14 @@ def check_if_admin(self):
578578
search_filter = "(userAccountControl:1.2.840.113556.1.4.803:=8192)"
579579
attributes = ["objectSid"]
580580
resp = self.search(search_filter, attributes, sizeLimit=0)
581+
resp_parsed = parse_result_attributes(resp)
582+
from pprint import pprint
583+
pprint(resp_parsed)
581584
answers = []
582585
if resp and (self.password != "" or self.lmhash != "" or self.nthash != "" or self.aesKey != "") and self.username != "":
583-
for attribute in resp[0][1]:
584-
if str(attribute["type"]) == "objectSid":
585-
sid = self.sid_to_str(attribute["vals"][0])
586-
self.sid_domain = "-".join(sid.split("-")[:-1])
586+
sid = self.sid_to_str(resp_parsed[0]["objectSid"])
587+
print(sid)
588+
self.sid_domain = "-".join(sid.split("-")[:-1])
587589

588590
# 2. get all group cn name
589591
search_filter = "(|(objectSid=" + self.sid_domain + "-512)(objectSid=" + self.sid_domain + "-544)(objectSid=" + self.sid_domain + "-519)(objectSid=S-1-5-32-549)(objectSid=S-1-5-32-551))"

0 commit comments

Comments
 (0)