X-Git-Url: https://www.flypig.org.uk/git/?a=blobdiff_plain;f=src%2Fhashcat.c;h=23b91c5eef2d420b11d5495befaa21ea7d3946b6;hb=e8aefb412cd45b7770bf7d3123b374aa822a0782;hp=44057892a4a35db3ec297985e176ecffc7e93d40;hpb=7ef80fb12b98e54511744487228a26b75ae89981;p=hashcat.git diff --git a/src/hashcat.c b/src/hashcat.c index 4405789..23b91c5 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -33,6 +33,7 @@ double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 }; #define MARKOV_DISABLE 0 #define MARKOV_CLASSIC 0 #define BENCHMARK 0 +#define STDOUT_FLAG 0 #define RESTORE 0 #define RESTORE_TIMER 60 #define RESTORE_DISABLE 0 @@ -74,9 +75,10 @@ double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 }; #define SEPARATOR ':' #define BITMAP_MIN 16 #define BITMAP_MAX 24 +#define NVIDIA_SPIN_DAMP 100 #define GPU_TEMP_DISABLE 0 #define GPU_TEMP_ABORT 90 -#define GPU_TEMP_RETAIN 0 +#define GPU_TEMP_RETAIN 65 #define WORKLOAD_PROFILE 2 #define KERNEL_ACCEL 0 #define KERNEL_LOOPS 0 @@ -388,6 +390,7 @@ const char *USAGE_BIG[] = " --outfile-autohex-disable | | Disable the use of $HEX[] in output plains |", " --outfile-check-timer | Num | Sets seconds between outfile checks to X | --outfile-check=30", " -p, --separator | Char | Separator char for hashlists and outfile | -p :", + " --stdout | | Do not crack a hash, instead print candidates only |", " --show | | Show cracked passwords only |", " --left | | Show un-cracked passwords only |", " --username | | Enable ignoring of usernames in hashfile |", @@ -415,6 +418,7 @@ const char *USAGE_BIG[] = " -w, --workload-profile | Num | Enable a specific workload profile, see pool below | -w 3", " -n, --kernel-accel | Num | Manual workload tuning, set outerloop step size to X | -n 64", " -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256", + " --nvidia-spin-damp | Num | Workaround NVidias CPU burning loop bug, in percent | --nvidia-spin-damp=50", " --gpu-temp-disable | | Disable temperature and fanspeed reads and triggers |", #ifdef HAVE_HWMON " --gpu-temp-abort | Num | Abort if GPU temperature reaches X degrees celsius | --gpu-temp-abort=100", @@ -2313,6 +2317,175 @@ static void check_cracked (hc_device_param_t *device_param, const uint salt_pos) } } +static void process_stdout (hc_device_param_t *device_param, const uint pws_cnt) +{ + char out_buf[HCBUFSIZ] = { 0 }; + + uint plain_buf[16] = { 0 }; + + u8 *plain_ptr = (u8 *) plain_buf; + + uint plain_len = 0; + + const uint il_cnt = device_param->kernel_params_buf32[27]; // ugly, i know + + if (data.attack_mode == ATTACK_MODE_STRAIGHT) + { + pw_t pw; + + for (uint gidvid = 0; gidvid < pws_cnt; gidvid++) + { + gidd_to_pw_t (device_param, gidvid, &pw); + + const uint pos = device_param->innerloop_pos; + + for (uint il_pos = 0; il_pos < il_cnt; il_pos++) + { + for (int i = 0; i < 8; i++) + { + plain_buf[i] = pw.i[i]; + } + + plain_len = pw.pw_len; + + plain_len = apply_rules (data.kernel_rules_buf[pos + il_pos].cmds, &plain_buf[0], &plain_buf[4], plain_len); + + if (plain_len > data.pw_max) plain_len = data.pw_max; + + format_output (stdout, out_buf, plain_ptr, plain_len, 0, NULL, 0); + } + } + } + else if (data.attack_mode == ATTACK_MODE_COMBI) + { + pw_t pw; + + for (uint gidvid = 0; gidvid < pws_cnt; gidvid++) + { + gidd_to_pw_t (device_param, gidvid, &pw); + + for (uint il_pos = 0; il_pos < il_cnt; il_pos++) + { + for (int i = 0; i < 8; i++) + { + plain_buf[i] = pw.i[i]; + } + + plain_len = pw.pw_len; + + char *comb_buf = (char *) device_param->combs_buf[il_pos].i; + uint comb_len = device_param->combs_buf[il_pos].pw_len; + + if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + memcpy (plain_ptr + plain_len, comb_buf, comb_len); + } + else + { + memmove (plain_ptr + comb_len, plain_ptr, plain_len); + + memcpy (plain_ptr, comb_buf, comb_len); + } + + plain_len += comb_len; + + if (data.pw_max != PW_DICTMAX1) + { + if (plain_len > data.pw_max) plain_len = data.pw_max; + } + + format_output (stdout, out_buf, plain_ptr, plain_len, 0, NULL, 0); + } + } + } + else if (data.attack_mode == ATTACK_MODE_BF) + { + for (uint gidvid = 0; gidvid < pws_cnt; gidvid++) + { + for (uint il_pos = 0; il_pos < il_cnt; il_pos++) + { + u64 l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid; + u64 r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos; + + uint l_start = device_param->kernel_params_mp_l_buf32[5]; + uint r_start = device_param->kernel_params_mp_r_buf32[5]; + + uint l_stop = device_param->kernel_params_mp_l_buf32[4]; + uint r_stop = device_param->kernel_params_mp_r_buf32[4]; + + sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop); + sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop); + + plain_len = data.css_cnt; + + format_output (stdout, out_buf, plain_ptr, plain_len, 0, NULL, 0); + } + } + } + else if (data.attack_mode == ATTACK_MODE_HYBRID1) + { + pw_t pw; + + for (uint gidvid = 0; gidvid < pws_cnt; gidvid++) + { + gidd_to_pw_t (device_param, gidvid, &pw); + + for (uint il_pos = 0; il_pos < il_cnt; il_pos++) + { + for (int i = 0; i < 8; i++) + { + plain_buf[i] = pw.i[i]; + } + + plain_len = pw.pw_len; + + u64 off = device_param->kernel_params_mp_buf64[3] + il_pos; + + uint start = 0; + uint stop = device_param->kernel_params_mp_buf32[4]; + + sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop); + + plain_len += start + stop; + + format_output (stdout, out_buf, plain_ptr, plain_len, 0, NULL, 0); + } + } + } + else if (data.attack_mode == ATTACK_MODE_HYBRID2) + { + pw_t pw; + + for (uint gidvid = 0; gidvid < pws_cnt; gidvid++) + { + gidd_to_pw_t (device_param, gidvid, &pw); + + for (uint il_pos = 0; il_pos < il_cnt; il_pos++) + { + for (int i = 0; i < 8; i++) + { + plain_buf[i] = pw.i[i]; + } + + plain_len = pw.pw_len; + + u64 off = device_param->kernel_params_mp_buf64[3] + il_pos; + + uint start = 0; + uint stop = device_param->kernel_params_mp_buf32[4]; + + memmove (plain_ptr + stop, plain_ptr, plain_len); + + sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop); + + plain_len += start + stop; + + format_output (stdout, out_buf, plain_ptr, plain_len, 0, NULL, 0); + } + } + } +} + static void save_hash () { char *hashfile = data.hashfile; @@ -2350,8 +2523,6 @@ static void save_hash () if (data.hash_mode != 2500) { - char out_buf[HCBUFSIZ] = { 0 }; - if (data.username == 1) { user_t *user = data.hash_info[idx]->user; @@ -2363,11 +2534,15 @@ static void save_hash () fputc (separator, fp); } + char out_buf[HCBUFSIZ]; // scratch buffer + + out_buf[0] = 0; + ascii_digest (out_buf, salt_pos, digest_pos); fputs (out_buf, fp); - log_out (fp, ""); + fputc ('\n', fp); } else { @@ -2405,7 +2580,7 @@ static void save_hash () unlink (old_hashfile); } -static void run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num, const uint event_update) +static void run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num, const uint event_update, const uint iteration) { uint num_elements = num; @@ -2468,21 +2643,50 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co hc_clFlush (data.ocl, device_param->command_queue); + if (device_param->nvidia_spin_damp) + { + if (data.devices_status == STATUS_RUNNING) + { + if (iteration < EXPECTED_ITERATIONS) + { + switch (kern_run) + { + case KERN_RUN_1: if (device_param->exec_us_prev1[iteration]) usleep (device_param->exec_us_prev1[iteration] * device_param->nvidia_spin_damp); break; + case KERN_RUN_2: if (device_param->exec_us_prev2[iteration]) usleep (device_param->exec_us_prev2[iteration] * device_param->nvidia_spin_damp); break; + case KERN_RUN_3: if (device_param->exec_us_prev3[iteration]) usleep (device_param->exec_us_prev3[iteration] * device_param->nvidia_spin_damp); break; + } + } + } + } + hc_clWaitForEvents (data.ocl, 1, &event); - if (event_update) - { - cl_ulong time_start; - cl_ulong time_end; + cl_ulong time_start; + cl_ulong time_end; - hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); - hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); + hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); + hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); - const double exec_time = (double) (time_end - time_start) / 1000000.0; + const double exec_us = (double) (time_end - time_start) / 1000; + if (data.devices_status == STATUS_RUNNING) + { + if (iteration < EXPECTED_ITERATIONS) + { + switch (kern_run) + { + case KERN_RUN_1: device_param->exec_us_prev1[iteration] = exec_us; break; + case KERN_RUN_2: device_param->exec_us_prev2[iteration] = exec_us; break; + case KERN_RUN_3: device_param->exec_us_prev3[iteration] = exec_us; break; + } + } + } + + if (event_update) + { uint exec_pos = device_param->exec_pos; - device_param->exec_ms[exec_pos] = exec_time; + device_param->exec_ms[exec_pos] = exec_us / 1000; exec_pos++; @@ -2695,8 +2899,15 @@ static void run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const */ } -static void choose_kernel (hc_device_param_t *device_param, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt) +static void choose_kernel (hc_device_param_t *device_param, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration) { + if (data.hash_mode == 2000) + { + process_stdout (device_param, pws_cnt); + + return; + } + if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { if (attack_mode == ATTACK_MODE_BF) @@ -2715,33 +2926,39 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex if (highest_pw_len < 16) { - run_kernel (KERN_RUN_1, device_param, pws_cnt, true); + run_kernel (KERN_RUN_1, device_param, pws_cnt, true, fast_iteration); } else if (highest_pw_len < 32) { - run_kernel (KERN_RUN_2, device_param, pws_cnt, true); + run_kernel (KERN_RUN_2, device_param, pws_cnt, true, fast_iteration); } else { - run_kernel (KERN_RUN_3, device_param, pws_cnt, true); + run_kernel (KERN_RUN_3, device_param, pws_cnt, true, fast_iteration); } } else { run_kernel_amp (device_param, pws_cnt); - run_kernel (KERN_RUN_1, device_param, pws_cnt, false); + run_kernel (KERN_RUN_1, device_param, pws_cnt, false, 0); if (opts_type & OPTS_TYPE_HOOK12) { - run_kernel (KERN_RUN_12, device_param, pws_cnt, false); + run_kernel (KERN_RUN_12, device_param, pws_cnt, false, 0); + + hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + + // do something with data + + hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); } uint iter = salt_buf->salt_iter; uint loop_step = device_param->kernel_loops; - for (uint loop_pos = 0; loop_pos < iter; loop_pos += loop_step) + for (uint loop_pos = 0, slow_iteration = 0; loop_pos < iter; loop_pos += loop_step, slow_iteration++) { uint loop_left = iter - loop_pos; @@ -2750,7 +2967,7 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex device_param->kernel_params_buf32[25] = loop_pos; device_param->kernel_params_buf32[26] = loop_left; - run_kernel (KERN_RUN_2, device_param, pws_cnt, true); + run_kernel (KERN_RUN_2, device_param, pws_cnt, true, slow_iteration); if (data.devices_status == STATUS_CRACKED) break; if (data.devices_status == STATUS_ABORTED) break; @@ -2782,7 +2999,7 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex if (opts_type & OPTS_TYPE_HOOK23) { - run_kernel (KERN_RUN_23, device_param, pws_cnt, false); + run_kernel (KERN_RUN_23, device_param, pws_cnt, false, 0); hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); @@ -2791,7 +3008,7 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); } - run_kernel (KERN_RUN_3, device_param, pws_cnt, false); + run_kernel (KERN_RUN_3, device_param, pws_cnt, false, 0); } } @@ -2893,11 +3110,11 @@ static double try_run (hc_device_param_t *device_param, const u32 kernel_accel, if (data.attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - run_kernel (KERN_RUN_1, device_param, kernel_power_try, true); + run_kernel (KERN_RUN_1, device_param, kernel_power_try, true, 0); } else { - run_kernel (KERN_RUN_2, device_param, kernel_power_try, true); + run_kernel (KERN_RUN_2, device_param, kernel_power_try, true, 0); } const double exec_ms_prev = get_avg_exec_time (device_param, 1); @@ -2924,10 +3141,13 @@ static void autotune (hc_device_param_t *device_param) if ((kernel_loops_min == kernel_loops_max) && (kernel_accel_min == kernel_accel_max)) { - try_run (device_param, kernel_accel, kernel_loops); - try_run (device_param, kernel_accel, kernel_loops); - try_run (device_param, kernel_accel, kernel_loops); - try_run (device_param, kernel_accel, kernel_loops); + if (data.hash_mode != 2000) + { + try_run (device_param, kernel_accel, kernel_loops); + try_run (device_param, kernel_accel, kernel_loops); + try_run (device_param, kernel_accel, kernel_loops); + try_run (device_param, kernel_accel, kernel_loops); + } device_param->kernel_accel = kernel_accel; device_param->kernel_loops = kernel_loops; @@ -3113,6 +3333,10 @@ static void autotune (hc_device_param_t *device_param) memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); + memset (device_param->exec_us_prev1, 0, EXPECTED_ITERATIONS * sizeof (double)); + memset (device_param->exec_us_prev2, 0, EXPECTED_ITERATIONS * sizeof (double)); + memset (device_param->exec_us_prev3, 0, EXPECTED_ITERATIONS * sizeof (double)); + // store device_param->kernel_accel = kernel_accel; @@ -3230,9 +3454,16 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) if (data.devices_status == STATUS_QUIT) break; if (data.devices_status == STATUS_BYPASS) break; + uint fast_iteration = 0; + uint innerloop_left = innerloop_cnt - innerloop_pos; - if (innerloop_left > innerloop_step) innerloop_left = innerloop_step; + if (innerloop_left > innerloop_step) + { + innerloop_left = innerloop_step; + + fast_iteration = 1; + } device_param->innerloop_pos = innerloop_pos; device_param->innerloop_left = innerloop_left; @@ -3390,7 +3621,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) hc_timer_set (&device_param->timer_speed); } - choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt); + choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt, fast_iteration); if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (); @@ -4004,7 +4235,13 @@ static void *thread_monitor (void *p) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { + #ifdef _WIN + hm_set_fanspeed_with_device_id_nvapi (device_id, fan_speed_new, 1); + #endif + #ifdef _LINUX + hm_set_fanspeed_with_device_id_xnvctrl (device_id, fan_speed_new); + #endif } fan_speed_chgd[device_id] = 1; @@ -4963,11 +5200,11 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po if (data.attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - run_kernel (KERN_RUN_1, device_param, 1, false); + run_kernel (KERN_RUN_1, device_param, 1, false, 0); } else { - run_kernel (KERN_RUN_1, device_param, 1, false); + run_kernel (KERN_RUN_1, device_param, 1, false, 0); uint loop_step = 16; @@ -4982,10 +5219,10 @@ static void weak_hash_check (hc_device_param_t *device_param, const uint salt_po device_param->kernel_params_buf32[25] = loop_pos; device_param->kernel_params_buf32[26] = loop_left; - run_kernel (KERN_RUN_2, device_param, 1, false); + run_kernel (KERN_RUN_2, device_param, 1, false, 0); } - run_kernel (KERN_RUN_3, device_param, 1, false); + run_kernel (KERN_RUN_3, device_param, 1, false, 0); } /** @@ -5425,7 +5662,7 @@ static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, cons * main */ -#ifdef _WIN +#ifdef WIN void SetConsoleWindowSize (const int x) { HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE); @@ -5451,26 +5688,9 @@ void SetConsoleWindowSize (const int x) } #endif -#ifdef _POSIX -int (*clock_gettime_orig) (clockid_t clk_id, struct timespec *tp); - -int clock_gettime (clockid_t clk_id, struct timespec *tp) -{ - int r = clock_gettime_orig (clk_id, tp); - - usleep (NVIDIA_100PERCENTCPU_WORKAROUND); - - return r; -} -#endif - int main (int argc, char **argv) { - #ifdef _POSIX - clock_gettime_orig = dlsym (RTLD_NEXT, "clock_gettime"); - #endif - - #ifdef _WIN + #ifdef WIN SetConsoleWindowSize (132); #endif @@ -5539,6 +5759,7 @@ int main (int argc, char **argv) uint version = VERSION; uint quiet = QUIET; uint benchmark = BENCHMARK; + uint stdout_flag = STDOUT_FLAG; uint show = SHOW; uint left = LEFT; uint username = USERNAME; @@ -5598,6 +5819,7 @@ int main (int argc, char **argv) uint workload_profile = WORKLOAD_PROFILE; uint kernel_accel = KERNEL_ACCEL; uint kernel_loops = KERNEL_LOOPS; + uint nvidia_spin_damp = NVIDIA_SPIN_DAMP; uint gpu_temp_disable = GPU_TEMP_DISABLE; #ifdef HAVE_HWMON uint gpu_temp_abort = GPU_TEMP_ABORT; @@ -5636,6 +5858,7 @@ int main (int argc, char **argv) #define IDX_FORCE 0xff08 #define IDX_RUNTIME 0xff09 #define IDX_BENCHMARK 'b' + #define IDX_STDOUT_FLAG 0xff77 #define IDX_HASH_MODE 'm' #define IDX_ATTACK_MODE 'a' #define IDX_RP_FILE 'r' @@ -5675,6 +5898,7 @@ int main (int argc, char **argv) #define IDX_WORKLOAD_PROFILE 'w' #define IDX_KERNEL_ACCEL 'n' #define IDX_KERNEL_LOOPS 'u' + #define IDX_NVIDIA_SPIN_DAMP 0xff79 #define IDX_GPU_TEMP_DISABLE 0xff29 #define IDX_GPU_TEMP_ABORT 0xff30 #define IDX_GPU_TEMP_RETAIN 0xff31 @@ -5716,6 +5940,7 @@ int main (int argc, char **argv) {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR}, {"force", no_argument, 0, IDX_FORCE}, {"benchmark", no_argument, 0, IDX_BENCHMARK}, + {"stdout", no_argument, 0, IDX_STDOUT_FLAG}, {"restore", no_argument, 0, IDX_RESTORE}, {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE}, {"status", no_argument, 0, IDX_STATUS}, @@ -5753,6 +5978,7 @@ int main (int argc, char **argv) {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE}, {"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL}, {"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS}, + {"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP}, {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE}, #ifdef HAVE_HWMON {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT}, @@ -5972,6 +6198,7 @@ int main (int argc, char **argv) uint runtime_chgd = 0; uint kernel_loops_chgd = 0; uint kernel_accel_chgd = 0; + uint nvidia_spin_damp_chgd = 0; uint attack_mode_chgd = 0; uint outfile_format_chgd = 0; uint rp_gen_seed_chgd = 0; @@ -6012,6 +6239,7 @@ int main (int argc, char **argv) case IDX_LIMIT: limit = atoll (optarg); break; case IDX_KEYSPACE: keyspace = 1; break; case IDX_BENCHMARK: benchmark = 1; break; + case IDX_STDOUT_FLAG: stdout_flag = 1; break; case IDX_RESTORE: break; case IDX_RESTORE_DISABLE: restore_disable = 1; break; case IDX_STATUS: status = 1; break; @@ -6059,6 +6287,8 @@ int main (int argc, char **argv) kernel_accel_chgd = 1; break; case IDX_KERNEL_LOOPS: kernel_loops = atoi (optarg); kernel_loops_chgd = 1; break; + case IDX_NVIDIA_SPIN_DAMP: nvidia_spin_damp = atoi (optarg); + nvidia_spin_damp_chgd = 1; break; case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break; #ifdef HAVE_HWMON case IDX_GPU_TEMP_ABORT: gpu_temp_abort = atoi (optarg); break; @@ -6125,6 +6355,10 @@ int main (int argc, char **argv) log_info ("%s (%s) starting in restore-mode...", PROGNAME, VERSION_TAG); log_info (""); } + else if (stdout_flag == 1) + { + // do nothing + } else { log_info ("%s (%s) starting...", PROGNAME, VERSION_TAG); @@ -6388,8 +6622,32 @@ int main (int argc, char **argv) case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break; } - if (benchmark == 0) + if (benchmark == 1) + { + if (myargv[optind] != 0) + { + log_error ("ERROR: Invalid argument for benchmark mode specified"); + + return (-1); + } + + if (attack_mode_chgd == 1) + { + if (attack_mode != ATTACK_MODE_BF) + { + log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode"); + + return (-1); + } + } + } + else { + if (stdout_flag == 1) // no hash here + { + optind--; + } + if (keyspace == 1) { int num_additional_params = 1; @@ -6447,25 +6705,6 @@ int main (int argc, char **argv) return (-1); } } - else - { - if (myargv[optind] != 0) - { - log_error ("ERROR: Invalid argument for benchmark mode specified"); - - return (-1); - } - - if (attack_mode_chgd == 1) - { - if (attack_mode != ATTACK_MODE_BF) - { - log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode"); - - return (-1); - } - } - } if (skip != 0 && limit != 0) { @@ -6498,6 +6737,24 @@ int main (int argc, char **argv) quiet = 1; } + if (stdout_flag == 1) + { + status_timer = 0; + restore_timer = 0; + restore_disable = 1; + restore = 0; + potfile_disable = 1; + weak_hash_threshold = 0; + gpu_temp_disable = 1; + hash_mode = 2000; + quiet = 1; + outfile_format = OUTFILE_FMT_PLAIN; + kernel_accel = 1024; + kernel_loops = 1024; + force = 1; + outfile_check_timer = 0; + } + if (remove_timer_chgd == 1) { if (remove == 0) @@ -6590,6 +6847,14 @@ int main (int argc, char **argv) weak_hash_threshold = 0; } + if (nvidia_spin_damp > 100) + { + log_error ("ERROR: setting --nvidia-spin-damp must be between 0 and 100 (inclusive)"); + + return (-1); + } + + /** * induction directory */ @@ -6844,12 +7109,14 @@ int main (int argc, char **argv) logfile_top_uint (attack_mode); logfile_top_uint (attack_kern); logfile_top_uint (benchmark); + logfile_top_uint (stdout_flag); logfile_top_uint (bitmap_min); logfile_top_uint (bitmap_max); logfile_top_uint (debug_mode); logfile_top_uint (force); logfile_top_uint (kernel_accel); logfile_top_uint (kernel_loops); + logfile_top_uint (nvidia_spin_damp); logfile_top_uint (gpu_temp_disable); #ifdef HAVE_HWMON logfile_top_uint (gpu_temp_abort); @@ -6969,7 +7236,9 @@ int main (int argc, char **argv) restore_disable = 1; potfile_disable = 1; weak_hash_threshold = 0; + nvidia_spin_damp = 0; gpu_temp_disable = 1; + outfile_check_timer = 0; #ifdef HAVE_HWMON if (powertune_enable == 1) @@ -6978,9 +7247,10 @@ int main (int argc, char **argv) } #endif - data.status_timer = status_timer; - data.restore_timer = restore_timer; - data.restore_disable = restore_disable; + data.status_timer = status_timer; + data.restore_timer = restore_timer; + data.restore_disable = restore_disable; + data.outfile_check_timer = outfile_check_timer; /** * force attack mode to be bruteforce @@ -8412,6 +8682,21 @@ int main (int argc, char **argv) dgst_pos3 = 3; break; + case 2000: hash_type = HASH_TYPE_STDOUT; + salt_type = SALT_TYPE_NONE; + attack_exec = ATTACK_EXEC_INSIDE_KERNEL; + opts_type = OPTS_TYPE_PT_GENERATE_LE; + kern_type = 0; + dgst_size = DGST_SIZE_4_4; + parse_func = NULL; + sort_by_digest = NULL; + opti_type = 0; + dgst_pos0 = 0; + dgst_pos1 = 0; + dgst_pos2 = 0; + dgst_pos3 = 0; + break; + case 2100: hash_type = HASH_TYPE_DCC2; salt_type = SALT_TYPE_EMBEDDED; attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL; @@ -10846,7 +11131,6 @@ int main (int argc, char **argv) dgst_pos3 = 6; break; - default: usage_mini_print (PROGNAME); return (-1); } @@ -11375,7 +11659,7 @@ int main (int argc, char **argv) uint hashes_avail = 0; - if (benchmark == 0) + if ((benchmark == 0) && (stdout_flag == 0)) { struct stat f; @@ -11557,6 +11841,10 @@ int main (int argc, char **argv) { // useless to read hash file for keyspace, cheat a little bit w/ optind } + else if (stdout_flag == 1) + { + // useless to read hash file for stdout, cheat a little bit w/ optind + } else if (hashes_avail == 0) { } @@ -12366,7 +12654,7 @@ int main (int argc, char **argv) return (0); } - if (keyspace == 0) + if ((keyspace == 0) && (stdout_flag == 0)) { if (hashes_cnt == 0) { @@ -13369,9 +13657,10 @@ int main (int argc, char **argv) * OpenCL devices: simply push all devices from all platforms into the same device array */ - int need_adl = 0; - int need_nvapi = 0; - int need_nvml = 0; + int need_adl = 0; + int need_nvapi = 0; + int need_nvml = 0; + int need_xnvctrl = 0; hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); @@ -13781,6 +14070,10 @@ int main (int argc, char **argv) { need_nvml = 1; + #ifdef _LINUX + need_xnvctrl = 1; + #endif + #ifdef _WIN need_nvapi = 1; #endif @@ -13837,6 +14130,29 @@ int main (int argc, char **argv) device_param->sm_minor = sm_minor; device_param->sm_major = sm_major; + + // CPU burning loop damper + // Value is given as number between 0-100 + // By default 100% + + device_param->nvidia_spin_damp = (double) nvidia_spin_damp; + + if (nvidia_spin_damp_chgd == 0) + { + if (data.attack_mode == ATTACK_MODE_STRAIGHT) + { + /** + * the workaround is not a friend of rule based attacks + * the words from the wordlist combined with fast and slow rules cause + * fluctuations which cause inaccurate wait time estimations + * using a reduced damping percentage almost compensates this + */ + + device_param->nvidia_spin_damp = 64; + } + } + + device_param->nvidia_spin_damp /= 100; } else { @@ -14058,19 +14374,22 @@ int main (int argc, char **argv) */ #ifdef HAVE_HWMON - hm_attrs_t hm_adapters_adl[DEVICES_MAX] = { { 0 } }; - hm_attrs_t hm_adapters_nvapi[DEVICES_MAX] = { { 0 } }; - hm_attrs_t hm_adapters_nvml[DEVICES_MAX] = { { 0 } }; + hm_attrs_t hm_adapters_adl[DEVICES_MAX] = { { 0 } }; + hm_attrs_t hm_adapters_nvapi[DEVICES_MAX] = { { 0 } }; + hm_attrs_t hm_adapters_nvml[DEVICES_MAX] = { { 0 } }; + hm_attrs_t hm_adapters_xnvctrl[DEVICES_MAX] = { { 0 } }; if (gpu_temp_disable == 0) { - ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR)); - NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); - NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); + ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR)); + NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); + NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); + XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) mymalloc (sizeof (XNVCTRL_PTR)); - data.hm_adl = NULL; - data.hm_nvapi = NULL; - data.hm_nvml = NULL; + data.hm_adl = NULL; + data.hm_nvapi = NULL; + data.hm_nvml = NULL; + data.hm_xnvctrl = NULL; if ((need_nvml == 1) && (nvml_init (nvml) == 0)) { @@ -14127,6 +14446,30 @@ int main (int argc, char **argv) } } + if ((need_xnvctrl == 1) && (xnvctrl_init (xnvctrl) == 0)) + { + data.hm_xnvctrl = xnvctrl; + } + + if (data.hm_xnvctrl) + { + if (hm_XNVCTRL_XOpenDisplay (data.hm_xnvctrl) == 0) + { + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) + { + hc_device_param_t *device_param = &data.devices_param[device_id]; + + if ((device_param->device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + + hm_adapters_xnvctrl[device_id].xnvctrl = device_id; + + int speed = 0; + + if (get_fan_speed_current (data.hm_xnvctrl, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = 1; + } + } + } + if ((need_adl == 1) && (adl_init (adl) == 0)) { data.hm_adl = adl; @@ -14173,7 +14516,7 @@ int main (int argc, char **argv) } } - if (data.hm_adl == NULL && data.hm_nvml == NULL) + if (data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl == NULL) { gpu_temp_disable = 1; } @@ -14262,7 +14605,7 @@ int main (int argc, char **argv) */ #ifdef HAVE_HWMON - if (gpu_temp_disable == 0 && data.hm_adl == NULL && data.hm_nvml == NULL) + if (gpu_temp_disable == 0 && data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl == NULL) { log_info ("Watchdog: Hardware Monitoring Interface not found on your system"); } @@ -14312,9 +14655,10 @@ int main (int argc, char **argv) data.hm_device[device_id].adl = hm_adapters_adl[platform_devices_id].adl; data.hm_device[device_id].nvapi = 0; data.hm_device[device_id].nvml = 0; + data.hm_device[device_id].xnvctrl = 0; data.hm_device[device_id].od_version = hm_adapters_adl[platform_devices_id].od_version; data.hm_device[device_id].fan_get_supported = hm_adapters_adl[platform_devices_id].fan_get_supported; - data.hm_device[device_id].fan_set_supported = hm_adapters_adl[platform_devices_id].fan_set_supported; + data.hm_device[device_id].fan_set_supported = 0; } if (device_param->device_vendor_id == VENDOR_ID_NV) @@ -14322,6 +14666,7 @@ int main (int argc, char **argv) data.hm_device[device_id].adl = 0; data.hm_device[device_id].nvapi = hm_adapters_nvapi[platform_devices_id].nvapi; data.hm_device[device_id].nvml = hm_adapters_nvml[platform_devices_id].nvml; + data.hm_device[device_id].xnvctrl = hm_adapters_xnvctrl[platform_devices_id].xnvctrl; data.hm_device[device_id].od_version = 0; data.hm_device[device_id].fan_get_supported = hm_adapters_nvml[platform_devices_id].fan_get_supported; data.hm_device[device_id].fan_set_supported = 0; @@ -14883,7 +15228,9 @@ int main (int argc, char **argv) if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23)) { - // none yet + switch (hash_mode) + { + } } // now check if all device-memory sizes which depend on the kernel_accel_max amplifier are within its boundaries @@ -15837,7 +16184,13 @@ int main (int argc, char **argv) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { + #ifdef _WIN + rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 1); + #endif + #ifdef _LINUX + rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); + #endif } if (rc == 0) @@ -15846,7 +16199,7 @@ int main (int argc, char **argv) } else { - log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1); + //log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1); data.hm_device[device_id].fan_set_supported = 0; } @@ -16734,11 +17087,18 @@ int main (int argc, char **argv) if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING; - hc_thread_t i_thread = 0; + uint i_threads_cnt = 0; + + hc_thread_t *i_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK)) { - hc_thread_create (i_thread, thread_keypress, &benchmark); + if (stdout_flag == 0) + { + hc_thread_create (i_threads[i_threads_cnt], thread_keypress, &benchmark); + + i_threads_cnt++; + } } if (wordlist_mode == WL_MODE_STDIN) data.status = 1; @@ -16747,9 +17107,12 @@ int main (int argc, char **argv) hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); - hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL); + if (stdout_flag == 0) + { + hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL); - ni_threads_cnt++; + ni_threads_cnt++; + } /** * Outfile remove @@ -17602,10 +17965,10 @@ int main (int argc, char **argv) * create autotune threads */ - data.devices_status = STATUS_AUTOTUNE; - hc_thread_t *c_threads = (hc_thread_t *) mycalloc (data.devices_cnt, sizeof (hc_thread_t)); + data.devices_status = STATUS_AUTOTUNE; + for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { hc_device_param_t *device_param = &devices_param[device_id]; @@ -17870,11 +18233,13 @@ int main (int argc, char **argv) // wait for interactive threads - if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK)) + for (uint thread_idx = 0; thread_idx < i_threads_cnt; thread_idx++) { - hc_thread_wait (1, &i_thread); + hc_thread_wait (1, &i_threads[thread_idx]); } + local_free (i_threads); + // we dont need restore file anymore if (data.restore_disable == 0) { @@ -18025,7 +18390,13 @@ int main (int argc, char **argv) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { + #ifdef _WIN + rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, fanpolicy); + #endif + #ifdef _LINUX + rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); + #endif } if (rc == -1) log_info ("WARNING: Failed to restore default fan speed and policy for device #%", device_id + 1); @@ -18123,6 +18494,24 @@ int main (int argc, char **argv) data.hm_nvml = NULL; } + if (data.hm_nvapi) + { + hm_NvAPI_Unload (data.hm_nvapi); + + nvapi_close (data.hm_nvapi); + + data.hm_nvapi = NULL; + } + + if (data.hm_xnvctrl) + { + hm_XNVCTRL_XCloseDisplay (data.hm_xnvctrl); + + xnvctrl_close (data.hm_xnvctrl); + + data.hm_xnvctrl = NULL; + } + if (data.hm_adl) { hm_ADL_Main_Control_Destroy (data.hm_adl);