How to retreive Filezilla FTP passwords using C#

FileZilla stores passwords in two xml files. In recent servers file(recentservers.xml) and site manager file(sitemanager.xml).

void ReadFileZillaFile(String filename)
{
    try
    {
	if (File.Exists(filename))
	{
		Console.WriteLine("Reading file " + filename + ".");
		Console.WriteLine("-----");
		XmlTextReader reader = new XmlTextReader(filename);
		XmlDocument doc = new XmlDocument();
		doc.Load(reader);
		foreach (XmlNode node in doc.DocumentElement.ChildNodes[0].ChildNodes)
		{
			foreach (XmlNode childNode in node.ChildNodes)
			{
				if (childNode.Name == "Host")
					Console.WriteLine("Host: \t" + childNode.InnerText);
				if (childNode.Name == "Port")
					Console.WriteLine("Port: \t" + childNode.InnerText);
				if (childNode.Name == "User")
					Console.WriteLine("User: \t" + childNode.InnerText);
				if (childNode.Name == "Pass")
					Console.WriteLine("Pass: \t" + Encoding.UTF8.GetString(Convert.FromBase64String(childNode.InnerText)));
			}
			Console.WriteLine("-----");
		}
	}
    }
    catch (Exception ex)
    {
	Console.WriteLine(ex.Message);
    }
}
//..
Console.WriteLine("FileZilla credentials");
Console.WriteLine("-------------------------------------");
 
String RecentServers = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
	Path.DirectorySeparatorChar + "FileZilla" + Path.DirectorySeparatorChar + "recentservers.xml";
String SiteManager = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
	Path.DirectorySeparatorChar + "FileZilla" + Path.DirectorySeparatorChar + "sitemanager.xml";
 
ReadFileZillaFile(RecentServers);
ReadFileZillaFile(SiteManager);
//..
%d bloggers like this: