Skip to content

Commit

Permalink
Update Invoke-ADEnum.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo4j authored Nov 2, 2024
1 parent c6648df commit ceff045
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Invoke-ADEnum.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,7 @@ Add-Type -TypeDefinition $code
"Target Name" = $GetDomainTrust.TargetName
"Trust Direction" = $GetDomainTrust.TrustDirection
"SIDHistory" = $GetDomainTrust.SIDHistoryStatus
"Filter_SIDS" = $GetDomainTrust.Filter_SIDS
"Trust Type" = $GetDomainTrust.TrustType
"Trust Attributes" = $GetDomainTrust.TrustAttributes
"When Created" = $GetDomainTrust.WhenCreated
Expand Down Expand Up @@ -1941,6 +1942,7 @@ Add-Type -TypeDefinition $code
"Target Name" = $GetDomainTrust.TargetName
"Trust Direction" = $GetDomainTrust.TrustDirection
"SIDHistory" = $GetDomainTrust.SIDHistoryStatus
"Filter_SIDS" = $GetDomainTrust.Filter_SIDS
"Trust Type" = $GetDomainTrust.TrustType
"Trust Attributes" = $GetDomainTrust.TrustAttributes
"When Created" = $GetDomainTrust.WhenCreated
Expand Down Expand Up @@ -8084,20 +8086,23 @@ function FindDomainTrusts {

# Resolve the trust attributes
$TrustAttributes = @()
$SIDFilteringForestAware = $false
$SIDFilteringEnabled = $false
$TreatAsExternal = $false
$ForestTransitive = $false

foreach ($key in $TrustAttributesMapping.Keys) {
if ($result.Properties["trustattributes"][0] -band $key) {
$TrustAttributes += $TrustAttributesMapping[$key]

# Check if FILTER_SIDS is set to determine SIDFilteringForestAware status
if ($key -eq [uint32]'0x00000004') {
$SIDFilteringForestAware = $true
}
# Track specific attribute flags for SID history determination
if ($key -eq [uint32]'0x00000004') { $SIDFilteringEnabled = $true }
if ($key -eq [uint32]'0x00000040') { $TreatAsExternal = $true }
if ($key -eq [uint32]'0x00000008') { $ForestTransitive = $true }
}
}

# Interpret SIDFilteringForestAware status for clarity
$SIDHistoryStatus = if ($SIDFilteringForestAware -and ($TrustAttributes -contains 'FOREST_TRANSITIVE')) {
# Determine SID history status based on flags
$SIDHistoryStatus = if ($TreatAsExternal -and $ForestTransitive) {
'Enabled'
} else {
'Disabled'
Expand All @@ -8111,6 +8116,7 @@ function FindDomainTrusts {
TrustType = $TrustType
TrustAttributes = ($TrustAttributes -join ', ')
SIDHistoryStatus = $SIDHistoryStatus
Filter_SIDS = $SIDFilteringEnabled
WhenCreated = $result.Properties["whenCreated"][0]
WhenChanged = $result.Properties["whenChanged"][0]
}
Expand Down

0 comments on commit ceff045

Please sign in to comment.