Skip to content

Commit 3860ba7

Browse files
committed
Simplify reg queries
1 parent b37c657 commit 3860ba7

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

nxc/modules/sccmrecon.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,8 @@ def on_login(self, context, connection):
5656
def EnumerateSS(self, dce, hRootKey):
5757
# Open the target registry key
5858
hkey = rrp.hBaseRegOpenKey(dce, hRootKey, "SOFTWARE\\Microsoft\\SMS")["phkResult"]
59-
60-
# Enumerate subkeys
61-
dwIndex = 0
62-
subkeys = []
63-
while True:
64-
try:
65-
ans = rrp.hBaseRegEnumKey(dce, hkey, dwIndex)
66-
subkeys.append(ans["lpNameOut"][:-1])
67-
dwIndex += 1
68-
except rrp.DCERPCSessionError as e:
69-
if "ERROR_NO_MORE_ITEMS" in str(e): # Stop when no more subkeys
70-
break
71-
else:
72-
self.context.log.fail(f"Got unexpected exception: {e}")
59+
num_keys = rrp.hBaseRegQueryInfoKey(dce, hkey)["lpcSubKeys"]
60+
subkeys = [rrp.hBaseRegEnumKey(dce, hkey, i)["lpNameOut"].rstrip("\x00") for i in range(num_keys)]
7361

7462
for subkey in subkeys:
7563
if subkey == "DP":

0 commit comments

Comments
 (0)