From 08118bedcc9d42e6381b1f20cc7636a00e446027 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 01:09:55 +0200 Subject: [PATCH 1/8] Add unit test for -m 3800 and -m 3910 --- tools/test_modules/m03800.pm | 44 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m03910.pm | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tools/test_modules/m03800.pm create mode 100644 tools/test_modules/m03910.pm diff --git a/tools/test_modules/m03800.pm b/tools/test_modules/m03800.pm new file mode 100644 index 000000000..4ae40c6d9 --- /dev/null +++ b/tools/test_modules/m03800.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, 15], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex ($salt . $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; + + $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/m03910.pm b/tools/test_modules/m03910.pm new file mode 100644 index 000000000..0416623c9 --- /dev/null +++ b/tools/test_modules/m03910.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], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex (md5_hex ($word) . md5_hex ($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; + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $salt); + + return ($new_hash, $word); +} + +1; From 438b74da569f874a78aece4263983131fc820b76 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 01:54:17 +0200 Subject: [PATCH 2/8] Add -m 4010 & -m 4110 unit tests --- tools/test_modules/m04010.pm | 44 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m04110.pm | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tools/test_modules/m04010.pm create mode 100644 tools/test_modules/m04110.pm diff --git a/tools/test_modules/m04010.pm b/tools/test_modules/m04010.pm new file mode 100644 index 000000000..b4cb00f5f --- /dev/null +++ b/tools/test_modules/m04010.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, 23], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex ($salt . md5_hex ($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; + + $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/m04110.pm b/tools/test_modules/m04110.pm new file mode 100644 index 000000000..97cc39715 --- /dev/null +++ b/tools/test_modules/m04110.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, 23], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md5_hex ($salt . 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; + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $salt); + + return ($new_hash, $word); +} + +1; From be4ab7320b6729b9848b7aba9a375b804d89ece7 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 01:56:42 +0200 Subject: [PATCH 3/8] Add -m 2600 unit test --- tools/test_modules/m02600.pm | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/test_modules/m02600.pm diff --git a/tools/test_modules/m02600.pm b/tools/test_modules/m02600.pm new file mode 100644 index 000000000..b07d893d6 --- /dev/null +++ b/tools/test_modules/m02600.pm @@ -0,0 +1,42 @@ +#!/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], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex md5_hex ($word); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; From 76ec0268a7ff8554c5e1c63cae1723b4538c7eea Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 02:20:03 +0200 Subject: [PATCH 4/8] Add unit test for -m 1410 -m 1420 -m ... -m 1440 -m 1710 -m 1720 -m 1730 -m 1740 -m 4300 -m 4400 -m 4500 -m 4520 -m 4700 --- tools/test_modules/m01410.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01420.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01430.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01440.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01710.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01720.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m01730.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m01740.pm | 45 ++++++++++++++++++++++++++++++++++++ tools/test_modules/m04300.pm | 42 +++++++++++++++++++++++++++++++++ tools/test_modules/m04400.pm | 43 ++++++++++++++++++++++++++++++++++ tools/test_modules/m04500.pm | 42 +++++++++++++++++++++++++++++++++ tools/test_modules/m04520.pm | 44 +++++++++++++++++++++++++++++++++++ tools/test_modules/m04700.pm | 43 ++++++++++++++++++++++++++++++++++ 13 files changed, 570 insertions(+) create mode 100644 tools/test_modules/m01410.pm create mode 100644 tools/test_modules/m01420.pm create mode 100644 tools/test_modules/m01430.pm create mode 100644 tools/test_modules/m01440.pm create mode 100644 tools/test_modules/m01710.pm create mode 100644 tools/test_modules/m01720.pm create mode 100644 tools/test_modules/m01730.pm create mode 100644 tools/test_modules/m01740.pm create mode 100644 tools/test_modules/m04300.pm create mode 100644 tools/test_modules/m04400.pm create mode 100644 tools/test_modules/m04500.pm create mode 100644 tools/test_modules/m04520.pm create mode 100644 tools/test_modules/m04700.pm diff --git a/tools/test_modules/m01410.pm b/tools/test_modules/m01410.pm new file mode 100644 index 000000000..83dd885a3 --- /dev/null +++ b/tools/test_modules/m01410.pm @@ -0,0 +1,44 @@ +#!/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], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_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/m01420.pm b/tools/test_modules/m01420.pm new file mode 100644 index 000000000..a01cd310a --- /dev/null +++ b/tools/test_modules/m01420.pm @@ -0,0 +1,44 @@ +#!/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], [0, 255], [0, 55], [0, 55], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha256_hex ($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); +} + +1; diff --git a/tools/test_modules/m01430.pm b/tools/test_modules/m01430.pm new file mode 100644 index 000000000..fc50531ce --- /dev/null +++ b/tools/test_modules/m01430.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_hex); +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_hex (encode ("UTF-16LE", $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/m01440.pm b/tools/test_modules/m01440.pm new file mode 100644 index 000000000..20d9fba07 --- /dev/null +++ b/tools/test_modules/m01440.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_hex); +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_hex ($salt . encode ("UTF-16LE", $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/m01710.pm b/tools/test_modules/m01710.pm new file mode 100644 index 000000000..2eea3aa98 --- /dev/null +++ b/tools/test_modules/m01710.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_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 = sha512_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/m01720.pm b/tools/test_modules/m01720.pm new file mode 100644 index 000000000..4cf470ee6 --- /dev/null +++ b/tools/test_modules/m01720.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha512_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 = sha512_hex ($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); +} + +1; diff --git a/tools/test_modules/m01730.pm b/tools/test_modules/m01730.pm new file mode 100644 index 000000000..7d69995b2 --- /dev/null +++ b/tools/test_modules/m01730.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_hex); +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 = sha512_hex (encode ("UTF-16LE", $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/m01740.pm b/tools/test_modules/m01740.pm new file mode 100644 index 000000000..ec2f30eda --- /dev/null +++ b/tools/test_modules/m01740.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_hex); +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 = sha512_hex ($salt . encode ("UTF-16LE", $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/m04300.pm b/tools/test_modules/m04300.pm new file mode 100644 index 000000000..305aef2f5 --- /dev/null +++ b/tools/test_modules/m04300.pm @@ -0,0 +1,42 @@ +#!/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], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex (uc (md5_hex ($word))); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04400.pm b/tools/test_modules/m04400.pm new file mode 100644 index 000000000..9ea04ef6a --- /dev/null +++ b/tools/test_modules/m04400.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = md5_hex (sha1_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04500.pm b/tools/test_modules/m04500.pm new file mode 100644 index 000000000..2eb160e99 --- /dev/null +++ b/tools/test_modules/m04500.pm @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = sha1_hex (sha1_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; diff --git a/tools/test_modules/m04520.pm b/tools/test_modules/m04520.pm new file mode 100644 index 000000000..ba0294290 --- /dev/null +++ b/tools/test_modules/m04520.pm @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [0, 255], [0, 55], [0, 31], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = sha1_hex ($salt . sha1_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/m04700.pm b/tools/test_modules/m04700.pm new file mode 100644 index 000000000..cf65f9771 --- /dev/null +++ b/tools/test_modules/m04700.pm @@ -0,0 +1,43 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5_hex); +use Digest::SHA qw (sha1_hex); + +sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + + my $digest = sha1_hex (md5_hex ($word)); + + my $hash = sprintf ("%s", $digest); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed); + + return ($new_hash, $word); +} + +1; From 3df9a862f3772c1bebb08abd485108cdef839f5f Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 02:44:39 +0200 Subject: [PATCH 5/8] Add -m 124 unit test --- tools/test_modules/m00124.pm | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tools/test_modules/m00124.pm diff --git a/tools/test_modules/m00124.pm b/tools/test_modules/m00124.pm new file mode 100644 index 000000000..df5dd87e7 --- /dev/null +++ b/tools/test_modules/m00124.pm @@ -0,0 +1,54 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1_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 = sha1_hex ($salt . $word); + + my $hash = sprintf ("sha1\$%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; + + my @data = split ('\$', $hash); + + return unless scalar @data == 3; + + my $signature = shift @data; + my $salt = shift @data; + my $checksum = shift @data; + + return unless ($signature eq "sha1"); + return unless defined $checksum; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, $salt); + + return ($new_hash, $word); +} + +1; From 54cfc60c57da09bbbdef30148f14493cf5ab2122 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 02:49:36 +0200 Subject: [PATCH 6/8] Add -m 1100 unit test --- tools/test_modules/m01100.pm | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/test_modules/m01100.pm diff --git a/tools/test_modules/m01100.pm b/tools/test_modules/m01100.pm new file mode 100644 index 000000000..458ceeb02 --- /dev/null +++ b/tools/test_modules/m01100.pm @@ -0,0 +1,45 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD4 qw (md4 md4_hex); +use Encode; + +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 27], [0, 27]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $digest = md4_hex (md4 (encode ("UTF-16LE", $word)) . encode ("UTF-16LE", lc ($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; From 99c14b4d5f68ddef180fbe916a87d998704620c3 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 03:01:12 +0200 Subject: [PATCH 7/8] Add -m 1411 unit test --- tools/test_modules/m01411.pm | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tools/test_modules/m01411.pm diff --git a/tools/test_modules/m01411.pm b/tools/test_modules/m01411.pm new file mode 100644 index 000000000..55e541802 --- /dev/null +++ b/tools/test_modules/m01411.pm @@ -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; From dabbc521cba8b5b7c721124058ae4faecae63916 Mon Sep 17 00:00:00 2001 From: mhasbini Date: Sun, 10 Feb 2019 03:33:41 +0200 Subject: [PATCH 8/8] Update -m 1100 unit test constraints --- tools/test_modules/m01100.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test_modules/m01100.pm b/tools/test_modules/m01100.pm index 458ceeb02..43876b261 100644 --- a/tools/test_modules/m01100.pm +++ b/tools/test_modules/m01100.pm @@ -11,7 +11,7 @@ use warnings; use Digest::MD4 qw (md4 md4_hex); use Encode; -sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 27], [0, 27]] } +sub module_constraints { [[0, 255], [0, 255], [0, 27], [0, 19], [0, 26]] } sub module_generate_hash {