Skip to content

Instantly share code, notes, and snippets.

@frioux
Created May 25, 2015 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frioux/8f84b5277306a00ed37b to your computer and use it in GitHub Desktop.
Save frioux/8f84b5277306a00ed37b to your computer and use it in GitHub Desktop.
Export passwords from Firefox into Keepass
#!/usr/bin/env perl
use 5.20.0;
use warnings;
use autodie;
use experimental 'postderef';
use File::KeePass;
use Text::CSV;
my ($file, $password) = @ARGV;
my $csv = Text::CSV->new;
my $k = File::KeePass->new;
$k->load_db($file, $password);
$k->unlock;
open my $fh, '<', "$HOME/password-export-2015-05-24";
# see https://addons.mozilla.org/en-US/firefox/addon/password-exporter/
$csv->column_names(
"hostname","username","password","formSubmitURL","httpRealm",
"usernameField","passwordField",
);
my $group = $k->find_group({ 'title =~' => qr/firefox/i });
$k->add_entry({
title => $_->{hostname},
username => $_->{username},
password => $_->{password},
group => $group->{id},
}) for $csv->getline_hr_all($fh)->@*;
$k->save_db($file, $password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment