Skip to content

Commit 8452430

Browse files
authored
Merge pull request #152 from michael-dev/feature/changepw-from-certificate
asktgt /changepw support with /certificate
2 parents f6685f4 + c13534a commit 8452430

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Rubeus/Commands/Asktgt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public void Execute(Dictionary<string, string> arguments)
255255
else if (String.IsNullOrEmpty(certificate))
256256
Ask.TGT(user, domain, hash, encType, outfile, ptt, dc, luid, true, opsec, servicekey, changepw, pac, proxyUrl, service);
257257
else
258-
Ask.TGT(user, domain, certificate, password, encType, outfile, ptt, dc, luid, true, verifyCerts, servicekey, getCredentials, proxyUrl, service);
258+
Ask.TGT(user, domain, certificate, password, encType, outfile, ptt, dc, luid, true, verifyCerts, servicekey, getCredentials, proxyUrl, service, changepw);
259259

260260
return;
261261
}

Rubeus/lib/Ask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public static X509Certificate2 FindCertificate(string certificate, string storeP
186186
}
187187
}
188188

189-
public static byte[] TGT(string userName, string domain, string certFile, string certPass, Interop.KERB_ETYPE etype, string outfile, bool ptt, string domainController = "", LUID luid = new LUID(), bool describe = false, bool verifyCerts = false, string servicekey = "", bool getCredentials = false, string proxyUrl = null, string service = null) {
189+
public static byte[] TGT(string userName, string domain, string certFile, string certPass, Interop.KERB_ETYPE etype, string outfile, bool ptt, string domainController = "", LUID luid = new LUID(), bool describe = false, bool verifyCerts = false, string servicekey = "", bool getCredentials = false, string proxyUrl = null, string service = null, bool changepw = false) {
190190
try {
191191
X509Certificate2 cert = FindCertificate(certFile, certPass);
192192

@@ -206,7 +206,7 @@ public static X509Certificate2 FindCertificate(string certificate, string storeP
206206
Console.WriteLine("[*] Using PKINIT with etype {0} and subject: {1} ", etype, cert.Subject);
207207
Console.WriteLine("[*] Building AS-REQ (w/ PKINIT preauth) for: '{0}\\{1}'", domain, userName);
208208

209-
AS_REQ pkinitASREQ = AS_REQ.NewASReq(userName, domain, cert, agreement, etype, verifyCerts, service);
209+
AS_REQ pkinitASREQ = AS_REQ.NewASReq(userName, domain, cert, agreement, etype, verifyCerts, service, changepw);
210210
return InnerTGT(pkinitASREQ, etype, outfile, ptt, domainController, luid, describe, true, false, servicekey, getCredentials, proxyUrl);
211211

212212
} catch (KerberosErrorException ex) {

Rubeus/lib/krb_structures/AS_REQ.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static AS_REQ NewASReq(string userName, string domain, string keyString,
159159
}
160160

161161
//TODO: Insert DHKeyPair parameter also.
162-
public static AS_REQ NewASReq(string userName, string domain, X509Certificate2 cert, KDCKeyAgreement agreement, Interop.KERB_ETYPE etype, bool verifyCerts = false, string service = null) {
162+
public static AS_REQ NewASReq(string userName, string domain, X509Certificate2 cert, KDCKeyAgreement agreement, Interop.KERB_ETYPE etype, bool verifyCerts = false, string service = null, bool changepw = false) {
163163

164164
// build a new AS-REQ for the given userName, domain, and etype, w/ PA-ENC-TIMESTAMP
165165
// used for "legit" AS-REQs w/ pre-auth
@@ -198,11 +198,16 @@ public static AS_REQ NewASReq(string userName, string domain, X509Certificate2 c
198198
req.req_body.sname.name_string.Add(part);
199199
}
200200
}
201-
else
201+
else if (!changepw)
202202
{
203203
req.req_body.sname.name_string.Add("krbtgt");
204204
req.req_body.sname.name_string.Add(domain);
205205
}
206+
else
207+
{
208+
req.req_body.sname.name_string.Add("kadmin");
209+
req.req_body.sname.name_string.Add("changepw");
210+
}
206211

207212
// add in our encryption type
208213
req.req_body.etypes.Add(etype);

0 commit comments

Comments
 (0)