Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit 786793c

Browse files
committed
Merge branch 'dev' of github.com:PowerShellMafia/PowerSploit into dev
2 parents 6789187 + 0e2daae commit 786793c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

Recon/PowerView.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18803,6 +18803,68 @@ Custom PSObject with translated domain API trust result fields.
1880318803
}
1880418804
}
1880518805

18806+
function Get-GPODelegation
18807+
{
18808+
<#
18809+
.SYNOPSIS
18810+
Finds users with write permissions on GPO objects which may allow privilege escalation within the domain.
18811+
18812+
Author: Itamar Mizrahi (@MrAnde7son)
18813+
License: GNU v3
18814+
Required Dependencies: None
18815+
Optional Dependencies: None
18816+
18817+
.DESCRIPTION
18818+
18819+
.PARAMETER GPOName
18820+
The GPO display name to query for, wildcards accepted.
18821+
18822+
.PARAMETER PageSize
18823+
18824+
.EXAMPLE
18825+
PS C:\> Get-GPODelegation
18826+
Returns all GPO delegations in current forest.
18827+
18828+
.EXAMPLE
18829+
PS C:\> Get-GPODelegation -GPOName
18830+
Returns all GPO delegations on a given GPO.
18831+
#>
18832+
[CmdletBinding()]
18833+
Param (
18834+
[String]
18835+
$GPOName = '*',
18836+
18837+
[ValidateRange(1,10000)]
18838+
[Int]
18839+
$PageSize = 200
18840+
)
18841+
18842+
$Exclusions = @("SYSTEM","Domain Admins","Enterprise Admins")
18843+
18844+
$Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
18845+
$DomainList = @($Forest.Domains)
18846+
$Domains = $DomainList | foreach { $_.GetDirectoryEntry() }
18847+
foreach ($Domain in $Domains) {
18848+
$Filter = "(&(objectCategory=groupPolicyContainer)(displayname=$GPOName))"
18849+
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
18850+
$Searcher.SearchRoot = $Domain
18851+
$Searcher.Filter = $Filter
18852+
$Searcher.PageSize = $PageSize
18853+
$Searcher.SearchScope = "Subtree"
18854+
$listGPO = $Searcher.FindAll()
18855+
foreach ($gpo in $listGPO){
18856+
$ACL = ([ADSI]$gpo.path).ObjectSecurity.Access | ? {$_.ActiveDirectoryRights -match "Write" -and $_.AccessControlType -eq "Allow" -and $Exclusions -notcontains $_.IdentityReference.toString().split("\")[1] -and $_.IdentityReference -ne "CREATOR OWNER"}
18857+
if ($ACL -ne $null){
18858+
$GpoACL = New-Object psobject
18859+
$GpoACL | Add-Member Noteproperty 'ADSPath' $gpo.Properties.adspath
18860+
$GpoACL | Add-Member Noteproperty 'GPODisplayName' $gpo.Properties.displayname
18861+
$GpoACL | Add-Member Noteproperty 'IdentityReference' $ACL.IdentityReference
18862+
$GpoACL | Add-Member Noteproperty 'ActiveDirectoryRights' $ACL.ActiveDirectoryRights
18863+
$GpoACL
18864+
}
18865+
}
18866+
}
18867+
}
1880618868

1880718869
########################################################
1880818870
#

0 commit comments

Comments
 (0)