Skip to content

Commit db7c590

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

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

nxc/modules/sccmrecon.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,10 @@ def EnumerateDP(self, dce, hRootKey):
101101
def EnumerateDB(self, dce, hRootKey):
102102
# Check for database site
103103
hkey = rrp.hBaseRegOpenKey(dce, hRootKey, "SOFTWARE\\Microsoft\\SMS\\COMPONENTS\\SMS_SITE_COMPONENT_MANAGER\\Multisite Component Servers")["phkResult"]
104+
num_keys = rrp.hBaseRegQueryInfoKey(dce, hkey)["lpcSubKeys"]
105+
subkeys = [rrp.hBaseRegEnumKey(dce, hkey, i)["lpNameOut"].rstrip("\x00") for i in range(num_keys)]
104106

105-
# Enumerate subkeys
106-
dwIndex = 0
107-
subkeys = []
108-
while True:
109-
try:
110-
ans = rrp.hBaseRegEnumKey(dce, hkey, dwIndex)
111-
subkeys.append(ans["lpNameOut"][:-1])
112-
dwIndex += 1
113-
except rrp.DCERPCSessionError as e:
114-
if "ERROR_NO_MORE_ITEMS" in str(e): # Stop when no more subkeys
115-
break
116-
else:
117-
self.context.log.fail(f"Got unexpected exception: {e}")
118-
119-
nbSiteDB = len(subkeys)
120-
if nbSiteDB == 0:
107+
if num_keys == 0:
121108
self.context.log.success("Local Site Database")
122109
else:
123110
for subkey in subkeys:

0 commit comments

Comments
 (0)