Skip to content

Commit 05b8231

Browse files
authored
Merge pull request #275 from jakehildreth/samerde/optimize-array-accumulation
Optimize hot-path array accumulation
2 parents d77ad10 + a90022c commit 05b8231

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

Invoke-Locksmith.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[CmdletBinding(HelpUri = 'https://jakehildreth.github.io/Locksmith/Invoke-Locksmith')]
1+
[CmdletBinding(HelpUri = 'https://jakehildreth.github.io/Locksmith/Invoke-Locksmith')]
22
param (
33
# The mode to run Locksmith in. Defaults to 0.
44
[Parameter(Mandatory = $false)]
@@ -2851,8 +2851,10 @@ function Invoke-Scans {
28512851
}
28522852
ESC3 {
28532853
Write-Host 'Identifying AD CS templates with dangerous ESC3 configurations...'
2854-
[array]$ESC3 = Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2855-
[array]$ESC3 += Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2854+
[array]$ESC3 = @(
2855+
Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2856+
Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2857+
)
28562858
}
28572859
ESC4 {
28582860
Write-Host 'Identifying AD CS templates with poor access control (ESC4)...'
@@ -2910,8 +2912,10 @@ function Invoke-Scans {
29102912
Write-Host 'Identifying AD CS templates with dangerous ESC2 configurations...'
29112913
[array]$ESC2 = Find-ESC2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
29122914
Write-Host 'Identifying AD CS templates with dangerous ESC3 configurations...'
2913-
[array]$ESC3 = Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2914-
[array]$ESC3 += Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2915+
[array]$ESC3 = @(
2916+
Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2917+
Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
2918+
)
29152919
Write-Host 'Identifying AD CS templates with poor access control (ESC4)...'
29162920
[array]$ESC4 = Find-ESC4 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -DangerousRights $DangerousRights -SafeOwners $SafeOwners -SafeObjectTypes $SafeObjectTypes -Mode $Mode -UnsafeUsers $UnsafeUsers
29172921
Write-Host 'Identifying AD CS objects with poor access control (ESC5)...'

Private/Invoke-Scans.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ function Invoke-Scans {
9090
}
9191
ESC3 {
9292
Write-Host 'Identifying AD CS templates with dangerous ESC3 configurations...'
93-
[array]$ESC3 = Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
94-
[array]$ESC3 += Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
93+
[array]$ESC3 = @(
94+
Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
95+
Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
96+
)
9597
}
9698
ESC4 {
9799
Write-Host 'Identifying AD CS templates with poor access control (ESC4)...'
@@ -149,8 +151,10 @@ function Invoke-Scans {
149151
Write-Host 'Identifying AD CS templates with dangerous ESC2 configurations...'
150152
[array]$ESC2 = Find-ESC2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
151153
Write-Host 'Identifying AD CS templates with dangerous ESC3 configurations...'
152-
[array]$ESC3 = Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
153-
[array]$ESC3 += Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
154+
[array]$ESC3 = @(
155+
Find-ESC3C1 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
156+
Find-ESC3C2 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -UnsafeUsers $UnsafeUsers
157+
)
154158
Write-Host 'Identifying AD CS templates with poor access control (ESC4)...'
155159
[array]$ESC4 = Find-ESC4 -ADCSObjects $ADCSObjects -SafeUsers $SafeUsers -DangerousRights $DangerousRights -SafeOwners $SafeOwners -SafeObjectTypes $SafeObjectTypes -Mode $Mode -UnsafeUsers $UnsafeUsers
156160
Write-Host 'Identifying AD CS objects with poor access control (ESC5)...'

0 commit comments

Comments
 (0)