diff --git a/tools/test_modules/m07700.pm b/tools/test_modules/m07700.pm new file mode 100644 index 000000000..07badbc6d --- /dev/null +++ b/tools/test_modules/m07700.pm @@ -0,0 +1,181 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5); + +sub module_constraints { [[-1, -1], [-1, -1], [0, 8], [1, 12], [0, 55]] } + +sub sapb_transcode +{ + my $data_s = shift; + + my @data = split "", $data_s; + + my $transTable_s = + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\x3f\x40\x41\x50\x43\x44\x45\x4b\x47\x48\x4d\x4e\x54\x51\x53\x46" . + "\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x56\x55\x5c\x49\x5d\x4a" . + "\x42\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" . + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x58\x5b\x59\xff\x52" . + "\x4c\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" . + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x57\x5e\x5a\x4f\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; + + my @transTable = unpack ("C256", $transTable_s); + + my @out; + + for (my $i = 0; $i < scalar @data; $i++) + { + $out[$i] = $transTable[int (ord ($data[$i]))]; + } + + return pack ("C*", @out); +} + +sub sapb_waldorf +{ + my $digest_s = shift; + + my $w_s = shift; + my $s_s = shift; + + my @w = unpack "C*", $w_s; + my @s = unpack "C*", $s_s; + + my $bcodeTable_s = + "\x14\x77\xf3\xd4\xbb\x71\x23\xd0\x03\xff\x47\x93\x55\xaa\x66\x91" . + "\xf2\x88\x6b\x99\xbf\xcb\x32\x1a\x19\xd9\xa7\x82\x22\x49\xa2\x51" . + "\xe2\xb7\x33\x71\x8b\x9f\x5d\x01\x44\x70\xae\x11\xef\x28\xf0\x0d"; + + my @bcodeTable = unpack ("C48", $bcodeTable_s); + + my @abcd = unpack ("C16", $digest_s); + + my $sum20 = ($abcd[0] & 3) + + ($abcd[1] & 3) + + ($abcd[2] & 3) + + ($abcd[3] & 3) + + ($abcd[5] & 3); + + $sum20 |= 0x20; + + my @out; + + for (my $i2 = 0; $i2 < $sum20; $i2++) + { + $out[$i2] = 0; + } + + for (my $i1 = 0, my $i2 = 0, my $i3 = 0; $i2 < $sum20; $i2++, $i2++) + { + if ($i1 < length $w_s) + { + if ($abcd[15 - $i1] & 1) + { + $out[$i2] = $bcodeTable[48 - 1 - $i1]; + + $i2++; + } + + $out[$i2] = $w[$i1]; + + $i1++; + $i2++; + } + + if ($i3 < length $s_s) + { + $out[$i2] = $s[$i3]; + + $i2++; + $i3++; + } + + $out[$i2] = $bcodeTable[$i2 - $i1 - $i3]; + } + + return substr (pack ("C*", @out), 0, $sum20); +} + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + $word = uc $word; + $salt = uc $salt; + + my $word_buf_t = sapb_transcode ($word); + my $salt_buf_t = sapb_transcode ($salt); + + my $digest1 = md5 ($word_buf_t . $salt_buf_t); + + my $data = sapb_waldorf ($digest1, $word_buf_t, $salt_buf_t); + + my $digest2 = md5 ($data); + + my ($a, $b, $c, $d) = unpack ("N4", $digest2); + + $a ^= $c; + $b ^= $d; + + my $hash = sprintf ("%s\$%08X%08X", $salt, $a, $b); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my @split1 = split (":", $line); + + my @split2 = split ('\$', $split1[0]); + + return unless scalar @split2 == 2; + + my $word; + + if (scalar @split1 > 1) + { + $word = $split1[1]; + } + else + { + $word = ""; + } + + my $salt = $split2[0]; + + 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/m07701.pm b/tools/test_modules/m07701.pm new file mode 100644 index 000000000..e2d4b2156 --- /dev/null +++ b/tools/test_modules/m07701.pm @@ -0,0 +1,181 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::MD5 qw (md5); + +sub module_constraints { [[-1, -1], [-1, -1], [0, 8], [1, 12], [0, 55]] } + +sub sapb_transcode +{ + my $data_s = shift; + + my @data = split "", $data_s; + + my $transTable_s = + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\x3f\x40\x41\x50\x43\x44\x45\x4b\x47\x48\x4d\x4e\x54\x51\x53\x46" . + "\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x56\x55\x5c\x49\x5d\x4a" . + "\x42\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" . + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x58\x5b\x59\xff\x52" . + "\x4c\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" . + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x57\x5e\x5a\x4f\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" . + "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; + + my @transTable = unpack ("C256", $transTable_s); + + my @out; + + for (my $i = 0; $i < scalar @data; $i++) + { + $out[$i] = $transTable[int (ord ($data[$i]))]; + } + + return pack ("C*", @out); +} + +sub sapb_waldorf +{ + my $digest_s = shift; + + my $w_s = shift; + my $s_s = shift; + + my @w = unpack "C*", $w_s; + my @s = unpack "C*", $s_s; + + my $bcodeTable_s = + "\x14\x77\xf3\xd4\xbb\x71\x23\xd0\x03\xff\x47\x93\x55\xaa\x66\x91" . + "\xf2\x88\x6b\x99\xbf\xcb\x32\x1a\x19\xd9\xa7\x82\x22\x49\xa2\x51" . + "\xe2\xb7\x33\x71\x8b\x9f\x5d\x01\x44\x70\xae\x11\xef\x28\xf0\x0d"; + + my @bcodeTable = unpack ("C48", $bcodeTable_s); + + my @abcd = unpack ("C16", $digest_s); + + my $sum20 = ($abcd[0] & 3) + + ($abcd[1] & 3) + + ($abcd[2] & 3) + + ($abcd[3] & 3) + + ($abcd[5] & 3); + + $sum20 |= 0x20; + + my @out; + + for (my $i2 = 0; $i2 < $sum20; $i2++) + { + $out[$i2] = 0; + } + + for (my $i1 = 0, my $i2 = 0, my $i3 = 0; $i2 < $sum20; $i2++, $i2++) + { + if ($i1 < length $w_s) + { + if ($abcd[15 - $i1] & 1) + { + $out[$i2] = $bcodeTable[48 - 1 - $i1]; + + $i2++; + } + + $out[$i2] = $w[$i1]; + + $i1++; + $i2++; + } + + if ($i3 < length $s_s) + { + $out[$i2] = $s[$i3]; + + $i2++; + $i3++; + } + + $out[$i2] = $bcodeTable[$i2 - $i1 - $i3]; + } + + return substr (pack ("C*", @out), 0, $sum20); +} + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + $word = uc $word; + $salt = uc $salt; + + my $word_buf_t = sapb_transcode ($word); + my $salt_buf_t = sapb_transcode ($salt); + + my $digest1 = md5 ($word_buf_t . $salt_buf_t); + + my $data = sapb_waldorf ($digest1, $word_buf_t, $salt_buf_t); + + my $digest2 = md5 ($data); + + my ($a, $b, $c, $d) = unpack ("N4", $digest2); + + $a ^= $c; + $b ^= $d; + + my $hash = sprintf ("%s\$%08X%08X", $salt, $a, 0); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my @split1 = split (":", $line); + + my @split2 = split ('\$', $split1[0]); + + return unless scalar @split2 == 2; + + my $word; + + if (scalar @split1 > 1) + { + $word = $split1[1]; + } + else + { + $word = ""; + } + + my $salt = $split2[0]; + + 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/m07800.pm b/tools/test_modules/m07800.pm new file mode 100644 index 000000000..bf17095c4 --- /dev/null +++ b/tools/test_modules/m07800.pm @@ -0,0 +1,107 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1 sha1_hex); + +sub module_constraints { [[-1, -1], [-1, -1], [0, 55], [1, 12], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $theMagicArray_s = + "\x91\xac\x51\x14\x9f\x67\x54\x43\x24\xe7\x3b\xe0\x28\x74\x7b\xc2" . + "\x86\x33\x13\xeb\x5a\x4f\xcb\x5c\x08\x0a\x73\x37\x0e\x5d\x1c\x2f" . + "\x33\x8f\xe6\xe5\xf8\x9b\xae\xdd\x16\xf2\x4b\x8d\x2c\xe1\xd4\xdc" . + "\xb0\xcb\xdf\x9d\xd4\x70\x6d\x17\xf9\x4d\x42\x3f\x9b\x1b\x11\x94" . + "\x9f\x5b\xc1\x9b\x06\x05\x9d\x03\x9d\x5e\x13\x8a\x1e\x9a\x6a\xe8" . + "\xd9\x7c\x14\x17\x58\xc7\x2a\xf6\xa1\x99\x63\x0a\xd7\xfd\x70\xc3" . + "\xf6\x5e\x74\x13\x03\xc9\x0b\x04\x26\x98\xf7\x26\x8a\x92\x93\x25" . + "\xb0\xa2\x0d\x23\xed\x63\x79\x6d\x13\x32\xfa\x3c\x35\x02\x9a\xa3" . + "\xb3\xdd\x8e\x0a\x24\xbf\x51\xc3\x7c\xcd\x55\x9f\x37\xaf\x94\x4c" . + "\x29\x08\x52\x82\xb2\x3b\x4e\x37\x9f\x17\x07\x91\x11\x3b\xfd\xcd"; + + $salt = uc $salt; + + my $digest = sha1 ($word . $salt); + + my ($a, $b, $c, $d, $e) = unpack ("I*", $digest); + + my $lengthMagicArray = 0x20; + my $offsetMagicArray = 0; + + $lengthMagicArray += (($a >> 0) & 0xff) % 6; + $lengthMagicArray += (($a >> 8) & 0xff) % 6; + $lengthMagicArray += (($a >> 16) & 0xff) % 6; + $lengthMagicArray += (($a >> 24) & 0xff) % 6; + $lengthMagicArray += (($b >> 0) & 0xff) % 6; + $lengthMagicArray += (($b >> 8) & 0xff) % 6; + $lengthMagicArray += (($b >> 16) & 0xff) % 6; + $lengthMagicArray += (($b >> 24) & 0xff) % 6; + $lengthMagicArray += (($c >> 0) & 0xff) % 6; + $lengthMagicArray += (($c >> 8) & 0xff) % 6; + $offsetMagicArray += (($c >> 16) & 0xff) % 8; + $offsetMagicArray += (($c >> 24) & 0xff) % 8; + $offsetMagicArray += (($d >> 0) & 0xff) % 8; + $offsetMagicArray += (($d >> 8) & 0xff) % 8; + $offsetMagicArray += (($d >> 16) & 0xff) % 8; + $offsetMagicArray += (($d >> 24) & 0xff) % 8; + $offsetMagicArray += (($e >> 0) & 0xff) % 8; + $offsetMagicArray += (($e >> 8) & 0xff) % 8; + $offsetMagicArray += (($e >> 16) & 0xff) % 8; + $offsetMagicArray += (($e >> 24) & 0xff) % 8; + + my $hash_buf = sha1_hex ($word . substr ($theMagicArray_s, $offsetMagicArray, $lengthMagicArray) . $salt); + + my $hash = sprintf ("%s\$%s", $salt, uc $hash_buf); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my @split1 = split (":", $line); + + my @split2 = split ('\$', $split1[0]); + + return unless scalar @split2 == 2; + + my $word; + + if (scalar @split1 > 1) + { + $word = $split1[1]; + } + else + { + $word = ""; + } + + my $salt = $split2[0]; + + 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/m07801.pm b/tools/test_modules/m07801.pm new file mode 100644 index 000000000..0ea6dda86 --- /dev/null +++ b/tools/test_modules/m07801.pm @@ -0,0 +1,107 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha1 sha1_hex); + +sub module_constraints { [[-1, -1], [-1, -1], [0, 55], [1, 12], [0, 55]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $theMagicArray_s = + "\x91\xac\x51\x14\x9f\x67\x54\x43\x24\xe7\x3b\xe0\x28\x74\x7b\xc2" . + "\x86\x33\x13\xeb\x5a\x4f\xcb\x5c\x08\x0a\x73\x37\x0e\x5d\x1c\x2f" . + "\x33\x8f\xe6\xe5\xf8\x9b\xae\xdd\x16\xf2\x4b\x8d\x2c\xe1\xd4\xdc" . + "\xb0\xcb\xdf\x9d\xd4\x70\x6d\x17\xf9\x4d\x42\x3f\x9b\x1b\x11\x94" . + "\x9f\x5b\xc1\x9b\x06\x05\x9d\x03\x9d\x5e\x13\x8a\x1e\x9a\x6a\xe8" . + "\xd9\x7c\x14\x17\x58\xc7\x2a\xf6\xa1\x99\x63\x0a\xd7\xfd\x70\xc3" . + "\xf6\x5e\x74\x13\x03\xc9\x0b\x04\x26\x98\xf7\x26\x8a\x92\x93\x25" . + "\xb0\xa2\x0d\x23\xed\x63\x79\x6d\x13\x32\xfa\x3c\x35\x02\x9a\xa3" . + "\xb3\xdd\x8e\x0a\x24\xbf\x51\xc3\x7c\xcd\x55\x9f\x37\xaf\x94\x4c" . + "\x29\x08\x52\x82\xb2\x3b\x4e\x37\x9f\x17\x07\x91\x11\x3b\xfd\xcd"; + + $salt = uc $salt; + + my $digest = sha1 ($word . $salt); + + my ($a, $b, $c, $d, $e) = unpack ("I*", $digest); + + my $lengthMagicArray = 0x20; + my $offsetMagicArray = 0; + + $lengthMagicArray += (($a >> 0) & 0xff) % 6; + $lengthMagicArray += (($a >> 8) & 0xff) % 6; + $lengthMagicArray += (($a >> 16) & 0xff) % 6; + $lengthMagicArray += (($a >> 24) & 0xff) % 6; + $lengthMagicArray += (($b >> 0) & 0xff) % 6; + $lengthMagicArray += (($b >> 8) & 0xff) % 6; + $lengthMagicArray += (($b >> 16) & 0xff) % 6; + $lengthMagicArray += (($b >> 24) & 0xff) % 6; + $lengthMagicArray += (($c >> 0) & 0xff) % 6; + $lengthMagicArray += (($c >> 8) & 0xff) % 6; + $offsetMagicArray += (($c >> 16) & 0xff) % 8; + $offsetMagicArray += (($c >> 24) & 0xff) % 8; + $offsetMagicArray += (($d >> 0) & 0xff) % 8; + $offsetMagicArray += (($d >> 8) & 0xff) % 8; + $offsetMagicArray += (($d >> 16) & 0xff) % 8; + $offsetMagicArray += (($d >> 24) & 0xff) % 8; + $offsetMagicArray += (($e >> 0) & 0xff) % 8; + $offsetMagicArray += (($e >> 8) & 0xff) % 8; + $offsetMagicArray += (($e >> 16) & 0xff) % 8; + $offsetMagicArray += (($e >> 24) & 0xff) % 8; + + my $hash_buf = sha1_hex ($word . substr ($theMagicArray_s, $offsetMagicArray, $lengthMagicArray) . $salt); + + my $hash = sprintf("%s\$%.20s%020X", $salt, uc $hash_buf, 0); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 < 1; + + my @split1 = split (":", $line); + + my @split2 = split ('\$', $split1[0]); + + return unless scalar @split2 == 2; + + my $word; + + if (scalar @split1 > 1) + { + $word = $split1[1]; + } + else + { + $word = ""; + } + + my $salt = $split2[0]; + + 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; +