1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-10 15:51:10 +00:00

Add unit tests for -m 1421 -m 1441 -m 1450 -m 1460 -m 1711

This commit is contained in:
mhasbini 2019-02-10 13:21:20 +02:00
parent c3f7c30eea
commit 7c67346bfc
5 changed files with 250 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha256_hex);
sub module_constraints { [[0, 255], [6, 6], [0, 55], [6, 6], [0, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = sha256_hex ($salt . $word);
my $hash = sprintf ("%s%s", $salt, $digest);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
return unless length ($hash) == 70;
my $salt = substr ($hash, 0, 6);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt);
return ($new_hash, $word);
}
1;

View File

@ -0,0 +1,58 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha256);
use MIME::Base64 qw (encode_base64 decode_base64);
use Encode;
sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 55], [0, 27]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = sha256 ($salt . encode ("UTF-16LE", $word));
my $base64_salt_buf = encode_base64 ($salt, "");
my $base64_hash_buf = encode_base64 ($digest, "");
$base64_hash_buf = substr ($base64_hash_buf, 0, 43);
my $hash = sprintf ("\$episerver\$*1*%s*%s", $base64_salt_buf, $base64_hash_buf);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($digest, $word) = split (':', $line);
$digest = substr ($digest, 14);
my ($base64_salt, $base64_hash) = split ('\*', $digest);
my $hash = decode_base64 ($base64_hash);
my $salt = decode_base64 ($base64_salt);
return unless defined $hash;
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;

View File

@ -0,0 +1,45 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha256);
use Digest::HMAC qw (hmac_hex);
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = hmac_hex ($salt, $word, \&sha256, 64);
my $hash = sprintf ("%s:%s", $digest, $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;

View File

@ -0,0 +1,45 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha256);
use Digest::HMAC qw (hmac_hex);
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = hmac_hex ($word, $salt, \&sha256, 64);
my $hash = sprintf ("%s:%s", $digest, $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;

View File

@ -0,0 +1,56 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Digest::SHA qw (sha512_hex);
use MIME::Base64 qw (encode_base64);
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] }
sub module_generate_hash
{
my $word = shift;
my $salt = shift;
my $digest = sha512_hex ($word . $salt);
my $base64_buf = encode_base64 (pack ("H*", $digest) . $salt, "");
my $hash = sprintf ("{SSHA512}%s", $base64_buf);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($digest, $word) = split (':', $line);
return unless defined $digest;
return unless defined $word;
my $signature = substr ($digest, 0, 9);
my $plain_base64 = substr ($digest, 9);
return unless ($signature eq "{SSHA512}");
return unless defined $plain_base64;
my $decoded = decode_base64 ($plain_base64);
my $salt = substr ($decoded, 64);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed, $salt);
return ($new_hash, $word);
}
1;