Import from KeePass2 XML #51

Open
mstarke opened this Issue Jul 17, 2013 · 27 comments

Comments

Projects
None yet
9 participants
@mstarke
Member

mstarke commented Jul 17, 2013

Export to XML works, Import should also be possible as it's trivial to parse the unencrypted data.

@mstarke mstarke modified the milestones: 0.5, 0.4 Mar 18, 2014

@BennoKieselstein

This comment has been minimized.

Show comment
Hide comment
@BennoKieselstein

BennoKieselstein Apr 8, 2014

I did not succed in importing an XML file that was exported from MacPass. Are there any conditions that apply? Would you mind to describe any use cases that were tested?

I did not succed in importing an XML file that was exported from MacPass. Are there any conditions that apply? Would you mind to describe any use cases that were tested?

@mstarke

This comment has been minimized.

Show comment
Hide comment
@mstarke

mstarke Apr 8, 2014

Member

As this ticket is open, it's not implemented ;). It's working but I did not add any warnings or other import features.

Member

mstarke commented Apr 8, 2014

As this ticket is open, it's not implemented ;). It's working but I did not add any warnings or other import features.

@mstarke

This comment has been minimized.

Show comment
Hide comment
@mstarke

mstarke Apr 8, 2014

Member

With "it's working" I mean the code is there but not used in the release

Member

mstarke commented Apr 8, 2014

With "it's working" I mean the code is there but not used in the release

@mstarke mstarke modified the milestones: 0.5, 0.6 Oct 28, 2014

@nremond

This comment has been minimized.

Show comment
Hide comment
@nremond

nremond Oct 12, 2015

Was wondering why the "import" didn't add anything ... got it now.

nremond commented Oct 12, 2015

Was wondering why the "import" didn't add anything ... got it now.

@timbru31

This comment has been minimized.

Show comment
Hide comment
@timbru31

timbru31 Jan 2, 2016

I stumbled across the same bug, maybe the button should be disabled until it's working 😃

timbru31 commented Jan 2, 2016

I stumbled across the same bug, maybe the button should be disabled until it's working 😃

@txdm

This comment has been minimized.

Show comment
Hide comment
@txdm

txdm Jan 4, 2016

Hello mstarke, I am currently writing a script to help people export their existing keychain data into a format that can be imported into MacPass. Do you plan to implement csv import?

txdm commented Jan 4, 2016

Hello mstarke, I am currently writing a script to help people export their existing keychain data into a format that can be imported into MacPass. Do you plan to implement csv import?

@mstarke mstarke modified the milestones: 0.7, 0.6 Feb 15, 2016

@robsalasco

This comment has been minimized.

Show comment
Hide comment
@robsalasco

robsalasco Aug 28, 2016

+1 for the csv import

+1 for the csv import

@hutch31

This comment has been minimized.

Show comment
Hide comment
@hutch31

hutch31 Jan 17, 2017

+1 more for csv import

I was deep into a script to convert pwsafe data into KeePass, was wondering why XML import fails out without creating entries.

hutch31 commented Jan 17, 2017

+1 more for csv import

I was deep into a script to convert pwsafe data into KeePass, was wondering why XML import fails out without creating entries.

@mstarke

This comment has been minimized.

Show comment
Hide comment
@mstarke

mstarke Jan 17, 2017

Member

The master can import XML but the last binary build (0.6.2) isn't able to.

Member

mstarke commented Jan 17, 2017

The master can import XML but the last binary build (0.6.2) isn't able to.

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Mar 28, 2017

Is there currently any macOS App for importing XMLs or LastPass CSVs into KeePass 2 Databases? After i noticed that the import function in MacPass is disabled, i tried KeyPassX, KeyPassXC and KeeWeb but they also lack of this feature on macOS.

kennymc-c commented Mar 28, 2017

Is there currently any macOS App for importing XMLs or LastPass CSVs into KeePass 2 Databases? After i noticed that the import function in MacPass is disabled, i tried KeyPassX, KeyPassXC and KeeWeb but they also lack of this feature on macOS.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

@kennymc-c KeeWeb currently appears to have an XML import function.

