
وحدة PowerShell مخصصة لإعداد بيئة مختبر Active Directory لممارسة اختبار الاختراق.
الغرض من هذه الوحدة هو أتمتة نشر مختبر Active Directory لممارسة اختبار الاختراق الداخلي.
يعود الفضل لـ Joe Helle ودورته PowerShell for Pentesters فيما يتعلق بتوليد نواقل الهجوم.
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
تقوم هذه الدالة بإعداد الجهاز الافتراضي/الكمبيوتر الحالي لاستخدامه كوحدة تحكم بالمجال للغابة الجديدة. تقوم بتعيين عنوان 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
تبدأ الدالة بإنشاء المجموعات والوحدات التنظيمية (OUs) المحددة في المتغير العام Groups. ثم تقوم بإنشاء 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-Roasting افتراضيًا.
# 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% من المستخدمين قابلين لـ Kerberoasting افتراضيًا.
# 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 حقوق GenericAll على مجموعة Domain Admins. ثم تمنح مجموعة Degens حقوق GenericALl على مجموعة Chads. وأخيرًا، تمنح حقوق GenericAll على بعض المستخدمين من مجموعة Degens لبعض مستخدمي مجموعة Normies.
# Create vulnerable ACLs and display verbose output
Set-BadACLs -Verbose
تقوم الدالة أولاً بتكوين GPO للسماح بـ WinRM عبر منفذ TCP 5985 إلى الأنظمة المنضمة للمجال. ثم تقوم بتمكين PS Remoting من خلال GPO.
# Enable PS Remoting and display verbose output
Set-PSRemoting -Verbose