|
1 | 1 | function Deploy-AdcsGoat { |
2 | | - $TemplateNames = @( |
3 | | - 'ESC1' |
4 | | - 'ESC2' |
5 | | - 'ESC3c1' |
6 | | - 'ESC3c2' |
7 | | - 'ESC4' |
8 | | - 'ESC9' |
| 2 | + [CmdletBinding()] |
| 3 | + param ( |
| 4 | + [switch]$Randomize |
9 | 5 | ) |
10 | 6 |
|
11 | | - # We need blank template objects. |
12 | | - $TemplateNames | ForEach-Object { |
13 | | - New-AGBlankTemplateObject -TemplateName $_ |
| 7 | + #region template issues |
| 8 | + $Templates = @( |
| 9 | + @{Name = 'AGESC1'; ESC = 'ESC1'} |
| 10 | + @{Name = 'AGESC2'; ESC = 'ESC2'} |
| 11 | + @{Name = 'AGESC3c1'; ESC = 'ESC3c1'} |
| 12 | + @{Name = 'AGESC3c2'; ESC = 'ESC3c2'} |
| 13 | + @{Name = 'AGESC4'; ESC = 'ESC4'} |
| 14 | + @{Name = 'AGESC9'; ESC = 'ESC9'} |
| 15 | + ) |
| 16 | + |
| 17 | + # What: Create blank template objects. |
| 18 | + # Why: |
| 19 | + $Templates | ForEach-Object { |
| 20 | + Write-Verbose "Creating blank template object: $($_.Name)" |
| 21 | + New-AGBlankTemplateObject -TemplateName $_.Name |
14 | 22 | } |
15 | 23 |
|
16 | | - # We need to assign properties to the blank template objects to turn them into real templates. |
17 | | - $TemplateNames.Where( { $_ -ne 'ESC4' } ) | ForEach-Object { |
18 | | - $PropertiesPath = Join-Path -Path ".\Research" -ChildPath "${_}.xml" |
| 24 | + # What: Assign properties to the blank template objects to turn them into real templates with vulnerable configs. |
| 25 | + # Why: |
| 26 | + $Templates | ForEach-Object { |
| 27 | + Write-Verbose "Assigning $($_.ESC) configuration to: $($_.Name)" |
| 28 | + $PropertiesPath = Join-Path -Path ".\Research" -ChildPath "$($_.ESC).xml" |
19 | 29 | $Properties = Import-Clixml -Path $PropertiesPath |
20 | | - Set-AGTemplateProperty -TemplateName $_ -Properties $Properties |
| 30 | + Set-AGTemplateProperty -TemplateName $_.Name -Properties $Properties |
| 31 | + } |
| 32 | + |
| 33 | + # What: Grant low privileged users Enroll right on template objects to turn them into ESC issues (except ESC4) |
| 34 | + # Why: |
| 35 | + $Templates.Where( { $_.ESC -ne 'ESC4' } ) | ForEach-Object { |
| 36 | + Write-Verbose "Granting Authenticated Users Enroll rights on: $($_.Name)" |
| 37 | + Set-AGTemplateAce -TemplateName $_.Name -AceType Enroll |
| 38 | + } |
| 39 | + |
| 40 | + # What: Grant low privileged users Full Control over a template object to turn it into an ESC4. |
| 41 | + # Why: |
| 42 | + $Templates.Where( { $_.ESC -eq 'ESC4' } ) | ForEach-Object { |
| 43 | + Write-Verbose "Granting Authenticated Users Full Control of: $($_.Name)" |
| 44 | + Set-AGTemplateAce -TemplateName $_.Name -AceType GenericAll |
21 | 45 | } |
| 46 | + #endregion template issues |
| 47 | + |
| 48 | + #region ca issues |
| 49 | + # What: Get the list of all Enrollment Services, generate their full CA names, then add the name to the CA object |
| 50 | + # Why: |
| 51 | + $EnrollmentServices = Find-AGEnrollmentService |
| 52 | + $EnrollmentServicesWithFullName = $EnrollmentServices | Set-AGEnrollmentServiceFullName |
22 | 53 |
|
23 | | - # We need to grant low privileged users Enroll right on template objects to turn them into ESC issues. |
24 | | - $TemplateNames.Where( { $_ -ne 'ESC4' } ) | ForEach-Object { |
25 | | - Set-AGTemplateAce -TemplateName $_ -AceType Enroll |
| 54 | + # What: Enable ESC5 configuration on all CAs. |
| 55 | + # Why: |
| 56 | + $EnrollmentServicesWithFullName | ForEach-Object { |
| 57 | + Write-Verbose "Granting Authenticated Users Full Control of: $($_.FullName)" |
| 58 | + # Enable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2 |
26 | 59 | } |
27 | 60 |
|
28 | | - # We need to grant low privileged users Full Control over a template object to turn it into an ESC4. |
29 | | - $TemplateNames.Where( { $_ -eq 'ESC4' } ) | ForEach-Object { |
30 | | - Set-AGTemplateAce -TemplateName $_ -AceType GenericAll |
| 61 | + # What: Enable ESC6 configuration on all CAs. |
| 62 | + # Why: |
| 63 | + $EnrollmentServicesWithFullName | ForEach-Object { |
| 64 | + Write-Verbose "Assigning ESC6 configuration to: $($_.Name)" |
| 65 | + Enable-PCEditFlag -CAFullName $_.FullName -Flag EDITF_ATTRIBUTESUBJECTALTNAME2 |
31 | 66 | } |
| 67 | + |
| 68 | + # What: Enable ESC11 configuration on all CAs. |
| 69 | + # Why: |
| 70 | + $EnrollmentServicesWithFullName | ForEach-Object { |
| 71 | + Write-Verbose "Assigning ESC11 configuration to: $($_.Name)" |
| 72 | + Disable-PCInterfaceFlag -CAFullName $_.FullName -Flag IF_ENFORCEENCRYPTICERTREQUEST |
| 73 | + } |
| 74 | + |
| 75 | + #endregion ca issues |
32 | 76 | } |
33 | 77 |
|
0 commit comments