Skip to content

Instantly share code, notes, and snippets.

@ravinggenius
Created November 11, 2012 01:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravinggenius/4053338 to your computer and use it in GitHub Desktop.
Save ravinggenius/4053338 to your computer and use it in GitHub Desktop.
Export XML passwords from Revelation password manager and convert to a CSV format that 1Password can import
-# this is an (incomplete) structure of the file that the script converts
%entry{:type => :folder}
%name Folder Name
-# forgot what type these entries are...
%entry{:type => :<not-folder>}
%name Name
%description Notes
%field{:id => 'generic-username'} Username
%field{:id => 'generic-password'} Password
%field{:id => 'generic-domain'} Domain Name
require 'csv'
require 'nokogiri'
require 'pry' # use binding.pry for debugging
password_file = ARGV.first
f = File.open(password_file)
xml = Nokogiri::XML(f)
f.close
lines = []
xml.css('entry[type="folder"]').each do |folder|
folder_name = folder.css('> name').first.text
folder.css('> entry').each do |entry|
line = {
:folder => folder_name,
:name => entry.css('name').text,
:description => entry.css('description').text,
}
entry.css('> field').each do |child|
line[child.attributes['id'].value.sub('generic-', '').to_sym] = child.text
end
lines << line
end
end
# if you do care about column order...
headers = [:folder, :name, :username, :password, :domain, :hostname, :url, :description]
# if you don't care about column order...
#headers = lines.map(&:keys).flatten.uniq
puts CSV.generate_line(headers, :force_quotes => true)
lines.each do |line|
puts CSV.generate_line(line.values_at(*headers), :force_quotes => true)
end
@antoineandrieu
Copy link

Thanks you

@ravinggenius
Copy link
Author

You're welcome! I have no idea if this works. Probably not...

@antoineandrieu
Copy link

I successfully used it to import my Revelation passwords into Bitwarden.

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