Faced with the desire to import from password gorilla a little while
ago, I did the following:

1. Made a small TrueCrypt (http://www.truecrypt.org/) volume on my computer.
2. Used Password Gorilla's "Export" to dump everything to a .CSV file on
that TrueCrypt volume.
3. Wrote & run the "migrator.rb" script (attached) to import everything
into my pass tree. (Under the top-level dir "Gorilla" (see the
"pass_top_level" variable) since I have a lot of entries that need pruning.)

Caveats:

- The TrueCrypt volume was to prevent any automatic backup or other
persistent storage of all my unencrypted passwords, your situation may vary.
- The migrator.rb script has some logic to prune out duplicate entries
that were in my password DB due to a previous Password Gorilla merge I did.
- The migrator.rb script does NOT correctly handle the case where you
have two entries in the same category with the same title.

Hope this helps.

David


On 3/15/13 10:21 AM, ilf wrote:
> Does anyone have/know of a conversion script for the Counterpane
> Passwordsafe 2.0 database family?
> 
> http://passwordsafe.sourceforge.net/
> http://nsd.dyndns.org/pwsafe/
> http://www.semanticgap.com/myps/
> https://github.com/zdia/gorilla/wiki
> 
> 
> 
> _______________________________________________
> Password-Store mailing list
> [email protected]
> http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com
> 

#!/usr/bin/env ruby

entries = {}

class HashCounter

  def initialize
    @h = Hash.new {|h,k| h[k] = 2 }
  end

  def get(k)
    v = @h[k]
    @h[k] = v + 1
    v
  end
end

hc = HashCounter.new

$stdin.each do |line|
  uuid, group, title, url, user, password, notes = line.strip.split(',')
  next if uuid == "uuid"

  # check for missing group
  # check for missing title

  prefix = "#{group}/#{title}".gsub(/[\s\'\"()!]/,'')


  if user && user.length > 0
    entries["#{prefix}/user"] = user
  end
  if url && url.length > 0
    entries["#{prefix}/url"] = url
  end
  if password && password.length > 0
    entries["#{prefix}/password"] = password
  end
  if notes && notes.length > 0
    entries["#{prefix}/notes"] = notes.gsub('\n',"\n").strip
  end
end

entries.keys.each do |k|
  if k =~ /^(.+?)-merged\d{4}-\d\d-\d\d\d\d:\d\d:\d\d(\/.+)$/
    other = $1 + $2
    if entries.has_key?(other)
      if entries[k] == entries[other]
        entries.delete(k)
      else
        i = hc.get(other)
        entries["#{other}#{i}"] = entries[k]
        entries.delete(k)
      end
    else
      entries[other] = entries[k]
      entries.delete(k)
    end
  end
end

pass_top_level = "Gorilla"
entries.keys.each do |k|
  print "#{k}...(#{entries[k]})..."
  IO.popen("pass insert -e -f '#{pass_top_level}/#{k}' > /dev/null", 'w') do |io|
    io.puts entries[k] + "\n"
  end
  if $? == 0
    puts " done!"
  else
    puts " error!"
  end
end
_______________________________________________
Password-Store mailing list
[email protected]
http://lists.zx2c4.com/listinfo.cgi/password-store-zx2c4.com

Reply via email to