Skip to content

Commit a8a25a5

Browse files
committed
feat: new functions
1 parent b1bc165 commit a8a25a5

24 files changed

Lines changed: 63 additions & 31 deletions

ADCSGoat/Private/GetHelloWorld.ps1

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
function Deploy-AdcsGoat {
2+
$TemplateNames = @(
3+
'ESC1'
4+
'ESC2'
5+
'ESC3c1'
6+
'ESC3c2'
7+
'ESC4'
8+
'ESC9'
9+
)
10+
11+
# We need blank template objects.
12+
$TemplateNames | ForEach-Object {
13+
New-AdcsGoatBlankTemplateObject -TemplateName $_
14+
}
15+
16+
# We need to assign properties to the blank template objects to turn them into real templates.
17+
$TemplateNames | ForEach-Object {
18+
$PropertiesPath = Join-Path -Path ".\Research" -ChildPath "${_}.xml"
19+
$Properties = Import-Clixml -Path $PropertiesPath
20+
Set-AdcsGoatTemplateProperty -TemplateName $_ -Properties $Properties
21+
}
22+
23+
# We need to grant low privileged users control over blank template objects to turn them into ESC issues.
24+
$TemplateNames | ForEach-Object {
25+
Set-AdcsGoatTemplateAce -TemplateName $_ -AceType GenericAll
26+
}
27+
}
28+
29+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function Find-AdcsGoatEnrollmentService {
2+
# Get the Configuration partition automatically via RootDSE
3+
$RootDSE = New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE")
4+
$ConfigurationPartition = $rootDSE.configurationNamingContext
5+
$EnrollmentServicesContainer = "CN=Enrollment Services,CN=Public Key Services,CN=Services,$ConfigurationPartition"
6+
$EnrollmentServicesPath = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$EnrollmentServicesContainer")
7+
$EnrollmentServicesPath.Children
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function Get-AdcsGoatEnrollmentServiceFullName {
2+
param (
3+
[Parameter(Mandatory)]
4+
[ValidateScript({ $_.objectClass -eq 'pKIEnrollmentService' })]
5+
[System.DirectoryServices.DirectoryEntry]$EnrollmentService
6+
)
7+
8+
"$($EnrollmentService.dNSHostName)\$($EnrollmentService.name)"
9+
}

ADCSGoat/Public/Get-HelloWorld.ps1

Lines changed: 0 additions & 22 deletions
This file was deleted.

ADCSGoat/Private/New-BLLBlankTemplateObject.ps1 renamed to ADCSGoat/Public/New-AdcsGoatBlankTemplateObject.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function New-BLLBlankTemplateObject {
1+
function New-AdcsGoatBlankTemplateObject {
22
[CmdletBinding()]
33
param (
44
[Parameter(ValueFromPipeline, Mandatory)]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function Set-AdcsGoatEnrollmentServiceFullName {
2+
param (
3+
[Parameter(Mandatory)]
4+
[ValidateScript({ $_.objectClass -eq 'pKIEnrollmentService' })]
5+
[System.DirectoryServices.DirectoryEntry]$EnrollmentService,
6+
[Parameter(Mandatory)]
7+
[string]$EnrollmentServiceFullName
8+
)
9+
10+
"$($EnrollmentService.dNSHostName)\$($EnrollmentService.name)"
11+
}

ADCSGoat/Private/Set-BLLTemplateAce.ps1 renamed to ADCSGoat/Public/Set-AdcsGoatTemplateAce.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Set-BLLTemplateAce {
1+
function Set-AdcsGoatTemplateAce {
22
[CmdletBinding()]
33
param (
44
[Parameter(ValueFromPipeline, Mandatory)]
@@ -37,7 +37,7 @@ function Set-BLLTemplateAce {
3737

3838
# Define Access Control Type for use in ACEs
3939
$Allow = [System.Security.AccessControl.AccessControlType]::Allow
40-
$Deny = [System.Security.AccessControl.AccessControlType]::Deny
40+
# $Deny = [System.Security.AccessControl.AccessControlType]::Deny
4141

4242
$AccessRule = switch -Regex ($AceType) {
4343
'Enroll' {

ADCSGoat/Private/Set-BLLTemplateProperty.ps1 renamed to ADCSGoat/Public/Set-AdcsGoatTemplateProperty.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
function Set-BLLTemplateProperty {
1+
function Set-AdcsGoatTemplateProperty {
22
[CmdletBinding()]
33
param (
44
[Parameter(ValueFromPipeline, Mandatory)]
55
[string]$TemplateName,
66
[Parameter(ValueFromPipeline, Mandatory)]
7-
[hashtable]$properties
7+
[hashtable]$Properties
88
)
99

1010
begin {
@@ -21,7 +21,7 @@ function Set-BLLTemplateProperty {
2121

2222
try {
2323
# Apply $Properties to the object
24-
foreach ($property in $properties.GetEnumerator()) {
24+
foreach ($property in $Properties.GetEnumerator()) {
2525
# Each $property could be of a different type, and each type has to be applied differently.
2626
if ($property.Value -is [System.Collections.ICollection] -and $property.Value -isnot [byte[]]) {
2727
# Handle different collection types (ArrayList, Array, etc.), but not byte arrays

0 commit comments

Comments
 (0)