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

Commit 30c5177

Browse files
committed
-added parsing of the 'useraccountcontrol' property into human readable format
-added parsing of the 'accountexpires' property into human readable format -added parsing of the 'grouptype' property into human readable format -added parsing of the 'samaccounttype' property into a readable format
1 parent 786793c commit 30c5177

File tree

1 file changed

+101
-24
lines changed

1 file changed

+101
-24
lines changed

Recon/PowerView.ps1

Lines changed: 101 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,10 +2793,19 @@ A custom PSObject with LDAP hashtable properties translated.
27932793
# convert the SID to a string
27942794
$ObjectProperties[$_] = (New-Object System.Security.Principal.SecurityIdentifier($Properties[$_][0], 0)).Value
27952795
}
2796+
elseif ($_ -eq 'grouptype') {
2797+
$ObjectProperties[$_] = $Properties[$_][0] -as $GroupTypeEnum
2798+
}
2799+
elseif ($_ -eq 'samaccounttype') {
2800+
$ObjectProperties[$_] = $Properties[$_][0] -as $SamAccountTypeEnum
2801+
}
27962802
elseif ($_ -eq 'objectguid') {
27972803
# convert the GUID to a string
27982804
$ObjectProperties[$_] = (New-Object Guid (,$Properties[$_][0])).Guid
27992805
}
2806+
elseif ($_ -eq 'useraccountcontrol') {
2807+
$ObjectProperties[$_] = $Properties[$_][0] -as $UACEnum
2808+
}
28002809
elseif ($_ -eq 'ntsecuritydescriptor') {
28012810
# $ObjectProperties[$_] = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList $Properties[$_][0], 0
28022811
$Descriptor = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList $Properties[$_][0], 0
@@ -2813,6 +2822,14 @@ A custom PSObject with LDAP hashtable properties translated.
28132822
$ObjectProperties['SystemAcl'] = $Descriptor.SystemAcl
28142823
}
28152824
}
2825+
elseif ($_ -eq 'accountexpires') {
2826+
if ($Properties[$_][0] -gt [DateTime]::MaxValue.Ticks) {
2827+
$ObjectProperties[$_] = "NEVER"
2828+
}
2829+
else {
2830+
$ObjectProperties[$_] = [datetime]::fromfiletime($Properties[$_][0])
2831+
}
2832+
}
28162833
elseif ( ($_ -eq 'lastlogon') -or ($_ -eq 'lastlogontimestamp') -or ($_ -eq 'pwdlastset') -or ($_ -eq 'lastlogoff') -or ($_ -eq 'badPasswordTime') ) {
28172834
# convert timestamps
28182835
if ($Properties[$_][0] -is [System.MarshalByRefObject]) {
@@ -18803,32 +18820,39 @@ Custom PSObject with translated domain API trust result fields.
1880318820
}
1880418821
}
1880518822

18823+
1880618824
function Get-GPODelegation
1880718825
{
1880818826
<#
18809-
.SYNOPSIS
18810-
Finds users with write permissions on GPO objects which may allow privilege escalation within the domain.
18827+
.SYNOPSIS
18828+
18829+
Finds users with write permissions on GPO objects which may allow privilege escalation within the domain.
1881118830

18812-
Author: Itamar Mizrahi (@MrAnde7son)
18813-
License: GNU v3
18814-
Required Dependencies: None
18815-
Optional Dependencies: None
18831+
Author: Itamar Mizrahi (@MrAnde7son)
18832+
License: BSD 3-Clause
18833+
Required Dependencies: None
1881618834

18817-
.DESCRIPTION
18835+
.PARAMETER GPOName
1881818836

18819-
.PARAMETER GPOName
18820-
The GPO display name to query for, wildcards accepted.
18837+
The GPO display name to query for, wildcards accepted.
1882118838

18822-
.PARAMETER PageSize
18839+
.PARAMETER PageSize
1882318840

18824-
.EXAMPLE
18825-
PS C:\> Get-GPODelegation
18826-
Returns all GPO delegations in current forest.
18841+
Specifies the PageSize to set for the LDAP searcher object.
18842+
18843+
.EXAMPLE
1882718844

18828-
.EXAMPLE
18829-
PS C:\> Get-GPODelegation -GPOName
18830-
Returns all GPO delegations on a given GPO.
18845+
Get-GPODelegation
18846+
18847+
Returns all GPO delegations in current forest.
18848+
18849+
.EXAMPLE
18850+
18851+
Get-GPODelegation -GPOName
18852+
18853+
Returns all GPO delegations on a given GPO.
1883118854
#>
18855+
1883218856
[CmdletBinding()]
1883318857
Param (
1883418858
[String]
@@ -18854,18 +18878,19 @@ function Get-GPODelegation
1885418878
$listGPO = $Searcher.FindAll()
1885518879
foreach ($gpo in $listGPO){
1885618880
$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-
}
18881+
if ($ACL -ne $null){
18882+
$GpoACL = New-Object psobject
18883+
$GpoACL | Add-Member Noteproperty 'ADSPath' $gpo.Properties.adspath
18884+
$GpoACL | Add-Member Noteproperty 'GPODisplayName' $gpo.Properties.displayname
18885+
$GpoACL | Add-Member Noteproperty 'IdentityReference' $ACL.IdentityReference
18886+
$GpoACL | Add-Member Noteproperty 'ActiveDirectoryRights' $ACL.ActiveDirectoryRights
18887+
$GpoACL
18888+
}
1886518889
}
1886618890
}
1886718891
}
1886818892

