@@ -1106,7 +1106,7 @@ def format_row(procInfo):
11061106 procInfo ["pSid" ],
11071107 f"{ procInfo ['WorkingSetSize' ] // 1000 :,} K" ,
11081108 )
1109-
1109+
11101110 try :
11111111 with TSTS .LegacyAPI (self .conn , self .host , self .kerberos ) as legacy :
11121112 try :
@@ -1141,12 +1141,12 @@ def format_row(procInfo):
11411141 # If a process was suppliad to args.tasklist and it was not found, we print a fail message
11421142 if self .args .tasklist is not True and not found_task :
11431143 self .logger .fail (f"Didn't find process { self .args .tasklist } " )
1144-
1144+
11451145 except SessionError :
11461146 self .logger .fail ("Cannot list remote tasks, RDP is probably disabled." )
11471147
11481148 def reg_sessions (self ):
1149-
1149+
11501150 def output (sessions ):
11511151 if sessions :
11521152 # Calculate max lengths for formatting
@@ -1164,7 +1164,7 @@ def output(sessions):
11641164
11651165 # Store result
11661166 result = [header , header2 ]
1167-
1167+
11681168 for sid , vals in sessions .items ():
11691169 username = vals ["Username" ]
11701170 domain = vals ["Domain" ]
@@ -1214,11 +1214,11 @@ def output(sessions):
12141214 # Enumerate HKU subkeys and recover SIDs
12151215 sid_filter = "^S-1-.*\\ d$"
12161216 exclude_sid = ["S-1-5-18" , "S-1-5-19" , "S-1-5-20" ]
1217-
1217+
12181218 key_handle = resp ["phKey" ]
12191219 index = 1
12201220 sessions = {}
1221-
1221+
12221222 while True :
12231223 try :
12241224 resp = rrp .hBaseRegEnumKey (dce , key_handle , index )
@@ -1236,7 +1236,7 @@ def output(sessions):
12361236 if not sessions :
12371237 self .logger .info (f"No sessions found via the Remote Registry service on { self .hostname } ." )
12381238 return
1239-
1239+
12401240 # Bind to the LSARPC Pipe for SID resolution
12411241 rpctransport = transport .SMBTransport (self .conn .getRemoteName (), self .conn .getRemoteHost (), filename = r"\lsarpc" , smb_connection = self .conn )
12421242 dce = rpctransport .get_dce_rpc ()
@@ -1247,7 +1247,7 @@ def output(sessions):
12471247 self .logger .debug (f"Failed to connect to LSARPC for SID resolution on { self .hostname } : { e } " )
12481248 output (sessions )
12491249 return
1250-
1250+
12511251 # Resolve SIDs with names
12521252 policy_handle = lsad .hLsarOpenPolicy2 (dce , MAXIMUM_ALLOWED | lsat .POLICY_LOOKUP_NAMES )["PolicyHandle" ]
12531253 try :
@@ -1259,13 +1259,13 @@ def output(sessions):
12591259 else :
12601260 resp = None
12611261 self .logger .debug (f"Could not resolve SID(s): { e } " )
1262-
1262+
12631263 if resp :
12641264 for sid , item in zip (sessions .keys (), resp ["TranslatedNames" ]["Names" ], strict = False ):
12651265 if item ["DomainIndex" ] >= 0 :
12661266 sessions [sid ]["Username" ] = item ["Name" ]
12671267 sessions [sid ]["Domain" ] = resp ["ReferencedDomains" ]["Domains" ][item ["DomainIndex" ]]["Name" ]
1268-
1268+
12691269 # Filter for usernames
12701270 if self .args .reg_sessions :
12711271 arg = self .args .reg_sessions
@@ -1274,7 +1274,7 @@ def output(sessions):
12741274 usernames = [line .strip ().lower () for line in f if line .strip ()]
12751275 else :
12761276 usernames = [arg .lower ()]
1277-
1277+
12781278 filtered_sessions = {}
12791279 for sid , info in sessions .items ():
12801280 if info ["Username" ].lower () not in usernames :
@@ -1284,7 +1284,7 @@ def output(sessions):
12841284 output (filtered_sessions )
12851285 else :
12861286 output (sessions )
1287-
1287+
12881288 def shares (self ):
12891289 temp_dir = ntpath .normpath ("\\ " + gen_random_string ())
12901290 temp_file = ntpath .normpath ("\\ " + gen_random_string () + ".txt" )
@@ -1399,7 +1399,7 @@ def shares(self):
13991399 self .logger .display ("Enumerated shares" )
14001400 self .logger .highlight (f"{ 'Share' :<15} { 'Permissions' :<15} { 'Remark' } " )
14011401 self .logger .highlight (f"{ '-----' :<15} { '-----------' :<15} { '------' } " )
1402-
1402+
14031403 for share in permissions :
14041404 name = share ["name" ]
14051405 remark = share ["remark" ]
0 commit comments