private void ProcessKdcProxy(KdcProxyMessage proxyMessage, string source) { var message = proxyMessage.UnwrapMessage(); var kdcBody = new { AsReq = TryDecode(message, m => KrbAsReq.DecodeApplication(m)), AsRep = TryDecode(message, m => KrbAsRep.DecodeApplication(m)), TgsReq = TryDecode(message, m => KrbTgsReq.DecodeApplication(m)), TgsRep = TryDecode(message, m => KrbTgsRep.DecodeApplication(m)), KrbError = TryDecode(message, m => KrbError.DecodeApplication(m)) }; if (kdcBody.AsReq != null) { ExplodeObject(kdcBody.AsReq, $"AS-REQ ({source})"); } else if (kdcBody.AsRep != null) { ExplodeObject(kdcBody.AsRep, $"AS-REP ({source})"); } else if (kdcBody.TgsReq != null) { ExplodeObject(kdcBody.TgsReq, $"TGS-REQ ({source})"); } else if (kdcBody.TgsRep != null) { ExplodeObject(kdcBody.TgsRep, $"TGS-REP ({source})"); } else if (kdcBody.KrbError != null) { ExplodeObject(kdcBody.KrbError, $"Krb-Error ({source})"); } }
private static KrbAsRep RequestTgt(out KrbEncryptionKey sessionKey) { var cred = new KerberosPasswordCredential(Upn, "P@ssw0rd!") { // cheating by skipping the initial leg of requesting PA-type Salts = new[] { new KeyValuePair <EncryptionType, string>( EncryptionType.AES256_CTS_HMAC_SHA1_96, "*****@*****.**" ) }, Configuration = Krb5Config.Default() }; var asReq = KrbAsReq.CreateAsReq( cred, AuthenticationOptions.AllAuthentication ); var handler = new KdcAsReqMessageHandler(asReq.EncodeApplication(), new KdcServerOptions { DefaultRealm = Realm, IsDebug = true, RealmLocator = realm => new FakeRealmService(realm) }); handler.PreAuthHandlers[PaDataType.PA_ENC_TIMESTAMP] = service => new PaDataTimestampHandler(service); var results = handler.Execute(); var decoded = KrbAsRep.DecodeApplication(results); var decrypted = cred.DecryptKdcRep( decoded, KeyUsage.EncAsRepPart, d => KrbEncAsRepPart.DecodeApplication(d) ); sessionKey = decrypted.Key; return(decoded); }