@kennymc-c KeeWeb currently appears to have an XML import function.

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Apr 1, 2017

I tried it but it only works for specific XMLs. My XML file is just converted from a LastPass CSV and KeeWeb apparently refuses such XMLs to import.

I tried it but it only works for specific XMLs. My XML file is just converted from a LastPass CSV and KeeWeb apparently refuses such XMLs to import.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

I have written a Ruby script that converts from CSV to KeePass 2 XML. It uses specific CSV fields, but it can easily be adapted (if I have time, I'll make it more generic): https://github.com/lifepillar/CSVKeychain/blob/master/csv2keepassxml. It is basically untested, but it should work.

When I import an XML file created with my script into KeeWeb, I get no errors, although KeeWeb displays only one item. However, if immediately after importing I export into a kdbx file, then I can open that kdbx file in MacPass and I see all the items.

I have written a Ruby script that converts from CSV to KeePass 2 XML. It uses specific CSV fields, but it can easily be adapted (if I have time, I'll make it more generic): https://github.com/lifepillar/CSVKeychain/blob/master/csv2keepassxml. It is basically untested, but it should work.

When I import an XML file created with my script into KeeWeb, I get no errors, although KeeWeb displays only one item. However, if immediately after importing I export into a kdbx file, then I can open that kdbx file in MacPass and I see all the items.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

Here you go: https://github.com/lifepillar/csv2keepassxml.

@kennymc-c I would be grateful if you could try it and report any feedback.

Here you go: https://github.com/lifepillar/csv2keepassxml.

@kennymc-c I would be grateful if you could try it and report any feedback.

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Apr 1, 2017

With my LastPass CSV I get the following error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/base64.rb:80:in urlsafe_encode64': wrong number of arguments (2 for 1) (ArgumentError) from csv2keepassxml/csv2keepassxml:23:inbase64_uuid'
from csv2keepassxml/csv2keepassxml:153:in block in <main>' from csv2keepassxml/csv2keepassxml:144:inopen'
from csv2keepassxml/csv2keepassxml:144:in `

'

With my LastPass CSV I get the following error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/base64.rb:80:in urlsafe_encode64': wrong number of arguments (2 for 1) (ArgumentError) from csv2keepassxml/csv2keepassxml:23:inbase64_uuid'
from csv2keepassxml/csv2keepassxml:153:in block in <main>' from csv2keepassxml/csv2keepassxml:144:inopen'
from csv2keepassxml/csv2keepassxml:144:in `

'

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

Please try the current master. I was using a newer version of Ruby and I didn't notice that incompatibility. Now it's fixed.

Please try the current master. I was using a newer version of Ruby and I didn't notice that incompatibility. Now it's fixed.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

Btw, after converting into kdbx, MacPass shows all the items, but it keeps complaining about expired passwords. KeePassX, KeePassXC and KeeWeb show only one item. There is probably something else that must be added to the generated XML, but I cannot find any documentation of the format. Any idea?

Btw, after converting into kdbx, MacPass shows all the items, but it keeps complaining about expired passwords. KeePassX, KeePassXC and KeeWeb show only one item. There is probably something else that must be added to the generated XML, but I cannot find any documentation of the format. Any idea?

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Apr 1, 2017

After exporting the converted xml to a kdbx file with KeePass MacPass and KeePassXC shows all entries as empty and i also get the expired password message. There are also 4 categories (Email, Internet....) that apparently were created automatically by your script. I think this should be disabled by default.

After exporting the converted xml to a kdbx file with KeePass MacPass and KeePassXC shows all entries as empty and i also get the expired password message. There are also 4 categories (Email, Internet....) that apparently were created automatically by your script. I think this should be disabled by default.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

Thanks for the quick feedback, I'll try to fix those bugs.

Thanks for the quick feedback, I'll try to fix those bugs.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 1, 2017

Ok, I think I've nailed it! Please update to the current master and let me know.

Ok, I think I've nailed it! Please update to the current master and let me know.

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Apr 1, 2017

Ok, now the password error and the additional categories are gone. The empty entries apparently were a problem with the column order. So i ran it with -U 1 -u 2 -p 3 -n 4 -t 5 -g 6 for LastPass's url,username,password,extra,name,grouping,fav CSV (theres no fav option in KeePass right?). But now my notes are stored in the password column and all passwords seem to be missing. I think Line 85 should be options[:notes] = o ;)

Another thing i noticed: When there are entries with a empty group column, the script puts them in a unnamed group instead of the root directory.

kennymc-c commented Apr 1, 2017

Ok, now the password error and the additional categories are gone. The empty entries apparently were a problem with the column order. So i ran it with -U 1 -u 2 -p 3 -n 4 -t 5 -g 6 for LastPass's url,username,password,extra,name,grouping,fav CSV (theres no fav option in KeePass right?). But now my notes are stored in the password column and all passwords seem to be missing. I think Line 85 should be options[:notes] = o ;)

Another thing i noticed: When there are entries with a empty group column, the script puts them in a unnamed group instead of the root directory.

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 2, 2017

Glad to hear that it (nearly) works for you.

I think Line 85 should be options[:notes] = o

Good catch. I've fixed it.

Another thing i noticed: When there are entries with a empty group column, the script puts them in a unnamed group instead of the root dictionary.

Could you open an issue at my repo and continue the discussion there? I'd like to know more about this.

Glad to hear that it (nearly) works for you.

I think Line 85 should be options[:notes] = o

Good catch. I've fixed it.

Another thing i noticed: When there are entries with a empty group column, the script puts them in a unnamed group instead of the root dictionary.

Could you open an issue at my repo and continue the discussion there? I'd like to know more about this.

@mstarke mstarke added the Plugin label Apr 2, 2017

@mstarke mstarke changed the title from Import from XML to Import from KeePass2 XML Apr 2, 2017

@mstarke

This comment has been minimized.

Show comment
Hide comment
@mstarke

mstarke Apr 2, 2017

Member

Thanks to you both for the effort you pour into this. The current master of MacPass can import KeePass XML files so you should be able to use your script to import them without any extra tools. KyPass AFAIK offers a CVS importer so this might be a viable option for a plugin to allow for differnt format imports

Member

mstarke commented Apr 2, 2017

Thanks to you both for the effort you pour into this. The current master of MacPass can import KeePass XML files so you should be able to use your script to import them without any extra tools. KyPass AFAIK offers a CVS importer so this might be a viable option for a plugin to allow for differnt format imports

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 2, 2017

I have tried the current master, but importing an XML file into a new document has no visible effect. Maybe, you mean the develop branch?

I have tried the current master, but importing an XML file into a new document has no visible effect. Maybe, you mean the develop branch?

@lifepillar

This comment has been minimized.

Show comment
Hide comment
@lifepillar

lifepillar Apr 2, 2017

Never mind, the version installed by Homebrew Cask (0.6.2-alpha) imports XML just fine. Should this issue be closed then?

Btw, thanks for super-wonderful and very much needed MacPass!

Never mind, the version installed by Homebrew Cask (0.6.2-alpha) imports XML just fine. Should this issue be closed then?

Btw, thanks for super-wonderful and very much needed MacPass!

@kennymc-c

This comment has been minimized.

Show comment
Hide comment
@kennymc-c

kennymc-c Apr 2, 2017

Ok, XML Import works for me as well with the latest version installed with Homebrew Cask.

Ok, XML Import works for me as well with the latest version installed with Homebrew Cask.

@mstarke

This comment has been minimized.

Show comment
Hide comment
@mstarke

mstarke Sep 7, 2017

Member

XML Import works but overrides the current file and is not the best way. The best solution would be:

  • Remove Import XML
  • Add XML as a file format for merging databases
  • Add XML as a file format for opening a new file
Member

mstarke commented Sep 7, 2017

XML Import works but overrides the current file and is not the best way. The best solution would be:

  • Remove Import XML
  • Add XML as a file format for merging databases
  • Add XML as a file format for opening a new file

@mstarke mstarke modified the milestones: 0.7, 0.8 Nov 18, 2017

@mstarke mstarke removed this from the 0.8 milestone Jan 3, 2018

@mstarke mstarke added this to the 0.9 milestone Jan 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment