diff --git a/docs/changes.txt b/docs/changes.txt index 219e53b02..33f18643d 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 @@ -25,6 +26,13 @@ - 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 +- 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 +- Fixed Unit Test false negative if there are spaces in the filesystem path to hashcat +- Fixed --hash-info example password output: force uppercase if OPTS_TYPE_PT_UPPER is set - Hash-Mode 9700: set native_threads to 32 with Apple GPU's - Hash-Mode 9710: set native_threads to 32 with Apple GPU's - Hash-Mode 9720: set native_threads to 32 with Apple GPU's @@ -54,6 +62,11 @@ - 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 - 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) +- 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/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/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/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/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/Makefile b/src/Makefile index 1443d4d5c..fc0afc4fb 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) +ifneq (,$(filter $(UNAME),FreeBSD NetBSD)) CC := cc CXX := c++ SED := gsed @@ -314,8 +314,14 @@ 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 +export MACOSX_DEPLOYMENT_TARGET=10.15 CFLAGS_NATIVE := $(CFLAGS) CFLAGS_NATIVE += -DWITH_HWMON @@ -324,7 +330,6 @@ CFLAGS_NATIVE += -DMISSING_CLOCK_GETTIME endif LFLAGS_NATIVE := $(LFLAGS) -LFLAGS_NATIVE += -framework OpenCL LFLAGS_NATIVE += -framework IOKit LFLAGS_NATIVE += -lpthread LFLAGS_NATIVE += -liconv @@ -458,10 +463,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/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 a469f0ad0..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; @@ -12318,27 +12364,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; @@ -12352,7 +12389,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; @@ -12364,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; @@ -12376,42 +12412,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/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/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/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/modules/module_25400.c b/src/modules/module_25400.c index f75c51860..7f7e1641e 100644 --- a/src/modules/module_25400.c +++ b/src/modules/module_25400.c @@ -549,7 +549,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, @@ -587,7 +587,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/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/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) 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..13f46c1ee 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; @@ -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 @@ -699,6 +706,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); @@ -720,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); } @@ -1175,7 +1213,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 +1228,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 +1250,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 +1267,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 +1385,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 +1817,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 +1933,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 +2009,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 +2035,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 +2055,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 +2098,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 +2133,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 +2173,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 +2203,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 +2254,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 +2290,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 +2320,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 +2372,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 +2384,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, 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; } diff --git a/tools/test.sh b/tools/test.sh index 205d8367d..e47c2d734 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 } @@ -180,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/" @@ -211,16 +219,17 @@ 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 + return 0 fi # extract: - ${EXTRACT_CMD} "${luks_tests}" >/dev/null 2>/dev/null + ${EXTRACT_CMD} "${luks_tests}" &>/dev/null # cleanup: @@ -231,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 @@ -296,17 +305,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 +354,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 +387,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 +403,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 +463,30 @@ 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)) + 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)) + ;; + + 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." + e_nf=$((e_nf + 1)) ;; + esac fi } @@ -436,14 +496,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 +514,7 @@ function attack_0() max=32 if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - max=12 - fi i=0 @@ -464,18 +522,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,12 +572,33 @@ function attack_0() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/dev/null - if [ "${?}" -ne 0 ]; then + newRet=$? + 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 @@ -536,23 +611,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 @@ -605,14 +681,18 @@ function attack_0() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/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)) @@ -625,18 +705,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 } @@ -645,14 +724,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 @@ -673,6 +752,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" @@ -738,7 +819,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}" @@ -775,12 +855,33 @@ 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 - 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 @@ -797,18 +898,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 @@ -826,6 +926,8 @@ function attack_1() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -895,38 +997,40 @@ 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 - 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 } @@ -935,14 +1039,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 @@ -975,13 +1079,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 @@ -995,10 +1095,8 @@ function attack_3() fi hash="${temp_file}" - fi - # construct a meaningful mask from the password itself: dict="${OUTD}/${hash_type}_passwords.txt" @@ -1017,21 +1115,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 @@ -1069,12 +1161,33 @@ 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 - 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 @@ -1089,18 +1202,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 @@ -1118,6 +1230,8 @@ function attack_3() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1126,9 +1240,7 @@ function attack_3() increment_max=8 if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then - increment_max=5 - fi increment_min=1 @@ -1275,27 +1387,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 @@ -1360,27 +1464,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 @@ -1445,27 +1541,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 @@ -1513,14 +1601,18 @@ function attack_3() search="${hash}:${pass}" fi - echo "${output}" | grep -F "${search}" >/dev/null 2>/dev/null + echo "${output}" | grep -F "${search}" &>/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)) @@ -1533,18 +1625,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 } @@ -1553,14 +1644,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 @@ -1599,7 +1690,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") @@ -1613,38 +1703,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 @@ -1713,7 +1791,6 @@ function attack_6() # end of shuf/sort -R - mask="" for j in $(seq 1 ${i}); do @@ -1747,18 +1824,37 @@ 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 - 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 @@ -1769,21 +1865,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 @@ -1801,6 +1896,8 @@ function attack_6() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -1823,15 +1920,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 @@ -1887,20 +1979,23 @@ 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 - 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} @@ -1910,18 +2005,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 } @@ -1930,14 +2024,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 @@ -1991,19 +2085,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 @@ -2166,18 +2254,39 @@ 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 - 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 @@ -2188,21 +2297,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 @@ -2220,6 +2328,8 @@ function attack_7() return fi + e_ce=0 + e_rs=0 e_to=0 e_nf=0 e_nm=0 @@ -2250,15 +2360,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 @@ -2341,20 +2446,23 @@ 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 - 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} @@ -2364,18 +2472,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 } @@ -2386,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 @@ -2402,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 @@ -2411,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 @@ -2420,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 @@ -2429,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 @@ -2438,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 @@ -2447,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 @@ -2456,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 @@ -2465,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 @@ -2474,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 @@ -2483,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 @@ -2492,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 @@ -2501,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 @@ -2510,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 @@ -2519,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 @@ -2535,18 +2642,30 @@ function cryptoloop_test() echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 - msg="OK" - - if [ ${ret} -ne 0 ]; then - e_nf=1 - msg="Error" - 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" + e_nm=0 + cnt=0 status ${ret} + + cnt=1 + + msg="OK" + + 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, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -2561,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 ;; @@ -2575,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 ;; @@ -2589,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 ;; @@ -2600,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 ;; @@ -2614,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 ;; @@ -2628,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 ;; @@ -2639,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 ;; @@ -2653,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 ;; @@ -2667,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 ;; @@ -2678,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 ;; @@ -2692,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 ;; @@ -2703,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 ;; @@ -2712,24 +2831,36 @@ 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=${?} echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 - msg="OK" - - if [ ${ret} -ne 0 ]; then - e_nf=1 - msg="Error" - 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" + e_nm=0 + cnt=0 status ${ret} + + cnt=1 + + msg="OK" + + 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, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" fi } @@ -2785,28 +2916,40 @@ 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=${?} echo "${output}" >> "${OUTD}/logfull.txt" - cnt=1 + e_ce=0 + e_rs=0 + e_to=0 e_nf=0 - msg="OK" - - if [ ${ret} -ne 0 ]; then - e_nf=1 - msg="Error" - 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" + e_nm=0 + cnt=0 status ${ret} + + cnt=1 + + msg="OK" + + 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, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" } function luks_test() @@ -2827,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 @@ -2879,57 +3022,75 @@ 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)) 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}" + 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}" + 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}" + 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}" + 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 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=$(eval ${CMD} 2>&1) + ret=${?} - echo "${output}" >> "${OUTD}/logfull.txt" - - cnt=1 - e_nf=0 - msg="OK" - - if [ ${ret} -ne 0 ]; then - e_nf=1 - msg="Error" + echo "${output}" >> "${OUTD}/logfull.txt" + else + ret=30 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" + e_ce=0 + e_rs=0 + e_to=0 + e_nf=0 + e_nm=0 + cnt=0 + + status ${ret} + + cnt=1 + + msg="OK" + + 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, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped" status ${ret} fi @@ -2995,6 +3156,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 @@ -3021,7 +3184,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") @@ -3153,6 +3316,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 ;; @@ -3185,6 +3352,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 @@ -3202,24 +3373,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 @@ -3237,7 +3402,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/.*-//") @@ -3325,7 +3489,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 @@ -3348,15 +3511,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 + if [ "${hash_type}" -eq 18600 ]; then + if [[ "$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 @@ -3523,27 +3716,20 @@ if [ "${PACKAGE}" -eq 1 ]; then MODE=2 - ls "${PACKAGE_FOLDER}"/*multi* >/dev/null 2>/dev/null - - if [ "${?}" -ne 0 ] - then + ls "${PACKAGE_FOLDER}"/*multi* &>/dev/null + 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 ? @@ -3581,6 +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 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 { 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]] }