diff --git a/include/restore.h b/include/restore.h index f740d60f9..70f4d7890 100644 --- a/include/restore.h +++ b/include/restore.h @@ -33,6 +33,8 @@ void write_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx); void cycle_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx); +void unlink_restore (restore_ctx_t *restore_ctx, status_ctx_t *status_ctx); + void stop_at_checkpoint (restore_ctx_t *restore_ctx, status_ctx_t *status_ctx); int restore_ctx_init (restore_ctx_t *restore_ctx, user_options_t *user_options, const folder_config_t *folder_config, int argc, char **argv); diff --git a/src/hashcat.c b/src/hashcat.c index 58d6a4c36..a514fef1b 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1207,33 +1207,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) myfree (inner_threads); - // we dont need restore file anymore - if (restore_ctx->enabled == true) - { - if ((status_ctx->devices_status == STATUS_EXHAUSTED) || (status_ctx->devices_status == STATUS_CRACKED)) - { - if (status_ctx->run_thread_level1 == true) // this is to check for [c]heckpoint - { - unlink (restore_ctx->eff_restore_file); - unlink (restore_ctx->new_restore_file); - } - else - { - cycle_restore (restore_ctx, opencl_ctx); - } - } - else - { - cycle_restore (restore_ctx, opencl_ctx); - } - } - - // finally save left hashes - if ((hashes->hashlist_mode == HL_MODE_FILE) && (user_options->remove == true) && (hashes->digests_saved != hashes->digests_done)) - { - save_hash (user_options, hashconfig, hashes); - } - /** * Clean up */ @@ -1527,7 +1500,11 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options->quiet = false; } - // Update dictionary statistic + // if exhausted or cracked, unlink the restore file + + unlink_restore (restore_ctx, status_ctx); + + // final update dictionary cache dictstat_write (dictstat_ctx); diff --git a/src/monitor.c b/src/monitor.c index b4574739e..22cb585fb 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -9,11 +9,6 @@ #include "memory.h" #include "interface.h" #include "timer.h" -#include "ext_OpenCL.h" -#include "ext_ADL.h" -#include "ext_nvapi.h" -#include "ext_nvml.h" -#include "ext_xnvctrl.h" #include "mpsp.h" #include "rp_cpu.h" #include "tuningdb.h" @@ -279,7 +274,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if (restore_left == 0) { - if (user_options->restore_disable == 0) cycle_restore (restore_ctx, opencl_ctx); + cycle_restore (restore_ctx, opencl_ctx); restore_left = user_options->restore_timer; } @@ -353,6 +348,23 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) } } + // final round of save_hash + + if (remove_check == true) + { + if (hashes->digests_saved != hashes->digests_done) + { + save_hash (user_options, hashconfig, hashes); + } + } + + // final round of cycle_restore + + if (restore_check == true) + { + cycle_restore (restore_ctx, opencl_ctx); + } + myfree (fan_speed_chgd); myfree (temp_diff_old); diff --git a/src/restore.c b/src/restore.c index 6c349bcfc..cb0a0b17b 100644 --- a/src/restore.c +++ b/src/restore.c @@ -288,8 +288,6 @@ void cycle_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx) struct stat st; - memset (&st, 0, sizeof(st)); - if (stat (eff_restore_file, &st) == 0) { if (unlink (eff_restore_file)) @@ -304,6 +302,18 @@ void cycle_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx) } } +void unlink_restore (restore_ctx_t *restore_ctx, status_ctx_t *status_ctx) +{ + if ((status_ctx->devices_status == STATUS_EXHAUSTED) || (status_ctx->devices_status == STATUS_CRACKED)) + { + if (status_ctx->run_thread_level1 == true) // this is to check for [c]heckpoint + { + unlink (restore_ctx->eff_restore_file); + unlink (restore_ctx->new_restore_file); + } + } +} + void stop_at_checkpoint (restore_ctx_t *restore_ctx, status_ctx_t *status_ctx) { // this feature only makes sense if --restore-disable was not specified