mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-23 07:08:19 +00:00
Add -m 10000 unit test
This commit is contained in:
parent
78d8c1583f
commit
b0bffaf5eb
76
tools/test_modules/m10000.pm
Normal file
76
tools/test_modules/m10000.pm
Normal file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Crypt::PBKDF2;
|
||||
use MIME::Base64 qw (encode_base64);
|
||||
|
||||
sub module_constraints { [[0, 255], [0, 15], [-1, -1], [-1, -1], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
my $iter = shift // 10000;
|
||||
|
||||
my $pbkdf2 = Crypt::PBKDF2->new
|
||||
(
|
||||
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
|
||||
iterations => $iter
|
||||
);
|
||||
|
||||
my $hash_buf = encode_base64 ($pbkdf2->PBKDF2 ($salt, $word), "");
|
||||
|
||||
my $hash = sprintf ("pbkdf2_sha256\$%i\$%s\$%s", $iter, $salt, $hash_buf);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
# Django (PBKDF2-SHA256)
|
||||
next unless (substr ($line, 0, 14) eq 'pbkdf2_sha256$');
|
||||
|
||||
# get hash
|
||||
my $index1 = index ($line, "\$", 14);
|
||||
|
||||
return if $index1 < 1;
|
||||
|
||||
my $index2 = index ($line, "\$", $index1 + 1);
|
||||
|
||||
# iter
|
||||
|
||||
my $iter = substr ($line, 14, $index1 - 14);
|
||||
|
||||
# salt
|
||||
|
||||
my $salt = substr ($line, $index1 + 1, $index2 - $index1 - 1);
|
||||
|
||||
# digest
|
||||
|
||||
$index1 = index ($line, ":", $index2 + 1);
|
||||
|
||||
return if $index1 < 1;
|
||||
|
||||
my $word = substr ($line, $index1 + 1);
|
||||
|
||||
return unless defined $salt;
|
||||
return unless defined $iter;
|
||||
return unless defined $word;
|
||||
|
||||
$word = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word, $salt, $iter);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user