mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-21 23:58:07 +00:00
Add XML support for keepass keyfile and improve performance by not using chdir()
This commit is contained in:
parent
fd5700a607
commit
e363bf787e
49
tools/recursivefiles2sha256sum.pl
Normal file → Executable file
49
tools/recursivefiles2sha256sum.pl
Normal file → Executable file
@ -16,6 +16,7 @@ use strict;
|
||||
use warnings;
|
||||
use File::Find;
|
||||
use Digest::SHA;
|
||||
use XML::Simple;
|
||||
|
||||
my $sha = Digest::SHA->new ("sha256");
|
||||
|
||||
@ -26,7 +27,13 @@ if (scalar @folders == 0)
|
||||
die ("use: $0 folder1 folder2...\n");
|
||||
}
|
||||
|
||||
find (\&handlefile, @folders);
|
||||
my $conf =
|
||||
{
|
||||
wanted => \&handlefile,
|
||||
no_chdir => 1,
|
||||
};
|
||||
|
||||
find ($conf, @folders);
|
||||
|
||||
sub handlefile
|
||||
{
|
||||
@ -35,6 +42,45 @@ sub handlefile
|
||||
return unless -f $file;
|
||||
return unless -r $file;
|
||||
|
||||
open (my $fh, $file) or return;
|
||||
|
||||
binmode $fh;
|
||||
|
||||
my $nread = read ($fh, my $data, 5);
|
||||
|
||||
close ($fh);
|
||||
|
||||
my $xmlhash;
|
||||
|
||||
if (($nread == 5) && ($data eq "<?xml"))
|
||||
{
|
||||
my $xml = eval { XMLin ($file) or die };
|
||||
|
||||
if ($@)
|
||||
{
|
||||
# not interesting
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exists $xml->{"Key"} && exists $xml->{"Key"}->{"Data"})
|
||||
{
|
||||
chomp $xml->{"Key"}->{"Data"};
|
||||
|
||||
$xmlhash = $xml->{"Key"}->{"Data"};
|
||||
}
|
||||
else
|
||||
{
|
||||
# not interesting
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $xmlhash)
|
||||
{
|
||||
print "$xmlhash\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my $sha_copy = $sha->clone;
|
||||
|
||||
$sha_copy->addfile ($file);
|
||||
@ -43,3 +89,4 @@ sub handlefile
|
||||
|
||||
print "$digest\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user