|
4 | 4 | use jtrts_inc;
|
5 | 5 | use Digest::MD5;
|
6 | 6 |
|
7 |
| -my $VERSION = "1.12.18"; |
8 |
| -my $RELEASE_DATE = "Oct 31, 2014"; |
| 7 | +my $VERSION = "1.13"; |
| 8 | +my $RELEASE_DATE = "Dec 21, 2014"; |
9 | 9 | # how to do alpha character left, so next 'alpha', or beta release will be easy.
|
10 | 10 | #use utf8;
|
11 | 11 | #my $VERSION = "1.10-\x{3B1}2"; # alpha-2
|
|
33 | 33 | my @validFormats=();
|
34 | 34 | my @tstdata;
|
35 | 35 | my $showtypes=0, my $basepath=""; my $prelims=0, my $stop_on_error=0, my $show_stderr=0;
|
36 |
| -my $last_line_len=0; |
| 36 | +my $last_line_len=0; my $internal_testing; |
37 | 37 | my $error_cnt = 0, my $error_cnt_pot = 0; my $done_cnt = 0; my $ret_val_non_zero_cnt = 0;
|
38 | 38 | my @startingTime;
|
39 | 39 |
|
|
47 | 47 | readData();
|
48 | 48 | if ($showtypes) { showTypeData(); exit 0; }
|
49 | 49 | johnPrelims();
|
| 50 | +if ($internal_testing) { doInternalMode(); } |
50 | 51 | filterPatterns();
|
51 | 52 | process();
|
52 | 53 | cleanup();
|
@@ -97,6 +98,7 @@ sub parseArgs {
|
97 | 98 | 'passthru=s' => \@passthru,
|
98 | 99 | 'stoponerror!' => \$stop_on_error,
|
99 | 100 | 'showstderr!' => \$show_stderr,
|
| 101 | + 'internal!' => \$internal_testing, |
100 | 102 | );
|
101 | 103 | if ($basepath ne "") {
|
102 | 104 | $JOHN_PATH = $basepath;
|
@@ -371,6 +373,9 @@ sub loadAllValidFormatTypeStrings {
|
371 | 373 | # Make all format labels listed from JtR lower case.
|
372 | 374 | $fmt_str = lc($fmt_str);
|
373 | 375 |
|
| 376 | + # removed dynamic_n IF it exists |
| 377 | + $fmt_str =~ s/\/dynamic_n//g; |
| 378 | + |
374 | 379 | # Ok, now if we have 'dynamic's, LOAD them
|
375 | 380 | if (grepUsage("--list=WHAT") || grepUsage("--subformat=LIST")) {
|
376 | 381 | if (grepUsage("--list=WHAT")) {
|
@@ -592,6 +597,18 @@ sub process {
|
592 | 597 | my $dict_name_ex = "";
|
593 | 598 | my $dict_name = "";
|
594 | 599 | my $line = "";
|
| 600 | + |
| 601 | + #my $k = 0; |
| 602 | + #foreach my $l(@tstdata) { |
| 603 | + # my @ar = split(',', $l); |
| 604 | + # print "line=$l\n"; |
| 605 | + # my $i = 0; |
| 606 | + # foreach my $e(@ar) { |
| 607 | + # print "ar[$i] = $e\n"; |
| 608 | + # $i += 1; |
| 609 | + # } |
| 610 | + # exit(0); |
| 611 | + #} |
595 | 612 |
|
596 | 613 | LINE: foreach my $line(@tstdata) {
|
597 | 614 | my @ar = split(',', $line);
|
@@ -820,4 +837,66 @@ sub cleanup {
|
820 | 837 | unlink ("tst.pot");
|
821 | 838 | unlink ("tst.log");
|
822 | 839 | unlink ("tst.ses");
|
| 840 | + unlink ("selftest.dic"); |
| 841 | + unlink ("selftest.in"); |
| 842 | +} |
| 843 | + |
| 844 | +############################################################################### |
| 845 | +# Internal mode. This will generate a file from the format itself |
| 846 | +# using: |
| 847 | +# john -format=$fmt -list=format-tests | cut -f3 > selftest.in |
| 848 | +# john -format=$fmt -list=format-tests | cut -f4 > selftest.dic |
| 849 | +# this function does not return, it cleans up, and exits with proper errorlevel. |
| 850 | +############################################################################### |
| 851 | +sub doInternalMode { |
| 852 | + if (grepUsage("--pot=NAME")) { |
| 853 | + # we are OK, we run only on jumbo mode. |
| 854 | + } else { |
| 855 | + ScreenOut("John CORE build detected.\n The -internal mode ONLY works for jumbo build of john.\n"); |
| 856 | + exit 1; |
| 857 | + } |
| 858 | + ScreenOutSemi("Running JTRTS in -internal mode\n"); |
| 859 | + ScreenOutVV("\@validFormats\n"); |
| 860 | + ScreenOutVV(@validFormats); |
| 861 | + ScreenOutVV("\n\n\@types (before fixups)\n"); |
| 862 | + ScreenOutVV(@types); |
| 863 | + if (scalar @types == 3 && $types[0] eq "base" && $types[1] eq "koi8r" && $types[2] eq "utf8") { |
| 864 | + @types = @validFormats; |
| 865 | + } |
| 866 | + # handle finding 'classes' here, such as $types[x] == "dynamic", then find all dynamic |
| 867 | + # also handle other wildcard stuff. |
| 868 | + |
| 869 | + ScreenOutVV("\n\n\@types (after fixups)\n"); |
| 870 | + ScreenOutVV(@types); |
| 871 | + ScreenOutVV("\n\n\@nontypes\n"); |
| 872 | + ScreenOutVV(@nontypes); |
| 873 | + |
| 874 | + # now process the internal stuff. |
| 875 | + foreach my $type (@types) { |
| 876 | + my $fnd = 0; |
| 877 | + foreach my $nontype (@nontypes) { |
| 878 | + my $s = $type; |
| 879 | + if ($s =~ m/$nontype/) { |
| 880 | + $fnd = 1; |
| 881 | + } |
| 882 | + } |
| 883 | + if ($fnd == 0) { |
| 884 | + # first, build our dictionary |
| 885 | + my $cmd = "$JOHN_EXE -format=$type -list=format-tests 2>&1 | cut -f 4 > selftest.dic"; |
| 886 | + $cmd = `$cmd`; |
| 887 | + # Now build the input file |
| 888 | + $cmd = "$JOHN_EXE -format=$type -list=format-tests 2>&1 | cut -f3 > selftest.in"; |
| 889 | + $cmd = `$cmd`; |
| 890 | + my $cnt = `wc -l selftest.in | awk \'{print \$1}\'`; |
| 891 | + chomp $cnt; |
| 892 | + # build the @tstdata array with 1 element |
| 893 | + @tstdata = ("($type),(X),(jumbo),10000,$type,selftest,selftest.in,$type,Y,X,($cnt)(-show$cnt),($cnt)"); |
| 894 | + ScreenOutVV("Preparing to run internal for type: $type\n"); |
| 895 | + process(); |
| 896 | + } |
| 897 | + } |
| 898 | + |
| 899 | + cleanup(); |
| 900 | + displaySummary(); |
| 901 | + exit $error_cnt+$error_cnt_pot+$ret_val_non_zero_cnt; |
823 | 902 | }
|
0 commit comments