mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-23 07:08:19 +00:00
data. no longer required in restore
This commit is contained in:
parent
59ebe10b07
commit
fd72834322
@ -23,6 +23,10 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
|
#define PW_MIN 0
|
||||||
|
#define PW_MAX 54
|
||||||
|
#define PW_MAX1 (PW_MAX + 1)
|
||||||
|
|
||||||
#define EXEC_CACHE 128
|
#define EXEC_CACHE 128
|
||||||
|
|
||||||
#define SPEED_CACHE 128
|
#define SPEED_CACHE 128
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#define PW_MIN 0
|
|
||||||
#define PW_MAX 54
|
|
||||||
#define PW_MAX1 (PW_MAX + 1)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* weak hashes shutcut
|
* weak hashes shutcut
|
||||||
*/
|
*/
|
||||||
|
@ -23,16 +23,20 @@
|
|||||||
#define RESTORE_VERSION_MIN 320
|
#define RESTORE_VERSION_MIN 320
|
||||||
#define RESTORE_VERSION_CUR 320
|
#define RESTORE_VERSION_CUR 320
|
||||||
|
|
||||||
u64 get_lowest_words_done (opencl_ctx_t *opencl_ctx);
|
u64 get_lowest_words_done (const restore_ctx_t *restore_ctx, const opencl_ctx_t *opencl_ctx);
|
||||||
|
|
||||||
restore_data_t *init_restore (int argc, char **argv, const user_options_t *user_options);
|
void init_restore (restore_ctx_t *restore_ctx);
|
||||||
|
|
||||||
void read_restore (const char *eff_restore_file, restore_data_t *rd);
|
void read_restore (restore_ctx_t *restore_ctx);
|
||||||
|
|
||||||
void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, restore_data_t *rd);
|
void write_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx);
|
||||||
|
|
||||||
void cycle_restore (opencl_ctx_t *opencl_ctx);
|
void cycle_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx);
|
||||||
|
|
||||||
void stop_at_checkpoint (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
|
void stop_at_checkpoint (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_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);
|
||||||
|
|
||||||
|
void restore_ctx_destroy (restore_ctx_t *restore_ctx);
|
||||||
|
|
||||||
#endif // _RESTORE_H
|
#endif // _RESTORE_H
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
|
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
|
||||||
|
|
||||||
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
|
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
|
||||||
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
|
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
|
||||||
void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig);
|
void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig);
|
||||||
void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const user_options_t *user_options);
|
void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const user_options_t *user_options);
|
||||||
|
|
||||||
|
@ -875,6 +875,20 @@ typedef struct
|
|||||||
|
|
||||||
} restore_data_t;
|
} restore_data_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
|
||||||
|
char *eff_restore_file;
|
||||||
|
char *new_restore_file;
|
||||||
|
|
||||||
|
restore_data_t *rd;
|
||||||
|
|
||||||
|
} restore_ctx_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u32 len;
|
u32 len;
|
||||||
@ -1175,8 +1189,6 @@ typedef struct
|
|||||||
char *mask;
|
char *mask;
|
||||||
u32 maskcnt;
|
u32 maskcnt;
|
||||||
u32 maskpos;
|
u32 maskpos;
|
||||||
char *eff_restore_file;
|
|
||||||
char *new_restore_file;
|
|
||||||
u32 pw_min;
|
u32 pw_min;
|
||||||
u32 pw_max;
|
u32 pw_max;
|
||||||
|
|
||||||
@ -1195,12 +1207,7 @@ typedef struct
|
|||||||
outcheck_ctx_t *outcheck_ctx;
|
outcheck_ctx_t *outcheck_ctx;
|
||||||
logfile_ctx_t *logfile_ctx;
|
logfile_ctx_t *logfile_ctx;
|
||||||
rules_ctx_t *rules_ctx;
|
rules_ctx_t *rules_ctx;
|
||||||
|
restore_ctx_t *restore_ctx;
|
||||||
/**
|
|
||||||
* used for restore
|
|
||||||
*/
|
|
||||||
|
|
||||||
restore_data_t *rd;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* status, timer
|
* status, timer
|
||||||
|
@ -243,15 +243,15 @@ static const struct option long_options[] =
|
|||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
void user_options_init (user_options_t *user_options, int myargc, char **myargv);
|
void user_options_init (user_options_t *user_options);
|
||||||
|
|
||||||
void user_options_destroy (user_options_t *user_options);
|
void user_options_destroy (user_options_t *user_options);
|
||||||
|
|
||||||
int user_options_parse (user_options_t *user_options, int myargc, char **myargv);
|
int user_options_parse (user_options_t *user_options, int argc, char **argv);
|
||||||
|
|
||||||
int user_options_sanity (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra);
|
int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra);
|
||||||
|
|
||||||
int user_options_extra_init (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra);
|
int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra);
|
||||||
|
|
||||||
void user_options_extra_destroy (user_options_extra_t *user_options_extra);
|
void user_options_extra_destroy (user_options_extra_t *user_options_extra);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "opencl.h"
|
#include "opencl.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
|
#include "terminal.h"
|
||||||
#include "autotune.h"
|
#include "autotune.h"
|
||||||
|
|
||||||
extern hc_global_data_t data;
|
extern hc_global_data_t data;
|
||||||
|
145
src/hashcat.c
145
src/hashcat.c
@ -224,7 +224,7 @@ static void goodbye_screen (const user_options_t *user_options, const time_t *pr
|
|||||||
log_info_nn ("Stopped: %s", ctime (proc_stop));
|
log_info_nn ("Stopped: %s", ctime (proc_stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int outer_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, int myargc, char **myargv, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, outfile_ctx_t *outfile_ctx, potfile_ctx_t *potfile_ctx, rules_ctx_t *rules_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx)
|
static int outer_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, outfile_ctx_t *outfile_ctx, potfile_ctx_t *potfile_ctx, rules_ctx_t *rules_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
opencl_ctx->devices_status = STATUS_INIT;
|
opencl_ctx->devices_status = STATUS_INIT;
|
||||||
|
|
||||||
@ -252,6 +252,9 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int myargc = restore_ctx->argc;
|
||||||
|
char **myargv = restore_ctx->argv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup prepare timer
|
* setup prepare timer
|
||||||
*/
|
*/
|
||||||
@ -1854,11 +1857,12 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
hcstat_table_t *root_table_buf = NULL;
|
hcstat_table_t *root_table_buf = NULL;
|
||||||
hcstat_table_t *markov_table_buf = NULL;
|
hcstat_table_t *markov_table_buf = NULL;
|
||||||
|
|
||||||
uint initial_restore_done = 0;
|
// still needed?
|
||||||
|
// bool initial_restore_done = false;
|
||||||
|
|
||||||
data.maskcnt = maskcnt;
|
data.maskcnt = maskcnt;
|
||||||
|
|
||||||
restore_data_t *rd = data.rd;
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
|
for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
|
||||||
{
|
{
|
||||||
@ -2179,9 +2183,18 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
|
|
||||||
data.cpt_total = 0;
|
data.cpt_total = 0;
|
||||||
|
|
||||||
if (user_options->restore == false)
|
data.words_cur = 0;
|
||||||
|
|
||||||
|
if (rd->words_cur)
|
||||||
{
|
{
|
||||||
rd->words_cur = user_options->skip;
|
data.words_cur = rd->words_cur;
|
||||||
|
|
||||||
|
user_options->skip = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_options->skip)
|
||||||
|
{
|
||||||
|
data.words_cur = user_options->skip;
|
||||||
|
|
||||||
user_options->skip = 0;
|
user_options->skip = 0;
|
||||||
}
|
}
|
||||||
@ -2190,8 +2203,6 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
|
|
||||||
data.kernel_power_final = 0;
|
data.kernel_power_final = 0;
|
||||||
|
|
||||||
data.words_cur = rd->words_cur;
|
|
||||||
|
|
||||||
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||||
{
|
{
|
||||||
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
||||||
@ -2772,14 +2783,16 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
* create cracker threads
|
* create cracker threads
|
||||||
*/
|
*/
|
||||||
|
|
||||||
opencl_ctx->devices_status = STATUS_RUNNING;
|
/* still needed ?
|
||||||
|
if (initial_restore_done == false)
|
||||||
if (initial_restore_done == 0)
|
|
||||||
{
|
{
|
||||||
if (user_options->restore_disable == false) cycle_restore (opencl_ctx);
|
if (user_options->restore_disable == false) cycle_restore (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
initial_restore_done = 1;
|
initial_restore_done = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
opencl_ctx->devices_status = STATUS_RUNNING;
|
||||||
|
|
||||||
hc_timer_set (&data.timer_running);
|
hc_timer_set (&data.timer_running);
|
||||||
|
|
||||||
@ -2830,9 +2843,12 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
opencl_ctx->devices_status = STATUS_EXHAUSTED;
|
opencl_ctx->devices_status = STATUS_EXHAUSTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
logfile_sub_var_uint ("status-after-work", opencl_ctx->devices_status);
|
if (opencl_ctx->devices_status == STATUS_EXHAUSTED)
|
||||||
|
{
|
||||||
|
rd->words_cur = 0;
|
||||||
|
}
|
||||||
|
|
||||||
user_options->restore = false;
|
logfile_sub_var_uint ("status-after-work", opencl_ctx->devices_status);
|
||||||
|
|
||||||
if (induct_ctx->induction_dictionaries_cnt)
|
if (induct_ctx->induction_dictionaries_cnt)
|
||||||
{
|
{
|
||||||
@ -2855,7 +2871,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
{
|
{
|
||||||
clear_prompt ();
|
clear_prompt ();
|
||||||
|
|
||||||
status_display (opencl_ctx, hashconfig, hashes, user_options, user_options_extra, rules_ctx);
|
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
|
||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
}
|
}
|
||||||
@ -2863,7 +2879,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
{
|
{
|
||||||
if (user_options->status == true)
|
if (user_options->status == true)
|
||||||
{
|
{
|
||||||
status_display (opencl_ctx, hashconfig, hashes, user_options, user_options_extra, rules_ctx);
|
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
|
||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
}
|
}
|
||||||
@ -2962,16 +2978,23 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
|
|||||||
myfree (inner_threads);
|
myfree (inner_threads);
|
||||||
|
|
||||||
// we dont need restore file anymore
|
// we dont need restore file anymore
|
||||||
if (user_options->restore_disable == false)
|
if (restore_ctx->enabled == true)
|
||||||
{
|
{
|
||||||
if ((opencl_ctx->devices_status == STATUS_EXHAUSTED) || (opencl_ctx->devices_status == STATUS_CRACKED))
|
if ((opencl_ctx->devices_status == STATUS_EXHAUSTED) || (opencl_ctx->devices_status == STATUS_CRACKED))
|
||||||
{
|
{
|
||||||
unlink (data.eff_restore_file);
|
if (opencl_ctx->run_thread_level1 == true) // this is to check for [c]heckpoint
|
||||||
unlink (data.new_restore_file);
|
{
|
||||||
|
unlink (restore_ctx->eff_restore_file);
|
||||||
|
unlink (restore_ctx->new_restore_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cycle_restore (opencl_ctx);
|
cycle_restore (restore_ctx, opencl_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cycle_restore (restore_ctx, opencl_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3227,63 +3250,16 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.user_options = user_options;
|
data.user_options = user_options;
|
||||||
|
|
||||||
user_options_init (user_options, argc, argv);
|
user_options_init (user_options);
|
||||||
|
|
||||||
const int rc_user_options_parse = user_options_parse (user_options, argc, argv);
|
const int rc_user_options_parse = user_options_parse (user_options, argc, argv);
|
||||||
|
|
||||||
if (rc_user_options_parse == -1) return -1;
|
if (rc_user_options_parse == -1) return -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* session
|
* some early exits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
|
||||||
char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
|
||||||
|
|
||||||
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
|
|
||||||
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
|
|
||||||
|
|
||||||
data.eff_restore_file = eff_restore_file;
|
|
||||||
data.new_restore_file = new_restore_file;
|
|
||||||
|
|
||||||
restore_data_t *rd = init_restore (argc, argv, user_options);
|
|
||||||
|
|
||||||
data.rd = rd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* restore file
|
|
||||||
*/
|
|
||||||
|
|
||||||
int myargc = argc;
|
|
||||||
char **myargv = argv;
|
|
||||||
|
|
||||||
if (user_options->restore == true)
|
|
||||||
{
|
|
||||||
read_restore (eff_restore_file, rd);
|
|
||||||
|
|
||||||
if (rd->version < RESTORE_VERSION_MIN)
|
|
||||||
{
|
|
||||||
log_error ("ERROR: Incompatible restore-file version");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
myargc = rd->argc;
|
|
||||||
myargv = rd->argv;
|
|
||||||
|
|
||||||
#if defined (_POSIX)
|
|
||||||
rd->pid = getpid ();
|
|
||||||
#elif defined (_WIN)
|
|
||||||
rd->pid = GetCurrentProcessId ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
user_options_init (user_options, myargc, myargv);
|
|
||||||
|
|
||||||
const int rc_user_options_parse = user_options_parse (user_options, myargc, myargv);
|
|
||||||
|
|
||||||
if (rc_user_options_parse == -1) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_options->version == true)
|
if (user_options->version == true)
|
||||||
{
|
{
|
||||||
log_info ("%s", VERSION_TAG);
|
log_info ("%s", VERSION_TAG);
|
||||||
@ -3298,6 +3274,18 @@ int main (int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* restore
|
||||||
|
*/
|
||||||
|
|
||||||
|
restore_ctx_t *restore_ctx = (restore_ctx_t *) mymalloc (sizeof (restore_ctx_t));
|
||||||
|
|
||||||
|
data.restore_ctx = restore_ctx;
|
||||||
|
|
||||||
|
const int rc_restore_init = restore_ctx_init (restore_ctx, user_options, folder_config, argc, argv);
|
||||||
|
|
||||||
|
if (rc_restore_init == -1) return -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process user input
|
* process user input
|
||||||
*/
|
*/
|
||||||
@ -3306,11 +3294,11 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.user_options_extra = user_options_extra;
|
data.user_options_extra = user_options_extra;
|
||||||
|
|
||||||
const int rc_user_options_extra_init = user_options_extra_init (user_options, myargc, myargv, user_options_extra);
|
const int rc_user_options_extra_init = user_options_extra_init (user_options, restore_ctx, user_options_extra);
|
||||||
|
|
||||||
if (rc_user_options_extra_init == -1) return -1;
|
if (rc_user_options_extra_init == -1) return -1;
|
||||||
|
|
||||||
const int rc_user_options_sanity = user_options_sanity (user_options, myargc, myargv, user_options_extra);
|
const int rc_user_options_sanity = user_options_sanity (user_options, restore_ctx, user_options_extra);
|
||||||
|
|
||||||
if (rc_user_options_sanity == -1) return -1;
|
if (rc_user_options_sanity == -1) return -1;
|
||||||
|
|
||||||
@ -3391,7 +3379,7 @@ int main (int argc, char **argv)
|
|||||||
* Sanity check for hashfile vs outfile (should not point to the same physical file)
|
* Sanity check for hashfile vs outfile (should not point to the same physical file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const int rc_outfile_and_hashfile = outfile_and_hashfile (outfile_ctx, myargv[user_options_extra->optind]);
|
const int rc_outfile_and_hashfile = outfile_and_hashfile (outfile_ctx, restore_ctx->argv[user_options_extra->optind]);
|
||||||
|
|
||||||
if (rc_outfile_and_hashfile == -1) return -1;
|
if (rc_outfile_and_hashfile == -1) return -1;
|
||||||
|
|
||||||
@ -3516,7 +3504,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (user_options->hash_mode_chgd == true)
|
if (user_options->hash_mode_chgd == true)
|
||||||
{
|
{
|
||||||
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
||||||
|
|
||||||
if (rc == -1) return -1;
|
if (rc == -1) return -1;
|
||||||
}
|
}
|
||||||
@ -3526,7 +3514,7 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
|
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
|
||||||
|
|
||||||
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
||||||
|
|
||||||
if (rc == -1) return -1;
|
if (rc == -1) return -1;
|
||||||
|
|
||||||
@ -3536,7 +3524,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
|
||||||
|
|
||||||
if (rc == -1) return -1;
|
if (rc == -1) return -1;
|
||||||
}
|
}
|
||||||
@ -3564,11 +3552,6 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
// free memory
|
// free memory
|
||||||
|
|
||||||
local_free (eff_restore_file);
|
|
||||||
local_free (new_restore_file);
|
|
||||||
|
|
||||||
local_free (rd);
|
|
||||||
|
|
||||||
debugfile_destroy (debugfile_ctx);
|
debugfile_destroy (debugfile_ctx);
|
||||||
|
|
||||||
rules_ctx_destroy (rules_ctx);
|
rules_ctx_destroy (rules_ctx);
|
||||||
@ -3593,6 +3576,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
opencl_ctx_devices_destroy (opencl_ctx);
|
opencl_ctx_devices_destroy (opencl_ctx);
|
||||||
|
|
||||||
|
restore_ctx_destroy (restore_ctx);
|
||||||
|
|
||||||
time_t proc_stop;
|
time_t proc_stop;
|
||||||
|
|
||||||
time (&proc_stop);
|
time (&proc_stop);
|
||||||
|
@ -39,6 +39,7 @@ extern hc_thread_mutex_t mux_hwmon;
|
|||||||
|
|
||||||
void *thread_monitor (void *p)
|
void *thread_monitor (void *p)
|
||||||
{
|
{
|
||||||
|
restore_ctx_t *restore_ctx = data.restore_ctx;
|
||||||
user_options_t *user_options = data.user_options;
|
user_options_t *user_options = data.user_options;
|
||||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||||
hashconfig_t *hashconfig = data.hashconfig;
|
hashconfig_t *hashconfig = data.hashconfig;
|
||||||
@ -279,7 +280,7 @@ void *thread_monitor (void *p)
|
|||||||
|
|
||||||
if (restore_left == 0)
|
if (restore_left == 0)
|
||||||
{
|
{
|
||||||
if (user_options->restore_disable == 0) cycle_restore (opencl_ctx);
|
if (user_options->restore_disable == 0) cycle_restore (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
restore_left = user_options->restore_timer;
|
restore_left = user_options->restore_timer;
|
||||||
}
|
}
|
||||||
@ -344,7 +345,7 @@ void *thread_monitor (void *p)
|
|||||||
|
|
||||||
if (user_options->quiet == false) log_info ("");
|
if (user_options->quiet == false) log_info ("");
|
||||||
|
|
||||||
status_display (opencl_ctx, hashconfig, hashes, user_options, user_options_extra, rules_ctx);
|
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
|
||||||
|
|
||||||
if (user_options->quiet == false) log_info ("");
|
if (user_options->quiet == false) log_info ("");
|
||||||
|
|
||||||
|
184
src/restore.c
184
src/restore.c
@ -5,31 +5,10 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "interface.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "ext_OpenCL.h"
|
#include "user_options.h"
|
||||||
#include "ext_ADL.h"
|
|
||||||
#include "ext_nvapi.h"
|
|
||||||
#include "ext_nvml.h"
|
|
||||||
#include "ext_xnvctrl.h"
|
|
||||||
#include "tuningdb.h"
|
|
||||||
#include "thread.h"
|
|
||||||
#include "opencl.h"
|
|
||||||
#include "hwmon.h"
|
|
||||||
#include "restore.h"
|
#include "restore.h"
|
||||||
#include "hash_management.h"
|
|
||||||
#include "rp_cpu.h"
|
|
||||||
#include "mpsp.h"
|
|
||||||
#include "outfile.h"
|
|
||||||
#include "potfile.h"
|
|
||||||
#include "debugfile.h"
|
|
||||||
#include "loopback.h"
|
|
||||||
#include "status.h"
|
|
||||||
#include "data.h"
|
|
||||||
|
|
||||||
extern hc_global_data_t data;
|
|
||||||
|
|
||||||
#if defined (_WIN)
|
#if defined (_WIN)
|
||||||
static void fsync (int fd)
|
static void fsync (int fd)
|
||||||
@ -40,8 +19,12 @@ static void fsync (int fd)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u64 get_lowest_words_done (opencl_ctx_t *opencl_ctx)
|
u64 get_lowest_words_done (const restore_ctx_t *restore_ctx, const opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
|
if (restore_ctx->enabled == false) return 0;
|
||||||
|
|
||||||
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
u64 words_cur = -1llu;
|
u64 words_cur = -1llu;
|
||||||
|
|
||||||
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||||
@ -61,26 +44,26 @@ u64 get_lowest_words_done (opencl_ctx_t *opencl_ctx)
|
|||||||
// the attack is running therefore we should stick to rd->words_cur.
|
// the attack is running therefore we should stick to rd->words_cur.
|
||||||
// Note that -s influences rd->words_cur we should keep a close look on that.
|
// Note that -s influences rd->words_cur we should keep a close look on that.
|
||||||
|
|
||||||
if (words_cur < data.rd->words_cur) words_cur = data.rd->words_cur;
|
if (words_cur < rd->words_cur) words_cur = rd->words_cur;
|
||||||
|
|
||||||
return words_cur;
|
return words_cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_data_t *init_restore (int argc, char **argv, const user_options_t *user_options)
|
static void check_running_process (restore_ctx_t *restore_ctx)
|
||||||
{
|
{
|
||||||
|
char *eff_restore_file = restore_ctx->eff_restore_file;
|
||||||
|
|
||||||
|
FILE *fp = fopen (eff_restore_file, "rb");
|
||||||
|
|
||||||
|
if (fp == NULL) return;
|
||||||
|
|
||||||
restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t));
|
restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t));
|
||||||
|
|
||||||
if (user_options->restore_disable == false)
|
const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);
|
||||||
{
|
|
||||||
FILE *fp = fopen (data.eff_restore_file, "rb");
|
|
||||||
|
|
||||||
if (fp)
|
|
||||||
{
|
|
||||||
size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);
|
|
||||||
|
|
||||||
if (nread != 1)
|
if (nread != 1)
|
||||||
{
|
{
|
||||||
log_error ("ERROR: Cannot read %s", data.eff_restore_file);
|
log_error ("ERROR: Cannot read %s", eff_restore_file);
|
||||||
|
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
@ -106,11 +89,11 @@ restore_data_t *init_restore (int argc, char **argv, const user_options_t *user_
|
|||||||
|
|
||||||
fclose (fd);
|
fclose (fd);
|
||||||
|
|
||||||
char *argv0_r = strrchr (argv[0], '/');
|
char *argv0_r = strrchr (restore_ctx->argv[0], '/');
|
||||||
|
|
||||||
char *pidbin_r = strrchr (pidbin, '/');
|
char *pidbin_r = strrchr (pidbin, '/');
|
||||||
|
|
||||||
if (argv0_r == NULL) argv0_r = argv[0];
|
if (argv0_r == NULL) argv0_r = restore_ctx->argv[0];
|
||||||
|
|
||||||
if (pidbin_r == NULL) pidbin_r = pidbin;
|
if (pidbin_r == NULL) pidbin_r = pidbin;
|
||||||
|
|
||||||
@ -154,17 +137,29 @@ restore_data_t *init_restore (int argc, char **argv, const user_options_t *user_
|
|||||||
|
|
||||||
if (rd->version < RESTORE_VERSION_MIN)
|
if (rd->version < RESTORE_VERSION_MIN)
|
||||||
{
|
{
|
||||||
log_error ("ERROR: Cannot use outdated %s. Please remove it.", data.eff_restore_file);
|
log_error ("ERROR: Cannot use outdated %s. Please remove it.", eff_restore_file);
|
||||||
|
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (rd, 0, sizeof (restore_data_t));
|
myfree (rd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_restore (restore_ctx_t *restore_ctx)
|
||||||
|
{
|
||||||
|
if (restore_ctx->enabled == false) return;
|
||||||
|
|
||||||
|
restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t));
|
||||||
|
|
||||||
|
restore_ctx->rd = rd;
|
||||||
|
|
||||||
|
check_running_process (restore_ctx);
|
||||||
|
|
||||||
rd->version = RESTORE_VERSION_CUR;
|
rd->version = RESTORE_VERSION_CUR;
|
||||||
|
|
||||||
|
rd->argc = restore_ctx->argc;
|
||||||
|
rd->argv = restore_ctx->argv;
|
||||||
|
|
||||||
#if defined (_POSIX)
|
#if defined (_POSIX)
|
||||||
rd->pid = getpid ();
|
rd->pid = getpid ();
|
||||||
#elif defined (_WIN)
|
#elif defined (_WIN)
|
||||||
@ -173,19 +168,18 @@ restore_data_t *init_restore (int argc, char **argv, const user_options_t *user_
|
|||||||
|
|
||||||
if (getcwd (rd->cwd, 255) == NULL)
|
if (getcwd (rd->cwd, 255) == NULL)
|
||||||
{
|
{
|
||||||
myfree (rd);
|
log_error ("ERROR: getcwd(): %s", strerror (errno));
|
||||||
|
|
||||||
return (NULL);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rd->argc = argc;
|
|
||||||
rd->argv = argv;
|
|
||||||
|
|
||||||
return (rd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_restore (const char *eff_restore_file, restore_data_t *rd)
|
void read_restore (restore_ctx_t *restore_ctx)
|
||||||
{
|
{
|
||||||
|
if (restore_ctx->enabled == false) return;
|
||||||
|
|
||||||
|
char *eff_restore_file = restore_ctx->eff_restore_file;
|
||||||
|
|
||||||
FILE *fp = fopen (eff_restore_file, "rb");
|
FILE *fp = fopen (eff_restore_file, "rb");
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
@ -195,6 +189,8 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
|
|||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
|
if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
|
||||||
{
|
{
|
||||||
log_error ("ERROR: Can't read %s", eff_restore_file);
|
log_error ("ERROR: Can't read %s", eff_restore_file);
|
||||||
@ -239,12 +235,18 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, restore_data_t *rd)
|
void write_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
u64 words_cur = get_lowest_words_done (opencl_ctx);
|
if (restore_ctx->enabled == false) return;
|
||||||
|
|
||||||
|
const u64 words_cur = get_lowest_words_done (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
rd->words_cur = words_cur;
|
rd->words_cur = words_cur;
|
||||||
|
|
||||||
|
char *new_restore_file = restore_ctx->new_restore_file;
|
||||||
|
|
||||||
FILE *fp = fopen (new_restore_file, "wb");
|
FILE *fp = fopen (new_restore_file, "wb");
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
@ -266,6 +268,7 @@ void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, rest
|
|||||||
for (uint i = 0; i < rd->argc; i++)
|
for (uint i = 0; i < rd->argc; i++)
|
||||||
{
|
{
|
||||||
fprintf (fp, "%s", rd->argv[i]);
|
fprintf (fp, "%s", rd->argv[i]);
|
||||||
|
|
||||||
fputc ('\n', fp);
|
fputc ('\n', fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,14 +279,14 @@ void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, rest
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cycle_restore (opencl_ctx_t *opencl_ctx)
|
void cycle_restore (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
const char *eff_restore_file = data.eff_restore_file;
|
if (restore_ctx->enabled == false) return;
|
||||||
const char *new_restore_file = data.new_restore_file;
|
|
||||||
|
|
||||||
restore_data_t *rd = data.rd;
|
const char *eff_restore_file = restore_ctx->eff_restore_file;
|
||||||
|
const char *new_restore_file = restore_ctx->new_restore_file;
|
||||||
|
|
||||||
write_restore (opencl_ctx, new_restore_file, rd);
|
write_restore (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -303,11 +306,11 @@ void cycle_restore (opencl_ctx_t *opencl_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_at_checkpoint (opencl_ctx_t *opencl_ctx, const user_options_t *user_options)
|
void stop_at_checkpoint (restore_ctx_t *restore_ctx, opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
// this feature only makes sense if --restore-disable was not specified
|
// this feature only makes sense if --restore-disable was not specified
|
||||||
|
|
||||||
if (user_options->restore_disable == true)
|
if (restore_ctx->enabled == false)
|
||||||
{
|
{
|
||||||
log_info ("WARNING: This feature is disabled when --restore-disable is specified");
|
log_info ("WARNING: This feature is disabled when --restore-disable is specified");
|
||||||
|
|
||||||
@ -337,3 +340,72 @@ void stop_at_checkpoint (opencl_ctx_t *opencl_ctx, const user_options_t *user_op
|
|||||||
log_info ("Checkpoint disabled: Restore Point updates will no longer be monitored");
|
log_info ("Checkpoint disabled: Restore Point updates will no longer be monitored");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int restore_ctx_init (restore_ctx_t *restore_ctx, user_options_t *user_options, const folder_config_t *folder_config, int argc, char **argv)
|
||||||
|
{
|
||||||
|
restore_ctx->enabled = false;
|
||||||
|
|
||||||
|
if (user_options->restore_disable == true) return 0;
|
||||||
|
|
||||||
|
char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||||
|
char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||||
|
|
||||||
|
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
|
||||||
|
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
|
||||||
|
|
||||||
|
restore_ctx->argc = argc;
|
||||||
|
restore_ctx->argv = argv;
|
||||||
|
|
||||||
|
restore_ctx->eff_restore_file = eff_restore_file;
|
||||||
|
restore_ctx->new_restore_file = new_restore_file;
|
||||||
|
|
||||||
|
restore_ctx->enabled = true;
|
||||||
|
|
||||||
|
init_restore (restore_ctx);
|
||||||
|
|
||||||
|
if (user_options->restore == true)
|
||||||
|
{
|
||||||
|
read_restore (restore_ctx);
|
||||||
|
|
||||||
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
|
if (rd->version < RESTORE_VERSION_MIN)
|
||||||
|
{
|
||||||
|
log_error ("ERROR: Incompatible restore-file version");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined (_POSIX)
|
||||||
|
rd->pid = getpid ();
|
||||||
|
#elif defined (_WIN)
|
||||||
|
rd->pid = GetCurrentProcessId ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
restore_ctx->argc = rd->argc;
|
||||||
|
restore_ctx->argv = rd->argv;
|
||||||
|
|
||||||
|
user_options_init (user_options);
|
||||||
|
|
||||||
|
const int rc_user_options_parse = user_options_parse (user_options, rd->argc, rd->argv);
|
||||||
|
|
||||||
|
if (rc_user_options_parse == -1) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_ctx_destroy (restore_ctx_t *restore_ctx)
|
||||||
|
{
|
||||||
|
if (restore_ctx->enabled == false) return;
|
||||||
|
|
||||||
|
restore_ctx->argc = 0;
|
||||||
|
restore_ctx->argv = NULL;
|
||||||
|
|
||||||
|
myfree (restore_ctx->rd);
|
||||||
|
|
||||||
|
myfree (restore_ctx->eff_restore_file);
|
||||||
|
myfree (restore_ctx->new_restore_file);
|
||||||
|
|
||||||
|
myfree (restore_ctx);
|
||||||
|
}
|
||||||
|
10
src/status.c
10
src/status.c
@ -164,7 +164,7 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en
|
|||||||
return exec_ms_sum / exec_ms_cnt;
|
return exec_ms_sum / exec_ms_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
|
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
|
||||||
{
|
{
|
||||||
if (opencl_ctx->devices_status == STATUS_INIT)
|
if (opencl_ctx->devices_status == STATUS_INIT)
|
||||||
{
|
{
|
||||||
@ -225,7 +225,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
|
|||||||
* words_cur
|
* words_cur
|
||||||
*/
|
*/
|
||||||
|
|
||||||
u64 words_cur = get_lowest_words_done (opencl_ctx);
|
u64 words_cur = get_lowest_words_done (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur);
|
fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur);
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
|
|||||||
fflush (out);
|
fflush (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
|
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
|
||||||
{
|
{
|
||||||
if (opencl_ctx->devices_status == STATUS_INIT)
|
if (opencl_ctx->devices_status == STATUS_INIT)
|
||||||
{
|
{
|
||||||
@ -327,7 +327,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
|
|||||||
|
|
||||||
if (user_options->machine_readable == true)
|
if (user_options->machine_readable == true)
|
||||||
{
|
{
|
||||||
status_display_machine_readable (opencl_ctx, hashes, user_options, user_options_extra, rules_ctx);
|
status_display_machine_readable (opencl_ctx, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -954,7 +954,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
|
|||||||
|
|
||||||
// Restore point
|
// Restore point
|
||||||
|
|
||||||
u64 restore_point = get_lowest_words_done (opencl_ctx);
|
u64 restore_point = get_lowest_words_done (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
u64 restore_total = data.words_base;
|
u64 restore_total = data.words_base;
|
||||||
|
|
||||||
|
@ -63,13 +63,14 @@ void *thread_keypress (void *p)
|
|||||||
|
|
||||||
while (opencl_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100);
|
while (opencl_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100);
|
||||||
|
|
||||||
|
restore_ctx_t *restore_ctx = data.restore_ctx;
|
||||||
user_options_t *user_options = data.user_options;
|
user_options_t *user_options = data.user_options;
|
||||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||||
hashconfig_t *hashconfig = data.hashconfig;
|
hashconfig_t *hashconfig = data.hashconfig;
|
||||||
hashes_t *hashes = data.hashes;
|
hashes_t *hashes = data.hashes;
|
||||||
rules_ctx_t *rules_ctx = data.rules_ctx;
|
rules_ctx_t *rules_ctx = data.rules_ctx;
|
||||||
|
|
||||||
uint quiet = user_options->quiet;
|
const bool quiet = user_options->quiet;
|
||||||
|
|
||||||
tty_break ();
|
tty_break ();
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ void *thread_keypress (void *p)
|
|||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
|
|
||||||
status_display (opencl_ctx, hashconfig, hashes, user_options, user_options_extra, rules_ctx);
|
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
|
||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
|
|
||||||
@ -146,7 +147,7 @@ void *thread_keypress (void *p)
|
|||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
|
|
||||||
stop_at_checkpoint (opencl_ctx, user_options);
|
stop_at_checkpoint (restore_ctx, opencl_ctx);
|
||||||
|
|
||||||
log_info ("");
|
log_info ("");
|
||||||
|
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
static char RULE_BUF_R[] = ":";
|
static char RULE_BUF_R[] = ":";
|
||||||
static char RULE_BUF_L[] = ":";
|
static char RULE_BUF_L[] = ":";
|
||||||
|
|
||||||
void user_options_init (user_options_t *user_options, int myargc, char **myargv)
|
void user_options_init (user_options_t *user_options)
|
||||||
{
|
{
|
||||||
if (myargv == NULL) myargv = NULL; // because compiler warning
|
|
||||||
|
|
||||||
user_options->attack_mode = ATTACK_MODE;
|
user_options->attack_mode = ATTACK_MODE;
|
||||||
user_options->benchmark = BENCHMARK;
|
user_options->benchmark = BENCHMARK;
|
||||||
user_options->bitmap_max = BITMAP_MAX;
|
user_options->bitmap_max = BITMAP_MAX;
|
||||||
@ -101,7 +99,7 @@ void user_options_init (user_options_t *user_options, int myargc, char **myargv)
|
|||||||
user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD;
|
user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD;
|
||||||
user_options->workload_profile = WORKLOAD_PROFILE;
|
user_options->workload_profile = WORKLOAD_PROFILE;
|
||||||
user_options->rp_files_cnt = 0;
|
user_options->rp_files_cnt = 0;
|
||||||
user_options->rp_files = (char **) mycalloc (myargc, sizeof (char *));
|
user_options->rp_files = (char **) mycalloc (256, sizeof (char *));
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_options_destroy (user_options_t *user_options)
|
void user_options_destroy (user_options_t *user_options)
|
||||||
@ -111,7 +109,7 @@ void user_options_destroy (user_options_t *user_options)
|
|||||||
myfree (user_options);
|
myfree (user_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
|
int user_options_parse (user_options_t *user_options, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
|
||||||
@ -120,7 +118,7 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
|
|||||||
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
|
|
||||||
while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
|
while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -369,7 +367,7 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int user_options_sanity (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra)
|
int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra)
|
||||||
{
|
{
|
||||||
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
|
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
|
||||||
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
|
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
|
||||||
@ -734,7 +732,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
|
|||||||
|
|
||||||
if (user_options->benchmark == true)
|
if (user_options->benchmark == true)
|
||||||
{
|
{
|
||||||
if (myargv[optind] != NULL)
|
if (restore_ctx->argv[optind] != NULL)
|
||||||
{
|
{
|
||||||
log_error ("ERROR: Invalid argument for benchmark mode specified");
|
log_error ("ERROR: Invalid argument for benchmark mode specified");
|
||||||
|
|
||||||
@ -753,9 +751,9 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
|
|||||||
}
|
}
|
||||||
else if (user_options->opencl_info == true)
|
else if (user_options->opencl_info == true)
|
||||||
{
|
{
|
||||||
if (user_options_extra->optind != myargc)
|
if (user_options_extra->optind != restore_ctx->argc)
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -764,43 +762,43 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
|
|||||||
{
|
{
|
||||||
if (user_options_extra->attack_kern == ATTACK_KERN_NONE)
|
if (user_options_extra->attack_kern == ATTACK_KERN_NONE)
|
||||||
{
|
{
|
||||||
if ((user_options_extra->optind + 1) != myargc)
|
if ((user_options_extra->optind + 1) != restore_ctx->argc)
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
|
else if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
|
||||||
{
|
{
|
||||||
if ((user_options_extra->optind + 1) > myargc)
|
if ((user_options_extra->optind + 1) > restore_ctx->argc)
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
||||||
{
|
{
|
||||||
if ((user_options_extra->optind + 3) != myargc)
|
if ((user_options_extra->optind + 3) != restore_ctx->argc)
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
||||||
{
|
{
|
||||||
if ((user_options_extra->optind + 1) > myargc)
|
if ((user_options_extra->optind + 1) > restore_ctx->argc)
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usage_mini_print (myargv[0]);
|
usage_mini_print (restore_ctx->argv[0]);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -809,10 +807,8 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int user_options_extra_init (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra)
|
int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra)
|
||||||
{
|
{
|
||||||
if (myargv == NULL) myargv = NULL; // because compiler warning
|
|
||||||
|
|
||||||
user_options_extra->attack_kern = ATTACK_KERN_NONE;
|
user_options_extra->attack_kern = ATTACK_KERN_NONE;
|
||||||
|
|
||||||
switch (user_options->attack_mode)
|
switch (user_options->attack_mode)
|
||||||
@ -846,7 +842,7 @@ int user_options_extra_init (user_options_t *user_options, int myargc, char **my
|
|||||||
num_additional_params = 2;
|
num_additional_params = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int keyspace_wordlist_specified = myargc - user_options_extra->optind - num_additional_params;
|
int keyspace_wordlist_specified = restore_ctx->argc - user_options_extra->optind - num_additional_params;
|
||||||
|
|
||||||
if (keyspace_wordlist_specified == 0) user_options_extra->optind--;
|
if (keyspace_wordlist_specified == 0) user_options_extra->optind--;
|
||||||
}
|
}
|
||||||
@ -855,7 +851,7 @@ int user_options_extra_init (user_options_t *user_options, int myargc, char **my
|
|||||||
user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
|
user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
|
||||||
user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
|
user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
|
||||||
|
|
||||||
user_options_extra->wordlist_mode = ((user_options_extra->optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
|
user_options_extra->wordlist_mode = ((user_options_extra->optind + 1) < restore_ctx->argc) ? WL_MODE_FILE : WL_MODE_STDIN;
|
||||||
|
|
||||||
if (user_options->attack_mode == ATTACK_MODE_BF)
|
if (user_options->attack_mode == ATTACK_MODE_BF)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user