Created
November 11, 2012 01:49
-
-
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I successfully used it to import my Revelation passwords into Bitwarden.