
Modulo PowerShell personalizzato per configurare un ambiente di laboratorio Active Directory per praticare test di penetrazione.
Lo scopo di questo modulo è automatizzare la distribuzione di un laboratorio Active Directory per praticare il penetration testing interno.
Ringraziamenti a Joe Helle e al suo corso PowerShell for Pentesters per la generazione dei vettori di attacco.
PSModulePath# Display PSModulePath
$env:PSModulePath.split(";")
# Move module to path
Move-Item .\ADLab\ "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\"
# Import global module
Import-Module ADLab
# Import local module
Import-Module .\ADLab.psm1
Questa funzione prepara la VM/computer corrente per essere utilizzato come controller di dominio per la nuova foresta. Imposta un indirizzo IP statico, imposta il server DNS su localhost e rinomina il computer.
# Prepare the current VM with all default values while displaying verbose output
Invoke-DCPrep -Verbose
# Set custom hostname and use Google DNS for Internet access
Invoke-DCPrep -Hostname "DC" -NewIPv4DNSServer "8.8.8.8"
# Use custom IP and default gateway and display verbose output
Invoke-DCPrep -Verbose -NewIPv4Address "192.168.1.99" -NewIPv4Gateway "192.168.1.1"
La funzione installa la funzionalità AD DS e configura una nuova foresta Active Directory, senza richiedere input utente. Riavvia il computer al termine.
# Installs a new forest with FQDN of "bufu-sec.local" with default DSRM password of "Password!"
Invoke-ForestDeploy -Domain bufu-sec.local
# Installs a new forest with FQDN of "bufu-sec.local" with the DSRM password set to "P@ssword!" and displaying debug messages
Invoke-ForestDeploy -Domain "bufu-sec.local" -DSRMPassword "P@ssword!" -Verbose
La funzione inizia installando la funzionalità DNS. Aggiunge quindi la zona primaria e configura il forwarder del server.
# Install and configure DNS on the current host and display verbose output.
Invoke-DNSDeploy -Verbose -NetworkID 192.168.47.0/24 -ZoneFile "47.168.192.in-addr.arpa.dns" -ServerForwarder 1.1.1.1
La funzione inizia installando la funzionalità DHCP sulla macchina corrente. Aggiunge quindi i gruppi di sicurezza necessari e autorizza il nuovo server DHCP con il controller di dominio. Infine, configura il nuovo ambito DHCP con i valori forniti.
# Install and configure DHCP on the local DC.
Invoke-DHCPDeploy -Verbose -ScopeName "Default" -ScopeID 192.168.47.0 -StartIP 192.168.47.100 -EndIP 192.168.47.200 -SubnetMask 255.255.255.0 -DNSServer 192.168.47.10 -Router 192.168.47.10
# Install and configure DHCP on the specified DC.
Invoke-DHCPDeploy -Verbose -ScopeName "Default" -ScopeID 192.168.47.0 -StartIP 192.168.47.100 -EndIP 192.168.47.200 -SubnetMask 255.255.255.0 -DNSServer 192.168.47.10 -Router 192.168.47.10 -DCFQDN DC01.bufu-sec.local
La funzione inizia creando i gruppi e le OU definiti nella variabile globale Groups. Genera quindi 10 oggetti utente per ogni OU per impostazione predefinita.
# Fill forest with objects and display verbose output
Invoke-ADLabConfig -Verbose
# Create 50 users for each OU and display verbose output
Invoke-ADLabConfig -Verbose -UserCount 50
La funzione ottiene un certo numero di utenti casuali dal dominio e imposta il flag DoesNotRequirePreAuth per ciascuno. Esclude account predefiniti come Administrator e krbtgt. Rende il 5% degli utenti ASREP-Roastable per impostazione predefinita.
# Make 5% of users ASREP-Roastable and display verbose output
Set-ASREPRoasting -Verbose
# Make 10 random users in the domain ASREP-Roastable
Set-ASREPRoasting -VulnerableUsersCount 10
# Make user bufu ASREP-Roastable and display verbose output
Set-ASREPRoasting -Users bufu -Verbose
# Make supplied list of users ASREP-roastable and display verbose output
Set-ASREPRoasting -Users ("bufu", "pepe") -Verbose
La funzione ottiene un certo numero di utenti casuali dal dominio e aggiunge un SPN per ciascuno. Esclude account predefiniti come Administrator e krbtgt. Rende il 5% degli utenti kerberoastable per impostazione predefinita.
# Make 5% of users ASREP-Roastable and display verbose output
Set-Kerberoasting -Verbose
# Make 10 random users in the domain ASREP-Roastable
Set-Kerberoasting -VulnerableUsersCount 10
# Make user bufu ASREP-Roastable and display verbose output
Set-Kerberoasting -Users bufu -Verbose
# Make supplied list of users ASREP-roastable and display verbose output
Set-Kerberoasting -Users ("bufu", "pepe") -Verbose
La funzione inizia concedendo al gruppo Chads i diritti GenericAll su Domain Admins. Concede quindi al gruppo Degens i diritti GenericAll sul gruppo Chads. Infine, concede diritti GenericAll su alcuni utenti del gruppo Degens ad alcuni utenti del gruppo Normies.
# Create vulnerable ACLs and display verbose output
Set-BadACLs -Verbose
La funzione prima configura un criterio di gruppo per consentire WinRM sulla porta TCP 5985 ai sistemi aggiunti al dominio. Abilita quindi PS Remoting tramite criterio di gruppo.
# Enable PS Remoting and display verbose output
Set-PSRemoting -Verbose