diff --git a/tools/test_modules/m01750.pm b/tools/test_modules/m01750.pm new file mode 100644 index 000000000..645b5ddc0 --- /dev/null +++ b/tools/test_modules/m01750.pm @@ -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; diff --git a/tools/test_modules/m01760.pm b/tools/test_modules/m01760.pm new file mode 100644 index 000000000..afe3b99ad --- /dev/null +++ b/tools/test_modules/m01760.pm @@ -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; diff --git a/tools/test_modules/m02100.pm b/tools/test_modules/m02100.pm new file mode 100644 index 000000000..d395b815b --- /dev/null +++ b/tools/test_modules/m02100.pm @@ -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; diff --git a/tools/test_modules/m02410.pm b/tools/test_modules/m02410.pm new file mode 100644 index 000000000..d34f8f71e --- /dev/null +++ b/tools/test_modules/m02410.pm @@ -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; diff --git a/tools/test_modules/m02611.pm b/tools/test_modules/m02611.pm new file mode 100644 index 000000000..ef5c43009 --- /dev/null +++ b/tools/test_modules/m02611.pm @@ -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; diff --git a/tools/test_modules/m02612.pm b/tools/test_modules/m02612.pm new file mode 100644 index 000000000..ccf650c67 --- /dev/null +++ b/tools/test_modules/m02612.pm @@ -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; diff --git a/tools/test_modules/m02711.pm b/tools/test_modules/m02711.pm new file mode 100644 index 000000000..1e9e8c0e0 --- /dev/null +++ b/tools/test_modules/m02711.pm @@ -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; diff --git a/tools/test_modules/m02811.pm b/tools/test_modules/m02811.pm new file mode 100644 index 000000000..63730edba --- /dev/null +++ b/tools/test_modules/m02811.pm @@ -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; diff --git a/tools/test_modules/m03100.pm b/tools/test_modules/m03100.pm new file mode 100644 index 000000000..3a75dd0d0 --- /dev/null +++ b/tools/test_modules/m03100.pm @@ -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;