From 560e8ab1f4aa41b4d0d1de5bdba42b7d831f5a43 Mon Sep 17 00:00:00 2001 From: "Remi GASCOU (Podalirius)" <79218792+p0dalirius@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:17:36 +0200 Subject: [PATCH] Fix unreachable target-properties guard in LAPSio.set() (Fixes #8) The filtering loop rebound results, the name it was iterating, to the last response dict, so len(results) == 0 tested a dict's key count and the guard could never fire; a target computer that was not found also crashed in paged_search() with a None search base before reaching it. Collect the searchResEntry responses into a separate list and return early when the target computer does not exist. --- pyLAPS.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pyLAPS.py b/pyLAPS.py index 3ca7024..86775c8 100644 --- a/pyLAPS.py +++ b/pyLAPS.py @@ -257,8 +257,9 @@ def set(self, sAMAccountName, value): except IndexError: print("[!] Computer not found in LDAP: %s" % sAMAccountName) - if dn is None and sid is None: + if dn is None: print("[!] Target computer does not exist! (wrong domain?)") + return else: print("[+] Target computer found: %s" % dn) @@ -267,11 +268,8 @@ def set(self, sAMAccountName, value): '(&(objectCategory=computer)(objectClass=*))', attributes=['sAMAccountName', 'objectSid', 'ms-Mcs-AdmPwd'] )) - for entry in results: - if entry['type'] != 'searchResEntry': - continue - results = entry - if len(results) == 0: + entries = [entry for entry in results if entry['type'] == 'searchResEntry'] + if len(entries) == 0: print("[!] Could not query target computer properties.") return