AD CS (Active Directory Certificate Services) Pentesting
AD CS is Public Key Infrastructure (PKI) implementation. The misconfiguration of certificate templates can be vulnerable to privilege escalation.
Last updated
AD CS is Public Key Infrastructure (PKI) implementation. The misconfiguration of certificate templates can be vulnerable to privilege escalation.
Last updated
We can retrieve certificates information on target Windows machine using certutil
.
Then check if Allow Full Control
or Allow Write
include the group which current user belongs to. If so, we can modify the template and might be able to escalate privilege.
If you get the error like "Kerberos SessionError: KRB_AP_ERR_SKEW(Clock skew too great)", sync the time with AD server.
Now we get the NT hash so we can login the target machine using this hash by Pass-The-Hash.
Now we get the TGT (.kirbi
) file.
We can use it to the following parts:
Crack TGT
Pass-The-Ticket
If we find the template which contains vulnerable parameters, we can create a new certificate using the template and can gain access to the Administrator's account. There are some method to create the new one. However, this section provides the easiest way using MMC.
Right-click on the Windows icon, and select Run.
Enter “mmc” (Microsoft Management Console)* in the form and click OK. The console window opens.
In the MMC window, click File → Add/Remote Snap-in..
Add the “Certificates” snap-in in the window then click OK.
Expand the Certificates in the left pane.
Right-click on the Personal and select All Tasks → Request New Certificate.
The Certificate Enrollment window, click Next twice.
In Request Certificates section, click the “More information is required to enroll…”.
In Certificate Properties window, choose types and enter values in the form.
Subject name:
Type: Common name
Value: vulncert (specify an arbitrary name)
Alternative name:
Type: User principal name
Value: tester@abc.example.com (specify the impersonated name and the target domain)
Add each name and click OK.
Return to the Request Certificates section. Check on the certificate we want to request, then click Enroll.
After finishing, expand Personal → Certificates. We should see the new certificate is added.
Double-click on the certificate. The Certificate window opens.
In the Certificate window, select Details tab and choose Subject Alternative Name. We should see the principal name is our specified name e.g. tester@abc.example.com. If we can, click OK to close the window.
At the end, in the MMC window, right-click on the new certificate which we created and select All Tasks → Export… to export the certificate. The Certificate Export Wizard opens.
In Export Private Key section, select “Yes, export the private key” and click Next.
In Export File Format, it is usually okey the default .PFX format so click Next without any changes.
In Security section, check the Password and enter new password.
In File to Export section, enter the file name and Next.
Finally click Finish then we could export the new malicious certificate.
If we create a new certificate, we can use it to impersonate the privileged user.
Request Kerberos TGT (Ticket Granting Ticket).
After that, we should get the TGT (.kirbi file). We can gain access using the TGT by changing the password of the DA account.
Change the Password of the DA (Domain Administrator) Account.
Get the Administrator’s Shell
Using runas command, we can gain access to the Administrator’s account. Use the new password which we’ve given the previous section in prompt.
After adding new computer, we might be able to retrieve certificate using this computer account.
At this time, try using alternate UPN (-upn
) for administrator because we want to escalate privilege.
If successful, the file which contains certificates and private key (e.g. administrator.pfx
) will be saved in current directory.
We might be able to retrieve TGT using the .pfx
file as below.
Then using/cracking it to authenticate as Administrator.
According to the article above, we may be able to authenticate over some protocols such as LDAP(S). First off, split the administrator.pfx
with certificate and private key using two commands below.
We can use for finding vulnerable templates, requesting TGT, and authentication.
We can use for enumerating the templates and requesting certificate. It can be downloaded from .
is useful to do for that. For details, see .
We can use the addcomputer () which is usually used for AD CS (Active Directory Certificate Services) Privilege Escalation.
Reference:
After that, using , we can spawn shell as Administrator via Schannel against LDAP(S).