Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PKINIT Authentication Minor Improvements #198

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Rubeus/lib/Ask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,19 @@ public static byte[] TGS(string userName, string domain, Ticket providedTicket,

// convert the key string to bytes
byte[] key;
if (GetPKInitRequest(asReq, out PA_PK_AS_REQ pkAsReq)) {
if (GetPKInitRequest(asReq, out PA_PK_AS_REQ pkAsReq)) {
// generate the decryption key using Diffie Hellman shared secret
PA_PK_AS_REP pkAsRep = (PA_PK_AS_REP)rep.padata[0].value;
// First find the padata type that is PK_AS_REP. Certain authentications can have multiple.
int i;
for (i = 0; i < rep.padata.Count; i++)
{
if (rep.padata[i].type == Interop.PADATA_TYPE.PK_AS_REP)
{
break;
}
}
// Use the found padata type and convert to PK_AS_REP
PA_PK_AS_REP pkAsRep = (PA_PK_AS_REP)rep.padata[i].value;
key = pkAsReq.Agreement.GenerateKey(pkAsRep.DHRepInfo.KDCDHKeyInfo.SubjectPublicKey.DepadLeft(), new byte[0],
pkAsRep.DHRepInfo.ServerDHNonce, GetKeySize(etype));
} else {
Expand Down
8 changes: 5 additions & 3 deletions Rubeus/lib/krb_structures/AS_REP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ private void Decode(AsnElt asn_AS_REP)
break;
case 2:
// sequence of pa-data
foreach(AsnElt pad in s.Sub) {
padata.Add(new PA_DATA(pad.Sub[0]));
}
int i;
for (i = 0; i < s.Sub[0].Sub.Length; i++)
{
padata.Add(new PA_DATA(s.Sub[0].Sub[i]));
}
break;
case 3:
crealm = Encoding.UTF8.GetString(s.Sub[0].GetOctetString());
Expand Down
1 change: 1 addition & 0 deletions Rubeus/lib/krb_structures/PA_DATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public PA_DATA(X509Certificate2 pkInitCert, KDCKeyAgreement agreement, KDCReqBod
byte[] pubKeyInfo = AsnElt.Make(AsnElt.SEQUENCE, new AsnElt[] {
AsnElt.MakeInteger(agreement.P),
AsnElt.MakeInteger(agreement.G),
AsnElt.MakeInteger(agreement.Q),
}).Encode();

authPack.ClientPublicValue = new KrbSubjectPublicKeyInfo(new KrbAlgorithmIdentifier(DiffieHellman, pubKeyInfo),
Expand Down
6 changes: 2 additions & 4 deletions Rubeus/lib/krb_structures/PA_PK_AS_REQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ public AsnElt Encode() {
signed.ComputeSignature(signer, silent: false);

return AsnElt.Make(AsnElt.SEQUENCE, new AsnElt[] {
AsnElt.Make(AsnElt.CONTEXT, 0, new AsnElt[]{
AsnElt.MakeBlob(signed.Encode())
//AsnElt.Decode(signed.Encode())
})
// SignedAuthPack must be implict for wireshark
AsnElt.MakeImplicit(AsnElt.CONTEXT, 0, AsnElt.MakeBlob(signed.Encode()))
});
}
}
Expand Down