mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 09:58:16 +00:00
Prepare hashcat_get_status()
This commit is contained in:
parent
f8a6d156eb
commit
2545ec6bf9
@ -6,9 +6,17 @@
|
||||
#ifndef _HASHCAT_H
|
||||
#define _HASHCAT_H
|
||||
|
||||
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
|
||||
int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
|
||||
void hashcat_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
|
||||
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_session_run (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
|
||||
int hashcat_session_pause (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_session_resume (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_session_bypass (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_session_checkpoint (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_session_quit (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
char *hashcat_get_log (hashcat_ctx_t *hashcat_ctx);
|
||||
int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_status);
|
||||
|
||||
#endif // _HASHCAT_H
|
||||
|
@ -29,8 +29,6 @@ int cycle_restore (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
void unlink_restore (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv);
|
||||
|
||||
void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
@ -12,16 +12,23 @@
|
||||
|
||||
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
|
||||
|
||||
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_display (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_benchmark (hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_session (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int status_progress_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_progress_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_progress_reset (hashcat_ctx_t *hashcat_ctx);
|
||||
int status_get_input_mode (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_input_base (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_input_mod (const hashcat_ctx_t *hashcat_ctx);
|
||||
char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx);
|
||||
int status_get_input_masks_pos (const hashcat_ctx_t *hashcat_ctx);
|
||||
int status_get_input_masks_cnt (const hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int status_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
int status_progress_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_progress_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_progress_reset (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
int status_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
#endif // _STATUS_H
|
||||
|
@ -42,3 +42,8 @@ int tty_getchar();
|
||||
int tty_fix();
|
||||
|
||||
#endif // _TERMINAL_H
|
||||
|
||||
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_display (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx);
|
||||
void status_benchmark (hashcat_ctx_t *hashcat_ctx);
|
||||
|
@ -56,12 +56,12 @@ void hc_signal (void (callback) (int));
|
||||
#endif
|
||||
*/
|
||||
|
||||
void mycracked (hashcat_ctx_t *hashcat_ctx);
|
||||
void myabort (hashcat_ctx_t *hashcat_ctx);
|
||||
void myquit (hashcat_ctx_t *hashcat_ctx);
|
||||
void bypass (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
void SuspendThreads (hashcat_ctx_t *hashcat_ctx);
|
||||
void ResumeThreads (hashcat_ctx_t *hashcat_ctx);
|
||||
int mycracked (hashcat_ctx_t *hashcat_ctx);
|
||||
int myabort (hashcat_ctx_t *hashcat_ctx);
|
||||
int myquit (hashcat_ctx_t *hashcat_ctx);
|
||||
int bypass (hashcat_ctx_t *hashcat_ctx);
|
||||
int SuspendThreads (hashcat_ctx_t *hashcat_ctx);
|
||||
int ResumeThreads (hashcat_ctx_t *hashcat_ctx);
|
||||
int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
#endif // _THREAD_H
|
||||
|
@ -1452,6 +1452,49 @@ typedef struct hashcat_ctx
|
||||
|
||||
} hashcat_ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool skipped;
|
||||
|
||||
|
||||
} device_info_t;
|
||||
|
||||
typedef enum input_mode
|
||||
{
|
||||
INPUT_MODE_NONE = 0,
|
||||
INPUT_MODE_STRAIGHT_FILE = 1,
|
||||
INPUT_MODE_STRAIGHT_FILE_RULES_FILE = 2,
|
||||
INPUT_MODE_STRAIGHT_FILE_RULES_GEN = 3,
|
||||
INPUT_MODE_STRAIGHT_STDIN = 4,
|
||||
INPUT_MODE_STRAIGHT_STDIN_RULES_FILE = 5,
|
||||
INPUT_MODE_STRAIGHT_STDIN_RULES_GEN = 6,
|
||||
INPUT_MODE_COMBINATOR_BASE_LEFT = 7,
|
||||
INPUT_MODE_COMBINATOR_BASE_RIGHT = 8,
|
||||
INPUT_MODE_MASK = 9,
|
||||
INPUT_MODE_MASK_CS = 10,
|
||||
INPUT_MODE_HYBRID1 = 11,
|
||||
INPUT_MODE_HYBRID1_CS = 12,
|
||||
INPUT_MODE_HYBRID2 = 13,
|
||||
INPUT_MODE_HYBRID2_CS = 14,
|
||||
|
||||
} input_mode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *status;
|
||||
char *session;
|
||||
int input_mode;
|
||||
char *input_base;
|
||||
char *input_mod;
|
||||
char *input_charset;
|
||||
char *hash_type;
|
||||
char *hash_target;
|
||||
|
||||
device_info_t device_info_buf[DEVICES_MAX];
|
||||
int device_info_cnt;
|
||||
|
||||
} hashcat_status_t;
|
||||
|
||||
typedef struct thread_param
|
||||
{
|
||||
u32 tid;
|
||||
|
207
src/hashcat.c
207
src/hashcat.c
@ -55,78 +55,6 @@
|
||||
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT;
|
||||
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
|
||||
|
||||
int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
|
||||
{
|
||||
if (event == NULL)
|
||||
{
|
||||
fprintf (stderr, "Event callback function is mandatory\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
hashcat_ctx->event = event;
|
||||
|
||||
hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); VERIFY_PTR (hashcat_ctx->bitmap_ctx);
|
||||
hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); VERIFY_PTR (hashcat_ctx->combinator_ctx);
|
||||
hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); VERIFY_PTR (hashcat_ctx->cpt_ctx);
|
||||
hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); VERIFY_PTR (hashcat_ctx->debugfile_ctx);
|
||||
hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); VERIFY_PTR (hashcat_ctx->dictstat_ctx);
|
||||
hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); VERIFY_PTR (hashcat_ctx->event_ctx);
|
||||
hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); VERIFY_PTR (hashcat_ctx->folder_config);
|
||||
hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); VERIFY_PTR (hashcat_ctx->hashcat_user);
|
||||
hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); VERIFY_PTR (hashcat_ctx->hashconfig);
|
||||
hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); VERIFY_PTR (hashcat_ctx->hashes);
|
||||
hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); VERIFY_PTR (hashcat_ctx->hwmon_ctx);
|
||||
hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); VERIFY_PTR (hashcat_ctx->induct_ctx);
|
||||
hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); VERIFY_PTR (hashcat_ctx->logfile_ctx);
|
||||
hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); VERIFY_PTR (hashcat_ctx->loopback_ctx);
|
||||
hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); VERIFY_PTR (hashcat_ctx->mask_ctx);
|
||||
hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); VERIFY_PTR (hashcat_ctx->opencl_ctx);
|
||||
hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); VERIFY_PTR (hashcat_ctx->outcheck_ctx);
|
||||
hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); VERIFY_PTR (hashcat_ctx->outfile_ctx);
|
||||
hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); VERIFY_PTR (hashcat_ctx->potfile_ctx);
|
||||
hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); VERIFY_PTR (hashcat_ctx->restore_ctx);
|
||||
hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); VERIFY_PTR (hashcat_ctx->status_ctx);
|
||||
hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); VERIFY_PTR (hashcat_ctx->straight_ctx);
|
||||
hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); VERIFY_PTR (hashcat_ctx->tuning_db);
|
||||
hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); VERIFY_PTR (hashcat_ctx->user_options_extra);
|
||||
hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); VERIFY_PTR (hashcat_ctx->user_options);
|
||||
hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx->wl_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
hcfree (hashcat_ctx->bitmap_ctx);
|
||||
hcfree (hashcat_ctx->combinator_ctx);
|
||||
hcfree (hashcat_ctx->cpt_ctx);
|
||||
hcfree (hashcat_ctx->debugfile_ctx);
|
||||
hcfree (hashcat_ctx->dictstat_ctx);
|
||||
hcfree (hashcat_ctx->event_ctx);
|
||||
hcfree (hashcat_ctx->folder_config);
|
||||
hcfree (hashcat_ctx->hashconfig);
|
||||
hcfree (hashcat_ctx->hashes);
|
||||
hcfree (hashcat_ctx->hwmon_ctx);
|
||||
hcfree (hashcat_ctx->induct_ctx);
|
||||
hcfree (hashcat_ctx->logfile_ctx);
|
||||
hcfree (hashcat_ctx->loopback_ctx);
|
||||
hcfree (hashcat_ctx->mask_ctx);
|
||||
hcfree (hashcat_ctx->opencl_ctx);
|
||||
hcfree (hashcat_ctx->outcheck_ctx);
|
||||
hcfree (hashcat_ctx->outfile_ctx);
|
||||
hcfree (hashcat_ctx->potfile_ctx);
|
||||
hcfree (hashcat_ctx->restore_ctx);
|
||||
hcfree (hashcat_ctx->status_ctx);
|
||||
hcfree (hashcat_ctx->straight_ctx);
|
||||
hcfree (hashcat_ctx->tuning_db);
|
||||
hcfree (hashcat_ctx->user_options_extra);
|
||||
hcfree (hashcat_ctx->user_options);
|
||||
hcfree (hashcat_ctx->wl_data);
|
||||
|
||||
memset (hashcat_ctx, 0, sizeof (hashcat_ctx_t));
|
||||
}
|
||||
|
||||
// inner2_loop iterates through wordlists, then calls kernel execution
|
||||
|
||||
static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
@ -809,7 +737,79 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime)
|
||||
int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
|
||||
{
|
||||
if (event == NULL)
|
||||
{
|
||||
fprintf (stderr, "Event callback function is mandatory\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
hashcat_ctx->event = event;
|
||||
|
||||
hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); VERIFY_PTR (hashcat_ctx->bitmap_ctx);
|
||||
hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); VERIFY_PTR (hashcat_ctx->combinator_ctx);
|
||||
hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); VERIFY_PTR (hashcat_ctx->cpt_ctx);
|
||||
hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); VERIFY_PTR (hashcat_ctx->debugfile_ctx);
|
||||
hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); VERIFY_PTR (hashcat_ctx->dictstat_ctx);
|
||||
hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); VERIFY_PTR (hashcat_ctx->event_ctx);
|
||||
hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); VERIFY_PTR (hashcat_ctx->folder_config);
|
||||
hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); VERIFY_PTR (hashcat_ctx->hashcat_user);
|
||||
hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); VERIFY_PTR (hashcat_ctx->hashconfig);
|
||||
hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); VERIFY_PTR (hashcat_ctx->hashes);
|
||||
hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); VERIFY_PTR (hashcat_ctx->hwmon_ctx);
|
||||
hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); VERIFY_PTR (hashcat_ctx->induct_ctx);
|
||||
hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); VERIFY_PTR (hashcat_ctx->logfile_ctx);
|
||||
hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); VERIFY_PTR (hashcat_ctx->loopback_ctx);
|
||||
hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); VERIFY_PTR (hashcat_ctx->mask_ctx);
|
||||
hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); VERIFY_PTR (hashcat_ctx->opencl_ctx);
|
||||
hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); VERIFY_PTR (hashcat_ctx->outcheck_ctx);
|
||||
hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); VERIFY_PTR (hashcat_ctx->outfile_ctx);
|
||||
hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); VERIFY_PTR (hashcat_ctx->potfile_ctx);
|
||||
hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); VERIFY_PTR (hashcat_ctx->restore_ctx);
|
||||
hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); VERIFY_PTR (hashcat_ctx->status_ctx);
|
||||
hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); VERIFY_PTR (hashcat_ctx->straight_ctx);
|
||||
hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); VERIFY_PTR (hashcat_ctx->tuning_db);
|
||||
hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); VERIFY_PTR (hashcat_ctx->user_options_extra);
|
||||
hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); VERIFY_PTR (hashcat_ctx->user_options);
|
||||
hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx->wl_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hashcat_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
hcfree (hashcat_ctx->bitmap_ctx);
|
||||
hcfree (hashcat_ctx->combinator_ctx);
|
||||
hcfree (hashcat_ctx->cpt_ctx);
|
||||
hcfree (hashcat_ctx->debugfile_ctx);
|
||||
hcfree (hashcat_ctx->dictstat_ctx);
|
||||
hcfree (hashcat_ctx->event_ctx);
|
||||
hcfree (hashcat_ctx->folder_config);
|
||||
hcfree (hashcat_ctx->hashconfig);
|
||||
hcfree (hashcat_ctx->hashes);
|
||||
hcfree (hashcat_ctx->hwmon_ctx);
|
||||
hcfree (hashcat_ctx->induct_ctx);
|
||||
hcfree (hashcat_ctx->logfile_ctx);
|
||||
hcfree (hashcat_ctx->loopback_ctx);
|
||||
hcfree (hashcat_ctx->mask_ctx);
|
||||
hcfree (hashcat_ctx->opencl_ctx);
|
||||
hcfree (hashcat_ctx->outcheck_ctx);
|
||||
hcfree (hashcat_ctx->outfile_ctx);
|
||||
hcfree (hashcat_ctx->potfile_ctx);
|
||||
hcfree (hashcat_ctx->restore_ctx);
|
||||
hcfree (hashcat_ctx->status_ctx);
|
||||
hcfree (hashcat_ctx->straight_ctx);
|
||||
hcfree (hashcat_ctx->tuning_db);
|
||||
hcfree (hashcat_ctx->user_options_extra);
|
||||
hcfree (hashcat_ctx->user_options);
|
||||
hcfree (hashcat_ctx->wl_data);
|
||||
|
||||
memset (hashcat_ctx, 0, sizeof (hashcat_ctx_t));
|
||||
}
|
||||
|
||||
int hashcat_session_run (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime)
|
||||
{
|
||||
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
@ -1088,10 +1088,67 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0;
|
||||
}
|
||||
|
||||
status_ctx_destroy (hashcat_ctx);
|
||||
event_ctx_destroy (hashcat_ctx);
|
||||
// do not clear status and event so we can access them from main.c after hashcat_session_run() finishes
|
||||
//status_ctx_destroy (hashcat_ctx);
|
||||
//event_ctx_destroy (hashcat_ctx);
|
||||
|
||||
// done
|
||||
|
||||
return rc_final;
|
||||
}
|
||||
|
||||
int hashcat_session_pause (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
return SuspendThreads (hashcat_ctx);
|
||||
}
|
||||
|
||||
int hashcat_session_resume (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
return ResumeThreads (hashcat_ctx);
|
||||
}
|
||||
|
||||
int hashcat_session_bypass (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
return bypass (hashcat_ctx);
|
||||
}
|
||||
|
||||
int hashcat_session_checkpoint (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
return stop_at_checkpoint (hashcat_ctx);
|
||||
}
|
||||
|
||||
int hashcat_session_quit (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
return myabort (hashcat_ctx);
|
||||
}
|
||||
|
||||
char *hashcat_get_log (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
return event_ctx->msg_buf;
|
||||
}
|
||||
|
||||
int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_status)
|
||||
{
|
||||
memset (hashcat_status, 0, sizeof (hashcat_status_t));
|
||||
|
||||
hashcat_status->session = status_get_session (hashcat_ctx);
|
||||
hashcat_status->status = status_get_status_string (hashcat_ctx);
|
||||
hashcat_status->input_mode = status_get_input_mode (hashcat_ctx);
|
||||
hashcat_status->input_base = status_get_input_base (hashcat_ctx);
|
||||
hashcat_status->input_mod = status_get_input_mod (hashcat_ctx);
|
||||
hashcat_status->input_charset = status_get_input_charset (hashcat_ctx);
|
||||
hashcat_status->hash_type = status_get_hash_type (hashcat_ctx);
|
||||
hashcat_status->hash_target = status_get_hash_target (hashcat_ctx);
|
||||
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status == STATUS_INIT) return -1;
|
||||
if (status_ctx->devices_status == STATUS_AUTOTUNE) return -1;
|
||||
|
||||
if (status_ctx->shutdown_inner == true) return -1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ int main (int argc, char **argv)
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx);
|
||||
|
||||
const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event);
|
||||
const int rc_hashcat_init = hashcat_init (hashcat_ctx, event);
|
||||
|
||||
if (rc_hashcat_init == -1) return -1;
|
||||
|
||||
@ -603,11 +603,11 @@ int main (int argc, char **argv)
|
||||
|
||||
// now run hashcat
|
||||
|
||||
const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
|
||||
const int rc_hashcat = hashcat_session_run (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
|
||||
|
||||
// finished with hashcat, clean up
|
||||
|
||||
hashcat_ctx_destroy (hashcat_ctx);
|
||||
hashcat_destroy (hashcat_ctx);
|
||||
|
||||
free (hashcat_ctx);
|
||||
|
||||
|
@ -38,7 +38,7 @@ int main ()
|
||||
|
||||
assert (hashcat_ctx);
|
||||
|
||||
const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event);
|
||||
const int rc_hashcat_init = hashcat_init (hashcat_ctx, event);
|
||||
|
||||
if (rc_hashcat_init == -1) return -1;
|
||||
|
||||
@ -69,20 +69,32 @@ int main ()
|
||||
|
||||
// now run hashcat
|
||||
|
||||
const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0);
|
||||
const int rc_hashcat = hashcat_session_run (hashcat_ctx, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
if (rc_hashcat == 0)
|
||||
{
|
||||
puts ("YAY, all hashes cracked!!");
|
||||
hashcat_status_t hashcat_status;
|
||||
|
||||
const int rc = hashcat_get_status (hashcat_ctx, &hashcat_status);
|
||||
|
||||
printf ("Session: %s\n", hashcat_status.session);
|
||||
printf ("Status: %s\n", hashcat_status.status);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
printf ("%d\n", hashcat_status.device_info_cnt);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (rc_hashcat == -1)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
char *msg = hashcat_get_log (hashcat_ctx);
|
||||
|
||||
fprintf (stderr, "%s\n", event_ctx->msg_buf);
|
||||
fprintf (stderr, "%s\n", msg);
|
||||
}
|
||||
|
||||
hashcat_ctx_destroy (hashcat_ctx);
|
||||
hashcat_destroy (hashcat_ctx);
|
||||
|
||||
free (hashcat_ctx);
|
||||
|
||||
|
@ -349,44 +349,6 @@ void unlink_restore (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
// this feature only makes sense if --restore-disable was not specified
|
||||
|
||||
if (restore_ctx->enabled == false)
|
||||
{
|
||||
event_log_warning (hashcat_ctx, "This feature is disabled when --restore-disable is specified");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return;
|
||||
|
||||
if ((status_ctx->run_thread_level1 == true) && (status_ctx->run_thread_level2 == true))
|
||||
{
|
||||
status_ctx->run_main_level1 = false;
|
||||
status_ctx->run_main_level2 = false;
|
||||
status_ctx->run_main_level3 = false;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = true;
|
||||
|
||||
event_log_info (hashcat_ctx, "Checkpoint enabled: Will quit at next Restore Point update");
|
||||
}
|
||||
else
|
||||
{
|
||||
status_ctx->run_main_level1 = true;
|
||||
status_ctx->run_main_level2 = true;
|
||||
status_ctx->run_main_level3 = true;
|
||||
status_ctx->run_thread_level1 = true;
|
||||
status_ctx->run_thread_level2 = true;
|
||||
|
||||
event_log_info (hashcat_ctx, "Checkpoint disabled: Restore Point updates will no longer be monitored");
|
||||
}
|
||||
}
|
||||
|
||||
int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
||||
{
|
||||
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
||||
|
1447
src/status.c
1447
src/status.c
File diff suppressed because it is too large
Load Diff
1128
src/terminal.c
1128
src/terminal.c
File diff suppressed because it is too large
Load Diff
76
src/thread.c
76
src/thread.c
@ -116,7 +116,7 @@ void hc_signal (void (callback) (int))
|
||||
#endif
|
||||
*/
|
||||
|
||||
void mycracked (hashcat_ctx_t *hashcat_ctx)
|
||||
int mycracked (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
@ -129,13 +129,16 @@ void mycracked (hashcat_ctx_t *hashcat_ctx)
|
||||
status_ctx->run_main_level3 = false;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void myabort (hashcat_ctx_t *hashcat_ctx)
|
||||
int myabort (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
//those checks create problems in benchmark mode, it's simply too short of a timeframe where it's running as STATUS_RUNNING
|
||||
// not sure if this is still valid, but abort is also called by gpu temp monitor
|
||||
//if (status_ctx->devices_status != STATUS_RUNNING) return;
|
||||
|
||||
status_ctx->devices_status = STATUS_ABORTED;
|
||||
@ -145,13 +148,15 @@ void myabort (hashcat_ctx_t *hashcat_ctx)
|
||||
status_ctx->run_main_level3 = false;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void myquit (hashcat_ctx_t *hashcat_ctx)
|
||||
int myquit (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
//if (status_ctx->devices_status != STATUS_RUNNING) return;
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
|
||||
|
||||
status_ctx->devices_status = STATUS_QUIT;
|
||||
|
||||
@ -160,13 +165,15 @@ void myquit (hashcat_ctx_t *hashcat_ctx)
|
||||
status_ctx->run_main_level3 = false;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bypass (hashcat_ctx_t *hashcat_ctx)
|
||||
int bypass (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
//if (status_ctx->devices_status != STATUS_RUNNING) return;
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
|
||||
|
||||
status_ctx->devices_status = STATUS_BYPASS;
|
||||
|
||||
@ -175,28 +182,77 @@ void bypass (hashcat_ctx_t *hashcat_ctx)
|
||||
status_ctx->run_main_level3 = true;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SuspendThreads (hashcat_ctx_t *hashcat_ctx)
|
||||
int SuspendThreads (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return;
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
|
||||
|
||||
hc_timer_set (&status_ctx->timer_paused);
|
||||
|
||||
status_ctx->devices_status = STATUS_PAUSED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ResumeThreads (hashcat_ctx_t *hashcat_ctx)
|
||||
int ResumeThreads (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_PAUSED) return;
|
||||
if (status_ctx->devices_status != STATUS_PAUSED) return -1;
|
||||
|
||||
double ms_paused = hc_timer_get (status_ctx->timer_paused);
|
||||
|
||||
status_ctx->ms_paused += ms_paused;
|
||||
|
||||
status_ctx->devices_status = STATUS_RUNNING;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
|
||||
|
||||
// this feature only makes sense if --restore-disable was not specified
|
||||
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
|
||||
if (restore_ctx->enabled == false)
|
||||
{
|
||||
event_log_warning (hashcat_ctx, "This feature is disabled when --restore-disable is specified");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Enable or Disable
|
||||
|
||||
if ((status_ctx->run_thread_level1 == true) && (status_ctx->run_thread_level2 == true))
|
||||
{
|
||||
status_ctx->run_main_level1 = false;
|
||||
status_ctx->run_main_level2 = false;
|
||||
status_ctx->run_main_level3 = false;
|
||||
status_ctx->run_thread_level1 = false;
|
||||
status_ctx->run_thread_level2 = true;
|
||||
|
||||
event_log_info (hashcat_ctx, "Checkpoint enabled: Will quit at next Restore Point update");
|
||||
}
|
||||
else
|
||||
{
|
||||
status_ctx->run_main_level1 = true;
|
||||
status_ctx->run_main_level2 = true;
|
||||
status_ctx->run_main_level3 = true;
|
||||
status_ctx->run_thread_level1 = true;
|
||||
status_ctx->run_thread_level2 = true;
|
||||
|
||||
event_log_info (hashcat_ctx, "Checkpoint disabled: Restore Point updates will no longer be monitored");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user