@@ -1183,7 +1183,6 @@ def output(sessions):
11831183 rpctransport = transport .SMBTransport (self .conn .getRemoteName (), self .conn .getRemoteHost (), filename = r"\winreg" , smb_connection = self .conn )
11841184 for binding_attempts in range (2 , 0 , - 1 ):
11851185 dce = rpctransport .get_dce_rpc ()
1186-
11871186 try :
11881187 dce .connect ()
11891188 dce .bind (rrp .MSRPC_UUID_RRP )
@@ -1193,7 +1192,6 @@ def output(sessions):
11931192 if binding_attempts == 1 : # Last attempt
11941193 self .logger .info (f"The Remote Registry service seems to be disabled on { self .hostname } ." )
11951194 return
1196-
11971195 # STATUS_PIPE_NOT_AVAILABLE : Waiting 1 second for the service to start (if idle and set to 'Automatic' startup type)
11981196 sleep (1 )
11991197
@@ -1205,9 +1203,9 @@ def output(sessions):
12051203 self .logger .info (f"Access denied while enumerating session using the Remote Registry on { self .hostname } ." )
12061204 return
12071205 else :
1208- self .logger .debug (f"Exception connecting to RPC on { self .hostname } : { e } " )
1206+ self .logger .fail (f"Exception connecting to RPC on { self .hostname } : { e } " )
12091207 except Exception as e :
1210- self .logger .debug (f"Exception connecting to RPC on { self .hostname } : { e } " )
1208+ self .logger .fail (f"Exception connecting to RPC on { self .hostname } : { e } " )
12111209
12121210 # Enumerate HKU subkeys and recover SIDs
12131211 sid_filter = "^S-1-.*\\ d$"
@@ -1225,8 +1223,13 @@ def output(sessions):
12251223 self .logger .info (f"User with SID { sid } is logged in on { self .hostname } " )
12261224 sessions .setdefault (sid , {"Username" : "" , "Domain" : "" })
12271225 index += 1
1228- except Exception :
1229- break
1226+ except rrp .DCERPCSessionError as e :
1227+ if "ERROR_NO_MORE_ITEMS" in str (e ):
1228+ self .logger .debug (f"No more items found in HKU on { self .hostname } ." )
1229+ break
1230+ else :
1231+ self .logger .fail (f"Error enumerating HKU subkeys on { self .hostname } : { e } " )
1232+ break
12301233
12311234 rrp .hBaseRegCloseKey (dce , key_handle )
12321235 dce .disconnect ()
0 commit comments