18893+
1886918894
########################################################
1887018895
#
1887118896
# Expose the Win32API functions and datastructures below
@@ -18879,6 +18904,58 @@ $Mod = New-InMemoryModule -ModuleName Win32
1887918904

1888018905
# [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPositionalParameters', Scope='Function', Target='psenum')]
1888118906

18907+
# used to parse the 'samAccountType' property for users/computers/groups
18908+
$SamAccountTypeEnum = psenum $Mod PowerView.GroupTypeEnum UInt32 @{
18909+
DOMAIN_OBJECT = '0x00000000'
18910+
GROUP_OBJECT = '0x10000000'
18911+
NON_SECURITY_GROUP_OBJECT = '0x10000001'
18912+
ALIAS_OBJECT = '0x20000000'
18913+
NON_SECURITY_ALIAS_OBJECT = '0x20000001'
18914+
USER_OBJECT = '0x30000000'
18915+
MACHINE_ACCOUNT = '0x30000001'
18916+
TRUST_ACCOUNT = '0x30000002'
18917+
APP_BASIC_GROUP = '0x40000000'
18918+
APP_QUERY_GROUP = '0x40000001'
18919+
ACCOUNT_TYPE_MAX = '0x7fffffff'
18920+
}
18921+
18922+
# used to parse the 'grouptype' property for groups
18923+
$GroupTypeEnum = psenum $Mod PowerView.SamAccountTypeEnum UInt32 @{
18924+
CREATED_BY_SYSTEM = '0x00000001'
18925+
GLOBAL_SCOPE = '0x00000002'
18926+
DOMAIN_LOCAL_SCOPE = '0x00000004'
18927+
UNIVERSAL_SCOPE = '0x00000008'
18928+
APP_BASIC = '0x00000010'
18929+
APP_QUERY = '0x00000020'
18930+
SECURITY = '0x80000000'
18931+
} -Bitfield
18932+
18933+
# used to parse the 'userAccountControl' property for users/groups
18934+
$UACEnum = psenum $Mod PowerView.UACEnum UInt32 @{
18935+
SCRIPT = 1
18936+
ACCOUNTDISABLE = 2
18937+
HOMEDIR_REQUIRED = 8
18938+
LOCKOUT = 16
18939+
PASSWD_NOTREQD = 32
18940+
PASSWD_CANT_CHANGE = 64
18941+
ENCRYPTED_TEXT_PWD_ALLOWED = 128
18942+
TEMP_DUPLICATE_ACCOUNT = 256
18943+
NORMAL_ACCOUNT = 512
18944+
INTERDOMAIN_TRUST_ACCOUNT = 2048
18945+
WORKSTATION_TRUST_ACCOUNT = 4096
18946+
SERVER_TRUST_ACCOUNT = 8192
18947+
DONT_EXPIRE_PASSWORD = 65536
18948+
MNS_LOGON_ACCOUNT = 131072
18949+
SMARTCARD_REQUIRED = 262144
18950+
TRUSTED_FOR_DELEGATION = 524288
18951+
NOT_DELEGATED = 1048576
18952+
USE_DES_KEY_ONLY = 2097152
18953+
DONT_REQ_PREAUTH = 4194304
18954+
PASSWORD_EXPIRED = 8388608
18955+
TRUSTED_TO_AUTH_FOR_DELEGATION = 16777216
18956+
PARTIAL_SECRETS_ACCOUNT = 67108864
18957+
} -Bitfield
18958+
1888218959
# enum used by $WTS_SESSION_INFO_1 below
1888318960
$WTSConnectState = psenum $Mod WTS_CONNECTSTATE_CLASS UInt16 @{
1888418961
Active = 0

0 commit comments

Comments
 (0)