forked from MrAnde7son/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind-Credentials.ps1
25 lines (21 loc) · 1.14 KB
/
Find-Credentials.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Potential credentials files
function Find-CredFiles {
return (Get-ChildItem c:\ -Recurse -Include *pass*, *cred*, *.config*, *vnc* -ErrorAction SilentlyContinue | Where-Object { -not $_.PSIsContainer } | select fullname).fullname
}
# Files with 'password' string
function Find-PasswordFiles {
$passfiles = Get-ChildItem c:\ -Recurse -Include *.xml, *.ini, *.txt -ErrorAction SilentlyContinue | Select-String -pattern "password" -ErrorAction SilentlyContinue
$passlist = @()
foreach ($match in $passfiles){
$obj = New-Object psobject
$obj | Add-Member NoteProperty 'FilePath' $match.Path
$obj | Add-Member NoteProperty 'LineNumber' $match.LineNumber
$obj | Add-Member NoteProperty 'Line' $match.Line
$passlist += $obj
}
return $passlist
}
# Registry values with 'password' string
function Find-RegPasswords{
return Get-ChildItem -path HKLM:\,HKCU:\ -Recurse -ErrorAction SilentlyContinue | % { $key=$_;$_.GetValueNames() | ? { $_ -match 'password' } | %{ Get-ItemProperty $key.pspath -Name $_ | select -ExcludeProperty PSProvider,PSChildName,PSParentPath } }
}