@@ -449,7 +449,7 @@ def valid_nthash(self, nthash):
449449 return Result (True , '' )
450450
451451 def valid_ticket (self , ticket_file ):
452- return valid_file (ticket_file )
452+ return valid_file (ticket_file , mode = '600' )
453453
454454 # Allows various modules to set the domain during enumeration. The domain can only be set once.
455455 # Currently, we rely on the information gained via unauth smb session to guess the domain.
@@ -3147,18 +3147,21 @@ def valid_domain(domain):
31473147 return True
31483148 return False
31493149
3150- def valid_file (file , mode = os . R_OK ):
3150+ def valid_file (file , mode = None ):
31513151 if not os .path .exists (file ):
31523152 return Result (False , f'File { file } does not exist' )
31533153
3154- if os .stat (file ).st_size == 0 :
3154+ stat = os .stat (file )
3155+ if stat .st_size == 0 :
31553156 return Result (False , f'File { file } is empty' )
31563157
3157- if not os .access (file , mode ):
3158- if mode == os .R_OK :
3159- return Result (False , f'Cannot read file { file } ' )
3160- if mode == os .W_OK :
3161- return Result (False , f'Cannot write file { file } ' )
3158+ cur_mode = oct (stat .st_mode )[- 3 :]
3159+ if mode and not cur_mode == mode :
3160+ return Result (False , f'File permissions for { file } are currently set to { cur_mode } , but Samba tools require { mode } ' )
3161+
3162+ if not os .access (file , os .R_OK ):
3163+ return Result (False , f'Cannot read file { file } ' )
3164+
31623165
31633166 return Result (True , '' )
31643167
0 commit comments