mirror of
https://github.com/hashcat/hashcat
synced 2025-01-03 11:16:23 +01:00
Add -m 1411 unit test
This commit is contained in:
parent
54cfc60c57
commit
99c14b4d5f
65
tools/test_modules/m01411.pm
Normal file
65
tools/test_modules/m01411.pm
Normal file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::SHA qw (sha256_hex);
|
||||
use MIME::Base64 qw (encode_base64 decode_base64);
|
||||
|
||||
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [0, 55]] }
|
||||
|
||||
|
||||
# static const char *ST_HASH_01411 = "{SSHA256}L5Wk0zPY2lmoR5pH20zngq37KkxFwgTquEhx95rxfVk3Ng==";
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $digest = sha256_hex ($word . $salt);
|
||||
|
||||
my $base64_buf = encode_base64 (pack ("H*", $digest) . $salt, "");
|
||||
|
||||
my $hash = sprintf ("{SSHA256}%s", $base64_buf);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my ($hash, $word) = split (':', $line);
|
||||
|
||||
return unless defined $hash;
|
||||
return unless defined $word;
|
||||
|
||||
my $signature = substr ($hash, 0, 9);
|
||||
my $plain_base64 = substr ($hash, 9);
|
||||
|
||||
print "line: $line\n";
|
||||
print "hash: $hash\n";
|
||||
print "signature: $signature\n";
|
||||
print "plain_base64: $plain_base64\n";
|
||||
|
||||
return unless ($signature eq "{SSHA256}");
|
||||
return unless defined $plain_base64;
|
||||
|
||||
# base64 decode to extract salt
|
||||
my $decoded = decode_base64 ($plain_base64);
|
||||
|
||||
my $salt = substr ($decoded, 32);
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $salt);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user