#  cpan install XML::Parser
#  cpan install Crypt::Rijndael
#  cpan install File::KeePass
#

use warnings; 
use strict;
use File::KeePass;
use open ':std', ':encoding(UTF-8)';

my $k = File::KeePass->new;
my ($p, $w) = @ARGV;
print "[+] KeePass dictionary password enumerator\n";
&banner and die "[!] Usage: perl $0 <Keepass DBv1 or DBv2> <Wordlist>" if  @ARGV != 2;
open (KEEPASSDB, "  <$p") or die "[-] Error: $p $!";
die "[-]Error: The database is empty." if (-z $p);
close (KEEPASSDB);
open (WORDLIST, "  <$w") or die "[-] Error: $w $!";
die "[-] Error: Wordlist is empty" if (-z $w);
my @file = <WORDLIST>;
print "[*] ======\n";
foreach my $c(@file)
{
  chomp $c;
if (! eval { $k->load_db($p, $c) }) {
        print "[?] Trying $c\n";
    } else{
       &banner and die "[*] Password for $p is $c\n";
    }
}
close (WORDLIST);
die "[-] Sorry, $@";