1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-23 00:28:11 +00:00

Merge pull request #1893 from 0xbsec/m18100_unit_test

Add unit test for -m 18100
This commit is contained in:
Jens Steube 2019-01-29 06:48:12 +01:00 committed by GitHub
commit 7df7476430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,57 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha1);
use Digest::HMAC qw (hmac_hex);
sub module_constraints { [[0, 255], [0, 55], [0, 255], [0, 55], [-1, -1]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $padded_time = sprintf ("%016x", int (int ($salt) / 30));
my $data = pack ('H*', $padded_time);
my $key = $word;
my $digest = hmac_hex ($data, $key, \&sha1, 64);
my $offset = hex (substr ($digest, -8)) & 0xf;
$offset *= 2;
my $token = hex (substr ($digest, $offset, 8));
$token &= 0x7fffffff;
$token %= 1000000;
# token must be leading zero padded, and salt leading zero stripped
my $hash = sprintf ("%06d:%d", $token, int ($salt));
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $salt, $word) = split (':', $line);
return unless defined $hash;
return unless defined $salt;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt);
return ($new_hash, $word);
}
1;