2016-09-07 20:01:34 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-07 20:01:34 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "memory.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
2016-09-24 23:02:44 +00:00
|
|
|
#include "user_options.h"
|
2016-10-31 10:28:06 +00:00
|
|
|
#include "shared.h"
|
2017-08-03 12:02:09 +00:00
|
|
|
#include "pidfile.h"
|
|
|
|
#include "folder.h"
|
2016-09-15 14:02:52 +00:00
|
|
|
#include "restore.h"
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int init_restore (hashcat_ctx_t *hashcat_ctx)
|
2016-09-24 23:02:44 +00:00
|
|
|
{
|
2016-10-06 14:34:30 +00:00
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
restore_data_t *rd = (restore_data_t *) hcmalloc (sizeof (restore_data_t));
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
restore_ctx->rd = rd;
|
|
|
|
|
2016-09-07 20:01:34 +00:00
|
|
|
rd->version = RESTORE_VERSION_CUR;
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
rd->argc = restore_ctx->argc;
|
|
|
|
rd->argv = restore_ctx->argv;
|
|
|
|
|
2016-09-07 20:01:34 +00:00
|
|
|
if (getcwd (rd->cwd, 255) == NULL)
|
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "getcwd(): %s", strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-08-03 12:02:09 +00:00
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
2016-10-06 14:34:30 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
if (restore_ctx->enabled == false) return 0;
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
char *eff_restore_file = restore_ctx->eff_restore_file;
|
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
HCFILE fp;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-07-01 15:27:08 +00:00
|
|
|
if (hc_fopen (&fp, eff_restore_file, "rb") == false)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
restore_data_t *rd = restore_ctx->rd;
|
|
|
|
|
2019-06-27 18:18:47 +00:00
|
|
|
if (hc_fread (rd, sizeof (restore_data_t), 1, &fp) != 1)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2016-10-30 15:08:41 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2017-02-15 12:19:53 +00:00
|
|
|
// we only use these 2 checks to avoid "tainted string" warnings
|
|
|
|
|
|
|
|
if (rd->argc < 1)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Unusually low number of arguments (argc) within restore file %s", eff_restore_file);
|
2017-02-15 12:19:53 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2017-02-15 12:19:53 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rd->argc > 250) // some upper bound check is always good (with some dirs/dicts it could be a large string)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Unusually high number of arguments (argc) within restore file %s", eff_restore_file);
|
2017-02-15 12:19:53 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2017-02-15 12:19:53 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
rd->argv = (char **) hccalloc (rd->argc, sizeof (char *));
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
for (u32 i = 0; i < rd->argc; i++)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2019-06-26 17:06:46 +00:00
|
|
|
if (hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp) == NULL)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2016-10-30 15:08:41 +00:00
|
|
|
|
2019-07-10 15:27:45 +00:00
|
|
|
hcfree (buf);
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t len = strlen (buf);
|
|
|
|
|
|
|
|
if (len) buf[len - 1] = 0;
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
rd->argv[i] = hcstrdup (buf);
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (buf);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2017-02-14 19:05:44 +00:00
|
|
|
if (hc_path_exist (rd->cwd) == false)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "%s: %s", rd->cwd, strerror (errno));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hc_path_is_directory (rd->cwd) == false)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "%s: %s", rd->cwd, strerror (errno));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:02:09 +00:00
|
|
|
if (strncmp (rd->cwd, folder_config->cwd, sizeof (rd->cwd)) != 0) // check if we need to change the current working directory
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-08-03 12:02:09 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Changing current working directory to '%s'", rd->cwd);
|
2017-02-23 10:59:34 +00:00
|
|
|
event_log_warning (hashcat_ctx, NULL);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2017-08-03 12:02:09 +00:00
|
|
|
if (chdir (rd->cwd))
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Directory '%s' needed to restore the session was not found.", rd->cwd);
|
|
|
|
|
|
|
|
event_log_warning (hashcat_ctx, "Either create the directory, or update the directory within the .restore file.");
|
|
|
|
event_log_warning (hashcat_ctx, "Restore files can be analyzed and modified with analyze_hc_restore.pl:");
|
|
|
|
event_log_warning (hashcat_ctx, " https://github.com/philsmd/analyze_hc_restore");
|
|
|
|
event_log_warning (hashcat_ctx, "Directory must contain all files and folders from the original command line.");
|
|
|
|
event_log_warning (hashcat_ctx, NULL);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we are here, we also need to update the folder_config and .pid file:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* updated folders
|
|
|
|
*/
|
|
|
|
|
2017-08-10 12:39:54 +00:00
|
|
|
// copy the paths of INSTALL_FOLDER and SHARED_FOLDER from the folder config:
|
2017-08-03 12:02:09 +00:00
|
|
|
|
2017-08-10 12:39:54 +00:00
|
|
|
char *install_folder = hcstrdup (folder_config->install_dir);
|
|
|
|
char *shared_folder = hcstrdup (folder_config->shared_dir);
|
2017-08-03 12:02:09 +00:00
|
|
|
|
|
|
|
folder_config_destroy (hashcat_ctx);
|
|
|
|
|
|
|
|
const int rc_folder_config_init = folder_config_init (hashcat_ctx, install_folder, shared_folder);
|
|
|
|
|
2017-08-10 12:39:54 +00:00
|
|
|
hcfree (install_folder);
|
|
|
|
hcfree (shared_folder);
|
|
|
|
|
2017-08-03 12:02:09 +00:00
|
|
|
if (rc_folder_config_init == -1) return -1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* updated pidfile
|
|
|
|
*/
|
|
|
|
|
|
|
|
pidfile_ctx_destroy (hashcat_ctx);
|
|
|
|
|
2019-07-13 05:23:50 +00:00
|
|
|
if (pidfile_ctx_init (hashcat_ctx) == -1) return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2016-10-20 20:14:54 +00:00
|
|
|
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
const restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
|
|
|
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
2016-10-06 14:34:30 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
if (restore_ctx->enabled == false) return 0;
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
restore_data_t *rd = restore_ctx->rd;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-20 20:14:54 +00:00
|
|
|
rd->masks_pos = mask_ctx->masks_pos;
|
|
|
|
rd->dicts_pos = straight_ctx->dicts_pos;
|
2016-10-20 19:27:42 +00:00
|
|
|
rd->words_cur = status_ctx->words_cur;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
char *new_restore_file = restore_ctx->new_restore_file;
|
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
HCFILE fp;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-07-01 15:27:08 +00:00
|
|
|
if (hc_fopen (&fp, new_restore_file, "wb") == false)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 15:58:08 +00:00
|
|
|
if (setvbuf (fp.pfp, NULL, _IONBF, 0))
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2016-10-30 15:08:41 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-27 18:18:47 +00:00
|
|
|
hc_fwrite (rd, sizeof (restore_data_t), 1, &fp);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
for (u32 i = 0; i < rd->argc; i++)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fprintf (&fp, "%s", rd->argv[i]);
|
2016-09-24 23:02:44 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fputc ('\n', &fp);
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fflush (&fp);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2021-08-21 11:29:10 +00:00
|
|
|
hc_fsync (&fp);
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-06-26 17:06:46 +00:00
|
|
|
hc_fclose (&fp);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2016-10-31 22:19:44 +00:00
|
|
|
rd->masks_pos = 0;
|
|
|
|
rd->dicts_pos = 0;
|
|
|
|
rd->words_cur = 0;
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return 0;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
int cycle_restore (hashcat_ctx_t *hashcat_ctx)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2016-10-06 14:34:30 +00:00
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
if (restore_ctx->enabled == false) return 0;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2022-08-31 09:44:13 +00:00
|
|
|
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
|
|
|
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
|
|
|
|
|
|
|
// no updates, no need to write
|
|
|
|
if ((restore_ctx->masks_pos_prev == mask_ctx->masks_pos)
|
|
|
|
&& (restore_ctx->dicts_pos_prev == straight_ctx->dicts_pos)
|
|
|
|
&& (restore_ctx->words_cur_prev == status_ctx->words_cur)) return 0;
|
|
|
|
|
|
|
|
restore_ctx->masks_pos_prev = mask_ctx->masks_pos;
|
|
|
|
restore_ctx->dicts_pos_prev = straight_ctx->dicts_pos;
|
|
|
|
restore_ctx->words_cur_prev = status_ctx->words_cur;
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
const char *eff_restore_file = restore_ctx->eff_restore_file;
|
|
|
|
const char *new_restore_file = restore_ctx->new_restore_file;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2019-07-13 05:23:50 +00:00
|
|
|
if (write_restore (hashcat_ctx) == -1) return -1;
|
2016-09-07 20:01:34 +00:00
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_exist (eff_restore_file) == true)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-01-27 10:46:45 +00:00
|
|
|
if (unlink (eff_restore_file) == -1)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Unlink file '%s': %s", eff_restore_file, strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (rename (new_restore_file, eff_restore_file) == -1)
|
2016-09-07 20:01:34 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-07 20:01:34 +00:00
|
|
|
}
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-10-06 14:34:30 +00:00
|
|
|
void unlink_restore (hashcat_ctx_t *hashcat_ctx)
|
2016-10-04 09:03:20 +00:00
|
|
|
{
|
2016-10-06 14:34:30 +00:00
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
|
|
|
|
2016-10-20 20:58:40 +00:00
|
|
|
if (restore_ctx->enabled == false) return;
|
|
|
|
|
2016-10-04 09:13:33 +00:00
|
|
|
if ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_thread_level1 == true)) // this is to check for [c]heckpoint
|
2016-10-04 09:03:20 +00:00
|
|
|
{
|
2016-10-04 09:13:33 +00:00
|
|
|
unlink (restore_ctx->eff_restore_file);
|
|
|
|
unlink (restore_ctx->new_restore_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status_ctx->devices_status == STATUS_CRACKED)
|
|
|
|
{
|
|
|
|
unlink (restore_ctx->eff_restore_file);
|
|
|
|
unlink (restore_ctx->new_restore_file);
|
2016-10-04 09:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-06 14:34:30 +00:00
|
|
|
int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
2016-09-24 23:02:44 +00:00
|
|
|
{
|
2016-10-06 14:34:30 +00:00
|
|
|
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
restore_ctx->enabled = false;
|
|
|
|
|
2016-10-20 19:27:42 +00:00
|
|
|
if (user_options->benchmark == true) return 0;
|
2020-12-29 03:58:58 +00:00
|
|
|
if (user_options->hash_info == true) return 0;
|
2016-10-20 19:27:42 +00:00
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
if (user_options->left == true) return 0;
|
|
|
|
if (user_options->show == true) return 0;
|
|
|
|
if (user_options->stdout_flag == true) return 0;
|
|
|
|
if (user_options->speed_only == true) return 0;
|
2016-12-09 22:44:43 +00:00
|
|
|
if (user_options->progress_only == true) return 0;
|
2016-10-20 19:27:42 +00:00
|
|
|
if (user_options->usage == true) return 0;
|
|
|
|
if (user_options->version == true) return 0;
|
2021-06-12 08:47:48 +00:00
|
|
|
if (user_options->identify == true) return 0;
|
2016-10-20 19:27:42 +00:00
|
|
|
if (user_options->restore_disable == true) return 0;
|
2022-02-13 11:33:11 +00:00
|
|
|
if (user_options->backend_info > 0) return 0;
|
2016-10-20 19:27:42 +00:00
|
|
|
|
|
|
|
if (argc == 0) return 0;
|
|
|
|
if (argv == NULL) return 0;
|
|
|
|
|
2016-10-27 21:09:50 +00:00
|
|
|
if (user_options->restore_file_path == NULL)
|
|
|
|
{
|
2016-12-23 23:40:40 +00:00
|
|
|
hc_asprintf (&restore_ctx->eff_restore_file, "%s/%s.restore", folder_config->session_dir, user_options->session);
|
|
|
|
hc_asprintf (&restore_ctx->new_restore_file, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
|
2016-10-27 21:09:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-20 21:54:52 +00:00
|
|
|
restore_ctx->eff_restore_file = hcstrdup (user_options->restore_file_path);
|
2016-12-23 23:40:40 +00:00
|
|
|
hc_asprintf (&restore_ctx->new_restore_file, "%s.new", user_options->restore_file_path);
|
2016-10-27 21:09:50 +00:00
|
|
|
}
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
restore_ctx->argc = argc;
|
|
|
|
restore_ctx->argv = argv;
|
|
|
|
|
2019-07-13 05:23:50 +00:00
|
|
|
if (init_restore (hashcat_ctx) == -1) return -1;
|
2016-09-24 23:02:44 +00:00
|
|
|
|
2016-09-24 23:18:08 +00:00
|
|
|
restore_ctx->enabled = true;
|
|
|
|
|
2019-08-06 12:07:43 +00:00
|
|
|
restore_ctx->restore_execute = false;
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
if (user_options->restore == true)
|
|
|
|
{
|
2019-07-13 05:23:50 +00:00
|
|
|
if (read_restore (hashcat_ctx) == -1) return -1;
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
restore_data_t *rd = restore_ctx->rd;
|
|
|
|
|
|
|
|
if (rd->version < RESTORE_VERSION_MIN)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Incompatible restore-file version.");
|
2016-09-24 23:02:44 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-10-06 14:40:29 +00:00
|
|
|
user_options_init (hashcat_ctx);
|
2016-09-24 23:02:44 +00:00
|
|
|
|
2019-07-13 05:23:50 +00:00
|
|
|
if (user_options_getopt (hashcat_ctx, rd->argc, rd->argv) == -1) return -1;
|
2019-08-06 12:07:43 +00:00
|
|
|
|
|
|
|
restore_ctx->restore_execute = true;
|
2016-09-24 23:02:44 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 09:44:13 +00:00
|
|
|
restore_ctx->masks_pos_prev = -1;
|
|
|
|
restore_ctx->dicts_pos_prev = -1;
|
|
|
|
restore_ctx->words_cur_prev = -1;
|
|
|
|
|
2016-09-24 23:02:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 14:34:30 +00:00
|
|
|
void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
2016-09-24 23:02:44 +00:00
|
|
|
{
|
2016-10-06 14:34:30 +00:00
|
|
|
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
|
|
|
|
2016-10-20 19:27:42 +00:00
|
|
|
if (restore_ctx->enabled == false) return;
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (restore_ctx->eff_restore_file);
|
|
|
|
hcfree (restore_ctx->new_restore_file);
|
|
|
|
hcfree (restore_ctx->rd);
|
2016-09-30 11:36:27 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
memset (restore_ctx, 0, sizeof (restore_ctx_t));
|
2016-09-24 23:02:44 +00:00
|
|
|
}
|