SecureCube.com

20Feb/090

Replace Password in FileZilla sitemanager.xml with VBscript

Because FileZilla, without recompiling, doesn't allow for the use of registry settings I made this script to aid in mass deployment to workstations without affecting other sites that may have been created. This is also very useful to rotate passwords without users having to change them.


The following is an example sitemanager.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FileZilla3>
 <Servers>
 <Folder expanded="1">PERSONAL
 <Server>
 <Host>ftp.domain.com</Host>
 <Port>21</Port>
 <Protocol>0</Protocol>
 <Type>0</Type>
 <User>User1</User>
 <Pass>8675309</Pass>
 <Logontype>1</Logontype>
 <TimezoneOffset>0</TimezoneOffset>
 <PasvMode>MODE_DEFAULT</PasvMode>
 <MaximumMultipleConnections>0</MaximumMultipleConnections>
 <EncodingType>Auto</EncodingType>
 <BypassProxy>0</BypassProxy>
 <Name>engineer</Name>
 <Comments></Comments>
 <LocalDir></LocalDir>
 <RemoteDir></RemoteDir>
 </Server>
 </Folder>
 <Folder expanded="1">BUSINESS
 <Server>
 <Host>ftp.domain2.com</Host>
 <Port>21</Port>
 <Protocol>0</Protocol>
 <Type>0</Type>
 <User>User2</User>
 <Pass>secret</Pass>
 <Logontype>1</Logontype>
 <TimezoneOffset>0</TimezoneOffset>
 <PasvMode>MODE_DEFAULT</PasvMode>
 <MaximumMultipleConnections>0</MaximumMultipleConnections>
 <EncodingType>Auto</EncodingType>
 <BypassProxy>0</BypassProxy>
 <Name>engineer</Name>
 <Comments></Comments>
 <LocalDir></LocalDir>
 <RemoteDir></RemoteDir>
 </Server>
 <Server>
 <Host>ftp.domain3.com</Host>
 <Port>21</Port>
 <Protocol>0</Protocol>
 <Type>0</Type>
 <User>User3</User>
 <Pass>secret</Pass>
 <Logontype>1</Logontype>
 <TimezoneOffset>0</TimezoneOffset>
 <PasvMode>MODE_DEFAULT</PasvMode>
 <MaximumMultipleConnections>0</MaximumMultipleConnections>
 <EncodingType>Auto</EncodingType>
 <BypassProxy>0</BypassProxy>
 <Name>engineer</Name>
 <Comments></Comments>
 <LocalDir></LocalDir>
 <RemoteDir></RemoteDir>
 </Server>
 </Folder>
 </Servers>
</FileZilla3>

Here is the vbscript code:

On Error Resume Next

Dim xmlFile : xmlFile = "c:\program files\filezilla-3.2.1\sitemanager.xml"

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.load(xmlFile)
 Dim sHost : sHost = "ftp.domain3.com"
 Dim sUser : sUser = "User3"
 Dim sPass : sPass = "123456"

 ' walk through Server tags and find engineer account to change password
 Set ElemList = xmlDoc.getElementsByTagName("Server")
 For Each x in ElemList
 Set Host = x.getElementsByTagName("Host")
 Set User = x.getElementsByTagName("User")
 Set Pass = x.getElementsByTagName("Pass")

 If ((User.item(0) Is Nothing) OR IsNull(User)) Then
 ' continue through loop
 User = null
 Else
 If (Host.item(0).Text = sHost AND User.item(0).Text = sUser) Then
 'MsgBox Pass.item(0).Text
 Pass.item(0).Text = sPass
 End If
 End If

 Host = null
 User = null
 Pass = null
 Next

xmlDoc.save(xmlFile)

wscript.quit()

Of course you will need to change:

  • xmlFile = to the folder at which the password is located under
  • sHost = the ftp host address
  • sUser = the username you want to replace the password for
  • sPass = the new password you want to be set

Other things to note is that you need to setup fzdefault.xml so all xml files are located in one location: This file should be located in the same place as the vbscript specifies.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.