Sunday, November 22, 2009

Converting from Password Depot to KeePassX

Bear with me for a moment all you non-technical people but I need to show that while I haven't been blogging I haven't been a complete slug and I have actually been doing something.

"Password Depot" is a very good password management program and since I deal with hundreds of the blighters it is an application that I absolutely have to have. Unfortunately it doesn't run on linux and it is getting a bit tiresome to load up a windows VM for no reason other than to get hold of a password so I looked around for a nice multi-platform password manager and KeePassX fits the bill. The only problem is that the export from Password Depot can't be imported into KeePassX so I had to do it the ugly way and write an xslt that converts from Password Depot export format to KeePassX import format. Someone else is bound to have this issue so here it is for anyone else that needs it.

Note that this comes with no guarantees from me and especially since the data elements in the Password Depot format do not map 1 to 1 with those in the KeePassX format so I made a few assumptions which I have been happy to accept but which others might not.

You can get the code for the xslt here

I am going to writing an application which takes the export from the Password Depot, the xslt above and returns the converted format for importing into KeePassX but I haven't got around to it so in the meantime, if you have access to XMLSpy that would work fine for applying the xslt.

Note to anyone from Password Depot that might read this, the DTD that is exported doesn't match the XML that follows. I found the following issues that should be corrected when you haven't got anything else to do. It doesn't affect the export, conversion and import but it would be nice if the DTD matched the actual XML exported.



The DTD listed at the top of the XML export of the contents of a PasswordDepot database
will cause any XSLT attempting to use the exported XML file to fail. In order to correct
the DTD the following alterations to the exported XML file must be done.

Original File has the following line:
<!ELEMENT GROUP (GROUP*,ITEM ) >
but the line should read like this:
<!ELEMENT GROUP (GROUP*,ITEM* ) >
Note the additional '*' after ITEM

Original File has the following line:
<!ELEMENT ITEM (DESCRIPTION ,PASSWORD ,USERNAME ,URL ,LASTMODIFIED ,EXPIRYDATE ,IMPORTANCE ,COMMENT ,TEMPLATE ,CUSTOMFIELDS ) >
but the line should read like this:
<!ELEMENT ITEM (DESCRIPTION ,PASSWORD ,USERNAME ,URL ,LASTMODIFIED ,EXPIRYDATE ,IMPORTANCE ,COMMENT ,TEMPLATE ,CUSTOMFIELDS* ) >
Note the additional '*' after CUSTOMFIELDS

Original File has the following line:
<!ELEMENT CUSTOMFIELDS (FIELD ) >
but the line should read like this:
<!ELEMENT CUSTOMFIELDS (FIELD* ) >
Note the additional '*' after FIELD

Original File has the following line:
<!ELEMENT FIELD (NAME ,VALUE ) >

<!ELEMENT VALUE (#PCDATA) >
but the line should read like this:
<!ELEMENT FIELD (NAME ,VALUE ) >

<!ELEMENT NAME (#PCDATA) >

<!ELEMENT VALUE (#PCDATA) >
Note the addition of the definition of the NAME element

1 comment:

Laurel said...

Would much rather see pictures!!