-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-FileZillaPassword.ps1
53 lines (48 loc) · 1.79 KB
/
Get-FileZillaPassword.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function Get-FileZillaPassword {
[CmdletBinding()]
param (
)
begin {
$SiteManagerLocation = $(@("$($env:APPDATA)\FileZilla\sitemanager.xml","$($Env:Programfiles)\FileZilla FTP Client\docs\fzdefaults.xml").ForEach({
if(Test-Path -Path $PSItem){
$PSItem
}
}))
if($null -eq $SiteManagerLocation){
Write-Host "Could not find any Sitemanager.xml"
return
}
}
process {
foreach($SiteManagerLocationElement in $SiteManagerLocation){
[xml]$XMLConfig = Get-Content -Path $SiteManagerLocationElement
if([string]::IsNullOrEmpty($XMLConfig.SelectNodes("//FileZilla3"))){
Write-Host "Configuration file: '$SiteManagerLocationElement' does not contain FileZilla3 node"
continue
}
$XMLConfig.SelectNodes("//Server").ForEach({
[PSCustomObject]@{
Name = $PSItem.Name
Host = $PSItem.Host
Port = $PSItem.Port
Protocol = $PSItem.Protocol
Account = $PSItem.Account
User = $PSItem.User
Password = $([Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($PSItem.Pass.'#text')))
LogonType = $(
switch ($PSItem.LogonType) {
0 { "anonymous"}
1 { "User/Password" }
2 { "AskForPassword"}
3 { "Interactive"}
4 { "Account"}
Default {$null}
}
)
}
})
}
}
end {
}
}