Skip to main content
PERSIST2 is a technique used to extend initial access to a machine into persistent access by requesting a client authentication certificate in the context of the machine account, which can be used for future authentication as the machine account. This requires administrative privileges on the system.

Template Requirements

According to Certified Pre-Owned, the following criteria comprise a suitable certificate template:
The enterprise CA grants enrollment rights to the machine account. Otherwise, the account would be unable to request any certificates from the CA.
The certificate template grants enrollment rights to the machine account. Otherwise, the account would be unable to request certificates based on the specific template.
The “manager approval” feature is disabled for the certificate template. Otherwise, a “CA Manager” would have to manually review and approve the certificate request.
The “authorized signature” feature is disabled for the certificate template. Otherwise, an enrollment agent would need to sign the certificate request on behalf of the requester.
The certificate template defines an Extended Key Usage (EKU) that enables client authentication:
  • Client Authentication (1.3.6.1.5.5.7.3.2)
  • PKINIT Client Authentication (1.3.6.1.5.2.3.4)
  • Smart Card Logon (1.3.6.1.4.1.311.20.2.2)
  • Any Purpose (2.5.29.37.0)
  • Subordinate CA (No EKUs)

Enumeration

We can search for certificate templates with these conditions using the enum-templates --filter-client-auth command from Certify. For more information about the command and its parameters, please refer to the Command Overview page.
Once we have identified a suitable certificate template that the machine account can enroll in, we can request a certificate based on the template using the request command from Certify.
Note the use of the --machine parameter to request a certificate for the machine account rather than the current user account.
When the certificate has been issued, it can be used to persistently authenticate as the machine account using the asktgt command from Rubeus.
The issued certificate will be able to authenticate for as long as is mentioned in the Validity Period attribute of the certificate template. In order to extend the persistence period, you need to abuse PERSIST3 - Account Persistence via Certificate Renewal.