mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-16 17:42:04 +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 warnings;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use Digest::SHA;
|
use Digest::SHA;
|
||||||
|
use XML::Simple;
|
||||||
|
|
||||||
my $sha = Digest::SHA->new ("sha256");
|
my $sha = Digest::SHA->new ("sha256");
|
||||||
|
|
||||||
@ -26,7 +27,13 @@ if (scalar @folders == 0)
|
|||||||
die ("use: $0 folder1 folder2...\n");
|
die ("use: $0 folder1 folder2...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
find (\&handlefile, @folders);
|
my $conf =
|
||||||
|
{
|
||||||
|
wanted => \&handlefile,
|
||||||
|
no_chdir => 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
find ($conf, @folders);
|
||||||
|
|
||||||
sub handlefile
|
sub handlefile
|
||||||
{
|
{
|
||||||
@ -35,6 +42,45 @@ sub handlefile
|
|||||||
return unless -f $file;
|
return unless -f $file;
|
||||||
return unless -r $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;
|
my $sha_copy = $sha->clone;
|
||||||
|
|
||||||
$sha_copy->addfile ($file);
|
$sha_copy->addfile ($file);
|
||||||
@ -42,4 +88,5 @@ sub handlefile
|
|||||||
my $digest = $sha_copy->hexdigest;
|
my $digest = $sha_copy->hexdigest;
|
||||||
|
|
||||||
print "$digest\n";
|
print "$digest\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user