mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-23 00:28:11 +00:00
Add -m 7300 unit test
This commit is contained in:
parent
6a387bf704
commit
179194a576
58
tools/test_modules/m07300.pm
Normal file
58
tools/test_modules/m07300.pm
Normal file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::HMAC qw (hmac_hex);
|
||||
use Digest::SHA qw (sha1);
|
||||
|
||||
sub module_constraints { [[0, 255], [32, 255], [0, 55], [32, 32], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $hash_buf = hmac_hex ($salt, $word, \&sha1);
|
||||
|
||||
my $hash = sprintf ("%s:%s", unpack ("H*", $salt), $hash_buf);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my $index1 = index ($line, ":");
|
||||
|
||||
return if $index1 < 1;
|
||||
|
||||
my $salt = substr ($line, 0, $index1);
|
||||
|
||||
$salt = pack ("H*", $salt);
|
||||
|
||||
my $rest = substr ($line, $index1 + 1);
|
||||
|
||||
my $index2 = index ($rest, ":");
|
||||
|
||||
return if $index2 < 1;
|
||||
|
||||
my $word = substr ($rest, $index2 + 1);
|
||||
|
||||
return unless defined $salt;
|
||||
return unless defined $word;
|
||||
|
||||
$word = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word, $salt);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user