diff --git a/tools/test_modules/m01421.pm b/tools/test_modules/m01421.pm new file mode 100644 index 000000000..37dd24d3e --- /dev/null +++ b/tools/test_modules/m01421.pm @@ -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; diff --git a/tools/test_modules/m01441.pm b/tools/test_modules/m01441.pm new file mode 100644 index 000000000..14b386fe7 --- /dev/null +++ b/tools/test_modules/m01441.pm @@ -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; diff --git a/tools/test_modules/m01450.pm b/tools/test_modules/m01450.pm new file mode 100644 index 000000000..ded944481 --- /dev/null +++ b/tools/test_modules/m01450.pm @@ -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; diff --git a/tools/test_modules/m01460.pm b/tools/test_modules/m01460.pm new file mode 100644 index 000000000..4195319f7 --- /dev/null +++ b/tools/test_modules/m01460.pm @@ -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; diff --git a/tools/test_modules/m01711.pm b/tools/test_modules/m01711.pm new file mode 100644 index 000000000..2d3a06dc1 --- /dev/null +++ b/tools/test_modules/m01711.pm @@ -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;