Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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