@@ -2263,7 +2263,7 @@ function Get-NetUser {
2263
2263
else {
2264
2264
# otherwise, use the current domain
2265
2265
if ($UserName ){
2266
- $UserSearcher = [adsisearcher ]" (&(samAccountType=805306368)(samAccountName=* $UserName * ))"
2266
+ $UserSearcher = [adsisearcher ]" (&(samAccountType=805306368)(samAccountName=$UserName ))"
2267
2267
}
2268
2268
# if we're specifying an OU
2269
2269
elseif ($OU ){
@@ -2955,33 +2955,15 @@ function Get-NetGUIDOUs {
2955
2955
$FullData
2956
2956
)
2957
2957
2958
- # grab the OUs for this domain
2959
- $OUs = Get-NetOUs - FullData - Domain $Domain
2960
-
2961
- $OUs | ForEach-Object {
2958
+ # grab the OUs for this domain and process each
2959
+ Get-NetOUs - FullData - Domain $Domain | % {
2962
2960
# grab all the GP links for this object and check for the target GUID
2963
- $a = $_.properties.gplink
2964
- $_ | % {
2965
- if ($_.properties.gplink -match $GUID ){
2966
- if ($FullData ){
2967
- $properties = $_.Properties
2968
- $out = New-Object psobject
2969
-
2970
- $properties.PropertyNames | % {
2971
- if ($_ -eq " objectguid" ){
2972
- # convert the GUID to a string
2973
- $out | Add-Member Noteproperty $_ (New-Object Guid (, $properties [$_ ][0 ])).Guid
2974
- }
2975
- else {
2976
- $out | Add-Member Noteproperty $_ $properties [$_ ][0 ]
2977
- }
2978
- }
2979
- $out
2980
- }
2981
-
2982
- else {
2983
- $_.properties.distinguishedname
2984
- }
2961
+ if ($_.gplink -match $GUID ) {
2962
+ if ($FullData ){
2963
+ $_
2964
+ }
2965
+ else {
2966
+ $_.distinguishedname
2985
2967
}
2986
2968
}
2987
2969
}
@@ -6118,7 +6100,7 @@ function Invoke-UserHunter {
6118
6100
if ($ShowAll ){}
6119
6101
# if we want to hunt for the effective domain users who can access a target server
6120
6102
elseif ($TargetServerAdmins ){
6121
- $TargetUsers = Get-NetLocalGroup WINDOWS4.dev.testlab.local - Recurse | ? {(-not $_.IsGroup ) -and $_.IsDomain } | % { ($_.AccountName ).split(" /" )[1 ].toLower() }
6103
+ $TargetUsers = Get-NetLocalGroup $TargetServerAdmins - Recurse | ? {(-not $_.IsGroup ) -and $_.IsDomain } | % { ($_.AccountName ).split(" /" )[1 ].toLower() }
6122
6104
}
6123
6105
# if we get a specific username, only use that
6124
6106
elseif ($UserName ){
@@ -6866,7 +6848,7 @@ function Invoke-StealthUserHunter {
6866
6848
if ($ShowAll ){}
6867
6849
# if we want to hunt for the effective domain users who can access a target server
6868
6850
elseif ($TargetServerAdmins ){
6869
- $TargetUsers = Get-NetLocalGroup WINDOWS4.dev.testlab.local - Recurse | ? {(-not $_.IsGroup ) -and $_.IsDomain } | % { ($_.AccountName ).split(" /" )[1 ].toLower() }
6851
+ $TargetUsers = Get-NetLocalGroup $TargetServerAdmins - Recurse | ? {(-not $_.IsGroup ) -and $_.IsDomain } | % { ($_.AccountName ).split(" /" )[1 ].toLower() }
6870
6852
}
6871
6853
# if we get a specific username, only use that
6872
6854
elseif ($UserName ){
0 commit comments