From 73af860f43def0f0d59423ddc053db4813851b8e Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Dec 2018 09:48:51 +0100 Subject: [PATCH] Add functionality in test.pl to allow empty hash returns. This is required to enable hash-mode depending password length checks. NTLM supports just 27 characters in optimized mode, but single mode would produce 32, resulting in a non found password --- modules/module_01000.c | 1 - src/Makefile | 1 + tools/test.pl | 40 ++++++++++++++++++------------------ tools/test.sh | 2 +- tools/test_modules/m01000.pm | 4 ++++ 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/modules/module_01000.c b/modules/module_01000.c index 3a8a68aff..83a884b90 100644 --- a/modules/module_01000.c +++ b/modules/module_01000.c @@ -8,7 +8,6 @@ #include "modules.h" #include "bitops.h" #include "convert.h" -#include "interface.h" #include "shared.h" static const u32 MODULE_VERSION_CURRENT = 520; diff --git a/src/Makefile b/src/Makefile index 82b366ea3..7de02f2c4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -371,6 +371,7 @@ default: $(HASHCAT_FRONTEND) clean: $(RM) -f $(HASHCAT_FRONTEND) $(RM) -f $(HASHCAT_LIBRARY) + $(RM) -f modules/*.dll $(RM) -f modules/*.so $(RM) -f obj/*.o $(RM) -f *.bin *.exe diff --git a/tools/test.pl b/tools/test.pl index 09638411a..d3985bc55 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -28,6 +28,9 @@ my $module = sprintf ("m%05d.pm", $MODE); eval { require $module; } or die "Could not load test module: $module\n$@"; +exists &{module_generate_hash} or die "Module function 'module_generate_hash' not found\n"; +exists &{module_verify_hash} or die "Module function 'module_verify_hash' not found\n"; + if ($TYPE eq 'single') { single (@ARGV); @@ -49,8 +52,6 @@ else sub single { - exists &{module_generate_hash} or die "Module function not found\n"; - my $len = shift; undef $len unless is_count ($len); @@ -62,6 +63,7 @@ sub single my $cur_len = $len // $i; my $word = random_numeric_string ($cur_len); + my $hash = module_generate_hash ($word); next unless defined $hash; @@ -72,15 +74,13 @@ sub single sub passthrough { - exists &{module_generate_hash} or die "Module function not found\n"; - - while (<>) + while (my $word = <>) { - chomp $_; + chomp $word; - next if length $_ > 256; + my $hash = module_generate_hash ($word); - my $hash = module_generate_hash ($_); + next unless defined $hash; print "$hash\n"; } @@ -88,8 +88,6 @@ sub passthrough sub verify { - exists &{module_verify_hash} or die "Module function not found\n"; - my $hashes_file = shift; my $cracks_file = shift; my $out_file = shift; @@ -98,33 +96,35 @@ sub verify my $hashlist; - while () + while (my $line = ) { - s/[\n\r]*$//; + $line =~ s/\n$//; + $line =~ s/\r$//; - push (@{$hashlist}, $_); + push (@{$hashlist}, $line); } - close IN; + close (IN); open (IN, '<', $cracks_file) or die "$cracks_file: $!\n"; open (OUT, '>', $out_file ) or die "$out_file: $!\n"; - while () + while (my $line = ) { - s/[\n\r]*$//; + $line =~ s/\n$//; + $line =~ s/\r$//; - my $hash = module_verify_hash ($_); + my $hash = module_verify_hash ($line); next unless defined $hash; next unless is_in_array ($hash, $hashlist); - print OUT "$_\n"; + print OUT "$line\n"; } - close IN; - close OUT; + close (IN); + close (OUT); } sub is_in_array diff --git a/tools/test.sh b/tools/test.sh index 8ca06a0db..454a9c68f 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -5,7 +5,7 @@ ## License.....: MIT ## -OPTS="--quiet --force --potfile-disable --runtime 400 --hwmon-disable" +OPTS="--quiet --force --potfile-disable --runtime 400 --hwmon-disable -O" TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/tools/test_modules/m01000.pm b/tools/test_modules/m01000.pm index be27b5d62..dbfbbe865 100644 --- a/tools/test_modules/m01000.pm +++ b/tools/test_modules/m01000.pm @@ -15,6 +15,8 @@ sub module_generate_hash { my $word = shift; + return if length $word > 27; + my $hash = md4_hex (encode ("UTF-16LE", $word)); return $hash; @@ -33,6 +35,8 @@ sub module_verify_hash my $new_hash = module_generate_hash ($word); + return unless defined $new_hash; + return unless $new_hash eq $hash; return $new_hash;