mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Add unit tests for several modes:
1750, 1760, 2100, 2410, 2611, 2612, 2711, 2811 & 3100
This commit is contained in:
parent
314d3c2f88
commit
e71fba037f
45
tools/test_modules/m01750.pm
Normal file
45
tools/test_modules/m01750.pm
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::SHA qw (sha512);
|
||||
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, \&sha512, 128);
|
||||
|
||||
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;
|
45
tools/test_modules/m01760.pm
Normal file
45
tools/test_modules/m01760.pm
Normal file
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::SHA qw (sha512);
|
||||
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, \&sha512, 128);
|
||||
|
||||
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;
|
74
tools/test_modules/m02100.pm
Normal file
74
tools/test_modules/m02100.pm
Normal file
@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD4 qw (md4 md4_hex);
|
||||
use Crypt::PBKDF2;
|
||||
use Encode;
|
||||
|
||||
sub module_constraints { [[0, 127], [0, 239], [0, 27], [0, 39], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
my $iterations = shift // 10240;
|
||||
|
||||
my $salt_bin = encode ("UTF-16LE", lc ($salt));
|
||||
|
||||
my $pbkdf2 = Crypt::PBKDF2->new
|
||||
(
|
||||
hash_class => 'HMACSHA1',
|
||||
iterations => $iterations,
|
||||
output_len => 16,
|
||||
salt_len => length ($salt_bin),
|
||||
);
|
||||
|
||||
my $digest = unpack ("H*", $pbkdf2->PBKDF2 ($salt_bin, md4 (md4 (encode ("UTF-16LE", $word)) . $salt_bin)));
|
||||
|
||||
my $hash = sprintf ("\$DCC2\$%i#%s#%s", $iterations, $salt, $digest);
|
||||
|
||||
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, 6);
|
||||
|
||||
return unless ($signature eq '$DCC2$');
|
||||
|
||||
$hash = substr ($hash, 6);
|
||||
|
||||
my @data = split ('#', $hash);
|
||||
|
||||
return unless scalar @data == 3;
|
||||
|
||||
my $iterations = shift @data;
|
||||
my $salt = shift @data;
|
||||
my $digest = shift @data;
|
||||
|
||||
return unless defined $iterations;
|
||||
return unless defined $salt;
|
||||
return unless defined $digest;
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $salt, $iterations);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
67
tools/test_modules/m02410.pm
Normal file
67
tools/test_modules/m02410.pm
Normal file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD5 qw (md5);
|
||||
use POSIX qw (ceil);
|
||||
|
||||
sub module_constraints { [[0, 255], [1, 4], [0, 55], [1, 4], [-1, -1]] }
|
||||
|
||||
sub pseudo_base64
|
||||
{
|
||||
my $itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
my $md5 = shift;
|
||||
my $s64 = "";
|
||||
for my $i (0..3) {
|
||||
my $v = unpack "V", substr ($md5, $i*4, 4);
|
||||
for (1..4) {
|
||||
$s64 .= substr ($itoa64, $v & 0x3f, 1);
|
||||
$v >>= 6;
|
||||
}
|
||||
}
|
||||
return $s64;
|
||||
}
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $word_salt = $word . $salt;
|
||||
|
||||
my $word_salt_len = length ($word_salt);
|
||||
|
||||
my $pad_len = ceil ($word_salt_len / 16) * 16;
|
||||
|
||||
my $digest = md5 ($word_salt . "\0" x ($pad_len - $word_salt_len));
|
||||
|
||||
my $hash = sprintf ("%s:%s", pseudo_base64 ($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;
|
44
tools/test_modules/m02611.pm
Normal file
44
tools/test_modules/m02611.pm
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD5 qw (md5_hex);
|
||||
|
||||
sub module_constraints { [[0, 255], [0, 223], [0, 55], [1, 23], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $digest = md5_hex (md5_hex ($word) . $salt);
|
||||
|
||||
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;
|
57
tools/test_modules/m02612.pm
Normal file
57
tools/test_modules/m02612.pm
Normal file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD5 qw (md5_hex);
|
||||
|
||||
sub module_constraints { [[0, 255], [0, 223], [0, 55], [1, 23], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $salt_hex = unpack ("H*", $salt);
|
||||
|
||||
my $digest = md5_hex (md5_hex ($word) . $salt);
|
||||
|
||||
my $hash = sprintf ("\$PHPS\$%s\$%s", $salt_hex, $digest);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my ($hash, $word) = split (':', $line);
|
||||
|
||||
return unless defined $hash;
|
||||
return unless defined $word;
|
||||
|
||||
my @data = split ('\$', $hash);
|
||||
|
||||
return unless scalar @data == 4;
|
||||
|
||||
shift @data;
|
||||
|
||||
my $signature = shift @data;
|
||||
my $salt = shift @data;
|
||||
my $digest = shift @data;
|
||||
|
||||
return unless ($signature eq "PHPS");
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $salt);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
44
tools/test_modules/m02711.pm
Normal file
44
tools/test_modules/m02711.pm
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD5 qw (md5_hex);
|
||||
|
||||
sub module_constraints { [[0, 255], [30, 30], [0, 55], [30, 30], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $digest = md5_hex (md5_hex ($word) . $salt);
|
||||
|
||||
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;
|
44
tools/test_modules/m02811.pm
Normal file
44
tools/test_modules/m02811.pm
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD5 qw (md5_hex);
|
||||
|
||||
sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 55], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $digest = md5_hex (md5_hex ($salt) . md5_hex ($word));
|
||||
|
||||
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;
|
75
tools/test_modules/m03100.pm
Normal file
75
tools/test_modules/m03100.pm
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Crypt::CBC;
|
||||
|
||||
sub module_constraints { [[0, 30], [0, 30], [0, 30], [0, 30], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
|
||||
my $digest = oracle_hash ($salt, $word);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
sub oracle_hash
|
||||
{
|
||||
my ($username, $password) = @_;
|
||||
|
||||
my $userpass = pack ('n*', unpack ('C*', uc ($username.$password)));
|
||||
$userpass .= pack ('C', 0) while (length ($userpass) % 8);
|
||||
|
||||
my $key = pack ('H*', "0123456789ABCDEF");
|
||||
my $iv = pack ('H*', "0000000000000000");
|
||||
|
||||
my $c = new Crypt::CBC (
|
||||
-literal_key => 1,
|
||||
-cipher => "DES",
|
||||
-key => $key,
|
||||
-iv => $iv,
|
||||
-header => "none"
|
||||
);
|
||||
my $key2 = substr ($c->encrypt ($userpass), length ($userpass)-8, 8);
|
||||
|
||||
my $c2 = new Crypt::CBC (
|
||||
-literal_key => 1,
|
||||
-cipher => "DES",
|
||||
-key => $key2,
|
||||
-iv => $iv,
|
||||
-header => "none"
|
||||
);
|
||||
my $hash = substr ($c2->encrypt ($userpass), length ($userpass)-8, 8);
|
||||
|
||||
return uc (unpack ('H*', $hash));
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user