此模块旨在自动化部署用于内部渗透测试练习的 Active Directory 实验室环境。
感谢 Joe Helle 及其 PowerShell for Pentesters 课程 提供的攻击向量生成思路。
# 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
此函数准备当前虚拟机/计算机以用作新林的域控制器。它会设置静态 IP 地址、将 DNS 服务器设为 localhost 并重命名计算机。
# 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"
此函数安装 AD DS 功能并设置新的 Active Directory 林,无需任何用户输入。完成后重新启动计算机。
# 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
此函数首先安装 DNS 功能。然后添加主要区域并配置服务器转发器。
# 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
此函数首先在当前计算机上安装 DHCP 功能。然后添加必要的安全组并使用域控制器授权新的 DHCP 服务器。最后,使用提供的值配置新的 DHCP 作用域。
# 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
此函数首先创建全局 Groups 变量中定义的组和 OU。然后默认情况下为每个 OU 生成 10 个用户对象。
# 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
此函数从域中获取一定数量的随机用户,并为每个用户设置 DoesNotRequirePreAuth 标志。排除 Administrator 和 krbtgt 等默认账户。默认情况下使 5% 的用户可 ASREP-Roast。
# 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
此函数从域中获取一定数量的随机用户,并为每个用户添加 SPN。排除 Administrator 和 krbtgt 等默认账户。默认情况下使 5% 的用户可 Kerberoast。
# 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
此函数首先授予 Chads 组对 Domain Admins 的 GenericAll 权限。然后授予 Degens 组对 Chads 组的 GenericAll 权限。最后,授予 Normies 组中的某些用户对 Degens 组中某些用户的 GenericAll 权限。
# Create vulnerable ACLs and display verbose output
Set-BadACLs -Verbose
此函数首先配置 GPO 以允许通过 TCP 端口 5985 对域内系统使用 WinRM。然后通过 GPO 启用 PS 远程处理。
# Enable PS Remoting and display verbose output
Set-PSRemoting -Verbose