|
| 1 | +#!/usr/bin/perl |
| 2 | +# @dynamic=expr@ fuzzer |
| 3 | + |
| 4 | +my @funcs = (); |
| 5 | + |
| 6 | +add_funcs ('md4', 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'gost', 'tiger', 'whirlpool', |
| 7 | + 'ripemd128', 'ripemd160', 'ripemd256', 'ripemd320', 'haval128_3', 'haval128_4', 'haval128_5', |
| 8 | + 'haval160_3', 'haval160_4', 'haval160_5', 'haval192_3', 'haval192_4', 'haval192_5', |
| 9 | + 'haval224_3', 'haval224_4', 'haval224_5', 'haval256_3', 'haval256_4', 'haval256_5', 'md2', |
| 10 | + 'skein224', 'skein256', 'skein384', 'skein512', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', |
| 11 | + 'keccak_256', 'keccak_512'); |
| 12 | + |
| 13 | +#foreach $f (@funcs) { |
| 14 | +# print "$f "; |
| 15 | +#} |
| 16 | +my $i; my $j; my $k; |
| 17 | +my $tests = 0; my $fails = 0; |
| 18 | +for ($i = 0; $i < scalar(@funcs); ++$i) { |
| 19 | + my $f = $funcs[$i]; |
| 20 | + next if $f =~ /_raw$/; |
| 21 | + my $s = `../run/john -test=0 -form=\'dynamic=$f(\$p)\'`; |
| 22 | + chomp $s; |
| 23 | + print $s." \r"; |
| 24 | + if (not $s =~ / PASS/) { |
| 25 | + print "-form=\'dynamic=$f(\$p)\' failed \n"; |
| 26 | + $fails += 1; |
| 27 | + } |
| 28 | + $tests += 1; |
| 29 | +} |
| 30 | +for ($i = 0; $i < scalar(@funcs); ++$i) { |
| 31 | + my $f = $funcs[$i]; |
| 32 | + next if $f =~ /_raw$/; |
| 33 | + for ($j = 0; $j < scalar(@funcs); ++$j) { |
| 34 | + my $f2 = $funcs[$j]; |
| 35 | + my $s = `../run/john -test=0 -form=\'dynamic=$f($f2(\$p))\'`; |
| 36 | + chomp $s; |
| 37 | + print $s." \r"; |
| 38 | + if (not $s =~ / PASS/) { |
| 39 | + print "-form=\'dynamic=$f($f2(\$p))\' failed \n"; |
| 40 | + $fails += 1; |
| 41 | + } |
| 42 | + $tests += 1; |
| 43 | + $s = `../run/john -test=0 -form=\'dynamic=$f($f2(\$s.\$p))\'`; |
| 44 | + chomp $s; |
| 45 | + print $s." \r"; |
| 46 | + if (not $s =~ / PASS/) { |
| 47 | + print "-form=\'dynamic=$f($f2(\$s.\$p))\' failed \n"; |
| 48 | + $fails += 1; |
| 49 | + } |
| 50 | + $tests += 1; |
| 51 | + $s = `../run/john -test=0 -form=\'dynamic=$f($f2(\$p).\$s)\'`; |
| 52 | + chomp $s; |
| 53 | + print $s." \r"; |
| 54 | + if (not $s =~ / PASS/) { |
| 55 | + print "-form=\'dynamic=$f($f2(\$p).\$s)\' failed \n"; |
| 56 | + $fails += 1; |
| 57 | + } |
| 58 | + $tests += 1; |
| 59 | + $s = `../run/john -test=0 -form=\'dynamic=$f($f2(\$p).\$s.$f(\$p))\'`; |
| 60 | + chomp $s; |
| 61 | + print $s." \r"; |
| 62 | + if (not $s =~ / PASS/) { |
| 63 | + print "-form=\'dynamic=$f($f2(\$p).\$s.$f(\$p))\' failed \n"; |
| 64 | + $fails += 1; |
| 65 | + } |
| 66 | + $s = `../run/john -test=0 -form=\'dynamic=$f(\$s.$f2(\$p).\$s.$f(\$p))\'`; |
| 67 | + chomp $s; |
| 68 | + print $s." \r"; |
| 69 | + if (not $s =~ / PASS/) { |
| 70 | + print "-form=\'dynamic=$f(\$s.$f2(\$p).\$s.$f(\$p))\' failed \n"; |
| 71 | + $fails += 1; |
| 72 | + } |
| 73 | + $tests += 1; |
| 74 | + } |
| 75 | +} |
| 76 | +print "dyna_expr_fuzzer.pl: Perfored $tests tests, and there were $fails failures. \n"; |
| 77 | + |
| 78 | +sub add_funcs { |
| 79 | + my $f = shift; |
| 80 | + while (defined $f) { |
| 81 | + push (@funcs, $f); |
| 82 | + push (@funcs, uc $f); |
| 83 | + push (@funcs, $f.'_raw'); |
| 84 | + push (@funcs, $f.'_64'); |
| 85 | + push (@funcs, $f.'_64c'); |
| 86 | + $f = shift; |
| 87 | + } |
| 88 | +} |
| 89 | + |
0 commit comments