From 0f0cf1fe08d546640a2eefb654b45f51666f5dcf Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 3 Jan 2022 17:16:27 +0100 Subject: [PATCH 01/18] Removed hc_clSetKernelArg() call from backend_session_update_mp_rl() --- src/backend.c | 26 +------------------------- src/mpsp.c | 1 - 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/backend.c b/src/backend.c index cbc81f84a..5005c059a 100644 --- a/src/backend.c +++ b/src/backend.c @@ -13808,7 +13808,7 @@ int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx) int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r) { mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; user_options_t *user_options = hashcat_ctx->user_options; if (backend_ctx->enabled == false) return 0; @@ -13832,42 +13832,18 @@ int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_ if (device_param->is_cuda == true) { - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_uint), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 9; i < 9; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 7; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_uint), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 8; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_root_css_buf, mask_ctx->root_css_buf, device_param->size_root_css, device_param->cuda_stream) == -1) return -1; if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_markov_css_buf, mask_ctx->markov_css_buf, device_param->size_markov_css, device_param->cuda_stream) == -1) return -1; } if (device_param->is_hip == true) { - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_uint), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 9; i < 9; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 7; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_uint), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 8; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_root_css_buf, mask_ctx->root_css_buf, device_param->size_root_css, device_param->hip_stream) == -1) return -1; if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_markov_css_buf, mask_ctx->markov_css_buf, device_param->size_markov_css, device_param->hip_stream) == -1) return -1; } if (device_param->is_opencl == true) { - for (u32 i = 3; i < 4; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]) == -1) return -1; } - for (u32 i = 4; i < 8; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_uint), device_param->kernel_params_mp_l[i]) == -1) return -1; } - for (u32 i = 9; i < 9; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_l, i, sizeof (cl_ulong), device_param->kernel_params_mp_l[i]) == -1) return -1; } - - for (u32 i = 3; i < 4; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]) == -1) return -1; } - for (u32 i = 4; i < 7; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_uint), device_param->kernel_params_mp_r[i]) == -1) return -1; } - for (u32 i = 8; i < 8; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp_r, i, sizeof (cl_ulong), device_param->kernel_params_mp_r[i]) == -1) return -1; } - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_root_css_buf, CL_FALSE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL) == -1) return -1; if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_markov_css_buf, CL_FALSE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL) == -1) return -1; diff --git a/src/mpsp.c b/src/mpsp.c index d096b97b5..fc34bbff8 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1219,7 +1219,6 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; - if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { if (user_options->attack_mode == ATTACK_MODE_COMBI) From 994083eaf58cd181c8ae46fa7adb445ae4aa5b21 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 3 Jan 2022 18:28:19 +0100 Subject: [PATCH 02/18] Removed hc_clSetKernelArg() call from backend_session_update_mp() --- src/backend.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/backend.c b/src/backend.c index cbc81f84a..af5ece224 100644 --- a/src/backend.c +++ b/src/backend.c @@ -13774,27 +13774,18 @@ int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx) if (device_param->is_cuda == true) { - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_ulong), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_uint), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_root_css_buf, mask_ctx->root_css_buf, device_param->size_root_css, device_param->cuda_stream) == -1) return -1; if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_markov_css_buf, mask_ctx->markov_css_buf, device_param->size_markov_css, device_param->cuda_stream) == -1) return -1; } if (device_param->is_hip == true) { - //for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_ulong), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - //for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_uint), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_root_css_buf, mask_ctx->root_css_buf, device_param->size_root_css, device_param->hip_stream) == -1) return -1; if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_markov_css_buf, mask_ctx->markov_css_buf, device_param->size_markov_css, device_param->hip_stream) == -1) return -1; } if (device_param->is_opencl == true) { - for (u32 i = 3; i < 4; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_ulong), device_param->kernel_params_mp[i]) == -1) return -1; } - for (u32 i = 4; i < 8; i++) { if (hc_clSetKernelArg (hashcat_ctx, device_param->opencl_kernel_mp, i, sizeof (cl_uint), device_param->kernel_params_mp[i]) == -1) return -1; } - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_root_css_buf, CL_FALSE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL) == -1) return -1; if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_markov_css_buf, CL_FALSE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL) == -1) return -1; From 80f0dff8fb6f44c94a59b6606c843e384574e8fb Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 4 Jan 2022 17:41:57 +0100 Subject: [PATCH 03/18] Makefile: updated MACOSX_DEPLOYMENT_TARGET to 10.15 and removed OpenCL framework from LFLAGS_NATIVE on MacOS --- docs/changes.txt | 1 + src/Makefile | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 94f7ef326..7ec3af2e1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -39,6 +39,7 @@ - Unit tests: Updated test.sh to set default device-type to CPU with Apple Intel and added -f (--force) option - OpenCL Backend: moved functions to ext_OpenCL.c and includes to ext_OpenCL.h - HIP Backend: moved functions to ext_hip.c/ext_hiprtc.c and includes to ext_hip.h/ext_hiprtc.h +- Makefile: updated MACOSX_DEPLOYMENT_TARGET to 10.15 and removed OpenCL framework from LFLAGS_NATIVE on MacOS * changes v6.2.4 -> v6.2.5 diff --git a/src/Makefile b/src/Makefile index 1443d4d5c..002d9c018 100644 --- a/src/Makefile +++ b/src/Makefile @@ -315,7 +315,7 @@ endif endif # FreeBSD ifeq ($(UNAME),Darwin) -export MACOSX_DEPLOYMENT_TARGET=10.9 +export MACOSX_DEPLOYMENT_TARGET=10.15 CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -DWITH_HWMON @@ -324,7 +324,6 @@ CFLAGS_NATIVE += -DMISSING_CLOCK_GETTIME endif LFLAGS_NATIVE := $(LFLAGS) -LFLAGS_NATIVE += -framework OpenCL LFLAGS_NATIVE += -framework IOKit LFLAGS_NATIVE += -lpthread LFLAGS_NATIVE += -liconv From 1cb24b0a3cc34a3afd950848063289be466b586c Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 9 Jan 2022 04:50:28 +0100 Subject: [PATCH 04/18] Fix the build for NetBSD --- include/sort_r.h | 9 ++++++-- src/Makefile | 14 +++++++---- src/affinity.c | 60 ++++++++++++++++++++++++++++++++++++++++++++---- src/folder.c | 20 ++++++++++++++-- src/terminal.c | 2 +- 5 files changed, 92 insertions(+), 13 deletions(-) diff --git a/include/sort_r.h b/include/sort_r.h index 061aed7aa..ebc344fe4 100644 --- a/include/sort_r.h +++ b/include/sort_r.h @@ -25,7 +25,7 @@ Slightly modified to work with hashcat to no falsly detect _SORT_R_LINUX with mi */ #if (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \ - defined __FreeBSD__ || defined __DragonFly__) + defined __FreeBSD__ || defined __DragonFly__ || defined __NetBSD__) # define _SORT_R_BSD # define _SORT_R_INLINE inline #elif (defined __linux__) || defined (__CYGWIN__) @@ -202,7 +202,12 @@ static _SORT_R_INLINE void sort_r_simple(void *base, size_t nel, size_t w, struct sort_r_data tmp; tmp.arg = arg; tmp.compar = compar; - qsort_r(base, nel, width, &tmp, sort_r_arg_swap); + + #if defined __NetBSD__ + sort_r_simple(base, nel, width, compar, arg); + #else + qsort_r(base, nel, width, &tmp, sort_r_arg_swap); + #endif #elif defined _SORT_R_WINDOWS diff --git a/src/Makefile b/src/Makefile index 1443d4d5c..9941e671e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -31,7 +31,7 @@ UNAME := $(patsubst MSYS_NT-%,MSYS2,$(UNAME)) UNAME := $(patsubst MINGW32_NT-%,MSYS2,$(UNAME)) UNAME := $(patsubst MINGW64_NT-%,MSYS2,$(UNAME)) -ifeq (,$(filter $(UNAME),Linux FreeBSD Darwin CYGWIN MSYS2)) +ifeq (,$(filter $(UNAME),Linux FreeBSD NetBSD Darwin CYGWIN MSYS2)) $(error "! Your Operating System ($(UNAME)) is not supported by this Makefile") endif @@ -78,7 +78,7 @@ SED_IN_PLACE := -i "" DARWIN_VERSION := $(shell uname -r | cut -d. -f1) endif -ifeq ($(UNAME),FreeBSD) +ifeq (,$(filter $(UNAME),FreeBSD NetBSD)) CC := cc CXX := c++ SED := gsed @@ -314,6 +314,12 @@ LFLAGS_NATIVE += -liconv endif endif # FreeBSD +ifeq ($(UNAME),NetBSD) +CFLAGS_NATIVE := $(CFLAGS) +LFLAGS_NATIVE := $(LFLAGS) +LFLAGS_NATIVE += -lpthread +endif # NetBSD + ifeq ($(UNAME),Darwin) export MACOSX_DEPLOYMENT_TARGET=10.9 CFLAGS_NATIVE := $(CFLAGS) @@ -458,10 +464,10 @@ distclean: clean # allow (whitelist) "make install" only on unix-based systems (also disallow cygwin/msys) ifneq ($(findstring install,$(MAKECMDGOALS)),) - ifeq (,$(filter $(UNAME),Linux FreeBSD Darwin)) + ifeq (,$(filter $(UNAME),Linux FreeBSD Darwin NetBSD)) define ERROR_INSTALL_DISALLOWED ! The 'install' target is not allowed on this operating system ($(UNAME)). \ -Only Linux, FreeBSD and Darwin can use the 'install' target +Only Linux, FreeBSD, NetBSD and Darwin can use the 'install' target endef $(error $(ERROR_INSTALL_DISALLOWED)) diff --git a/src/affinity.c b/src/affinity.c index 3faa46638..920f24f87 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -45,6 +45,12 @@ static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t typedef cpuset_t cpu_set_t; #endif +#if defined(__NetBSD__) +#include +#include +typedef cpuset_t cpu_set_t; +#endif + int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) { #if defined (__CYGWIN__) @@ -54,19 +60,31 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) if (user_options->cpu_affinity == NULL) return 0; + char *devices = hcstrdup (user_options->cpu_affinity); + + if (devices == NULL) return -1; + #if defined (_WIN) DWORD_PTR aff_mask = 0; const int cpu_id_max = 8 * sizeof (aff_mask); + #elif defined(__NetBSD__) + cpuset_t * cpuset; + const int cpu_id_max = 8 * cpuset_size (cpuset); + cpuset = cpuset_create(); + if (cpuset == NULL) + { + event_log_error (hashcat_ctx, "cpuset_create() failed with error: %d", errno); + + hcfree (devices); + + return -1; + } #else cpu_set_t cpuset; const int cpu_id_max = 8 * sizeof (cpuset); CPU_ZERO (&cpuset); #endif - char *devices = hcstrdup (user_options->cpu_affinity); - - if (devices == NULL) return -1; - char *saveptr = NULL; char *next = strtok_r (devices, ",", &saveptr); @@ -79,6 +97,17 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) { #if defined (_WIN) aff_mask = 0; + #elif defined (__NetBSD__) + cpuset_destroy (cpuset); + cpuset = cpuset_create (); + if (cpuset == NULL) + { + event_log_error (hashcat_ctx, "cpuset_create() failed with error: %d", errno); + + hcfree (devices); + + return -1; + } #else CPU_ZERO (&cpuset); #endif @@ -90,6 +119,10 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "Invalid cpu_id %d specified.", cpu_id); + #if defined (__NetBSD__) + cpuset_destroy (cpuset); + #endif + hcfree (devices); return -1; @@ -97,12 +130,18 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) #if defined (_WIN) aff_mask |= ((DWORD_PTR) 1) << (cpu_id - 1); + #elif defined (__NetBSD__) + cpuset_set (cpu_id - 1, cpuset); #else CPU_SET ((cpu_id - 1), &cpuset); #endif } while ((next = strtok_r ((char *) NULL, ",", &saveptr)) != NULL); + #if defined (__NetBSD__) + cpuset_destroy (cpuset); + #endif + hcfree (devices); #if defined (_WIN) @@ -114,6 +153,19 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) return -1; } + #elif defined (__NetBSD__) + + pthread_t thread = pthread_self (); + + const int rc = pthread_setaffinity_np (thread, cpuset_size(cpuset), cpuset); + + if (rc != 0) + { + event_log_error (hashcat_ctx, "pthread_setaffinity_np() failed with error: %d", rc); + + return -1; + } + #else pthread_t thread = pthread_self (); diff --git a/src/folder.c b/src/folder.c index eb5914dbe..8a50eeb9c 100644 --- a/src/folder.c +++ b/src/folder.c @@ -13,6 +13,9 @@ #if defined (__APPLE__) #include "event.h" +#elif defined (__FreeBSD__) || defined (__NetBSD__) +#include +#include #endif static int get_exec_path (char *exec_path, const size_t exec_path_sz) @@ -45,8 +48,6 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) #elif defined (__FreeBSD__) - #include - int mib[4]; mib[0] = CTL_KERN; @@ -60,6 +61,21 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) const size_t len = strlen (exec_path); + #elif defined (__NetBSD__) + + int mib[4]; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC_ARGS; + mib[2] = getpid(); + mib[3] = KERN_PROC_PATHNAME; + + size_t size = exec_path_sz; + + sysctl (mib, 4, exec_path, &size, NULL, 0); + + const size_t len = strlen (exec_path); + #else #error Your Operating System is not supported or detected #endif diff --git a/src/terminal.c b/src/terminal.c index 81381b2dc..e56e311c1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -439,7 +439,7 @@ void SetConsoleWindowSize (const int x) } #endif -#if defined (__linux__) || defined (__CYGWIN__) +#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__linux__) || defined (__CYGWIN__) static struct termios savemodes; static int havemodes = 0; From c48f044fb77ebbaf8bfbd3925f89a87a9eb31b57 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 10 Jan 2022 01:50:32 +0100 Subject: [PATCH 05/18] Fixed false negative on Unit Test with hash-type 25400 --- docs/changes.txt | 1 + src/modules/module_25400.c | 4 ++-- tools/test.sh | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9e13fa513..f99eb33dd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -25,6 +25,7 @@ - Fixed missing option flag OPTS_TYPE_SUGGEST_KG for hash-mode 11600 to inform the user about possible false positives in this mode - Fixed undefined function call to hc_byte_perm_S() in hash-mode 17010 on non-CUDA compute devices - Fixed wordlist handling in -m 3000 when candidate passwords use the $HEX[...] syntax +- Fixed false negative on Unit Test with hash-type 25400 ## ## Technical diff --git a/src/modules/module_25400.c b/src/modules/module_25400.c index c00ad420b..026302c5f 100644 --- a/src/modules/module_25400.c +++ b/src/modules/module_25400.c @@ -541,7 +541,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE pdf_t *pdf = (pdf_t *) esalt_buf; if (pdf->id_len == 32) { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%s", + line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", pdf->V, pdf->R, 128, @@ -579,7 +579,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%s", + line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", pdf->V, pdf->R, 128, diff --git a/tools/test.sh b/tools/test.sh index 205d8367d..c0c2edcb5 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -518,6 +518,11 @@ function attack_0() search="${hash}:${pass}" fi + if [ ${hash_type} -eq 25400 ]; then + tmp=$(echo $output | sed -e 's/ (user password[^)].*//g') + output="${tmp}" + fi + echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null if [ "${?}" -ne 0 ]; then From 3fe9f8632657a01f4b793ab6484279c72b1bf438 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 10 Jan 2022 02:06:19 +0100 Subject: [PATCH 06/18] simplified regex --- tools/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test.sh b/tools/test.sh index c0c2edcb5..1acbd4cb3 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -519,7 +519,7 @@ function attack_0() fi if [ ${hash_type} -eq 25400 ]; then - tmp=$(echo $output | sed -e 's/ (user password[^)].*//g') + tmp=$(echo $output | sed -e 's/ (user password.*//g') output="${tmp}" fi From 7650894e02253d4e94abf8d230bdab802c736163 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 11 Jan 2022 04:58:30 +0100 Subject: [PATCH 07/18] fixed bug in benchmark engine, updated negative status code --- docs/changes.txt | 2 ++ docs/status_codes.txt | 6 ++++ include/types.h | 11 +++++++ src/autotune.c | 1 - src/backend.c | 77 ++++++++++++++++++++++++++++++++++--------- src/dispatch.c | 4 --- src/hashcat.c | 45 ++++++++++++++++++++++++- src/monitor.c | 2 -- src/selftest.c | 1 - src/status.c | 11 ++----- src/terminal.c | 19 ----------- 11 files changed, 126 insertions(+), 53 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f99eb33dd..514ce1ca9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -26,6 +26,7 @@ - Fixed undefined function call to hc_byte_perm_S() in hash-mode 17010 on non-CUDA compute devices - Fixed wordlist handling in -m 3000 when candidate passwords use the $HEX[...] syntax - Fixed false negative on Unit Test with hash-type 25400 +- Fixed bug on benchmark engine, from now it will not stop at the first error detected ## ## Technical @@ -45,6 +46,7 @@ - HIP Backend: moved functions to ext_hip.c/ext_hiprtc.c and includes to ext_hip.h/ext_hiprtc.h - CUDA Backend: moved functions to ext_cuda.c/ext_nvrtc.c and includes to ext_cuda.h/ext_nvrtc.h - Makefile: updated MACOSX_DEPLOYMENT_TARGET to 10.15 and removed OpenCL framework from LFLAGS_NATIVE on MacOS +- Status code: updated negative status code, usefull in Unit tests engine (test.sh) * changes v6.2.4 -> v6.2.5 diff --git a/docs/status_codes.txt b/docs/status_codes.txt index 0c8c831b4..b7889ff2e 100644 --- a/docs/status_codes.txt +++ b/docs/status_codes.txt @@ -1,6 +1,12 @@ status codes on exit: ===================== +-8 = mixed backend errors (combo of -3, -4, -5, -6, -7 errors type) +-7 = backend error: Invalid module_extra_buffer_size +-6 = backend error: Too many compute units to keep minimum kernel accel limit +-5 = backend error: main kernel build error +-4 = backend error: memory hit +-3 = backend error: skipping hash-type due to module_unstable_warning settings -2 = gpu-watchdog alarm -1 = error 0 = OK/cracked diff --git a/include/types.h b/include/types.h index fa3e2de6c..d665dd8ad 100644 --- a/include/types.h +++ b/include/types.h @@ -1683,6 +1683,17 @@ typedef struct backend_ctx { bool enabled; + // global rc + + bool memory_hit_warning; + bool runtime_skip_warning; + bool kernel_build_warning; + bool kernel_accel_warnings; + bool extra_size_warning; + bool mixed_warnings; + + // generic + void *cuda; void *hip; void *ocl; diff --git a/src/autotune.c b/src/autotune.c index b5a66f75f..c89373126 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -525,7 +525,6 @@ HC_API_CALL void *thread_autotune (void *p) hc_device_param_t *device_param = backend_ctx->devices_param + thread_param->tid; if (device_param->skipped == true) return NULL; - if (device_param->skipped_warning == true) return NULL; if (device_param->is_cuda == true) diff --git a/src/backend.c b/src/backend.c index 63fbba09b..53a2fb819 100644 --- a/src/backend.c +++ b/src/backend.c @@ -112,7 +112,6 @@ static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *backend_device = &backend_ctx->devices_param[backend_devices_pos]; if (backend_device->skipped == true) continue; - if (backend_device->skipped_warning == true) continue; for (int device_id_alias_pos = 0; device_id_alias_pos < backend_device->device_id_alias_cnt; device_id_alias_pos++) @@ -122,7 +121,6 @@ static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *alias_device = &backend_ctx->devices_param[alias_pos]; if (alias_device->skipped == true) continue; - if (alias_device->skipped_warning == true) continue; // this lets CUDA devices survive over OpenCL @@ -6433,7 +6431,6 @@ void backend_ctx_devices_sync_tuning (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param_src = &backend_ctx->devices_param[backend_devices_cnt_src]; if (device_param_src->skipped == true) continue; - if (device_param_src->skipped_warning == true) continue; for (int backend_devices_cnt_dst = backend_devices_cnt_src + 1; backend_devices_cnt_dst < backend_ctx->backend_devices_cnt; backend_devices_cnt_dst++) @@ -6441,7 +6438,6 @@ void backend_ctx_devices_sync_tuning (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param_dst = &backend_ctx->devices_param[backend_devices_cnt_dst]; if (device_param_dst->skipped == true) continue; - if (device_param_dst->skipped_warning == true) continue; if (is_same_device_type (device_param_src, device_param_dst) == false) continue; @@ -6477,7 +6473,6 @@ void backend_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; kernel_power_all += device_param->kernel_power; @@ -6525,7 +6520,6 @@ void backend_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; device_param->kernel_loops_min = device_param->kernel_loops_min_sav; @@ -7321,6 +7315,19 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) u32 hardware_power_all = 0; + int backend_memory_hit_warnings = 0; + int backend_runtime_skip_warnings = 0; + int backend_kernel_build_warnings = 0; + int backend_kernel_accel_warnings = 0; + int backend_extra_size_warning = 0; + + backend_ctx->memory_hit_warning = false; + backend_ctx->runtime_skip_warning = false; + backend_ctx->kernel_build_warning = false; + backend_ctx->kernel_accel_warnings = false; + backend_ctx->extra_size_warning = false; + backend_ctx->mixed_warnings = false; + for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++) { /** @@ -7351,8 +7358,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, " This is due to a known CUDA/HIP/OpenCL runtime/driver issue (not a hashcat issue)"); event_log_warning (hashcat_ctx, " You can use --force to override, but do not report related errors."); - device_param->skipped_warning = true; + backend_runtime_skip_warnings++; + device_param->skipped_warning = true; continue; } } @@ -7940,7 +7948,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "Invalid extra buffer size."); - device_param->skipped = true; + backend_extra_size_warning++; + + device_param->skipped_warning = true; continue; } @@ -8475,7 +8485,10 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed.", device_param->device_id + 1, source_file); - return -1; + backend_kernel_build_warnings++; + + device_param->skipped_warning = true; + continue; } hcfree (build_options_module_buf); @@ -8636,7 +8649,10 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "* Device #%u: Not enough allocatable device memory for this hashlist/ruleset.", device_id + 1); - return -1; + backend_memory_hit_warnings++; + + device_param->skipped_warning = true; + continue; } if (device_param->is_cuda == true) @@ -11226,7 +11242,10 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "* Device #%u: Too many compute units to keep minimum kernel accel limit.", device_id + 1); event_log_error (hashcat_ctx, " Retry with lower --backend-kernel-threads value."); - return -1; + backend_kernel_accel_warnings++; + + device_param->skipped_warning = true; + continue; } // Opposite direction check: find out if we would request too much memory on memory blocks which are based on kernel_accel @@ -11411,7 +11430,10 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "* Device #%u: Not enough allocatable device memory for this attack.", device_id + 1); - return -1; + backend_memory_hit_warnings++; + + device_param->skipped_warning = true; + continue; } // similar process for association attack @@ -11740,6 +11762,32 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) EVENT_DATA (EVENT_BACKEND_DEVICE_INIT_POST, &backend_devices_idx, sizeof (int)); } + int rc = 0; + + backend_ctx->memory_hit_warning = (backend_memory_hit_warnings == backend_ctx->backend_devices_active); + backend_ctx->runtime_skip_warning = (backend_runtime_skip_warnings == backend_ctx->backend_devices_active); + backend_ctx->kernel_build_warning = (backend_kernel_build_warnings == backend_ctx->backend_devices_active); + backend_ctx->kernel_accel_warnings = (backend_kernel_accel_warnings == backend_ctx->backend_devices_active); + backend_ctx->extra_size_warning = (backend_extra_size_warning == backend_ctx->backend_devices_active); + + // if all active devices failed, set rc to -1 + // later we prevent hashcat exit if is started in benchmark mode + if ((backend_ctx->memory_hit_warning == true) || + (backend_ctx->runtime_skip_warning == true) || + (backend_ctx->kernel_build_warning == true) || + (backend_ctx->kernel_accel_warnings == true) || + (backend_ctx->extra_size_warning == true)) + { + rc = -1; + } + else + { + // handle mix of, in case of multiple devices with different warnings + backend_ctx->mixed_warnings = ((backend_memory_hit_warnings + backend_runtime_skip_warnings + backend_kernel_build_warnings + backend_kernel_accel_warnings + backend_extra_size_warning) == backend_ctx->backend_devices_active); + + if (backend_ctx->mixed_warnings) rc = -1; + } + if (user_options->benchmark == false) { if (hardware_power_all == 0) return -1; @@ -11749,7 +11797,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) EVENT_DATA (EVENT_BACKEND_SESSION_HOSTMEM, &size_total_host_all, sizeof (u64)); - return 0; + return rc; } void backend_session_destroy (hashcat_ctx_t *hashcat_ctx) @@ -12264,7 +12312,6 @@ int backend_session_update_combinator (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; // kernel_params @@ -12310,7 +12357,6 @@ int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; device_param->kernel_params_mp_buf64[3] = 0; @@ -12355,7 +12401,6 @@ int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_ hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; device_param->kernel_params_mp_l_buf64[3] = 0; diff --git a/src/dispatch.c b/src/dispatch.c index 2078cfdac..d8870d033 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -32,7 +32,6 @@ static u64 get_highest_words_done (const hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; const u64 words_done = device_param->words_done; @@ -54,7 +53,6 @@ static u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; const u64 words_done = device_param->words_done; @@ -353,7 +351,6 @@ HC_API_CALL void *thread_calc_stdin (void *p) hc_device_param_t *device_param = backend_ctx->devices_param + thread_param->tid; if (device_param->skipped) return NULL; - if (device_param->skipped_warning == true) return NULL; if (device_param->is_cuda == true) @@ -1605,7 +1602,6 @@ HC_API_CALL void *thread_calc (void *p) hc_device_param_t *device_param = backend_ctx->devices_param + thread_param->tid; if (device_param->skipped) return NULL; - if (device_param->skipped_warning == true) return NULL; if (device_param->is_cuda == true) diff --git a/src/hashcat.c b/src/hashcat.c index bf936ccc0..91a25f2cf 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -767,7 +767,38 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_BACKEND_SESSION_PRE); - if (backend_session_begin (hashcat_ctx) == -1) return -1; + if (backend_session_begin (hashcat_ctx) == -1) + { + if (user_options->benchmark == true) + { + if (user_options->hash_mode_chgd == false) + { + // finalize backend session + + backend_session_destroy (hashcat_ctx); + + // clean up + + #ifdef WITH_BRAIN + brain_ctx_destroy (hashcat_ctx); + #endif + + bitmap_ctx_destroy (hashcat_ctx); + combinator_ctx_destroy (hashcat_ctx); + cpt_ctx_destroy (hashcat_ctx); + hashconfig_destroy (hashcat_ctx); + hashes_destroy (hashcat_ctx); + mask_ctx_destroy (hashcat_ctx); + status_progress_destroy (hashcat_ctx); + straight_ctx_destroy (hashcat_ctx); + wl_data_destroy (hashcat_ctx); + + return 0; + } + } + + return -1; + } EVENT (EVENT_BACKEND_SESSION_POST); @@ -1500,6 +1531,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; + backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; // start logfile entry @@ -1712,6 +1744,17 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; if (status_ctx->devices_status == STATUS_ERROR) rc_final = -1; } + else if (rc_final == -1) + { + // setup the new negative status code, usefull in test.sh + // -2 is marked as used in status_codes.txt + if (backend_ctx->runtime_skip_warning == true) rc_final = -3; + if (backend_ctx->memory_hit_warning == true) rc_final = -4; + if (backend_ctx->kernel_build_warning == true) rc_final = -5; + if (backend_ctx->kernel_accel_warnings == true) rc_final = -6; + if (backend_ctx->extra_size_warning == true) rc_final = -7; + if (backend_ctx->mixed_warnings == true) rc_final = -8; + } // special case for --stdout diff --git a/src/monitor.c b/src/monitor.c index b61a41824..ce02a7a90 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -151,7 +151,6 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; const int rc_throttle = hm_get_throttle_with_devices_idx (hashcat_ctx, backend_devices_idx); @@ -261,7 +260,6 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) continue; - if (device_param->skipped_warning == true) continue; exec_cnt++; diff --git a/src/selftest.c b/src/selftest.c index 5379650aa..28b7b6d4f 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -900,7 +900,6 @@ HC_API_CALL void *thread_selftest (void *p) hc_device_param_t *device_param = backend_ctx->devices_param + thread_param->tid; if (device_param->skipped == true) return NULL; - if (device_param->skipped_warning == true) return NULL; if (device_param->is_cuda == true) diff --git a/src/status.c b/src/status.c index 8bf13d4b3..ed7d0ba9a 100644 --- a/src/status.c +++ b/src/status.c @@ -1885,6 +1885,7 @@ char *status_get_brain_rx_all (const hashcat_ctx_t *hashcat_ctx) for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++) { hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; + if ((device_param->skipped == false) && (device_param->skipped_warning == false)) { brain_rx_all += device_param->brain_link_recv_bytes; @@ -1927,6 +1928,7 @@ char *status_get_brain_tx_all (const hashcat_ctx_t *hashcat_ctx) for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++) { hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; + if ((device_param->skipped == false) && (device_param->skipped_warning == false)) { brain_tx_all += device_param->brain_link_send_bytes; @@ -2024,7 +2026,6 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_ snprintf (output_buf, HCBUFSIZ_TINY, "N/A"); if (device_param->skipped == true) return output_buf; - if (device_param->skipped_warning == true) return output_buf; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -2093,7 +2094,6 @@ int status_get_corespeed_dev (const hashcat_ctx_t *hashcat_ctx, const int backen hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return -1; - if (device_param->skipped_warning == true) return -1; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -2114,7 +2114,6 @@ int status_get_memoryspeed_dev (const hashcat_ctx_t *hashcat_ctx, const int back hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return -1; - if (device_param->skipped_warning == true) return -1; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -2135,7 +2134,6 @@ u64 status_get_progress_dev (const hashcat_ctx_t *hashcat_ctx, const int backend hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; return device_param->outerloop_left; @@ -2148,7 +2146,6 @@ double status_get_runtime_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; return device_param->outerloop_msec; @@ -2161,7 +2158,6 @@ int status_get_kernel_accel_dev (const hashcat_ctx_t *hashcat_ctx, const int bac hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; if (device_param->kernel_accel_prev) return device_param->kernel_accel_prev; @@ -2176,7 +2172,6 @@ int status_get_kernel_loops_dev (const hashcat_ctx_t *hashcat_ctx, const int bac hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; if (device_param->kernel_loops_prev) return device_param->kernel_loops_prev; @@ -2191,7 +2186,6 @@ int status_get_kernel_threads_dev (const hashcat_ctx_t *hashcat_ctx, const int b hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; if (device_param->kernel_threads_prev) return device_param->kernel_threads_prev; @@ -2206,7 +2200,6 @@ int status_get_vector_width_dev (const hashcat_ctx_t *hashcat_ctx, const int bac hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; if (device_param->skipped == true) return 0; - if (device_param->skipped_warning == true) return 0; return device_param->vector_width; diff --git a/src/terminal.c b/src/terminal.c index 81381b2dc..2660b72ba 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1175,7 +1175,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; printf ("%" PRIu64 "\t", (u64) (device_info->hashes_msec_dev * 1000)); @@ -1191,7 +1190,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; printf ("%f\t", device_info->exec_msec_dev); @@ -1214,7 +1212,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; const int temp = hm_get_temperature_with_devices_idx (hashcat_ctx, device_id); @@ -1232,7 +1229,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; // ok, little cheat here again... @@ -1351,7 +1347,6 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_num != 0) @@ -1784,7 +1779,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, @@ -1901,7 +1895,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_info->brain_link_status_dev == BRAIN_LINK_STATUS_CONNECTED) @@ -1978,7 +1971,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, @@ -2005,7 +1997,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_info->guess_candidates_dev == NULL) continue; @@ -2026,7 +2017,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_info->hwmon_dev == NULL) continue; @@ -2070,7 +2060,6 @@ void status_benchmark_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, "%d:%u:%d:%d:%.2f:%" PRIu64, device_id + 1, hash_mode, device_info->corespeed_dev, device_info->memoryspeed_dev, device_info->exec_msec_dev, (u64) (device_info->hashes_msec_dev_benchmark * 1000)); @@ -2106,7 +2095,6 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, @@ -2147,7 +2135,6 @@ void status_speed_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, "%d:%" PRIu64, device_id + 1, (u64) (device_info->hashes_msec_dev_benchmark * 1000)); @@ -2178,7 +2165,6 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_num != 0) @@ -2230,7 +2216,6 @@ void status_speed (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, @@ -2267,7 +2252,6 @@ void status_progress_machine_readable (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, "%d:%" PRIu64 ":%0.2f", device_id + 1, device_info->progress_dev, device_info->runtime_msec_dev); @@ -2298,7 +2282,6 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; if (device_num != 0) @@ -2351,7 +2334,6 @@ void status_progress (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, @@ -2364,7 +2346,6 @@ void status_progress (hashcat_ctx_t *hashcat_ctx) const device_info_t *device_info = hashcat_status->device_info_buf + device_id; if (device_info->skipped_dev == true) continue; - if (device_info->skipped_warning_dev == true) continue; event_log_info (hashcat_ctx, From 5708b4cf6f5111e5e75eca38bd698781fac50021 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 11 Jan 2022 15:05:02 -0600 Subject: [PATCH 08/18] Fix logic flaw Line 81 contains inverted logic introduced by PR#3117, this should fix that logic to detect BSD and correctly select `gsed` on BSD and not on linux --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 369eb7dc0..fc0afc4fb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -78,7 +78,7 @@ SED_IN_PLACE := -i "" DARWIN_VERSION := $(shell uname -r | cut -d. -f1) endif -ifeq (,$(filter $(UNAME),FreeBSD NetBSD)) +ifneq (,$(filter $(UNAME),FreeBSD NetBSD)) CC := cc CXX := c++ SED := gsed From 516f7588f1a08e034ea618a7620e7e065d8a0e55 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Wed, 12 Jan 2022 09:19:52 +0100 Subject: [PATCH 09/18] Updated Unit Test --- docs/changes.txt | 3 + docs/credits.txt | 2 +- tools/test.sh | 651 +++++++++++++++++++++++++++++------------------ 3 files changed, 412 insertions(+), 244 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f99eb33dd..0d2fc5fb1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -26,6 +26,7 @@ - Fixed undefined function call to hc_byte_perm_S() in hash-mode 17010 on non-CUDA compute devices - Fixed wordlist handling in -m 3000 when candidate passwords use the $HEX[...] syntax - Fixed false negative on Unit Test with hash-type 25400 +- Fixed false negative on Unit Test in case of out-of-memory with grep in single mode ## ## Technical @@ -45,6 +46,8 @@ - HIP Backend: moved functions to ext_hip.c/ext_hiprtc.c and includes to ext_hip.h/ext_hiprtc.h - CUDA Backend: moved functions to ext_cuda.c/ext_nvrtc.c and includes to ext_cuda.h/ext_nvrtc.h - Makefile: updated MACOSX_DEPLOYMENT_TARGET to 10.15 and removed OpenCL framework from LFLAGS_NATIVE on MacOS +- Unit tests: added -r (--runtime) option +- Unit tests: handle negative status code, skip deprecated hash-types, skip hash-types with known perl modules issues, updated output * changes v6.2.4 -> v6.2.5 diff --git a/docs/credits.txt b/docs/credits.txt index 62c5b04e1..1d962206e 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -24,7 +24,7 @@ Gabriele "matrix" Gristina (@gm4tr1x) * Apple macOS port * Apple Silicon support * Hardware monitor initial code base and maintenance -* Test suite initial code base +* Test suite initial code base and maintenance * Makefile initial code base * Multithreading initial code base * MultiGPU initial code base diff --git a/tools/test.sh b/tools/test.sh index 1acbd4cb3..dbc50bb35 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -5,9 +5,10 @@ ## License.....: MIT ## -OPTS="--quiet --potfile-disable --runtime 400 --hwmon-disable" +OPTS="--quiet --potfile-disable --hwmon-disable" FORCE=0 +RUNTIME=400 TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -150,11 +151,13 @@ mask_7[31]="?d?d?d?d?d?d?d?d0000000" # $1: value # $2: array # Returns 0 (SUCCESS) if the value is found, 1 otherwise + function is_in_array() { for e in "${@:2}"; do [ "$e" = "$1" ] && return 0 done + return 1 } @@ -211,8 +214,9 @@ function init() echo "" # download: + wget -q "${luks_tests_url}" - if ! wget -q "${luks_tests_url}" >/dev/null 2>/dev/null; then + if [ $? -ne 0 ] || [ ! -f "${luks_tests}" ]; then cd - >/dev/null echo "ERROR: Could not fetch the luks test files from this url: ${luks_tests_url}" exit 1 @@ -296,17 +300,14 @@ function init() # special case (passwords longer than expected) pass_len=${#pass} - if [ "${pass_len}" -gt 1 ] - then + if [ "${pass_len}" -gt 1 ]; then p1=$((p1 + min_offset)) p0=$((p0 + min_offset)) if [ "${p1}" -gt "${pass_len}" ]; then - p1=${pass_len} p0=$((p1 - 1)) - fi # add splitted password to dicts @@ -348,6 +349,7 @@ function init() if [ "${MODE}" -ge 1 ]; then i=2 + while [ "$i" -lt 9 ]; do cmd_file=${OUTD}/${hash_type}_multi_${i}.txt @@ -380,6 +382,7 @@ function init() echo "${pass}" | cut -c ${p1}- >> "${OUTD}/${hash_type}_dict2_multi_${i}" done 9< "${OUTD}/${hash_type}_passwords_multi_${i}.txt" + i=$((i + 1)) done @@ -395,20 +398,56 @@ function status() if [ "${RET}" -ne 0 ]; then case ${RET} in + 248) + echo "skipped by runtime (mixed backend errors detected), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + + 249) + echo "skipped by runtime (Invalid module_extra_buffer_size), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + + 250) + echo "skipped by runtime (Too many compute units to keep minimum kernel accel limit), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + + 251) + echo "skipped by runtime (main kernel build error), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + + 252) + echo "skipped by runtime (memory hit limit), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + + 253) + echo "skipped by runtime (module_unstable_warning), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + 1) if ! is_in_array "${hash_type}" ${NEVER_CRACK_ALGOS}; then - echo "password not found, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" e_nf=$((e_nf + 1)) - fi ;; + 4) echo "timeout reached, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" - e_to=$((e_to + 1)) + e_to=$((e_to + 1)) ;; + 10) if is_in_array "${hash_type}" ${NEVER_CRACK_ALGOS}; then return @@ -419,14 +458,24 @@ function status() else echo "hash:plains not matched in output, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.tx"t fi + e_nm=$((e_nm + 1)) + ;; + 20) + echo "grep out-of-memory (cannot check if plains match in output), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_ce=$((e_ce + 1)) + e_nm=$((e_nm + 1)) ;; + *) echo "! unhandled return code ${RET}, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" echo "! unhandled return code, see ${OUTD}/logfull.txt or ${OUTD}/test_report.log for details." + e_nf=$((e_nf + 1)) ;; + esac fi } @@ -436,14 +485,14 @@ function attack_0() file_only=0 if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then - file_only=1 - fi # single hash if [ "${MODE}" -ne 1 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -454,9 +503,7 @@ function attack_0() max=32 if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - max=12 - fi i=0 @@ -464,18 +511,14 @@ function attack_0() while read -r -u 9 line; do if [ "${i}" -ge ${max} ]; then - break - fi hash="$(echo "${line}" | cut -d\' -f2)" pass="$(echo "${line}" | cut -d' ' -f2)" if [ -z "${hash}" ]; then - break - fi if [ "${file_only}" -eq 1 ]; then @@ -518,17 +561,33 @@ function attack_0() search="${hash}:${pass}" fi - if [ ${hash_type} -eq 25400 ]; then - tmp=$(echo $output | sed -e 's/ (user password.*//g') - output="${tmp}" - fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -eq 2 ]; then + # out-of-memory, workaround + + echo "${output}" | head -1 > tmp_file_out + echo "${search}" > tmp_file_search + + out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) + search_md5=$(md5sum tmp_file_search | cut -d' ' -f1) + + rm tmp_file_out tmp_file_search + + if [ "${out_md5}" == "${search_md5}" ]; then + newRet=0 + fi + fi + + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi fi fi @@ -541,23 +600,24 @@ function attack_0() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi # multihash if [ "${MODE}" -ne 0 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -612,12 +672,16 @@ function attack_0() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi break - fi i=$((i + 1)) @@ -630,18 +694,17 @@ function attack_0() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -650,14 +713,14 @@ function attack_1() file_only=0 if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then - file_only=1 - fi # single hash if [ "${MODE}" -ne 1 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -678,6 +741,8 @@ function attack_1() elif [ "${hash_type}" -eq 15400 ]; then min=0 max=5 + elif [ "${hash_type}" -eq 20510 ]; then + min=2 fi echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" @@ -743,7 +808,6 @@ function attack_1() # finally, modify the dicts accordingly: tmp_file="${dict1}_mod" - head -n $((line_nr - 1)) "${dict1}" > "${tmp_file}" echo "${line_dict1}" >> "${tmp_file}" tail -n $((line_num - line_nr - 1)) "${dict1}" >> "${tmp_file}" @@ -782,10 +846,31 @@ function attack_1() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -eq 2 ]; then + + # out-of-memory, workaround + + echo "${output}" | head -1 > tmp_file_out + echo "${search}" > tmp_file_search + + out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) + search_md5=$(md5sum tmp_file_search | cut -d' ' -f1) + + rm tmp_file_out tmp_file_search + + if [ "${out_md5}" == "${search_md5}" ]; then + newRet=0 + fi + fi + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi fi fi @@ -802,18 +887,17 @@ function attack_1() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi # multihash @@ -831,6 +915,8 @@ function attack_1() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -902,36 +988,38 @@ function attack_1() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi break - fi i=$((i + 1)) done 9< "${OUTD}/${hash_type}_multihash_combi.txt" - fi status ${ret} msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -940,14 +1028,14 @@ function attack_3() file_only=0 if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then - file_only=1 - fi # single hash if [ "${MODE}" -ne 1 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -980,13 +1068,9 @@ function attack_3() while read -r -u 9 hash; do if [ "${i}" -gt 6 ]; then - if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - break - fi - fi if [ "${file_only}" -eq 1 ]; then @@ -1000,10 +1084,8 @@ function attack_3() fi hash="${temp_file}" - fi - # construct a meaningful mask from the password itself: dict="${OUTD}/${hash_type}_passwords.txt" @@ -1022,21 +1104,15 @@ function attack_3() mask="" if [ "${hash_type}" -eq 14000 ]; then - mask="${pass}" - elif [ "${hash_type}" -eq 14100 ]; then - mask="${pass}" - else - for i in $(seq 1 ${i}); do mask="${mask}?d" done mask="${mask}${pass_part_2}" - fi if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key @@ -1076,10 +1152,31 @@ function attack_3() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? + + if [ "${newRet}" -eq 2 ]; then - ret=10 + # out-of-memory, workaround + echo "${output}" | head -1 > tmp_file_out + echo "${search}" > tmp_file_search + + out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) + search_md5=$(md5sum tmp_file_search | cut -d' ' -f1) + + rm tmp_file_out tmp_file_search + + if [ "${out_md5}" == "${search_md5}" ]; then + newRet=0 + fi + fi + + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi fi fi @@ -1094,18 +1191,17 @@ function attack_3() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi # multihash @@ -1123,6 +1219,8 @@ function attack_3() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1131,9 +1229,7 @@ function attack_3() increment_max=8 if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - increment_max=5 - fi increment_min=1 @@ -1280,27 +1376,19 @@ function attack_3() # just make sure that all custom charset fields are initialized if [ -z "${charset_1}" ]; then - charset_1="1" - fi if [ -z "${charset_2}" ]; then - charset_2="2" - fi if [ -z "${charset_3}" ]; then - charset_3="3" - fi if [ -z "${charset_4}" ]; then - charset_4="4" - fi # unique and remove new lines @@ -1365,27 +1453,19 @@ function attack_3() # just make sure that all custom charset fields are initialized if [ -z "${charset_1}" ]; then - charset_1="1" - fi if [ -z "${charset_2}" ]; then - charset_2="2" - fi if [ -z "${charset_3}" ]; then - charset_3="3" - fi if [ -z "${charset_4}" ]; then - charset_4="4" - fi # unique and remove new lines @@ -1450,27 +1530,19 @@ function attack_3() # just make sure that all custom charset fields are initialized if [ -z "${charset_1}" ]; then - charset_1="1" - fi if [ -z "${charset_2}" ]; then - charset_2="2" - fi if [ -z "${charset_3}" ]; then - charset_3="3" - fi if [ -z "${charset_4}" ]; then - charset_4="4" - fi # unique and remove new lines @@ -1520,12 +1592,16 @@ function attack_3() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi break - fi i=$((i + 1)) @@ -1538,18 +1614,17 @@ function attack_3() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -1558,14 +1633,14 @@ function attack_6() file_only=0 if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then - file_only=1 - fi # single hash if [ "${MODE}" -ne 1 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1604,7 +1679,6 @@ function attack_6() # special case: we need to split the first line if [ "${min}" -eq 0 ]; then - pass_part_1=$(sed -n 1p "${OUTD}/${hash_type}_dict1") pass_part_2=$(sed -n 1p "${OUTD}/${hash_type}_dict2") @@ -1618,38 +1692,26 @@ function attack_6() for i in $(seq 1 $((${#pass} - mask_offset))); do if [ "${hash_type}" -eq 14000 ]; then - char=$(echo -n "${pass}" | cut -b $((i + mask_offset))) mask_custom="${mask_custom}${char}" - elif [ "${hash_type}" -eq 14100 ]; then - char=$(echo -n "${pass}" | cut -b $((i + mask_offset))) mask_custom="${mask_custom}${char}" - else - mask_custom="${mask_custom}?d" - fi done - fi - i=1 while read -r -u 9 hash; do if [ "${i}" -gt 6 ]; then - if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - break - fi - fi if [ ${i} -gt ${min} ]; then @@ -1718,7 +1780,6 @@ function attack_6() # end of shuf/sort -R - mask="" for j in $(seq 1 ${i}); do @@ -1754,16 +1815,35 @@ function attack_6() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -eq 2 ]; then + # out-of-memory, workaround + + echo "${output}" | head -1 > tmp_file_out + echo "${search}" > tmp_file_search + + out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) + search_md5=$(md5sum tmp_file_search | cut -d' ' -f1) + + rm tmp_file_out tmp_file_search + + if [ "${out_md5}" == "${search_md5}" ]; then + newRet=0 + fi + fi + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi fi fi status ${ret} - fi if [ "${i}" -eq ${max} ]; then break; fi @@ -1774,21 +1854,20 @@ function attack_6() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" rm -f "${OUTD}/${hash_type}_dict1_custom" rm -f "${OUTD}/${hash_type}_dict2_custom" - fi # multihash @@ -1806,6 +1885,8 @@ function attack_6() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1828,15 +1909,10 @@ function attack_6() fi if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - max=5 - if [ "${hash_type}" -eq 3200 ]; then - max=3 - fi - fi i=2 @@ -1894,18 +1970,21 @@ function attack_6() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi break - fi j=$((j + 1)) done 9< "${OUTD}/${hash_type}_hashes_multi_${i}.txt" - fi status ${ret} @@ -1915,18 +1994,17 @@ function attack_6() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -1935,14 +2013,14 @@ function attack_7() file_only=0 if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then - file_only=1 - fi # single hash if [ "${MODE}" -ne 1 ]; then + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1996,19 +2074,13 @@ function attack_7() for i in $(seq 1 ${mask_offset}); do if [ "${hash_type}" -eq 14000 ]; then - char=$(echo -n "${pass}" | cut -b ${i}) mask_custom="${mask_custom}${char}" - elif [ "${hash_type}" -eq 14100 ]; then - char=$(echo -n "${pass}" | cut -b ${i}) mask_custom="${mask_custom}${char}" - else - mask_custom="${mask_custom}?d" - fi done @@ -2173,16 +2245,37 @@ function attack_7() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -eq 2 ]; then + # out-of-memory, workaround + + echo "${output}" | head -1 > tmp_file_out + echo "${search}" > tmp_file_search + + out_md5=$(md5sum tmp_file_out | cut -d' ' -f1) + search_md5=$(md5sum tmp_file_search | cut -d' ' -f1) + + rm tmp_file_out tmp_file_search + + if [ "${out_md5}" == "${search_md5}" ]; then + newRet=0 + fi + fi + + if [ "${newRet}" -ne 0 ]; then + + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi fi fi status ${ret} - fi if [ $i -eq ${max} ]; then break; fi @@ -2193,21 +2286,20 @@ function attack_7() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" rm -f "${OUTD}/${hash_type}_dict1_custom" rm -f "${OUTD}/${hash_type}_dict2_custom" - fi # multihash @@ -2225,6 +2317,8 @@ function attack_7() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -2255,15 +2349,10 @@ function attack_7() fi if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - max=7 - if [ "${hash_type}" -eq 3200 ]; then - max=4 - fi - fi i=2 @@ -2348,18 +2437,21 @@ function attack_7() echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? - ret=10 + if [ "${newRet}" -ne 0 ]; then + if [ "${newRet}" -eq 2 ]; then + ret=20 + else + ret=10 + fi break - fi j=$((j + 1)) done 9< "${OUTD}/${hash_type}_hashes_multi_${i}.txt" - fi status ${ret} @@ -2369,18 +2461,17 @@ function attack_7() msg="OK" - if [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then - + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" - elif [ "${e_to}" -ne 0 ]; then - msg="Warning" - fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout" - + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -2540,18 +2631,30 @@ function cryptoloop_test() echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 + e_nm=0 + cnt=0 + + status ${ret} + + cnt=1 + msg="OK" - if [ ${ret} -ne 0 ]; then - e_nf=1 + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" + elif [ "${e_to}" -ne 0 ]; then + msg="Warning" fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Key-Size ${keySize} ] > $msg : ${e_nf}/${cnt} not found" - - status ${ret} + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Key-Size ${keySize} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -2723,18 +2826,30 @@ function truecrypt_test() echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 + e_nm=0 + cnt=0 + + status ${ret} + + cnt=1 + msg="OK" - if [ ${ret} -ne 0 ]; then - e_nf=1 + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" + elif [ "${e_to}" -ne 0 ]; then + msg="Warning" fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, tcMode ${tcMode} ] > $msg : ${e_nf}/${cnt} not found" - - status ${ret} + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, tcMode ${tcMode} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -2800,18 +2915,30 @@ function veracrypt_test() echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 + e_nm=0 + cnt=0 + + status ${ret} + + cnt=1 + msg="OK" - if [ ${ret} -ne 0 ]; then - e_nf=1 + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" + elif [ "${e_to}" -ne 0 ]; then + msg="Warning" fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade} ] > $msg : ${e_nf}/${cnt} not found" - - status ${ret} + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" } function luks_test() @@ -2925,16 +3052,30 @@ function luks_test() echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 + e_nm=0 + cnt=0 + + status ${ret} + + cnt=1 + msg="OK" - if [ ${ret} -ne 0 ]; then - e_nf=1 + if [ "${e_ce}" -ne 0 ]; then + msg="Compare Error" + elif [ "${e_rs}" -ne 0 ]; then + msg="Skip" + elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then msg="Error" + elif [ "${e_to}" -ne 0 ]; then + msg="Warning" fi - echo "[ ${OUTD} ] [ Type ${hash_type}, Attack ${attackType}, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode} ] > $msg : ${e_nf}/${cnt} not found" + echo "[ ${OUTD} ] [ Type ${hash_type}, Attack ${attackType}, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" status ${ret} fi @@ -3000,6 +3141,8 @@ OPTIONS: -f Use --force to ignore hashcat warnings (default : disabled) + -r Setup max runtime limit (default: 400) + -p Package the tests into a .7z file -F Use this folder as test folder instead of the default one @@ -3026,7 +3169,7 @@ HT=0 PACKAGE=0 OPTIMIZED=1 -while getopts "V:t:m:a:b:hcpd:x:o:d:D:F:POI:s:f" opt; do +while getopts "V:t:m:a:b:hcpd:x:o:d:D:F:POI:s:fr:" opt; do case ${opt} in "V") @@ -3158,6 +3301,10 @@ while getopts "V:t:m:a:b:hcpd:x:o:d:D:F:POI:s:f" opt; do FORCE=1 ;; + "r") + RUNTIME=${OPTARG} + ;; + \?) usage ;; @@ -3190,6 +3337,10 @@ if [ "${OPTIMIZED}" -eq 1 ]; then OPTS="${OPTS} -O" fi +# set max-runtime + +OPTS="${OPTS} --runtime ${RUNTIME}" + # set default device-type to CPU with Apple Intel, else GPU if [ "${DEVICE_TYPE}" = "null" ]; then @@ -3207,24 +3358,18 @@ if [ ${FORCE} -eq 1 ]; then fi if [ -n "${ARCHITECTURE}" ]; then - BIN="${BIN}${ARCHITECTURE}" - fi if [ -n "${EXTENSION}" ]; then - BIN="${BIN}.${EXTENSION}" - fi if [ -n "${PACKAGE_FOLDER}" ]; then - if [ ! -e "${PACKAGE_FOLDER}" ]; then echo "! folder '${PACKAGE_FOLDER}' does not exist" exit 1 fi - fi if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then @@ -3242,7 +3387,6 @@ if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then HT_MIN=${HT} HT_MAX=${HT} elif echo -n "${HT}" | grep -q '^[0-9]\+-[1-9][0-9]*$'; then - HT_MIN=$(echo -n ${HT} | sed "s/-.*//") HT_MAX=$(echo -n ${HT} | sed "s/.*-//") @@ -3330,7 +3474,6 @@ if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then for hash_type in $HASH_TYPES; do if [ "${HT}" -ne 65535 ]; then - # check if the loop variable "hash_type" is between HT_MIN and HT_MAX (both included) if [ "${hash_type}" -lt "${HT_MIN}" ]; then @@ -3353,15 +3496,45 @@ if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then fi fi - if [ -z "${PACKAGE_FOLDER}" ]; then + # skip deprecated hash-types + if [ "${hash_type}" -eq 2500 ] || [ "${hash_type}" -eq 2501 ] || [ "${hash_type}" -eq 16800 ] || [ "${hash_type}" -eq 16801 ] ; then + continue + fi + + # test.pl produce wrong hashes with Apple + # would be necessary to investigate to understand why + if [ "${hash_type}" -eq 1800 ]; then + if [[ "$OSTYPE" == "darwin"* ]]; then + continue + fi + fi + # Digest::BLAKE2 is broken on Apple Silicon + if [ "${hash_type}" -eq 600 ]; then + if [ "${IS_APPLE_SILICON}" -eq 1 ]; then + continue + fi + fi + + # Digest::GOST is broken on Apple Silicon + if [ "${hash_type}" -eq 6900 ]; then + if [ "${IS_APPLE_SILICON}" -eq 1 ]; then + continue + fi + fi + + # Crypt::GCrypt is broken on Apple and Linux + if [ "${hash_type}" -eq 18600 ]; then + if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then + continue + fi + fi + + if [ -z "${PACKAGE_FOLDER}" ]; then # init test data init - else - echo "[ ${OUTD} ] > Run packaged test for hash type $hash_type." - fi if [ "${PACKAGE}" -eq 0 ]; then @@ -3530,25 +3703,18 @@ if [ "${PACKAGE}" -eq 1 ]; then ls "${PACKAGE_FOLDER}"/*multi* >/dev/null 2>/dev/null - if [ "${?}" -ne 0 ] - then - + if [ "${?}" -ne 0 ]; then MODE=0 - fi HT=$(grep -o -- "-m *[0-9]*" "${PACKAGE_FOLDER}/all.sh" | sort -u | sed 's/-m //' 2> /dev/null) if [ -n "${HT}" ]; then - HT_COUNT=$(echo "${HT}" | wc -l) if [ "${HT_COUNT}" -gt 1 ]; then - HT=65535 - fi - fi #ATTACK=65535 # more appropriate ? @@ -3587,5 +3753,4 @@ if [ "${PACKAGE}" -eq 1 ]; then "${OUTD}/test.sh" ${PACKAGE_CMD} "${OUTD}/${OUTD}.7z" "${OUTD}/" >/dev/null 2>/dev/null - fi From e0e8ce81652a267473aafae69b2a7f268e937d8a Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 13 Jan 2022 13:24:23 +0100 Subject: [PATCH 10/18] Removed limitation with hash-type 18600 on linux --- tools/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test.sh b/tools/test.sh index dbc50bb35..26ec545ac 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -3523,9 +3523,9 @@ if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then fi fi - # Crypt::GCrypt is broken on Apple and Linux + # Crypt::GCrypt is broken on Apple if [ "${hash_type}" -eq 18600 ]; then - if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then + if [[ "$OSTYPE" == "darwin"* ]]; then continue fi fi From a621c856bd69469f3cee2fdfb8c78ffe47ebe6ae Mon Sep 17 00:00:00 2001 From: b0lek <95943440+b0lek@users.noreply.github.com> Date: Thu, 13 Jan 2022 17:53:04 +0100 Subject: [PATCH 11/18] allow hex format for --separator #3084 --- src/user_options.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/user_options.c b/src/user_options.c index ddc4fdc89..b55f4d83a 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -7,6 +7,7 @@ #include "types.h" #include "memory.h" #include "event.h" +#include "convert.h" #include "logfile.h" #include "interface.h" #include "shared.h" @@ -594,9 +595,31 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->separator_chgd == true) { - if (strlen (user_options->separator) != 1) + bool error = false; + if ((strlen (user_options->separator) != 1) && (strlen (user_options->separator) != 4)) { - event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte."); + error = true; + } + if (strlen (user_options->separator) == 4) + { + if ((user_options->separator[0] == '0') && (user_options->separator[1] == 'x')) + { + if (is_valid_hex_string((u8 * )(&(user_options->separator[2])),2)){ + u8 sep = hex_to_u8((u8 * )(&(user_options->separator[2]))); + user_options->separator[0] = sep; + user_options->separator[1] = 0; + } + else + { + error = true; + } + } + else{ + error = true; + } + } + if (error){ + event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte (single char or hex format e.g. 0x09 for TAB)"); return -1; } From 0c0e161cec908e4fb56f103155c802cb5b8cfef5 Mon Sep 17 00:00:00 2001 From: b0lek <95943440+b0lek@users.noreply.github.com> Date: Thu, 13 Jan 2022 17:56:45 +0100 Subject: [PATCH 12/18] Update changes.txt --- docs/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes.txt b/docs/changes.txt index 0d2fc5fb1..6cbb2427f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -14,6 +14,7 @@ - Added support to use --debug-mode in attack-mode 9 (Association Attack) - Added guess data to --status-json output +- Added hex format for --separator option ## ## Bugs From 50a4d6b58d124a8e337f5cbeb841a2a33bfee7f1 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 14 Jan 2022 18:28:08 +0100 Subject: [PATCH 13/18] Fixed Unit Test early exit on luks test file download/extract failure --- docs/changes.txt | 1 + tools/test.sh | 63 ++++++++++++++++++++++++++++++------------------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0d2fc5fb1..4bc515c4a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -27,6 +27,7 @@ - Fixed wordlist handling in -m 3000 when candidate passwords use the $HEX[...] syntax - Fixed false negative on Unit Test with hash-type 25400 - Fixed false negative on Unit Test in case of out-of-memory with grep in single mode +- Fixed Unit Test early exit on luks test file download/extract failure ## ## Technical diff --git a/tools/test.sh b/tools/test.sh index 26ec545ac..c17d20cf7 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -183,6 +183,11 @@ function init() fi if [ "${hash_type}" -eq ${LUKS_MODE} ]; then + which 7z &>/dev/null + if [ $? -eq 1 ]; then + echo "ATTENTION: 7z is missing. Skipping download and extract luks test files." + return 0 + fi luks_tests_folder="${TDIR}/luks_tests/" @@ -219,12 +224,12 @@ function init() if [ $? -ne 0 ] || [ ! -f "${luks_tests}" ]; then cd - >/dev/null echo "ERROR: Could not fetch the luks test files from this url: ${luks_tests_url}" - exit 1 + return 0 fi # extract: - ${EXTRACT_CMD} "${luks_tests}" >/dev/null 2>/dev/null + ${EXTRACT_CMD} "${luks_tests}" &>/dev/null # cleanup: @@ -235,7 +240,7 @@ function init() if [ ! -f "${luks_first_test_file}" ]; then echo "ERROR: downloading and extracting ${luks_tests} into ${luks_tests_folder} did not complete successfully" - exit 1 + return 0 fi fi @@ -469,6 +474,12 @@ function status() e_nm=$((e_nm + 1)) ;; + 30) + echo "luks test files are missing, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" + + e_rs=$((e_rs + 1)) + ;; + *) echo "! unhandled return code ${RET}, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" echo "! unhandled return code, see ${OUTD}/logfull.txt or ${OUTD}/test_report.log for details." @@ -561,7 +572,7 @@ function attack_0() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -670,7 +681,7 @@ function attack_0() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -844,7 +855,7 @@ function attack_1() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -986,7 +997,7 @@ function attack_1() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -1150,7 +1161,7 @@ function attack_3() search="${hash}:${line_dict}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -1590,7 +1601,7 @@ function attack_3() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -1813,7 +1824,7 @@ function attack_6() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -1968,7 +1979,7 @@ function attack_6() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -2243,7 +2254,7 @@ function attack_7() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -2435,7 +2446,7 @@ function attack_7() search="${hash}:${line_dict1}${line_dict2}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null newRet=$? @@ -2959,7 +2970,7 @@ function luks_test() LUKS_MODES="cbc-essiv cbc-plain64 xts-plain64" LUKS_KEYSIZES="128 256 512" - LUKS_PASSWORD=$(cat "${TDIR}/luks_tests/pw") + LUKS_PASSWORD=$(cat "${TDIR}/luks_tests/pw" 2>/dev/null) for luks_h in ${LUKS_HASHES}; do for luks_c in ${LUKS_CIPHERS}; do @@ -3017,15 +3028,15 @@ function luks_test() luks_pass_part1_len=$((${#LUKS_PASSWORD} / 2)) luks_pass_part2_start=$((luks_pass_part1_len + 1)) - echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" - echo "${LUKS_PASSWORD}" | cut -c${luks_pass_part2_start}- > "${luks_pass_part_file2}" + echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null + echo "${LUKS_PASSWORD}" | cut -c${luks_pass_part2_start}- > "${luks_pass_part_file2}" 2>/dev/null CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} ${luks_file} ${luks_pass_part_file1} ${luks_pass_part_file2}" ;; 3) luks_mask_fixed_len=$((${#LUKS_PASSWORD} - 1)) - luks_mask="$(echo "${LUKS_PASSWORD}" | cut -c-${luks_mask_fixed_len})" + luks_mask="$(echo "${LUKS_PASSWORD}" | cut -c-${luks_mask_fixed_len} 2>/dev/null)" luks_mask="${luks_mask}${luks_main_mask}" CMD="./${BIN} ${OPTS} -a 3 -m ${hashType} ${luks_file} ${luks_mask}" @@ -3033,12 +3044,12 @@ function luks_test() 6) luks_pass_part1_len=$((${#LUKS_PASSWORD} - 1)) - echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" + echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} ${luks_file} ${luks_pass_part_file1} ${luks_mask}" ;; 7) - echo "${LUKS_PASSWORD}" | cut -c2- > "${luks_pass_part_file1}" + echo "${LUKS_PASSWORD}" | cut -c2- > "${luks_pass_part_file1}" 2>/dev/null CMD="./${BIN} ${OPTS} -a 7 -m ${hashType} ${luks_file} ${luks_mask} ${luks_pass_part_file1}" ;; @@ -3047,10 +3058,14 @@ function luks_test() if [ -n "${CMD}" ]; then echo "> Testing hash type ${hashType} with attack mode ${attackType}, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" - output=$(${CMD} 2>&1) - ret=${?} + if [ -f "${luks_first_test_file}" ]; then + output=$(${CMD} 2>&1) + ret=${?} - echo "${output}" >> "${OUTD}/logfull.txt" + echo "${output}" >> "${OUTD}/logfull.txt" + else + ret=30 + fi e_ce=0 e_rs=0 @@ -3701,7 +3716,7 @@ if [ "${PACKAGE}" -eq 1 ]; then MODE=2 - ls "${PACKAGE_FOLDER}"/*multi* >/dev/null 2>/dev/null + ls "${PACKAGE_FOLDER}"/*multi* &>/dev/null if [ "${?}" -ne 0 ]; then MODE=0 @@ -3752,5 +3767,5 @@ if [ "${PACKAGE}" -eq 1 ]; then -e "s/^\(ATTACK\)=0/\1=${ATTACK}/" \ "${OUTD}/test.sh" - ${PACKAGE_CMD} "${OUTD}/${OUTD}.7z" "${OUTD}/" >/dev/null 2>/dev/null + ${PACKAGE_CMD} "${OUTD}/${OUTD}.7z" "${OUTD}/" &>/dev/null fi From 54605b9254bcbd6ec50a8b8fb75968bc93a8011b Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 15 Jan 2022 16:27:15 +0100 Subject: [PATCH 14/18] Fixed Unit Test salt-max in case of optimized kernel, with hash-type 22 and 23 --- docs/changes.txt | 1 + tools/test_modules/m00022.pm | 2 +- tools/test_modules/m00023.pm | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 48290e341..89d5a8ac8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -29,6 +29,7 @@ - Fixed bug on benchmark engine, from now it will not stop at the first error detected - Fixed false negative on Unit Test in case of out-of-memory with grep in single mode - Fixed Unit Test early exit on luks test file download/extract failure +- Fixed Unit Test salt-max in case of optimized kernel, with hash-type 22 and 23 ## ## Technical diff --git a/tools/test_modules/m00022.pm b/tools/test_modules/m00022.pm index 631be7bbd..fccdc879e 100644 --- a/tools/test_modules/m00022.pm +++ b/tools/test_modules/m00022.pm @@ -10,7 +10,7 @@ use warnings; use Digest::MD5 qw (md5); -sub module_constraints { [[0, 232], [0, 232], [0, 32], [0, 32], [0, 32]] } +sub module_constraints { [[0, 232], [0, 232], [0, 32], [0, 28], [0, 32]] } sub module_generate_hash { diff --git a/tools/test_modules/m00023.pm b/tools/test_modules/m00023.pm index 8caa91577..19120e329 100644 --- a/tools/test_modules/m00023.pm +++ b/tools/test_modules/m00023.pm @@ -10,7 +10,7 @@ use warnings; use Digest::MD5 qw (md5_hex); -sub module_constraints { [[0, 247], [0, 247], [0, 47], [0, 47], [0, 47]] } +sub module_constraints { [[0, 247], [0, 247], [0, 47], [0, 43], [0, 47]] } sub module_generate_hash { From dc6d40c0126206d764ebaded87bdb73bc573cb36 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 16 Jan 2022 07:15:29 +0100 Subject: [PATCH 15/18] Fixed Unit Test false negative if there are spaces in the filesystem path to hashcat --- docs/changes.txt | 1 + tools/test.sh | 110 +++++++++++++++++++++++------------------------ 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 48290e341..85adc153c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -29,6 +29,7 @@ - Fixed bug on benchmark engine, from now it will not stop at the first error detected - Fixed false negative on Unit Test in case of out-of-memory with grep in single mode - Fixed Unit Test early exit on luks test file download/extract failure +- Fixed Unit Test false negative if there are spaces in the filesystem path to hashcat ## ## Technical diff --git a/tools/test.sh b/tools/test.sh index c17d20cf7..e47c2d734 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -2493,14 +2493,14 @@ function cryptoloop_test() CMD="unset" mkdir -p ${OUTD}/cl_tests - chmod u+x ${TDIR}/cryptoloop2hashcat.py + chmod u+x "${TDIR}/cryptoloop2hashcat.py" case $hashType in 14511) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha1_aes_${keySize}.img --hash sha1 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_aes_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_aes_${keySize}.img\" --hash sha1 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_aes_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_aes_${keySize}.hash hashca?l" ;; esac @@ -2509,7 +2509,7 @@ function cryptoloop_test() 14512) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha1_serpent_${keySize}.img --hash sha1 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_serpent_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_serpent_${keySize}.img\" --hash sha1 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_serpent_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_serpent_${keySize}.hash hashca?l" ;; esac @@ -2518,7 +2518,7 @@ function cryptoloop_test() 14513) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha1_twofish_${keySize}.img --hash sha1 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_twofish_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_twofish_${keySize}.img\" --hash sha1 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_twofish_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_twofish_${keySize}.hash hashca?l" ;; esac @@ -2527,7 +2527,7 @@ function cryptoloop_test() 14521) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha256_aes_${keySize}.img --hash sha256 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_aes_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_aes_${keySize}.img\" --hash sha256 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_aes_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_aes_${keySize}.hash hashca?l" ;; esac @@ -2536,7 +2536,7 @@ function cryptoloop_test() 14522) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha256_serpent_${keySize}.img --hash sha256 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_serpent_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_serpent_${keySize}.img\" --hash sha256 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_serpent_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_serpent_${keySize}.hash hashca?l" ;; esac @@ -2545,7 +2545,7 @@ function cryptoloop_test() 14523) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha256_twofish_${keySize}.img --hash sha256 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_twofish_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_twofish_${keySize}.img\" --hash sha256 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_twofish_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_twofish_${keySize}.hash hashca?l" ;; esac @@ -2554,7 +2554,7 @@ function cryptoloop_test() 14531) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha512_aes_${keySize}.img --hash sha512 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_aes_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_aes_${keySize}.img\" --hash sha512 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_aes_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_aes_${keySize}.hash hashca?l" ;; esac @@ -2563,7 +2563,7 @@ function cryptoloop_test() 14532) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha512_serpent_${keySize}.img --hash sha512 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_serpent_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_serpent_${keySize}.img\" --hash sha512 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_serpent_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_serpent_${keySize}.hash hashca?l" ;; esac @@ -2572,7 +2572,7 @@ function cryptoloop_test() 14533) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_sha512_twofish_${keySize}.img --hash sha512 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_twofish_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_twofish_${keySize}.img\" --hash sha512 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_twofish_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_twofish_${keySize}.hash hashca?l" ;; esac @@ -2581,7 +2581,7 @@ function cryptoloop_test() 14541) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_ripemd160_aes_${keySize}.img --hash ripemd160 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_aes_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_aes_${keySize}.img\" --hash ripemd160 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_aes_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_aes_${keySize}.hash hashca?l" ;; esac @@ -2590,7 +2590,7 @@ function cryptoloop_test() 14542) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_ripemd160_serpent_${keySize}.img --hash ripemd160 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_serpent_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_serpent_${keySize}.img\" --hash ripemd160 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_serpent_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_serpent_${keySize}.hash hashca?l" ;; esac @@ -2599,7 +2599,7 @@ function cryptoloop_test() 14543) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_ripemd160_twofish_${keySize}.img --hash ripemd160 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_twofish_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_twofish_${keySize}.img\" --hash ripemd160 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_twofish_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_twofish_${keySize}.hash hashca?l" ;; esac @@ -2608,7 +2608,7 @@ function cryptoloop_test() 14551) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_whirlpool_aes_${keySize}.img --hash whirlpool --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_aes_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_whirlpool_aes_${keySize}.img\" --hash whirlpool --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_aes_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_aes_${keySize}.hash hashca?l" ;; esac @@ -2617,7 +2617,7 @@ function cryptoloop_test() 14552) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_whirlpool_serpent_${keySize}.img --hash whirlpool --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_serpent_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_whirlpool_serpent_${keySize}.img\" --hash whirlpool --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_serpent_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_serpent_${keySize}.hash hashca?l" ;; esac @@ -2626,7 +2626,7 @@ function cryptoloop_test() 14553) case $keySize in 128|192|256) - ${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_whirlpool_twofish_${keySize}.img --hash whirlpool --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_twofish_${keySize}.hash + eval \"${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_whirlpool_twofish_${keySize}.img\" --hash whirlpool --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_twofish_${keySize}.hash CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_twofish_${keySize}.hash hashca?l" ;; esac @@ -2680,13 +2680,13 @@ function truecrypt_test() 6211) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6211 ${TDIR}/tc_tests/hashcat_ripemd160_aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_aes.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6211 ${TDIR}/tc_tests/hashcat_ripemd160_serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_serpent.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6211 ${TDIR}/tc_tests/hashcat_ripemd160_twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_twofish.tc' hashca?l" ;; esac ;; @@ -2694,13 +2694,13 @@ function truecrypt_test() 6212) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6212 ${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6212 ${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6212 ${TDIR}/tc_tests/hashcat_ripemd160_twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_twofish-serpent.tc' hashca?l" ;; esac ;; @@ -2708,10 +2708,10 @@ function truecrypt_test() 6213) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6213 ${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6213 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6213 ${TDIR}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6213 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.tc' hashca?l" ;; esac ;; @@ -2719,13 +2719,13 @@ function truecrypt_test() 6221) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6221 ${TDIR}/tc_tests/hashcat_sha512_aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_aes.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6221 ${TDIR}/tc_tests/hashcat_sha512_serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_serpent.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6221 ${TDIR}/tc_tests/hashcat_sha512_twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_twofish.tc' hashca?l" ;; esac ;; @@ -2733,13 +2733,13 @@ function truecrypt_test() 6222) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6222 ${TDIR}/tc_tests/hashcat_sha512_aes-twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_aes-twofish.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6222 ${TDIR}/tc_tests/hashcat_sha512_serpent-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_serpent-aes.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6222 ${TDIR}/tc_tests/hashcat_sha512_twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_twofish-serpent.tc' hashca?l" ;; esac ;; @@ -2747,10 +2747,10 @@ function truecrypt_test() 6223) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6223 ${TDIR}/tc_tests/hashcat_sha512_aes-twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6223 '${TDIR}/tc_tests/hashcat_sha512_aes-twofish-serpent.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6223 ${TDIR}/tc_tests/hashcat_sha512_serpent-twofish-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6223 '${TDIR}/tc_tests/hashcat_sha512_serpent-twofish-aes.tc' hashca?l" ;; esac ;; @@ -2758,13 +2758,13 @@ function truecrypt_test() 6231) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6231 ${TDIR}/tc_tests/hashcat_whirlpool_aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_aes.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6231 ${TDIR}/tc_tests/hashcat_whirlpool_serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_serpent.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6231 ${TDIR}/tc_tests/hashcat_whirlpool_twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_twofish.tc' hashca?l" ;; esac ;; @@ -2772,13 +2772,13 @@ function truecrypt_test() 6232) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6232 ${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6232 ${TDIR}/tc_tests/hashcat_whirlpool_serpent-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_serpent-aes.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6232 ${TDIR}/tc_tests/hashcat_whirlpool_twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_twofish-serpent.tc' hashca?l" ;; esac ;; @@ -2786,10 +2786,10 @@ function truecrypt_test() 6233) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6233 ${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6233 '${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6233 ${TDIR}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6233 '${TDIR}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.tc' hashca?l" ;; esac ;; @@ -2797,13 +2797,13 @@ function truecrypt_test() 6241) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6241 ${TDIR}/tc_tests/hashcat_ripemd160_aes_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_aes_boot.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6241 ${TDIR}/tc_tests/hashcat_ripemd160_serpent_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_serpent_boot.tc' hashca?l" ;; 2) - CMD="./${BIN} ${OPTS} -a 3 -m 6241 ${TDIR}/tc_tests/hashcat_ripemd160_twofish_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_twofish_boot.tc' hashca?l" ;; esac ;; @@ -2811,10 +2811,10 @@ function truecrypt_test() 6242) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6242 ${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6242 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish_boot.tc' hashca?l" ;; 1) - CMD="./${BIN} ${OPTS} -a 3 -m 6242 ${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6242 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes_boot.tc' hashca?l" ;; esac ;; @@ -2822,7 +2822,7 @@ function truecrypt_test() 6243) case $tcMode in 0) - CMD="./${BIN} ${OPTS} -a 3 -m 6243 ${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.tc hashca?l" + CMD="./${BIN} ${OPTS} -a 3 -m 6243 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.tc' hashca?l" ;; esac ;; @@ -2831,7 +2831,7 @@ function truecrypt_test() if [ ${#CMD} -gt 5 ]; then echo "> Testing hash type $hashType with attack mode 3, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, tcMode ${tcMode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" - output=$(${CMD} 2>&1) + output=$(eval ${CMD} 2>&1) ret=${?} @@ -2916,11 +2916,11 @@ function veracrypt_test() # The hash-cipher combination might be invalid (e.g. RIPEMD-160 + Kuznyechik) [ -f "${filename}" ] || return - CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} ${filename} hashc?lt" + CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} '${filename}' hashc?lt" echo "> Testing hash type ${hash_type} with attack mode 0, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" - output=$(${CMD} 2>&1) + output=$(eval ${CMD} 2>&1) ret=${?} @@ -3022,7 +3022,7 @@ function luks_test() case $attackType in 0) - CMD="./${BIN} ${OPTS} -a 0 -m ${hashType} ${luks_file} ${TDIR}/luks_tests/pw" + CMD="./${BIN} ${OPTS} -a 0 -m ${hashType} '${luks_file}' '${TDIR}/luks_tests/pw'" ;; 1) luks_pass_part1_len=$((${#LUKS_PASSWORD} / 2)) @@ -3031,7 +3031,7 @@ function luks_test() echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null echo "${LUKS_PASSWORD}" | cut -c${luks_pass_part2_start}- > "${luks_pass_part_file2}" 2>/dev/null - CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} ${luks_file} ${luks_pass_part_file1} ${luks_pass_part_file2}" + CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luks_file}' ${luks_pass_part_file1} ${luks_pass_part_file2}" ;; 3) luks_mask_fixed_len=$((${#LUKS_PASSWORD} - 1)) @@ -3039,19 +3039,19 @@ function luks_test() luks_mask="$(echo "${LUKS_PASSWORD}" | cut -c-${luks_mask_fixed_len} 2>/dev/null)" luks_mask="${luks_mask}${luks_main_mask}" - CMD="./${BIN} ${OPTS} -a 3 -m ${hashType} ${luks_file} ${luks_mask}" + CMD="./${BIN} ${OPTS} -a 3 -m ${hashType} '${luks_file}' ${luks_mask}" ;; 6) luks_pass_part1_len=$((${#LUKS_PASSWORD} - 1)) echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null - CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} ${luks_file} ${luks_pass_part_file1} ${luks_mask}" + CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luks_file}' ${luks_pass_part_file1} ${luks_mask}" ;; 7) echo "${LUKS_PASSWORD}" | cut -c2- > "${luks_pass_part_file1}" 2>/dev/null - CMD="./${BIN} ${OPTS} -a 7 -m ${hashType} ${luks_file} ${luks_mask} ${luks_pass_part_file1}" + CMD="./${BIN} ${OPTS} -a 7 -m ${hashType} '${luks_file}' ${luks_mask} ${luks_pass_part_file1}" ;; esac @@ -3059,7 +3059,7 @@ function luks_test() echo "> Testing hash type ${hashType} with attack mode ${attackType}, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" if [ -f "${luks_first_test_file}" ]; then - output=$(${CMD} 2>&1) + output=$(eval ${CMD} 2>&1) ret=${?} echo "${output}" >> "${OUTD}/logfull.txt" From adfe94275197136af14857e8cdd1f7500524acb5 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 16 Jan 2022 08:40:42 +0100 Subject: [PATCH 16/18] Fixed --hash-info example password output: force uppercase if OPTS_TYPE_PT_UPPER is set --- docs/changes.txt | 1 + src/terminal.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 48290e341..1519dba47 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -29,6 +29,7 @@ - Fixed bug on benchmark engine, from now it will not stop at the first error detected - Fixed false negative on Unit Test in case of out-of-memory with grep in single mode - Fixed Unit Test early exit on luks test file download/extract failure +- Fixed --hash-info example password output: force uppercase if OPTS_TYPE_PT_UPPER is set ## ## Technical diff --git a/src/terminal.c b/src/terminal.c index b39b502bc..3692c10b3 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -699,6 +699,20 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op hcfree (tmp_buf); } + else if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) + { + size_t st_pass_len = strlen (hashconfig->st_pass); + + char *tmp_buf = (char *) hcmalloc (st_pass_len + 1); + + strncpy (tmp_buf, hashconfig->st_pass, st_pass_len); + + uppercase ((u8 *) tmp_buf, st_pass_len); + + event_log_info (hashcat_ctx, " Example.Pass........: %s", tmp_buf); + + hcfree (tmp_buf); + } else { event_log_info (hashcat_ctx, " Example.Pass........: %s", hashconfig->st_pass); From c1b56a3018904044572e974d74b92d49a08de027 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 16 Jan 2022 14:48:49 +0100 Subject: [PATCH 17/18] Hash Info: show more information (Updated Hash-Format. Added Autodetect, Self-Test, Potfile and Plaintext encoding) --- docs/changes.txt | 1 + src/terminal.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 1519dba47..916898b4a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -52,6 +52,7 @@ - Status code: updated negative status code, usefull in Unit tests engine (test.sh) - Unit tests: added -r (--runtime) option - Unit tests: handle negative status code, skip deprecated hash-types, skip hash-types with known perl modules issues, updated output +- Hash Info: show more information (Updated Hash-Format. Added Autodetect, Self-Test, Potfile and Plaintext encoding) * changes v6.2.4 -> v6.2.5 diff --git a/src/terminal.c b/src/terminal.c index 3692c10b3..13f46c1ee 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -667,7 +667,14 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op { if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) { - event_log_info (hashcat_ctx, " Example.Hash.Format.: hex-encoded"); + if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL) + { + event_log_info (hashcat_ctx, " Example.Hash.Format.: hex-encoded"); + } + else + { + event_log_info (hashcat_ctx, " Example.Hash.Format.: hex-encoded (binary file only)"); + } event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash); } else @@ -734,6 +741,23 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op event_log_info (hashcat_ctx, " Benchmark.Mask......: N/A"); } + event_log_info (hashcat_ctx, " Autodetect.Enabled..: %s", (hashconfig->opts_type & OPTS_TYPE_AUTODETECT_DISABLE) ? "No" : "Yes"); + event_log_info (hashcat_ctx, " Self.Test.Enabled...: %s", (hashconfig->opts_type & OPTS_TYPE_SELF_TEST_DISABLE) ? "No" : "Yes"); + event_log_info (hashcat_ctx, " Potfile.Enabled.....: %s", (hashconfig->opts_type & OPTS_TYPE_POTFILE_NOPASS) ? "No" : "Yes"); + + if (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) + { + event_log_info (hashcat_ctx, " Plaintext.Encoding..: ASCII only"); + } + else if (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_HEXIFY) + { + event_log_info (hashcat_ctx, " Plaintext.Encoding..: HEX only"); + } + else + { + event_log_info (hashcat_ctx, " Plaintext.Encoding..: ASCII, HEX"); + } + event_log_info (hashcat_ctx, NULL); } From 3c5b28e007e638fafd12ce8658c4637a96a56920 Mon Sep 17 00:00:00 2001 From: philsmd <921533+philsmd@users.noreply.github.com> Date: Tue, 18 Jan 2022 16:20:45 +0100 Subject: [PATCH 18/18] remove unnecessary perl modules from Exodus tests --- tools/test_modules/m28200.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/test_modules/m28200.pm b/tools/test_modules/m28200.pm index 5732cdbd9..85bde1ec1 100644 --- a/tools/test_modules/m28200.pm +++ b/tools/test_modules/m28200.pm @@ -8,11 +8,9 @@ use strict; use warnings; -use Crypt::ScryptKDF qw (scrypt_hash scrypt_raw); -use Crypt::CBC; -use MIME::Base64 qw (decode_base64 encode_base64); -use Digest::SHA qw (sha512); use Crypt::AuthEnc::GCM; +use Crypt::ScryptKDF qw (scrypt_raw); +use MIME::Base64 qw (decode_base64 encode_base64); sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] }