Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use v5.10;
- use strict;
- use warnings;
- use File::KeePass;
- use Getopt::Long;
- use IO::Prompt;
- use Data::Dump 'dump';
- use Mac::Pasteboard;
- my $db_file;
- GetOptions('file=s' => \$db_file);
- $db_file || die "usage:\nperl $0 --file KeePass.kdb";
- -r $db_file || die "can't read $db_file";
- my $pwd = IO::Prompt::prompt("$db_file password? ", -e => '*');
- my $k = File::KeePass->load_db($db_file, $pwd);
- my $pattern = IO::Prompt::prompt("look for? ");
- my @entries = $k->find_entries({ 'title =~' => qr/$pattern/i });
- say 'found ', scalar(@entries), ' entries';
- $k->unlock;
- for (my $i = 0; $i <= $#entries; $i++) {
- say join "\t", $i + 1, @{ $entries[$i] }{qw/title url username/};
- if (IO::Prompt::prompt('copy password? [y/n] ', -tys => 0.2)) {
- my $pb = Mac::Pasteboard->new();
- $pb->clear();
- $pb->copy($entries[$i]->{password});
- last;
- } ## end if (IO::Prompt::prompt...)
- } ## end for (my $i = 0; $i <= $#entries...)
- $k->lock;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement