From 81650dcc4688f46363752dc6b12a9b8f1a0d24fb Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 7 Oct 2016 16:56:44 +0200 Subject: [PATCH 001/106] Initial proposal --- include/hashcat.h | 2 +- include/shared.h | 2 + include/types.h | 37 ++++++ src/hashcat.c | 175 ++++++++-------------------- src/main.c | 284 ++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 350 insertions(+), 150 deletions(-) diff --git a/include/hashcat.h b/include/hashcat.h index 8b3b3f9fb..b4cd4e905 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -8,7 +8,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx); +void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t *, const u32)); void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _HASHCAT_H diff --git a/include/shared.h b/include/shared.h index 9971466f1..9d9b518d2 100644 --- a/include/shared.h +++ b/include/shared.h @@ -12,6 +12,8 @@ #include #include +#define EVENT_SEND(id) { const int rc_event = hashcat_ctx->event (hashcat_ctx, (id)); if (rc_event == -1) return -1; } + bool is_power_of_2 (const u32 v); u32 get_random_num (const u32 min, const u32 max); diff --git a/include/types.h b/include/types.h index cf6edf9ae..e756e9916 100644 --- a/include/types.h +++ b/include/types.h @@ -81,6 +81,31 @@ typedef struct stat64 hc_stat; // enums +typedef enum event_identifier +{ + EVENT_WELCOME_SCREEN = 0x00000011, + EVENT_GOODBYE_SCREEN = 0x00000012, + EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021, + EVENT_LOGFILE_TOP_FINALIZE = 0x00000022, + EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023, + EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, + EVENT_OUTERLOOP_STARTING = 0x00000031, + EVENT_OUTERLOOP_FINISHED = 0x00000032, + EVENT_INNERLOOP1_STARTING = 0x00000041, + EVENT_INNERLOOP1_FINISHED = 0x00000042, + EVENT_INNERLOOP2_STARTING = 0x00000051, + EVENT_INNERLOOP2_FINISHED = 0x00000052, + EVENT_AUTOTUNE_STARTING = 0x00000053, + EVENT_AUTOTUNE_FINISHED = 0x00000054, + EVENT_CRACKER_STARTING = 0x00000055, + EVENT_CRACKER_FINISHED = 0x00000056, + EVENT_CRACKER_FINAL_STATS = 0x00000057, + EVENT_CRACKER_HASH_CRACKED = 0x00000058, + + // there will be much more event types soon + +} event_identifier_t; + typedef enum amplifier_count { KERNEL_BFS = 1024, @@ -1350,6 +1375,15 @@ typedef struct status_ctx } status_ctx_t; +typedef struct hashcat_user +{ + // use this for context specific data + + int outer_threads_cnt; + hc_thread_t *outer_threads; + +} hashcat_user_t; + typedef struct hashcat_ctx { bitmap_ctx_t *bitmap_ctx; @@ -1358,6 +1392,7 @@ typedef struct hashcat_ctx debugfile_ctx_t *debugfile_ctx; dictstat_ctx_t *dictstat_ctx; folder_config_t *folder_config; + hashcat_user_t *hashcat_user; hashconfig_t *hashconfig; hashes_t *hashes; hwmon_ctx_t *hwmon_ctx; @@ -1377,6 +1412,8 @@ typedef struct hashcat_ctx user_options_t *user_options; wl_data_t *wl_data; + int (*event) (struct hashcat_ctx *, const u32); + } hashcat_ctx_t; typedef struct thread_param diff --git a/src/hashcat.c b/src/hashcat.c index a792c1bb7..76c6f36f4 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -46,7 +46,6 @@ #include "rp.h" #include "status.h" #include "straight.h" -#include "terminal.h" #include "tuningdb.h" #include "usage.h" #include "user_options.h" @@ -56,14 +55,24 @@ extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx) +void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t *, const u32)) { + if (event == NULL) + { + fprintf (stderr, "Event callback function is mandatory\n"); + + exit (-1); + } + + hashcat_ctx->event = event; + hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) mymalloc (sizeof (bitmap_ctx_t)); hashcat_ctx->combinator_ctx = (combinator_ctx_t *) mymalloc (sizeof (combinator_ctx_t)); hashcat_ctx->cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t)); hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) mymalloc (sizeof (debugfile_ctx_t)); hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) mymalloc (sizeof (dictstat_ctx_t)); hashcat_ctx->folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t)); + hashcat_ctx->hashcat_user = (hashcat_user_t *) mymalloc (sizeof (hashcat_user_t)); hashcat_ctx->hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t)); hashcat_ctx->hashes = (hashes_t *) mymalloc (sizeof (hashes_t)); hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) mymalloc (sizeof (hwmon_ctx_t)); @@ -135,9 +144,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - logfile_generate_subid (hashcat_ctx); - - logfile_sub_msg ("START"); + EVENT_SEND (EVENT_LOGFILE_SUB_INITIALIZE); status_progress_reset (hashcat_ctx); @@ -188,6 +195,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) return 0; } + // restore stuff + if (status_ctx->words_cur > status_ctx->words_base) { log_error ("ERROR: Restore value greater keyspace"); @@ -195,8 +204,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) return -1; } - // restore progress - if (status_ctx->words_cur) { const u64 progress_restored = status_ctx->words_cur * user_options_extra_amplifier (hashcat_ctx); @@ -219,6 +226,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) * create autotune threads */ + EVENT_SEND (EVENT_AUTOTUNE_STARTING); + thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); hc_thread_t *c_threads = (hc_thread_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); @@ -237,6 +246,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (opencl_ctx->devices_cnt, c_threads); + EVENT_SEND (EVENT_AUTOTUNE_FINISHED); + /** * autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all */ @@ -252,23 +263,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) loopback_write_open (hashcat_ctx); } - /** - * Tell user we're about to start - */ - - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false)) - { - if (user_options->quiet == false) send_prompt (); - } - } - else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) - { - if (user_options->quiet == false) log_info ("Starting attack in stdin mode..."); - if (user_options->quiet == false) log_info (""); - } - /** * Prepare cracking stats */ @@ -287,6 +281,8 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) * create cracker threads */ + EVENT_SEND (EVENT_CRACKER_STARTING); + status_ctx->devices_status = STATUS_RUNNING; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) @@ -312,8 +308,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) myfree (threads_param); - // calculate final status - if ((status_ctx->devices_status != STATUS_CRACKED) && (status_ctx->devices_status != STATUS_ABORTED) && (status_ctx->devices_status != STATUS_QUIT) @@ -322,7 +316,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_EXHAUSTED; } - logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); + EVENT_SEND (EVENT_CRACKER_FINISHED); // update some timer @@ -337,7 +331,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) time (&status_ctx->prepare_start); - logfile_sub_msg ("STOP"); + EVENT_SEND (EVENT_CRACKER_FINAL_STATS); // no more skip and restore from here @@ -353,39 +347,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) loopback_write_close (hashcat_ctx); } - // print final status - - if (user_options->benchmark == true) - { - status_benchmark (hashcat_ctx); - - if (user_options->machine_readable == false) - { - log_info (""); - } - } - else - { - if (user_options->quiet == false) - { - clear_prompt (); - - if (hashes->digests_saved != hashes->digests_done) log_info (""); - - status_display (hashcat_ctx); - - log_info (""); - } - else - { - if (user_options->status == true) - { - status_display (hashcat_ctx); - - log_info (""); - } - } - } + EVENT_SEND (EVENT_LOGFILE_SUB_FINALIZE); // New induction folder check @@ -908,7 +870,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) potfile_write_close (hashcat_ctx); - // finalize session + // finalize opencl session opencl_session_destroy (hashcat_ctx); @@ -937,22 +899,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime) { - /** - * To help users a bit - */ - - setup_environment_variables (); - - setup_umask (); - - /** - * main init - */ - - logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; /** * status init @@ -962,6 +911,8 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_status_init == -1) return -1; + EVENT_SEND (EVENT_WELCOME_SCREEN); + /** * folder */ @@ -986,26 +937,24 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options_extra_init (hashcat_ctx); + // from here all user configuration is pre-processed so we can start logging + + EVENT_SEND (EVENT_LOGFILE_TOP_INITIALIZE); + + /** + * To help users a bit + */ + + setup_environment_variables (); + + setup_umask (); + /** * prepare seeding for random number generator, required by logfile and rules generator */ setup_seeding (user_options->rp_gen_seed_chgd, user_options->rp_gen_seed); - /** - * logfile init - */ - - const int rc_logfile_init = logfile_init (hashcat_ctx); - - if (rc_logfile_init == -1) return -1; - - logfile_generate_topid (hashcat_ctx); - - logfile_top_msg ("START"); - - user_options_logger (hashcat_ctx); - /** * tuning db */ @@ -1105,6 +1054,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold const int rc_devices_init = opencl_ctx_devices_init (hashcat_ctx, comptime); if (rc_devices_init == -1) return -1; + /** * HM devices: init */ @@ -1113,30 +1063,12 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_hwmon_init == -1) return -1; - /** - * keypress thread - */ - - int outer_threads_cnt = 0; - - hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); - - status_ctx->shutdown_outer = false; - - if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false) - { - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - hc_thread_create (outer_threads[outer_threads_cnt], thread_keypress, hashcat_ctx); - - outer_threads_cnt++; - } - } - /** * outer loop */ + EVENT_SEND (EVENT_OUTERLOOP_STARTING); + if (user_options->benchmark == true) { user_options->quiet = true; @@ -1168,16 +1100,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc == -1) return -1; } - // wait for outer threads - - status_ctx->shutdown_outer = true; - - for (int thread_idx = 0; thread_idx < outer_threads_cnt; thread_idx++) - { - hc_thread_wait (1, &outer_threads[thread_idx]); - } - - myfree (outer_threads); + EVENT_SEND (EVENT_OUTERLOOP_FINISHED); if (user_options->benchmark == true) { @@ -1225,9 +1148,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_top_uint (status_ctx->proc_start); logfile_top_uint (status_ctx->proc_stop); - logfile_top_msg ("STOP"); - - logfile_destroy (hashcat_ctx); + EVENT_SEND (EVENT_LOGFILE_TOP_FINALIZE); user_options_extra_destroy (hashcat_ctx); @@ -1240,7 +1161,11 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; + EVENT_SEND (EVENT_GOODBYE_SCREEN); + status_ctx_destroy (hashcat_ctx); + // done + return rc_final; } diff --git a/src/main.c b/src/main.c index f9666d699..eb43053f2 100644 --- a/src/main.c +++ b/src/main.c @@ -11,18 +11,276 @@ #include "types.h" #include "user_options.h" #include "hashcat.h" +#include "memory.h" // commandline only #include "terminal.h" // commandline only #include "usage.h" // commandline only +#include "logging.h" // commandline only +#include "logfile.h" // commandline only +#include "thread.h" // commandline only +#include "status.h" // commandline only #define RUN_AS_COMMANDLINE true +#if (RUN_AS_COMMANDLINE == true) + +static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx) +{ + // sets dos window size (windows only) + + setup_console (); + + // Inform user things getting started + + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + welcome_screen (hashcat_ctx, status_ctx->proc_start, VERSION_TAG); + + return 0; +} + +static int event_goodbye_screen (hashcat_ctx_t *hashcat_ctx) +{ + // Inform user we're done + + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop); + + return 0; +} + +static int event_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx) +{ + const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + + // logfile init + + const int rc_logfile_init = logfile_init (hashcat_ctx); + + if (rc_logfile_init == -1) return -1; + + logfile_generate_topid (hashcat_ctx); + + logfile_top_msg ("START"); + + // add all user options to logfile in case we want to debug some user session + + user_options_logger (hashcat_ctx); + + return 0; +} + +static int event_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx) +{ + const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + + logfile_top_msg ("STOP"); + + logfile_destroy (hashcat_ctx); + + return 0; +} + +static int event_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx) +{ + const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + + logfile_generate_subid (hashcat_ctx); + + logfile_sub_msg ("START"); + + return 0; +} + +static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx) +{ + const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + + logfile_sub_msg ("STOP"); + + return 0; +} + +static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx) +{ + hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + /** + * keypress thread + */ + + hashcat_user->outer_threads_cnt = 0; + + hashcat_user->outer_threads = (hc_thread_t *) mycalloc (2, sizeof (hc_thread_t)); + + status_ctx->shutdown_outer = false; + + if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false) + { + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + // see thread_keypress() how to access status information + + hc_thread_create (hashcat_user->outer_threads[hashcat_user->outer_threads_cnt], thread_keypress, hashcat_ctx); + + hashcat_user->outer_threads_cnt++; + } + } + + return 0; +} + +static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx) +{ + hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + // wait for outer threads + + status_ctx->shutdown_outer = true; + + for (int thread_idx = 0; thread_idx < hashcat_user->outer_threads_cnt; thread_idx++) + { + hc_thread_wait (1, &hashcat_user->outer_threads[thread_idx]); + } + + myfree (hashcat_user->outer_threads); + + hashcat_user->outer_threads_cnt = 0; + + return 0; +} + +static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) +{ + user_options_t *user_options = hashcat_ctx->user_options; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + // Tell the user we're about to start + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false)) + { + if (user_options->quiet == false) send_prompt (); + } + } + else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) + { + if (user_options->quiet == false) log_info ("Starting attack in stdin mode..."); + if (user_options->quiet == false) log_info (""); + } + + return 0; +} + +static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx) +{ + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); + + return 0; +} + +static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) +{ + hashes_t *hashes = hashcat_ctx->hashes; + user_options_t *user_options = hashcat_ctx->user_options; + + // print final status + + if (user_options->benchmark == true) + { + status_benchmark (hashcat_ctx); + + if (user_options->machine_readable == false) + { + log_info (""); + } + } + else + { + if (user_options->quiet == false) + { + clear_prompt (); + + if (hashes->digests_saved != hashes->digests_done) log_info (""); + + status_display (hashcat_ctx); + + log_info (""); + } + else + { + if (user_options->status == true) + { + status_display (hashcat_ctx); + + log_info (""); + } + } + } + + return 0; +} + +static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx) +{ + hashes_t *hashes = hashcat_ctx->hashes; + user_options_t *user_options = hashcat_ctx->user_options; + + if (hashes == NULL) hashes = NULL; + if (user_options == NULL) user_options = NULL; + + return 0; +} + +int event (hashcat_ctx_t *hashcat_ctx, const u32 event) +{ + int rc = 0; + + switch (event) + { + case EVENT_WELCOME_SCREEN: rc = event_welcome_screen (hashcat_ctx); break; + case EVENT_GOODBYE_SCREEN: rc = event_goodbye_screen (hashcat_ctx); break; + case EVENT_LOGFILE_TOP_INITIALIZE: rc = event_logfile_top_initialize (hashcat_ctx); break; + case EVENT_LOGFILE_TOP_FINALIZE: rc = event_logfile_top_finalize (hashcat_ctx); break; + case EVENT_LOGFILE_SUB_INITIALIZE: rc = event_logfile_sub_initialize (hashcat_ctx); break; + case EVENT_LOGFILE_SUB_FINALIZE: rc = event_logfile_sub_finalize (hashcat_ctx); break; + case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break; + case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break; + case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break; + case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break; + case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break; + case EVENT_CRACKER_HASH_CRACKED: rc = event_cracker_hash_cracked (hashcat_ctx); break; + } + + return rc; +} + +#else + +int event (hashcat_ctx_t *hashcat_ctx, const u32 event) +{ + switch (event) + { + } +} + +#endif + int main (int argc, char **argv) { // hashcat main context hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); - hashcat_ctx_init (hashcat_ctx); + hashcat_ctx_init (hashcat_ctx, event); // initialize the session via getops for commandline use or // alternatively you can set the user_options directly @@ -46,12 +304,6 @@ int main (int argc, char **argv) shared_folder = SHARED_FOLDER; #endif - // sets dos window size (windows only) - - const int rc_console = setup_console (); - - if (rc_console == -1) return -1; - // initialize the user options with some defaults (you can override them later) user_options_init (hashcat_ctx); @@ -84,25 +336,9 @@ int main (int argc, char **argv) return 0; } - // Inform user things getting started - - time_t proc_start; - - time (&proc_start); - - welcome_screen (hashcat_ctx, proc_start, VERSION_TAG); - // now run hashcat rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); - - // Inform user we're done - - time_t proc_stop; - - time (&proc_stop); - - goodbye_screen (hashcat_ctx, proc_start, proc_stop); } else { @@ -141,4 +377,4 @@ int main (int argc, char **argv) free (hashcat_ctx); return rc_hashcat; -} \ No newline at end of file +} From 27887bf9ce8932c6f28ffe17dc2ea8022351aef2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 7 Oct 2016 21:47:11 +0200 Subject: [PATCH 002/106] Get rid of more log_info() in hashcat() --- include/potfile.h | 2 +- include/types.h | 9 ++ src/hashcat.c | 146 ++--------------- src/main.c | 400 ++++++++++++++++++++++++++++++++++------------ src/potfile.c | 31 ++-- 5 files changed, 337 insertions(+), 251 deletions(-) diff --git a/include/potfile.h b/include/potfile.h index 9b552214e..3101e414d 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -33,7 +33,7 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); -int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); +void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); void potfile_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _POTFILE_H diff --git a/include/types.h b/include/types.h index e756e9916..ac01c86a5 100644 --- a/include/types.h +++ b/include/types.h @@ -91,16 +91,24 @@ typedef enum event_identifier EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, EVENT_OUTERLOOP_STARTING = 0x00000031, EVENT_OUTERLOOP_FINISHED = 0x00000032, + EVENT_OUTERLOOP_MAINSCREEN = 0x00000033, + EVENT_OUTERLOOP_WEAK_HASH = 0x00000034, EVENT_INNERLOOP1_STARTING = 0x00000041, EVENT_INNERLOOP1_FINISHED = 0x00000042, EVENT_INNERLOOP2_STARTING = 0x00000051, EVENT_INNERLOOP2_FINISHED = 0x00000052, + EVENT_CALCULATED_WORDS_BASE = 0x00000059, EVENT_AUTOTUNE_STARTING = 0x00000053, EVENT_AUTOTUNE_FINISHED = 0x00000054, EVENT_CRACKER_STARTING = 0x00000055, EVENT_CRACKER_FINISHED = 0x00000056, EVENT_CRACKER_FINAL_STATS = 0x00000057, EVENT_CRACKER_HASH_CRACKED = 0x00000058, + EVENT_POTFILE_REMOVE_PARSE = 0x00000061, + EVENT_POTFILE_NUM_CRACKED = 0x00000062, + EVENT_POTFILE_ALL_CRACKED = 0x00000063, + EVENT_OPENCL_SESSION_PRE = 0x00000071, + EVENT_OPENCL_SESSION_POST = 0x00000072, // there will be much more event types soon @@ -499,6 +507,7 @@ typedef struct hashes void *esalts_buf; + u32 hashes_cnt_orig; u32 hashes_cnt; hash_t *hashes_buf; diff --git a/src/hashcat.c b/src/hashcat.c index 76c6f36f4..7faf17978 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -188,12 +188,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx); - if (user_options->keyspace == true) - { - log_info ("%" PRIu64 "", status_ctx->words_base); + EVENT_SEND (EVENT_CALCULATED_WORDS_BASE); - return 0; - } + if (user_options->keyspace == true) return 0; // restore stuff @@ -427,10 +424,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) static int outer_loop (hashcat_ctx_t *hashcat_ctx) { - bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; @@ -506,23 +500,21 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) } /** - * Potfile removes + * potfile removes */ - int potfile_remove_cracks = 0; - if (user_options->potfile_disable == 0) { - if (user_options->quiet == false) log_info_nn ("Comparing hashes with potfile entries..."); + EVENT_SEND (EVENT_POTFILE_REMOVE_PARSE); - potfile_remove_cracks = potfile_remove_parse (hashcat_ctx); + potfile_remove_parse (hashcat_ctx); } /** * load hashes, stage 2, remove duplicates, build base structure */ - const u32 hashes_cnt_orig = hashes->hashes_cnt; + hashes->hashes_cnt_orig = hashes->hashes_cnt; const int rc_hashes_init_stage2 = hashes_init_stage2 (hashcat_ctx); @@ -534,13 +526,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_CRACKED) { - if (user_options->quiet == false) - { - log_info ("INFO: All hashes found in potfile! You can use --show to display them."); - log_info (""); - log_info ("INFO: No more hashes left to crack, exiting..."); - log_info (""); - } + EVENT_SEND (EVENT_POTFILE_ALL_CRACKED); hashes_destroy (hashcat_ctx); @@ -640,107 +626,20 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (rc_status_init == -1) return -1; /** - * enable custom signal handler(s) - * currently disabled, because man page says: - * The effects of signal() in a multithreaded process are unspecified. + * main screen */ - /* - if (user_options->benchmark == false) - { - hc_signal (sigHandler_default); - } - else - { - hc_signal (sigHandler_benchmark); - } - */ + EVENT_SEND (EVENT_OUTERLOOP_MAINSCREEN); /** * inform the user */ - if (user_options->quiet == false) - { - log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - - log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); - - if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) - { - log_info ("Rules: %u", straight_ctx->kernel_rules_cnt); - } - - if (user_options->quiet == false) log_info (""); - - if (hashconfig->opti_type) - { - log_info ("Applicable Optimizers:"); - - for (u32 i = 0; i < 32; i++) - { - const u32 opti_bit = 1u << i; - - if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit)); - } - } - - if (user_options->quiet == false) log_info (""); - - /** - * Watchdog and Temperature balance - */ - - if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) - { - log_info ("Watchdog: Hardware Monitoring Interface not found on your system"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) - { - log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); - } - else - { - log_info ("Watchdog: Temperature abort trigger disabled"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) - { - log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); - } - else - { - log_info ("Watchdog: Temperature retain trigger disabled"); - } - - if (user_options->quiet == false) log_info (""); - } - - #if defined (DEBUG) - if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode); - #endif - - if (user_options->quiet == false) log_info_nn ("Initializing device kernels and memory..."); + EVENT_SEND (EVENT_OPENCL_SESSION_PRE); opencl_session_begin (hashcat_ctx); - if (user_options->quiet == false) log_info_nn (""); - - /** - * In benchmark-mode, inform user which algorithm is checked - */ - - if (user_options->benchmark == true) - { - if (user_options->machine_readable == false) - { - char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - - log_info ("Hashtype: %s", hash_type); - log_info (""); - } - } + EVENT_SEND (EVENT_OPENCL_SESSION_POST); /** * weak hash check is the first to write to potfile, so open it for writing from here @@ -767,7 +666,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) break; } - if (user_options->quiet == false) log_info_nn ("Checking for weak hashes..."); + EVENT_SEND (EVENT_OUTERLOOP_WEAK_HASH); for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { @@ -807,25 +706,12 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * Tell user about cracked hashes by potfile */ - if (user_options->quiet == false) - { - if (potfile_remove_cracks > 0) - { - if (potfile_remove_cracks == 1) - { - log_info ("INFO: Removed 1 hash found in potfile"); - log_info (""); - } - else - { - log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks); - log_info (""); - } - } - } + EVENT_SEND (EVENT_POTFILE_NUM_CRACKED); // main call + EVENT_SEND (EVENT_INNERLOOP1_STARTING); + if (mask_ctx->masks_cnt) { restore_data_t *rd = restore_ctx->rd; @@ -866,6 +752,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) myfree (inner_threads); + EVENT_SEND (EVENT_INNERLOOP1_FINISHED); + // finalize potfile potfile_write_close (hashcat_ctx); diff --git a/src/main.c b/src/main.c index eb43053f2..75440bbfd 100644 --- a/src/main.c +++ b/src/main.c @@ -10,18 +10,20 @@ #include "common.h" #include "types.h" #include "user_options.h" +#include "usage.h" #include "hashcat.h" -#include "memory.h" // commandline only -#include "terminal.h" // commandline only -#include "usage.h" // commandline only -#include "logging.h" // commandline only -#include "logfile.h" // commandline only -#include "thread.h" // commandline only -#include "status.h" // commandline only -#define RUN_AS_COMMANDLINE true +#define RUN_AS_COMMANDLINE -#if (RUN_AS_COMMANDLINE == true) +#if defined (RUN_AS_COMMANDLINE) + +#include "memory.h" +#include "terminal.h" +#include "logging.h" +#include "logfile.h" +#include "thread.h" +#include "status.h" +#include "interface.h" static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx) { @@ -103,10 +105,11 @@ static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx) static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx) { - hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; /** * keypress thread @@ -156,8 +159,10 @@ static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx) static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) { - user_options_t *user_options = hashcat_ctx->user_options; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return 0; // Tell the user we're about to start @@ -165,13 +170,13 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) { if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false)) { - if (user_options->quiet == false) send_prompt (); + send_prompt (); } } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - if (user_options->quiet == false) log_info ("Starting attack in stdin mode..."); - if (user_options->quiet == false) log_info (""); + log_info ("Starting attack in stdin mode..."); + log_info (""); } return 0; @@ -179,8 +184,8 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx) { - logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); @@ -189,8 +194,8 @@ static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx) static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) { - hashes_t *hashes = hashcat_ctx->hashes; - user_options_t *user_options = hashcat_ctx->user_options; + const hashes_t *hashes = hashcat_ctx->hashes; + const user_options_t *user_options = hashcat_ctx->user_options; // print final status @@ -231,8 +236,8 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx) { - hashes_t *hashes = hashcat_ctx->hashes; - user_options_t *user_options = hashcat_ctx->user_options; + const hashes_t *hashes = hashcat_ctx->hashes; + const user_options_t *user_options = hashcat_ctx->user_options; if (hashes == NULL) hashes = NULL; if (user_options == NULL) user_options = NULL; @@ -240,6 +245,190 @@ static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx) return 0; } +static int event_calculated_words_base (hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->keyspace == true) + { + log_info ("%" PRIu64 "", status_ctx->words_base); + } + + return 0; +} + +static int event_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Comparing hashes with potfile entries..."); + + return 0; +} + +static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const hashes_t *hashes = hashcat_ctx->hashes; + + if (user_options->quiet == true) return 0; + + const int potfile_remove_cracks = hashes->digests_done; + + if (potfile_remove_cracks > 0) + { + if (potfile_remove_cracks == 1) + { + log_info ("INFO: Removed 1 hash found in potfile"); + log_info (""); + } + else + { + log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks); + log_info (""); + } + } + + return 0; +} + +static int event_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info ("INFO: All hashes found in potfile! You can use --show to display them."); + log_info (""); + log_info ("INFO: No more hashes left to crack, exiting..."); + log_info (""); + + return 0; +} + +static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx) +{ + const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + /** + * In benchmark-mode, inform user which algorithm is checked + */ + + if (user_options->benchmark == true) + { + if (user_options->machine_readable == false) + { + char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug + + log_info ("Hashtype: %s", hash_type); + log_info (""); + } + } + + if (user_options->quiet == true) return 0; + + log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + + log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + log_info ("Rules: %u", straight_ctx->kernel_rules_cnt); + } + + if (user_options->quiet == false) log_info (""); + + if (hashconfig->opti_type) + { + log_info ("Applicable Optimizers:"); + + for (u32 i = 0; i < 32; i++) + { + const u32 opti_bit = 1u << i; + + if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit)); + } + } + + log_info (""); + + /** + * Watchdog and Temperature balance + */ + + if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) + { + log_info ("Watchdog: Hardware Monitoring Interface not found on your system"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) + { + log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); + } + else + { + log_info ("Watchdog: Temperature abort trigger disabled"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) + { + log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); + } + else + { + log_info ("Watchdog: Temperature retain trigger disabled"); + } + + log_info (""); + + #if defined (DEBUG) + if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode); + #endif + + return 0; +} + +static int event_opencl_session_pre (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Initializing device kernels and memory..."); + + return 0; +} + +static int event_opencl_session_post (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn (""); + + return 0; +} + +static int event_outerloop_weak_hash (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Checking for weak hashes..."); + + return 0; +} + int event (hashcat_ctx_t *hashcat_ctx, const u32 event) { int rc = 0; @@ -254,10 +443,18 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) case EVENT_LOGFILE_SUB_FINALIZE: rc = event_logfile_sub_finalize (hashcat_ctx); break; case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break; case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break; + case EVENT_OUTERLOOP_MAINSCREEN: rc = event_outerloop_mainscreen (hashcat_ctx); break; + case EVENT_OUTERLOOP_WEAK_HASH: rc = event_outerloop_weak_hash (hashcat_ctx); break; case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break; case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break; case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break; case EVENT_CRACKER_HASH_CRACKED: rc = event_cracker_hash_cracked (hashcat_ctx); break; + case EVENT_CALCULATED_WORDS_BASE: rc = event_calculated_words_base (hashcat_ctx); break; + case EVENT_POTFILE_REMOVE_PARSE: rc = event_potfile_remove_parse (hashcat_ctx); break; + case EVENT_POTFILE_NUM_CRACKED: rc = event_potfile_num_cracked (hashcat_ctx); break; + case EVENT_POTFILE_ALL_CRACKED: rc = event_potfile_all_cracked (hashcat_ctx); break; + case EVENT_OPENCL_SESSION_PRE: rc = event_opencl_session_pre (hashcat_ctx); break; + case EVENT_OPENCL_SESSION_POST: rc = event_opencl_session_post (hashcat_ctx); break; } return rc; @@ -267,9 +464,15 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) int event (hashcat_ctx_t *hashcat_ctx, const u32 event) { + if (hashcat_ctx == NULL) hashcat_ctx = NULL; + + int rc = 0; + switch (event) { } + + return rc; } #endif @@ -285,91 +488,88 @@ int main (int argc, char **argv) // initialize the session via getops for commandline use or // alternatively you can set the user_options directly - int rc_hashcat = 0; + #if defined (RUN_AS_COMMANDLINE) - bool run_as_commandline = RUN_AS_COMMANDLINE; + // install and shared folder need to be set to recognize "make install" use - if (run_as_commandline == true) + char *install_folder = NULL; + char *shared_folder = NULL; + + #if defined (INSTALL_FOLDER) + install_folder = INSTALL_FOLDER; + #endif + + #if defined (SHARED_FOLDER) + shared_folder = SHARED_FOLDER; + #endif + + // initialize the user options with some defaults (you can override them later) + + user_options_init (hashcat_ctx); + + // parse commandline parameters and check them + + const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv); + + if (rc_options_getopt == -1) return -1; + + const int rc_options_sanity = user_options_sanity (hashcat_ctx); + + if (rc_options_sanity == -1) return -1; + + // some early exits + + user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->version == true) { - // install and shared folder need to be set to recognize "make install" use + printf ("%s\n", VERSION_TAG); - char *install_folder = NULL; - char *shared_folder = NULL; - - #if defined (INSTALL_FOLDER) - install_folder = INSTALL_FOLDER; - #endif - - #if defined (SHARED_FOLDER) - shared_folder = SHARED_FOLDER; - #endif - - // initialize the user options with some defaults (you can override them later) - - user_options_init (hashcat_ctx); - - // parse commandline parameters and check them - - const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv); - - if (rc_options_getopt == -1) return -1; - - const int rc_options_sanity = user_options_sanity (hashcat_ctx); - - if (rc_options_sanity == -1) return -1; - - // some early exits - - user_options_t *user_options = hashcat_ctx->user_options; - - if (user_options->version == true) - { - printf ("%s\n", VERSION_TAG); - - return 0; - } - - if (user_options->usage == true) - { - usage_big_print (PROGNAME); - - return 0; - } - - // now run hashcat - - rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); + return 0; } - else + + if (user_options->usage == true) { - // this is a bit ugly, but it's the example you're looking for + usage_big_print (PROGNAME); - char *hash = "8743b52063cd84097a65d1633f5c74f5"; - char *mask = "?l?l?l?l?l?l?l"; - - char *hc_argv[] = { hash, mask, NULL }; - - // initialize the user options with some defaults (you can override them later) - - user_options_init (hashcat_ctx); - - // your own stuff - - user_options_t *user_options = hashcat_ctx->user_options; - - user_options->hc_argv = hc_argv; - user_options->hc_argc = 2; - user_options->quiet = true; - user_options->potfile_disable = true; - user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3 - user_options->hash_mode = 0; // MD5 - user_options->workload_profile = 3; - - // now run hashcat - - rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); + return 0; } + // now run hashcat + + const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); + + #else + + // this is a bit ugly, but it's the example you're looking for + + char *hash = "8743b52063cd84097a65d1633f5c74f5"; + char *mask = "?l?l?l?l?l?l?l"; + + char *hc_argv[] = { hash, mask, NULL }; + + // initialize the user options with some defaults (you can override them later) + + user_options_init (hashcat_ctx); + + // your own stuff + + user_options_t *user_options = hashcat_ctx->user_options; + + user_options->hc_argv = hc_argv; + user_options->hc_argc = 2; + user_options->quiet = true; + user_options->potfile_disable = true; + user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3 + user_options->hash_mode = 0; // MD5 + user_options->workload_profile = 3; + + // now run hashcat + + const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); + + #endif + // finished with hashcat, clean up hashcat_ctx_destroy (hashcat_ctx); diff --git a/src/potfile.c b/src/potfile.c index d98a1717d..d6940947e 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -762,30 +762,25 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i if (weak_hash_found == 1) myfree (pot_right_ptr); } -int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) +void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - if (potfile_ctx->enabled == false) return 0; + if (potfile_ctx->enabled == false) return; hash_t *hashes_buf = hashes->hashes_buf; - u32 hashes_cnt = hashes->hashes_cnt; + u32 hashes_cnt = hashes->hashes_cnt; // no solution for these special hash types (for instane because they use hashfile in output etc) - if (hashconfig->hash_mode == 5200) - return 0; - - if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) - return 0; - - if (hashconfig->hash_mode == 9000) - return 0; - - if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) - return 0; + if (hashconfig->hash_mode == 5200) return; + if ((hashconfig->hash_mode >= 6200) + && (hashconfig->hash_mode <= 6299)) return; + if (hashconfig->hash_mode == 9000) return; + if ((hashconfig->hash_mode >= 13700) + && (hashconfig->hash_mode <= 13799)) return; hash_t hash_buf; @@ -807,9 +802,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) const int rc = potfile_read_open (hashcat_ctx); - if (rc == -1) return 0; - - int potfile_remove_cracks = 0; + if (rc == -1) return; char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); @@ -946,8 +939,6 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (found == NULL) continue; - if (!found->cracked) potfile_remove_cracks++; - found->cracked = 1; if (found) break; @@ -973,6 +964,4 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } myfree (hash_buf.digest); - - return potfile_remove_cracks; } From d993aa5ffa7143fd1fdd84180f71bb8f3339d5ff Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 7 Oct 2016 22:16:03 +0200 Subject: [PATCH 003/106] Get rid of more log_info() in hashcat() --- include/types.h | 9 ++++++--- src/bitmap.c | 2 -- src/hashcat.c | 12 +++++++++++- src/main.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/include/types.h b/include/types.h index ac01c86a5..4935f8b70 100644 --- a/include/types.h +++ b/include/types.h @@ -90,9 +90,8 @@ typedef enum event_identifier EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023, EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, EVENT_OUTERLOOP_STARTING = 0x00000031, - EVENT_OUTERLOOP_FINISHED = 0x00000032, - EVENT_OUTERLOOP_MAINSCREEN = 0x00000033, - EVENT_OUTERLOOP_WEAK_HASH = 0x00000034, + EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, + EVENT_OUTERLOOP_FINISHED = 0x00000033, EVENT_INNERLOOP1_STARTING = 0x00000041, EVENT_INNERLOOP1_FINISHED = 0x00000042, EVENT_INNERLOOP2_STARTING = 0x00000051, @@ -109,6 +108,10 @@ typedef enum event_identifier EVENT_POTFILE_ALL_CRACKED = 0x00000063, EVENT_OPENCL_SESSION_PRE = 0x00000071, EVENT_OPENCL_SESSION_POST = 0x00000072, + EVENT_BITMAP_INIT_PRE = 0x00000081, + EVENT_BITMAP_INIT_POST = 0x00000082, + EVENT_WEAK_HASH_PRE = 0x00000091, + EVENT_WEAK_HASH_POST = 0x00000092, // there will be much more event types soon diff --git a/src/bitmap.c b/src/bitmap.c index abb5c9c1a..a66bf5e9a 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -94,8 +94,6 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++) { - if (user_options->quiet == false) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits); - bitmap_nums = 1u << bitmap_bits; bitmap_mask = bitmap_nums - 1; diff --git a/src/hashcat.c b/src/hashcat.c index 7faf17978..e5c6ef5f7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -392,6 +392,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) * loop through wordlists */ + EVENT_SEND (EVENT_INNERLOOP2_STARTING); + restore_data_t *rd = restore_ctx->rd; if (straight_ctx->dicts_cnt) @@ -416,6 +418,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) if (rc_inner2_loop == -1) return -1; } + EVENT_SEND (EVENT_INNERLOOP2_FINISHED); + return 0; } @@ -551,8 +555,12 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * bitmaps */ + EVENT_SEND (EVENT_BITMAP_INIT_PRE); + bitmap_ctx_init (hashcat_ctx); + EVENT_SEND (EVENT_BITMAP_INIT_POST); + /** * cracks-per-time allocate buffer */ @@ -666,12 +674,14 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) break; } - EVENT_SEND (EVENT_OUTERLOOP_WEAK_HASH); + EVENT_SEND (EVENT_WEAK_HASH_PRE); for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { weak_hash_check (hashcat_ctx, device_param, salt_pos); } + + EVENT_SEND (EVENT_WEAK_HASH_POST); } /** diff --git a/src/main.c b/src/main.c index 75440bbfd..19bb43ce3 100644 --- a/src/main.c +++ b/src/main.c @@ -413,12 +413,12 @@ static int event_opencl_session_post (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == true) return 0; - log_info_nn (""); + log_info_nn ("Initialized device kernels and memory..."); return 0; } -static int event_outerloop_weak_hash (hashcat_ctx_t *hashcat_ctx) +static int event_weak_hash_pre (hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -429,6 +429,40 @@ static int event_outerloop_weak_hash (hashcat_ctx_t *hashcat_ctx) return 0; } +static int event_weak_hash_post (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Checked for weak hashes..."); + + return 0; +} + +static int event_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Generating bitmap tables..."); + + return 0; +} + +static int event_bitmap_init_post (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + log_info_nn ("Generated bitmap tables..."); + + return 0; +} + + int event (hashcat_ctx_t *hashcat_ctx, const u32 event) { int rc = 0; @@ -444,7 +478,6 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break; case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break; case EVENT_OUTERLOOP_MAINSCREEN: rc = event_outerloop_mainscreen (hashcat_ctx); break; - case EVENT_OUTERLOOP_WEAK_HASH: rc = event_outerloop_weak_hash (hashcat_ctx); break; case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break; case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break; case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break; @@ -455,6 +488,10 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) case EVENT_POTFILE_ALL_CRACKED: rc = event_potfile_all_cracked (hashcat_ctx); break; case EVENT_OPENCL_SESSION_PRE: rc = event_opencl_session_pre (hashcat_ctx); break; case EVENT_OPENCL_SESSION_POST: rc = event_opencl_session_post (hashcat_ctx); break; + case EVENT_BITMAP_INIT_PRE: rc = event_bitmap_init_pre (hashcat_ctx); break; + case EVENT_BITMAP_INIT_POST: rc = event_bitmap_init_post (hashcat_ctx); break; + case EVENT_WEAK_HASH_PRE: rc = event_weak_hash_pre (hashcat_ctx); break; + case EVENT_WEAK_HASH_POST: rc = event_weak_hash_post (hashcat_ctx); break; } return rc; From f4696940302d7bda94778f89c5fe3c7fe59ecafd Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 7 Oct 2016 22:25:52 +0200 Subject: [PATCH 004/106] Add event_set_kernel_power_final() --- include/types.h | 1 + src/bitmap.c | 1 - src/dispatch.c | 29 +++++++++++++---------------- src/main.c | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/include/types.h b/include/types.h index 4935f8b70..e0ed1c663 100644 --- a/include/types.h +++ b/include/types.h @@ -112,6 +112,7 @@ typedef enum event_identifier EVENT_BITMAP_INIT_POST = 0x00000082, EVENT_WEAK_HASH_PRE = 0x00000091, EVENT_WEAK_HASH_POST = 0x00000092, + EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1, // there will be much more event types soon diff --git a/src/bitmap.c b/src/bitmap.c index a66bf5e9a..0069f0f92 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -6,7 +6,6 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" #include "bitmap.h" static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, const u32 bitmap_size, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d, const u64 collisions_max) diff --git a/src/dispatch.c b/src/dispatch.c index b38dd84a7..361e18fdf 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -35,21 +35,15 @@ #include "shared.h" #include "dispatch.h" -static void set_kernel_power_final (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const u64 kernel_power_final) +static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final) { - if (user_options->quiet == false) - { - clear_prompt (); + EVENT_SEND (EVENT_SET_KERNEL_POWER_FINAL); - //log_info (""); - - log_info ("INFO: approaching final keyspace, workload adjusted"); - log_info (""); - - send_prompt (); - } + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; opencl_ctx->kernel_power_final = kernel_power_final; + + return 0; } static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param) @@ -72,8 +66,12 @@ static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param) return device_param->kernel_power; } -static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const user_options_t *user_options, hc_device_param_t *device_param, const u64 max) +static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 max) { + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + hc_thread_mutex_lock (status_ctx->mux_dispatcher); const u64 words_cur = status_ctx->words_cur; @@ -89,7 +87,7 @@ static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const u { if (opencl_ctx->kernel_power_final == 0) { - set_kernel_power_final (opencl_ctx, user_options, words_left); + set_kernel_power_final (hashcat_ctx, words_left); } } @@ -255,7 +253,6 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) hashes_t *hashes = hashcat_ctx->hashes; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const u32 attack_mode = user_options->attack_mode; @@ -265,7 +262,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { while (status_ctx->run_thread_level1 == true) { - const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, -1u); + const u32 work = get_work (hashcat_ctx, device_param, -1u); if (work == 0) break; @@ -407,7 +404,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) while (max) { - const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, max); + const u32 work = get_work (hashcat_ctx, device_param, max); if (work == 0) break; diff --git a/src/main.c b/src/main.c index 19bb43ce3..d3aee33d1 100644 --- a/src/main.c +++ b/src/main.c @@ -462,6 +462,21 @@ static int event_bitmap_init_post (hashcat_ctx_t *hashcat_ctx) return 0; } +static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + clear_prompt (); + + log_info ("INFO: approaching final keyspace, workload adjusted"); + log_info (""); + + send_prompt (); + + return 0; +} int event (hashcat_ctx_t *hashcat_ctx, const u32 event) { @@ -492,6 +507,8 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) case EVENT_BITMAP_INIT_POST: rc = event_bitmap_init_post (hashcat_ctx); break; case EVENT_WEAK_HASH_PRE: rc = event_weak_hash_pre (hashcat_ctx); break; case EVENT_WEAK_HASH_POST: rc = event_weak_hash_post (hashcat_ctx); break; + case EVENT_SET_KERNEL_POWER_FINAL: rc = event_set_kernel_power_final (hashcat_ctx); break; + } return rc; From 42677df2a603ae81a1159bd26e05aacd36575033 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:16:40 +0200 Subject: [PATCH 005/106] Start context-related logging with goal to get rid of logging.c --- include/event.h | 28 +++ include/hashcat.h | 2 +- include/shared.h | 2 - include/types.h | 14 +- src/Makefile | 2 +- src/dispatch.c | 10 +- src/event.c | 205 ++++++++++++++++++ src/hashcat.c | 80 ++++--- src/main.c | 255 ++++++++++++++--------- src/opencl.c | 519 +++++++++++++++++++++++----------------------- 10 files changed, 720 insertions(+), 397 deletions(-) create mode 100644 include/event.h create mode 100644 src/event.c diff --git a/include/event.h b/include/event.h new file mode 100644 index 000000000..f3c8d42f9 --- /dev/null +++ b/include/event.h @@ -0,0 +1,28 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _EVENT_H +#define _EVENT_H + +#include +#include + +int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len); + +#define EVENT(id) { const int rc_event = event_call ((id), hashcat_ctx, NULL, 0); if (rc_event == -1) return -1; } +#define EVENT_DATA(id,buf,len) { const int rc_event = event_call ((id), hashcat_ctx, (buf), (len)); if (rc_event == -1) return -1; } + +size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); + +size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); + +int event_ctx_init (hashcat_ctx_t *hashcat_ctx); +void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx); + +#endif // _EVENT_H diff --git a/include/hashcat.h b/include/hashcat.h index b4cd4e905..0e01c74d6 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -8,7 +8,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t *, const u32)); +void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)); void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _HASHCAT_H diff --git a/include/shared.h b/include/shared.h index 9d9b518d2..9971466f1 100644 --- a/include/shared.h +++ b/include/shared.h @@ -12,8 +12,6 @@ #include #include -#define EVENT_SEND(id) { const int rc_event = hashcat_ctx->event (hashcat_ctx, (id)); if (rc_event == -1) return -1; } - bool is_power_of_2 (const u32 v); u32 get_random_num (const u32 min, const u32 max); diff --git a/include/types.h b/include/types.h index e0ed1c663..0aa060ebc 100644 --- a/include/types.h +++ b/include/types.h @@ -83,6 +83,9 @@ typedef struct stat64 hc_stat; typedef enum event_identifier { + EVENT_LOG_INFO = 0x00000001, + EVENT_LOG_WARNING = 0x00000002, + EVENT_LOG_ERROR = 0x00000003, EVENT_WELCOME_SCREEN = 0x00000011, EVENT_GOODBYE_SCREEN = 0x00000012, EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021, @@ -1397,6 +1400,14 @@ typedef struct hashcat_user } hashcat_user_t; +typedef struct event_ctx +{ + int last_len; + + hc_thread_mutex_t mux_event; + +} event_ctx_t; + typedef struct hashcat_ctx { bitmap_ctx_t *bitmap_ctx; @@ -1404,6 +1415,7 @@ typedef struct hashcat_ctx cpt_ctx_t *cpt_ctx; debugfile_ctx_t *debugfile_ctx; dictstat_ctx_t *dictstat_ctx; + event_ctx_t *event_ctx; folder_config_t *folder_config; hashcat_user_t *hashcat_user; hashconfig_t *hashconfig; @@ -1425,7 +1437,7 @@ typedef struct hashcat_ctx user_options_t *user_options; wl_data_t *wl_data; - int (*event) (struct hashcat_ctx *, const u32); + int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t); } hashcat_ctx_t; diff --git a/src/Makefile b/src/Makefile index f1dcfc06c..fa3920d78 100644 --- a/src/Makefile +++ b/src/Makefile @@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi ## Objects ## -OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist +OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o) diff --git a/src/dispatch.c b/src/dispatch.c index 361e18fdf..5480c8b23 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -9,7 +9,6 @@ #include "filehandling.h" #include "interface.h" #include "timer.h" -#include "logging.h" #include "ext_OpenCL.h" #include "ext_ADL.h" #include "ext_nvapi.h" @@ -33,11 +32,12 @@ #include "wordlist.h" #include "status.h" #include "shared.h" +#include "event.h" #include "dispatch.h" static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final) { - EVENT_SEND (EVENT_SET_KERNEL_POWER_FINAL); + EVENT (EVENT_SET_KERNEL_POWER_FINAL); opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; @@ -314,7 +314,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (fd == NULL) { - log_error ("ERROR: %s: %s", dictfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile, strerror (errno)); return; } @@ -331,7 +331,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (combs_fp == NULL) { - log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); fclose (fd); @@ -348,7 +348,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (combs_fp == NULL) { - log_error ("ERROR: %s: %s", dictfilec, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfilec, strerror (errno)); fclose (fd); diff --git a/src/event.c b/src/event.c new file mode 100644 index 000000000..60a1fd672 --- /dev/null +++ b/src/event.c @@ -0,0 +1,205 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "thread.h" +#include "event.h" + +int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +{ + bool need_mux = true; + + switch (id) + { + case EVENT_LOG_INFO: need_mux = false; + case EVENT_LOG_WARNING: need_mux = false; + case EVENT_LOG_ERROR: need_mux = false; + } + + if (need_mux == true) + { + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + hc_thread_mutex_lock (event_ctx->mux_event); + } + + const int rc = hashcat_ctx->event (id, hashcat_ctx, buf, len); + + if (need_mux == true) + { + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + hc_thread_mutex_unlock (event_ctx->mux_event); + } + + return rc; +} + +static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) +{ + return vsnprintf (s, sz, fmt, ap); +} + +size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len); + + return len; +} + +size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len); + + return len; +} + +size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len); + + return len; +} + +size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + #if defined (_WIN) + + buf[len + 0] = '\r'; + buf[len + 1] = '\n'; + + event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 2); + + #else + + buf[len] = '\n'; + + event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 1); + + #endif + + return len; +} + +size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + #if defined (_WIN) + + buf[len + 0] = '\r'; + buf[len + 1] = '\n'; + + event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 2); + + #else + + buf[len] = '\n'; + + event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 1); + + #endif + + return len; +} + +size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + + char buf[BUFSIZ]; + + const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + + va_end (ap); + + #if defined (_WIN) + + buf[len + 0] = '\r'; + buf[len + 1] = '\n'; + + event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 2); + + #else + + buf[len] = '\n'; + + event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 1); + + #endif + + return len; +} + +int event_ctx_init (hashcat_ctx_t *hashcat_ctx) +{ + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + hc_thread_mutex_init (event_ctx->mux_event); + + event_ctx->last_len = 0; + + return 0; +} + +void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx) +{ + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + hc_thread_mutex_delete (event_ctx->mux_event); + + event_ctx->last_len = 0; +} diff --git a/src/hashcat.c b/src/hashcat.c index e5c6ef5f7..59f0d10c6 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -14,7 +14,6 @@ #include "types.h" #include "folder.h" #include "locking.h" -#include "logging.h" #include "memory.h" #include "shared.h" #include "thread.h" @@ -30,6 +29,7 @@ #include "debugfile.h" #include "dictstat.h" #include "dispatch.h" +#include "event.h" #include "hashes.h" #include "hwmon.h" #include "induct.h" @@ -55,7 +55,7 @@ extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t *, const u32)) +void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)) { if (event == NULL) { @@ -71,6 +71,7 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t * hashcat_ctx->cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t)); hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) mymalloc (sizeof (debugfile_ctx_t)); hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) mymalloc (sizeof (dictstat_ctx_t)); + hashcat_ctx->event_ctx = (event_ctx_t *) mymalloc (sizeof (event_ctx_t)); hashcat_ctx->folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t)); hashcat_ctx->hashcat_user = (hashcat_user_t *) mymalloc (sizeof (hashcat_user_t)); hashcat_ctx->hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t)); @@ -100,6 +101,7 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) myfree (hashcat_ctx->cpt_ctx); myfree (hashcat_ctx->debugfile_ctx); myfree (hashcat_ctx->dictstat_ctx); + myfree (hashcat_ctx->event_ctx); myfree (hashcat_ctx->folder_config); myfree (hashcat_ctx->hashconfig); myfree (hashcat_ctx->hashes); @@ -144,7 +146,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - EVENT_SEND (EVENT_LOGFILE_SUB_INITIALIZE); + EVENT (EVENT_LOGFILE_SUB_INITIALIZE); status_progress_reset (hashcat_ctx); @@ -188,7 +190,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx); - EVENT_SEND (EVENT_CALCULATED_WORDS_BASE); + EVENT (EVENT_CALCULATED_WORDS_BASE); if (user_options->keyspace == true) return 0; @@ -196,7 +198,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->words_cur > status_ctx->words_base) { - log_error ("ERROR: Restore value greater keyspace"); + event_log_error (hashcat_ctx, "ERROR: Restore value greater keyspace"); return -1; } @@ -223,7 +225,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) * create autotune threads */ - EVENT_SEND (EVENT_AUTOTUNE_STARTING); + EVENT (EVENT_AUTOTUNE_STARTING); thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); @@ -243,7 +245,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (opencl_ctx->devices_cnt, c_threads); - EVENT_SEND (EVENT_AUTOTUNE_FINISHED); + EVENT (EVENT_AUTOTUNE_FINISHED); /** * autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all @@ -278,7 +280,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) * create cracker threads */ - EVENT_SEND (EVENT_CRACKER_STARTING); + EVENT (EVENT_CRACKER_STARTING); status_ctx->devices_status = STATUS_RUNNING; @@ -313,7 +315,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_EXHAUSTED; } - EVENT_SEND (EVENT_CRACKER_FINISHED); + EVENT (EVENT_CRACKER_FINISHED); // update some timer @@ -328,7 +330,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) time (&status_ctx->prepare_start); - EVENT_SEND (EVENT_CRACKER_FINAL_STATS); + EVENT (EVENT_CRACKER_FINAL_STATS); // no more skip and restore from here @@ -344,7 +346,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) loopback_write_close (hashcat_ctx); } - EVENT_SEND (EVENT_LOGFILE_SUB_FINALIZE); + EVENT (EVENT_LOGFILE_SUB_FINALIZE); // New induction folder check @@ -392,7 +394,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) * loop through wordlists */ - EVENT_SEND (EVENT_INNERLOOP2_STARTING); + EVENT (EVENT_INNERLOOP2_STARTING); restore_data_t *rd = restore_ctx->rd; @@ -418,7 +420,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) if (rc_inner2_loop == -1) return -1; } - EVENT_SEND (EVENT_INNERLOOP2_FINISHED); + EVENT (EVENT_INNERLOOP2_FINISHED); return 0; } @@ -484,7 +486,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if (hashes->hashes_cnt == 0) { - log_error ("ERROR: No hashes loaded"); + event_log_error (hashcat_ctx, "ERROR: No hashes loaded"); return -1; } @@ -509,7 +511,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_disable == 0) { - EVENT_SEND (EVENT_POTFILE_REMOVE_PARSE); + EVENT (EVENT_POTFILE_REMOVE_PARSE); potfile_remove_parse (hashcat_ctx); } @@ -530,7 +532,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_CRACKED) { - EVENT_SEND (EVENT_POTFILE_ALL_CRACKED); + EVENT (EVENT_POTFILE_ALL_CRACKED); hashes_destroy (hashcat_ctx); @@ -555,11 +557,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * bitmaps */ - EVENT_SEND (EVENT_BITMAP_INIT_PRE); + EVENT (EVENT_BITMAP_INIT_PRE); bitmap_ctx_init (hashcat_ctx); - EVENT_SEND (EVENT_BITMAP_INIT_POST); + EVENT (EVENT_BITMAP_INIT_POST); /** * cracks-per-time allocate buffer @@ -605,7 +607,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1)) { - log_error ("ERROR: --skip/--limit are not supported with --increment or mask files"); + event_log_error (hashcat_ctx, "ERROR: --skip/--limit are not supported with --increment or mask files"); return -1; } @@ -619,7 +621,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1)) { - log_error ("ERROR: --keyspace is not supported with --increment or mask files"); + event_log_error (hashcat_ctx, "ERROR: --keyspace is not supported with --increment or mask files"); return -1; } @@ -637,17 +639,17 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * main screen */ - EVENT_SEND (EVENT_OUTERLOOP_MAINSCREEN); + EVENT (EVENT_OUTERLOOP_MAINSCREEN); /** * inform the user */ - EVENT_SEND (EVENT_OPENCL_SESSION_PRE); + EVENT (EVENT_OPENCL_SESSION_PRE); opencl_session_begin (hashcat_ctx); - EVENT_SEND (EVENT_OPENCL_SESSION_POST); + EVENT (EVENT_OPENCL_SESSION_POST); /** * weak hash check is the first to write to potfile, so open it for writing from here @@ -674,14 +676,14 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) break; } - EVENT_SEND (EVENT_WEAK_HASH_PRE); + EVENT (EVENT_WEAK_HASH_PRE); for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { weak_hash_check (hashcat_ctx, device_param, salt_pos); } - EVENT_SEND (EVENT_WEAK_HASH_POST); + EVENT (EVENT_WEAK_HASH_POST); } /** @@ -716,11 +718,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * Tell user about cracked hashes by potfile */ - EVENT_SEND (EVENT_POTFILE_NUM_CRACKED); + EVENT (EVENT_POTFILE_NUM_CRACKED); // main call - EVENT_SEND (EVENT_INNERLOOP1_STARTING); + EVENT (EVENT_INNERLOOP1_STARTING); if (mask_ctx->masks_cnt) { @@ -762,7 +764,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) myfree (inner_threads); - EVENT_SEND (EVENT_INNERLOOP1_FINISHED); + EVENT (EVENT_INNERLOOP1_FINISHED); // finalize potfile @@ -801,6 +803,14 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; + /** + * event init (needed for logging so should be first) + */ + + const int rc_event_init = event_ctx_init (hashcat_ctx); + + if (rc_event_init == -1) return -1; + /** * status init */ @@ -809,7 +819,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_status_init == -1) return -1; - EVENT_SEND (EVENT_WELCOME_SCREEN); + EVENT (EVENT_WELCOME_SCREEN); /** * folder @@ -837,7 +847,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold // from here all user configuration is pre-processed so we can start logging - EVENT_SEND (EVENT_LOGFILE_TOP_INITIALIZE); + EVENT (EVENT_LOGFILE_TOP_INITIALIZE); /** * To help users a bit @@ -965,7 +975,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold * outer loop */ - EVENT_SEND (EVENT_OUTERLOOP_STARTING); + EVENT (EVENT_OUTERLOOP_STARTING); if (user_options->benchmark == true) { @@ -998,7 +1008,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc == -1) return -1; } - EVENT_SEND (EVENT_OUTERLOOP_FINISHED); + EVENT (EVENT_OUTERLOOP_FINISHED); if (user_options->benchmark == true) { @@ -1046,7 +1056,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_top_uint (status_ctx->proc_start); logfile_top_uint (status_ctx->proc_stop); - EVENT_SEND (EVENT_LOGFILE_TOP_FINALIZE); + EVENT (EVENT_LOGFILE_TOP_FINALIZE); user_options_extra_destroy (hashcat_ctx); @@ -1059,7 +1069,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; - EVENT_SEND (EVENT_GOODBYE_SCREEN); + EVENT (EVENT_GOODBYE_SCREEN); + + event_ctx_destroy (hashcat_ctx); status_ctx_destroy (hashcat_ctx); diff --git a/src/main.c b/src/main.c index d3aee33d1..42e193551 100644 --- a/src/main.c +++ b/src/main.c @@ -19,13 +19,73 @@ #include "memory.h" #include "terminal.h" -#include "logging.h" #include "logfile.h" #include "thread.h" #include "status.h" #include "interface.h" +#include "event.h" -static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" + +static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t len, FILE *fp) +{ + if (len == 0) return; + + // handle last_len + + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + if (event_ctx->last_len) + { + fputc ('\r', fp); + + for (int i = 0; i < event_ctx->last_len; i++) + { + fputc (' ', fp); + } + + fputc ('\r', fp); + } + + if (buf[len - 1] == '\n') + { + event_ctx->last_len = 0; + } + else + { + event_ctx->last_len = len; + } + + // finally, print + + fwrite (buf, len, 1, fp); + + fflush (fp); +} + +static int main_log_info (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +{ + main_log (hashcat_ctx, buf, len, stdout); + + return 0; +} + +static int main_log_warning (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +{ + main_log (hashcat_ctx, buf, len, stdout); + + return 0; +} + +static int main_log_error (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +{ + main_log (hashcat_ctx, buf, len, stderr); + + return 0; +} + +static int main_welcome_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { // sets dos window size (windows only) @@ -40,7 +100,7 @@ static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_goodbye_screen (hashcat_ctx_t *hashcat_ctx) +static int main_goodbye_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { // Inform user we're done @@ -51,7 +111,7 @@ static int event_goodbye_screen (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx) +static int main_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -72,7 +132,7 @@ static int event_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx) +static int main_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -83,7 +143,7 @@ static int event_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx) +static int main_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -94,7 +154,7 @@ static int event_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx) +static int main_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -103,7 +163,7 @@ static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx) +static int main_outerloop_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -136,7 +196,7 @@ static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx) +static int main_outerloop_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -157,7 +217,7 @@ static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) +static int main_cracker_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -175,14 +235,14 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx) } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - log_info ("Starting attack in stdin mode..."); - log_info (""); + event_log_info (hashcat_ctx, "Starting attack in stdin mode..."); + event_log_info (hashcat_ctx, ""); } return 0; } -static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx) +static int main_cracker_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -192,7 +252,7 @@ static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) +static int main_cracker_final_stats (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -205,7 +265,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) if (user_options->machine_readable == false) { - log_info (""); + event_log_info (hashcat_ctx, ""); } } else @@ -214,11 +274,11 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) { clear_prompt (); - if (hashes->digests_saved != hashes->digests_done) log_info (""); + if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - log_info (""); + event_log_info (hashcat_ctx, ""); } else { @@ -226,7 +286,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) { status_display (hashcat_ctx); - log_info (""); + event_log_info (hashcat_ctx, ""); } } } @@ -234,7 +294,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx) +static int main_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -245,31 +305,31 @@ static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx) return 0; } -static int event_calculated_words_base (hashcat_ctx_t *hashcat_ctx) +static int main_calculated_words_base (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->keyspace == true) { - log_info ("%" PRIu64 "", status_ctx->words_base); + event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base); } return 0; } -static int event_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) +static int main_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Comparing hashes with potfile entries..."); + event_log_info (hashcat_ctx, "Comparing hashes with potfile entries..."); return 0; } -static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx) +static int main_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const hashes_t *hashes = hashcat_ctx->hashes; @@ -282,34 +342,34 @@ static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx) { if (potfile_remove_cracks == 1) { - log_info ("INFO: Removed 1 hash found in potfile"); - log_info (""); + event_log_info (hashcat_ctx, "INFO: Removed 1 hash found in potfile"); + event_log_info (hashcat_ctx, ""); } else { - log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks); - log_info (""); + event_log_info (hashcat_ctx, "INFO: Removed %d hashes found in potfile", potfile_remove_cracks); + event_log_info (hashcat_ctx, ""); } } return 0; } -static int event_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx) +static int main_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info ("INFO: All hashes found in potfile! You can use --show to display them."); - log_info (""); - log_info ("INFO: No more hashes left to crack, exiting..."); - log_info (""); + event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them."); + event_log_info (hashcat_ctx, ""); + event_log_info (hashcat_ctx, "INFO: No more hashes left to crack, exiting..."); + event_log_info (hashcat_ctx, ""); return 0; } -static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx) +static int main_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -328,37 +388,36 @@ static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx) { char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - log_info ("Hashtype: %s", hash_type); - log_info (""); + event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); + event_log_info (hashcat_ctx, ""); } } if (user_options->quiet == true) return 0; - log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - - log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - log_info ("Rules: %u", straight_ctx->kernel_rules_cnt); + event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); } - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); if (hashconfig->opti_type) { - log_info ("Applicable Optimizers:"); + event_log_info (hashcat_ctx, "Applicable Optimizers:"); for (u32 i = 0; i < 32; i++) { const u32 opti_bit = 1u << i; - if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit)); + if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); } } - log_info (""); + event_log_info (hashcat_ctx, ""); /** * Watchdog and Temperature balance @@ -366,103 +425,103 @@ static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx) if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) { - log_info ("Watchdog: Hardware Monitoring Interface not found on your system"); + event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) { - log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); } else { - log_info ("Watchdog: Temperature abort trigger disabled"); + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) { - log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); } else { - log_info ("Watchdog: Temperature retain trigger disabled"); + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); } - log_info (""); + event_log_info (hashcat_ctx, ""); #if defined (DEBUG) - if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode); + if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); #endif return 0; } -static int event_opencl_session_pre (hashcat_ctx_t *hashcat_ctx) +static int main_opencl_session_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Initializing device kernels and memory..."); + event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory..."); return 0; } -static int event_opencl_session_post (hashcat_ctx_t *hashcat_ctx) +static int main_opencl_session_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Initialized device kernels and memory..."); + event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory..."); return 0; } -static int event_weak_hash_pre (hashcat_ctx_t *hashcat_ctx) +static int main_weak_hash_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Checking for weak hashes..."); + event_log_info_nn (hashcat_ctx, "Checking for weak hashes..."); return 0; } -static int event_weak_hash_post (hashcat_ctx_t *hashcat_ctx) +static int main_weak_hash_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Checked for weak hashes..."); + event_log_info_nn (hashcat_ctx, "Checked for weak hashes..."); return 0; } -static int event_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx) +static int main_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Generating bitmap tables..."); + event_log_info_nn (hashcat_ctx, "Generating bitmap tables..."); return 0; } -static int event_bitmap_init_post (hashcat_ctx_t *hashcat_ctx) +static int main_bitmap_init_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->quiet == true) return 0; - log_info_nn ("Generated bitmap tables..."); + event_log_info_nn (hashcat_ctx, "Generated bitmap tables..."); return 0; } -static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx) +static int main_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -470,45 +529,47 @@ static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx) clear_prompt (); - log_info ("INFO: approaching final keyspace, workload adjusted"); - log_info (""); + event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted"); + event_log_info (hashcat_ctx, ""); send_prompt (); return 0; } -int event (hashcat_ctx_t *hashcat_ctx, const u32 event) +int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { int rc = 0; - switch (event) + switch (id) { - case EVENT_WELCOME_SCREEN: rc = event_welcome_screen (hashcat_ctx); break; - case EVENT_GOODBYE_SCREEN: rc = event_goodbye_screen (hashcat_ctx); break; - case EVENT_LOGFILE_TOP_INITIALIZE: rc = event_logfile_top_initialize (hashcat_ctx); break; - case EVENT_LOGFILE_TOP_FINALIZE: rc = event_logfile_top_finalize (hashcat_ctx); break; - case EVENT_LOGFILE_SUB_INITIALIZE: rc = event_logfile_sub_initialize (hashcat_ctx); break; - case EVENT_LOGFILE_SUB_FINALIZE: rc = event_logfile_sub_finalize (hashcat_ctx); break; - case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break; - case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break; - case EVENT_OUTERLOOP_MAINSCREEN: rc = event_outerloop_mainscreen (hashcat_ctx); break; - case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break; - case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break; - case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break; - case EVENT_CRACKER_HASH_CRACKED: rc = event_cracker_hash_cracked (hashcat_ctx); break; - case EVENT_CALCULATED_WORDS_BASE: rc = event_calculated_words_base (hashcat_ctx); break; - case EVENT_POTFILE_REMOVE_PARSE: rc = event_potfile_remove_parse (hashcat_ctx); break; - case EVENT_POTFILE_NUM_CRACKED: rc = event_potfile_num_cracked (hashcat_ctx); break; - case EVENT_POTFILE_ALL_CRACKED: rc = event_potfile_all_cracked (hashcat_ctx); break; - case EVENT_OPENCL_SESSION_PRE: rc = event_opencl_session_pre (hashcat_ctx); break; - case EVENT_OPENCL_SESSION_POST: rc = event_opencl_session_post (hashcat_ctx); break; - case EVENT_BITMAP_INIT_PRE: rc = event_bitmap_init_pre (hashcat_ctx); break; - case EVENT_BITMAP_INIT_POST: rc = event_bitmap_init_post (hashcat_ctx); break; - case EVENT_WEAK_HASH_PRE: rc = event_weak_hash_pre (hashcat_ctx); break; - case EVENT_WEAK_HASH_POST: rc = event_weak_hash_post (hashcat_ctx); break; - case EVENT_SET_KERNEL_POWER_FINAL: rc = event_set_kernel_power_final (hashcat_ctx); break; - + case EVENT_LOG_INFO: rc = main_log_info (hashcat_ctx, buf, len); break; + case EVENT_LOG_WARNING: rc = main_log_warning (hashcat_ctx, buf, len); break; + case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break; + case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break; + case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_FINAL_STATS: rc = main_cracker_final_stats (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break; + case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_REMOVE_PARSE: rc = main_potfile_remove_parse (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_NUM_CRACKED: rc = main_potfile_num_cracked (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_ALL_CRACKED: rc = main_potfile_all_cracked (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_PRE: rc = main_opencl_session_pre (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_POST: rc = main_opencl_session_post (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_PRE: rc = main_bitmap_init_pre (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_POST: rc = main_bitmap_init_post (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_PRE: rc = main_weak_hash_pre (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_POST: rc = main_weak_hash_post (hashcat_ctx, buf, len); break; + case EVENT_SET_KERNEL_POWER_FINAL: rc = main_set_kernel_power_final (hashcat_ctx, buf, len); break; } return rc; @@ -516,13 +577,11 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) #else -int event (hashcat_ctx_t *hashcat_ctx, const u32 event) +int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; - int rc = 0; - switch (event) + switch (id) { } @@ -531,6 +590,8 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event) #endif +#pragma GCC diagnostic pop + int main (int argc, char **argv) { // hashcat main context diff --git a/src/opencl.c b/src/opencl.c index 94e127480..956518c19 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -6,7 +6,6 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" #include "locking.h" #include "thread.h" #include "timer.h" @@ -24,6 +23,7 @@ #include "shared.h" #include "hashes.h" #include "cpu_md5.h" +#include "event.h" #include "opencl.h" static const u32 full01 = 0x01010101; @@ -97,7 +97,7 @@ static void generate_cached_kernel_amp_filename (const u32 attack_kern, char *pr snprintf (cached_file, 255, "%s/kernels/amp_a%d.%s.kernel", profile_dir, attack_kern, device_name_chksum); } -static u32 setup_opencl_platforms_filter (const char *opencl_platforms) +static u32 setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_platforms) { u32 opencl_platforms_filter = 0; @@ -113,7 +113,7 @@ static u32 setup_opencl_platforms_filter (const char *opencl_platforms) if (platform < 1 || platform > 32) { - log_error ("ERROR: Invalid OpenCL platform %u specified", platform); + event_log_error (hashcat_ctx, "ERROR: Invalid OpenCL platform %u specified", platform); exit (-1); } @@ -132,7 +132,7 @@ static u32 setup_opencl_platforms_filter (const char *opencl_platforms) return opencl_platforms_filter; } -static u32 setup_devices_filter (const char *opencl_devices) +static u32 setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_devices) { u32 devices_filter = 0; @@ -148,7 +148,7 @@ static u32 setup_devices_filter (const char *opencl_devices) if (device_id < 1 || device_id > 32) { - log_error ("ERROR: Invalid device_id %u specified", device_id); + event_log_error (hashcat_ctx, "ERROR: Invalid device_id %u specified", device_id); exit (-1); } @@ -167,7 +167,7 @@ static u32 setup_devices_filter (const char *opencl_devices) return devices_filter; } -static cl_device_type setup_device_types_filter (const char *opencl_device_types) +static cl_device_type setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_device_types) { cl_device_type device_types_filter = 0; @@ -183,7 +183,7 @@ static cl_device_type setup_device_types_filter (const char *opencl_device_types if (device_type < 1 || device_type > 3) { - log_error ("ERROR: Invalid device_type %u specified", device_type); + event_log_error (hashcat_ctx, "ERROR: Invalid device_type %u specified", device_type); exit (-1); } @@ -205,7 +205,7 @@ static cl_device_type setup_device_types_filter (const char *opencl_device_types return device_types_filter; } -static void read_kernel_binary (const char *kernel_file, int num_devices, size_t *kernel_lengths, char **kernel_sources) +static void read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, int num_devices, size_t *kernel_lengths, char **kernel_sources) { FILE *fp = fopen (kernel_file, "rb"); @@ -223,7 +223,7 @@ static void read_kernel_binary (const char *kernel_file, int num_devices, size_t if (num_read != (size_t) st.st_size) { - log_error ("ERROR: %s: %s", kernel_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); exit (-1); } @@ -241,7 +241,7 @@ static void read_kernel_binary (const char *kernel_file, int num_devices, size_t } else { - log_error ("ERROR: %s: %s", kernel_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); exit (-1); } @@ -249,11 +249,18 @@ static void read_kernel_binary (const char *kernel_file, int num_devices, size_t return; } -static void write_kernel_binary (char *dst, char *binary, size_t binary_size) +static void write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, char *binary, size_t binary_size) { if (binary_size > 0) { - FILE *fp = fopen (dst, "wb"); + FILE *fp = fopen (kernel_file, "wb"); + + if (fp == NULL) + { + event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); + + exit (-1); + } lock_file (fp); fwrite (binary, sizeof (char), binary_size, fp); @@ -271,7 +278,7 @@ int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, c if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -312,7 +319,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -346,7 +353,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -357,7 +364,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -410,7 +417,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -421,7 +428,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -475,7 +482,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -491,7 +498,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -515,7 +522,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -525,7 +532,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -550,7 +557,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clWaitForEvents(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clWaitForEvents(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -563,7 +570,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetEventProfilingInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetEventProfilingInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -603,7 +610,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clReleaseEvent(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clReleaseEvent(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -612,7 +619,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -679,7 +686,7 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -691,7 +698,7 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -700,7 +707,7 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -709,7 +716,7 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -736,7 +743,7 @@ int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -745,7 +752,7 @@ int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -754,7 +761,7 @@ int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -785,7 +792,7 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -797,7 +804,7 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -806,7 +813,7 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -815,7 +822,7 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -851,7 +858,7 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -863,7 +870,7 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -872,7 +879,7 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -881,7 +888,7 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -900,7 +907,7 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -930,7 +937,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -995,7 +1002,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1249,7 +1256,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1260,7 +1267,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1271,7 +1278,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1282,7 +1289,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1293,7 +1300,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1407,7 +1414,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL platform selection */ - u32 opencl_platforms_filter = setup_opencl_platforms_filter (user_options->opencl_platforms); + u32 opencl_platforms_filter = setup_opencl_platforms_filter (hashcat_ctx, user_options->opencl_platforms); opencl_ctx->opencl_platforms_filter = opencl_platforms_filter; @@ -1415,7 +1422,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL device selection */ - u32 devices_filter = setup_devices_filter (user_options->opencl_devices); + u32 devices_filter = setup_devices_filter (hashcat_ctx, user_options->opencl_devices); opencl_ctx->devices_filter = devices_filter; @@ -1423,7 +1430,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL device type selection */ - cl_device_type device_types_filter = setup_device_types_filter (user_options->opencl_device_types); + cl_device_type device_types_filter = setup_device_types_filter (hashcat_ctx, user_options->opencl_device_types); opencl_ctx->device_types_filter = device_types_filter; @@ -1440,20 +1447,20 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetPlatformIDs(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetPlatformIDs(): %s\n", val2cstr_cl (CL_err)); return -1; } if (platforms_cnt == 0) { - log_info ("ATTENTION! No OpenCL compatible platform found"); - log_info (""); - log_info ("You're probably missing the OpenCL runtime installation"); - log_info (" AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); - log_info (" Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); - log_info (" NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); - log_info (""); + event_log_info (hashcat_ctx, "ATTENTION! No OpenCL compatible platform found"); + event_log_info (hashcat_ctx, ""); + event_log_info (hashcat_ctx, "You're probably missing the OpenCL runtime installation"); + event_log_info (hashcat_ctx, " AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); + event_log_info (hashcat_ctx, " Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); + event_log_info (hashcat_ctx, " NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); + event_log_info (hashcat_ctx, ""); return -1; } @@ -1464,7 +1471,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (opencl_platforms_filter > platform_cnt_mask) { - log_error ("ERROR: The platform selected by the --opencl-platforms parameter is larger than the number of available platforms (%d)", platforms_cnt); + event_log_error (hashcat_ctx, "ERROR: The platform selected by the --opencl-platforms parameter is larger than the number of available platforms (%d)", platforms_cnt); return -1; } @@ -1489,7 +1496,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - //log_error ("ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); + //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); //return -1; @@ -1508,7 +1515,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1609,7 +1616,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1663,7 +1670,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - //log_error ("ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); + //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); //return -1; @@ -1678,7 +1685,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1689,7 +1696,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1703,23 +1710,23 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (platform_skipped == 0) { - const int len = log_info ("OpenCL Platform #%u: %s", platform_id + 1, platform_vendor); + const int len = event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s", platform_id + 1, platform_vendor); char line[256] = { 0 }; for (int i = 0; i < len; i++) line[i] = '='; - log_info (line); + event_log_info (hashcat_ctx, line); } else if (platform_skipped == 1) { - log_info ("OpenCL Platform #%u: %s, skipped", platform_id + 1, platform_vendor); - log_info (""); + event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s, skipped", platform_id + 1, platform_vendor); + event_log_info (hashcat_ctx, ""); } else if (platform_skipped == 2) { - log_info ("OpenCL Platform #%u: %s, skipped! No OpenCL compatible devices found", platform_id + 1, platform_vendor); - log_info (""); + event_log_info (hashcat_ctx, "OpenCL Platform #%u: %s, skipped! No OpenCL compatible devices found", platform_id + 1, platform_vendor); + event_log_info (hashcat_ctx, ""); } } } @@ -1755,7 +1762,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1770,7 +1777,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1781,7 +1788,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1794,7 +1801,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1805,7 +1812,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1859,7 +1866,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1870,7 +1877,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1883,7 +1890,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1894,7 +1901,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1909,7 +1916,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1925,7 +1932,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1940,7 +1947,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1955,7 +1962,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1970,7 +1977,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -1985,14 +1992,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if (device_endian_little == CL_FALSE) { - log_info ("- Device #%u: WARNING: Not a little endian device", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Not a little endian device", device_id + 1); device_param->skipped = 1; } @@ -2005,14 +2012,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if (device_available == CL_FALSE) { - log_info ("- Device #%u: WARNING: Device not available", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device not available", device_id + 1); device_param->skipped = 1; } @@ -2025,14 +2032,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if (device_compiler_available == CL_FALSE) { - log_info ("- Device #%u: WARNING: No compiler available for device", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: No compiler available for device", device_id + 1); device_param->skipped = 1; } @@ -2045,14 +2052,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if ((device_execution_capabilities & CL_EXEC_KERNEL) == 0) { - log_info ("- Device #%u: WARNING: Device does not support executing kernels", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support executing kernels", device_id + 1); device_param->skipped = 1; } @@ -2065,7 +2072,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2076,21 +2083,21 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if (strstr (device_extensions, "base_atomics") == 0) { - log_info ("- Device #%u: WARNING: Device does not support base atomics", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support base atomics", device_id + 1); device_param->skipped = 1; } if (strstr (device_extensions, "byte_addressable_store") == 0) { - log_info ("- Device #%u: WARNING: Device does not support byte addressable store", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support byte addressable store", device_id + 1); device_param->skipped = 1; } @@ -2105,14 +2112,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } if (device_local_mem_size < 32768) { - log_info ("- Device #%u: WARNING: Device local mem size is too small", device_id + 1); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device local mem size is too small", device_id + 1); device_param->skipped = 1; } @@ -2129,8 +2136,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - log_info ("- Device #%u: WARNING: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); - log_info (" You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, "- Device #%u: WARNING: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); + event_log_info (hashcat_ctx, " You can use --force to override this but do not post error reports if you do so"); device_param->skipped = 1; } @@ -2148,7 +2155,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2159,7 +2166,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2219,7 +2226,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2236,7 +2243,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2245,7 +2252,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2304,7 +2311,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->skipped == 0) { - log_info ("- Device #%u: %s, %lu/%lu MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "- Device #%u: %s, %lu/%lu MB allocatable, %uMCU", device_id + 1, device_name, (unsigned int) (device_maxmem_alloc / 1024 / 1024), @@ -2313,7 +2320,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } else { - log_info ("- Device #%u: %s, skipped", + event_log_info (hashcat_ctx, "- Device #%u: %s, skipped", device_id + 1, device_name); } @@ -2349,25 +2356,25 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (catalyst_broken == 1) { - log_info ("ATTENTION! The Catalyst driver installed on your system is known to be broken!"); - log_info ("It passes over cracked hashes and will not report them as cracked"); - log_info ("You are STRONGLY encouraged not to use it"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); + event_log_info (hashcat_ctx, "ATTENTION! The Catalyst driver installed on your system is known to be broken!"); + event_log_info (hashcat_ctx, "It passes over cracked hashes and will not report them as cracked"); + event_log_info (hashcat_ctx, "You are STRONGLY encouraged not to use it"); + event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, ""); return -1; } if (catalyst_warn == 1) { - log_info ("ATTENTION! Unsupported or incorrectly installed Catalyst driver detected!"); - log_info ("You are STRONGLY encouraged to use the official supported catalyst driver"); - log_info ("See hashcat's homepage for official supported catalyst drivers"); + event_log_info (hashcat_ctx, "ATTENTION! Unsupported or incorrectly installed Catalyst driver detected!"); + event_log_info (hashcat_ctx, "You are STRONGLY encouraged to use the official supported catalyst driver"); + event_log_info (hashcat_ctx, "See hashcat's homepage for official supported catalyst drivers"); #if defined (_WIN) - log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); + event_log_info (hashcat_ctx, "Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); #endif - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); + event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, ""); return -1; } @@ -2376,8 +2383,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->kernel_exec_timeout != 0) { - log_info ("- Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); - log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); + event_log_info (hashcat_ctx, "- Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); + event_log_info (hashcat_ctx, " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); } } } @@ -2389,11 +2396,11 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - log_info ("ATTENTION! OpenCL support for CPU of catalyst driver is not reliable."); - log_info ("You are STRONGLY encouraged not to use it"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info ("A good alternative is the free pocl >= v0.13, but make sure to use a LLVM >= v3.8"); - log_info (""); + event_log_info (hashcat_ctx, "ATTENTION! OpenCL support for CPU of catalyst driver is not reliable."); + event_log_info (hashcat_ctx, "You are STRONGLY encouraged not to use it"); + event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, "A good alternative is the free pocl >= v0.13, but make sure to use a LLVM >= v3.8"); + event_log_info (hashcat_ctx, ""); return -1; } @@ -2417,7 +2424,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->machine_readable == false) { - log_info (""); + event_log_info (hashcat_ctx, ""); } } } @@ -2429,7 +2436,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (devices_active == 0) { - log_error ("ERROR: No devices found/left"); + event_log_error (hashcat_ctx, "ERROR: No devices found/left"); return -1; } @@ -2442,7 +2449,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (opencl_ctx->devices_filter > devices_cnt_mask) { - log_error ("ERROR: The device specified by the --opencl-devices parameter is larger than the number of available devices (%d)", devices_cnt); + event_log_error (hashcat_ctx, "ERROR: The device specified by the --opencl-devices parameter is larger than the number of available devices (%d)", devices_cnt); return -1; } @@ -2520,12 +2527,12 @@ void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) { clear_prompt (); - log_info ("ATTENTION!"); - log_info (" The wordlist or mask you are using is too small."); - log_info (" Therefore, hashcat is unable to utilize the full parallelization power of your device(s)."); - log_info (" The cracking speed will drop."); - log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed"); - log_info (""); + event_log_info (hashcat_ctx, "ATTENTION!"); + event_log_info (hashcat_ctx, " The wordlist or mask you are using is too small."); + event_log_info (hashcat_ctx, " Therefore, hashcat is unable to utilize the full parallelization power of your device(s)."); + event_log_info (hashcat_ctx, " The cracking speed will drop."); + event_log_info (hashcat_ctx, " Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed"); + event_log_info (hashcat_ctx, ""); } } } @@ -2637,7 +2644,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2648,7 +2655,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2743,7 +2750,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateContext(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateContext(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2759,7 +2766,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateCommandQueue(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateCommandQueue(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -2831,7 +2838,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) || (hashes->salts_buf[i].scrypt_r != scrypt_r) || (hashes->salts_buf[i].scrypt_p != scrypt_p)) { - log_error ("ERROR: Mixed scrypt settings not supported"); + event_log_error (hashcat_ctx, "ERROR: Mixed scrypt settings not supported"); return -1; } @@ -2892,14 +2899,14 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if ((size_scrypt / 4) > device_param->device_maxmem_alloc) { - log_info ("WARNING: Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_info (hashcat_ctx, "WARNING: Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } if (size_scrypt > device_param->device_global_mem) { - log_info ("WARNING: Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_info (hashcat_ctx, "WARNING: Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } @@ -2914,12 +2921,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (tmto == tmto_stop) { - log_error ("ERROR: Can't allocate enough device memory"); + event_log_error (hashcat_ctx, "ERROR: Can't allocate enough device memory"); return -1; } - if (user_options->quiet == false) log_info ("SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64 "\n", scrypt_tmto_final, size_scrypt); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64 "\n", scrypt_tmto_final, size_scrypt); } size_t size_scrypt4 = size_scrypt / 4; @@ -3015,7 +3022,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (kernel_accel_max < kernel_accel_min) { - log_error ("- Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); + event_log_error (hashcat_ctx, "- Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); return -1; } @@ -3026,7 +3033,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) /* if (kernel_accel_max < kernel_accel) { - if (user_options->quiet == false) log_info ("- Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); device_param->kernel_accel = kernel_accel_max; } @@ -3046,7 +3053,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (chdir (folder_config->cpath_real) == -1) { - log_error ("ERROR: %s: %s", folder_config->cpath_real, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", folder_config->cpath_real, strerror (errno)); return -1; } @@ -3090,7 +3097,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (fd == NULL) { - log_error ("ERROR: %s: fopen(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: fopen(): %s", files_names[i], strerror (errno)); return -1; } @@ -3101,7 +3108,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (n != 1) { - log_error ("ERROR: %s: fread(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: fread(): %s", files_names[i], strerror (errno)); return -1; } @@ -3122,7 +3129,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) strncpy (build_opts, build_opts_new, sizeof (build_opts)); #if defined (DEBUG) - log_info ("- Device #%u: build_opts '%s'\n", device_id + 1, build_opts); + event_log_info (hashcat_ctx, "- Device #%u: build_opts '%s'\n", device_id + 1, build_opts); #endif /** @@ -3142,7 +3149,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - log_error ("ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); return -1; } @@ -3176,15 +3183,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (cached == 0) { - if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - read_kernel_binary (source_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3193,7 +3200,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); //return -1; } @@ -3205,7 +3212,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3225,7 +3232,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3239,7 +3246,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - log_info ("- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3250,7 +3257,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3261,28 +3268,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } - write_kernel_binary (cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); myfree (binary); } else { #if defined (DEBUG) - log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (cached_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3291,7 +3298,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3300,16 +3307,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) else { #if defined (DEBUG) - log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size); #endif - read_kernel_binary (source_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3333,7 +3340,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); //return -1; } @@ -3345,7 +3352,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3365,7 +3372,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3379,7 +3386,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - log_info ("- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); } } @@ -3406,7 +3413,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - log_error ("ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); return -1; } @@ -3438,16 +3445,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - read_kernel_binary (source_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_mp); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3456,7 +3463,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); //return -1; } @@ -3468,7 +3475,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3488,7 +3495,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3502,7 +3509,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - log_info ("- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3513,7 +3520,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3524,28 +3531,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } - write_kernel_binary (cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); myfree (binary); } else { #if defined (DEBUG) - log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (cached_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_mp); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3554,7 +3561,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3587,7 +3594,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - log_error ("ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); return -1; } @@ -3619,16 +3626,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - read_kernel_binary (source_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_amp); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3637,7 +3644,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); //return -1; } @@ -3649,7 +3656,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3669,7 +3676,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3683,7 +3690,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - log_info ("- Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); + event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); continue; } @@ -3694,7 +3701,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3705,28 +3712,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } - write_kernel_binary (cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); myfree (binary); } else { #if defined (DEBUG) - if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (cached_file, 1, kernel_lengths, kernel_sources); + read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_amp); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3735,7 +3742,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3750,7 +3757,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (chdir (folder_config->cwd) == -1) { - log_error ("ERROR: %s: %s", folder_config->cwd, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", folder_config->cwd, strerror (errno)); return -1; } @@ -3793,7 +3800,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3812,7 +3819,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3828,7 +3835,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3837,7 +3844,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3851,7 +3858,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3866,7 +3873,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3878,7 +3885,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -3887,7 +3894,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4055,7 +4062,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4066,7 +4073,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4077,7 +4084,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4090,7 +4097,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4101,7 +4108,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4112,7 +4119,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4128,7 +4135,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4137,7 +4144,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4152,7 +4159,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4163,7 +4170,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4174,7 +4181,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4187,7 +4194,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4196,7 +4203,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4210,7 +4217,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4219,7 +4226,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4232,7 +4239,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4248,7 +4255,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4265,7 +4272,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4277,7 +4284,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4286,7 +4293,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4297,7 +4304,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4311,7 +4318,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4321,7 +4328,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4333,7 +4340,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4345,7 +4352,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4354,7 +4361,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4365,7 +4372,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4374,7 +4381,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4390,7 +4397,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4399,7 +4406,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4417,7 +4424,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4429,7 +4436,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4502,7 +4509,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4527,7 +4534,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4611,7 +4618,7 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: hc_clReleaseContext(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: hc_clReleaseContext(): %s\n", val2cstr_cl (CL_err)); } device_param->pws_buf = NULL; @@ -4737,7 +4744,7 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4752,7 +4759,7 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4785,7 +4792,7 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4795,7 +4802,7 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4834,7 +4841,7 @@ int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -4844,7 +4851,7 @@ int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } From 88565b4a5e3b162f5e891bb55e6b58f48f55080a Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:38:34 +0200 Subject: [PATCH 006/106] Switch CPU affinity stuff to event_log_* --- include/affinity.h | 3 +- src/affinity.c | 120 ++++++++++++++++++++++++--------------------- src/hashcat.c | 32 ++++++------ 3 files changed, 82 insertions(+), 73 deletions(-) diff --git a/include/affinity.h b/include/affinity.h index 742fc8fb8..ff88f85a3 100644 --- a/include/affinity.h +++ b/include/affinity.h @@ -17,12 +17,13 @@ #if defined (__APPLE__) #include #include +#include #endif // __APPLE__ #if defined (_WIN) #include #endif // _WIN -void set_cpu_affinity (char *cpu_affinity); +int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx); #endif // _AFFINITY_H diff --git a/src/affinity.c b/src/affinity.c index b408fb058..0837156fe 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -10,7 +10,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "affinity.h" #if defined (__APPLE__) @@ -29,7 +29,7 @@ static int CPU_ISSET (int num, cpu_set_t *cs) return (cs->count & (1 << num)); } -static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set) +static int pthread_setaffinity_np (hashcat_ctx_t *hashcat_ctx, pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set) { int core; @@ -40,78 +40,86 @@ static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t thread_affinity_policy_data_t policy = { core }; - const int rc = thread_policy_set (pthread_mach_thread_np (thread), THREAD_AFFINITY_POLICY, (thread_policy_t) &policy, 1); - - if (rc != KERN_SUCCESS) - { - log_error ("ERROR: %s : %d", "thread_policy_set()", rc); - - exit (-1); - } - - return rc; + return thread_policy_set (pthread_mach_thread_np (thread), THREAD_AFFINITY_POLICY, (thread_policy_t) &policy, 1); } #endif -void set_cpu_affinity (char *cpu_affinity) +#if defined (__FreeBSD__) +typedef cpuset_t cpu_set_t; +#endif + +int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) { - #if defined(_WIN) + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->cpu_affinity == NULL) return 0; + + #if defined (_WIN) DWORD_PTR aff_mask = 0; - #elif defined(__FreeBSD__) - cpuset_t cpuset; - CPU_ZERO (&cpuset); - #elif defined(_POSIX) + #else cpu_set_t cpuset; CPU_ZERO (&cpuset); #endif - if (cpu_affinity) + char *devices = mystrdup (user_options->cpu_affinity); + + char *next = strtok (devices, ","); + + do { - char *devices = mystrdup (cpu_affinity); + int cpu_id = atoi (next); - char *next = strtok (devices, ","); - - do + if (cpu_id == 0) { - int cpu_id = atoi (next); - - if (cpu_id == 0) - { - #if defined (_WIN) - aff_mask = 0; - #elif defined (_POSIX) - CPU_ZERO (&cpuset); - #endif - - break; - } - - if (cpu_id > 32) - { - log_error ("ERROR: Invalid cpu_id %u specified", cpu_id); - - exit (-1); - } - #if defined (_WIN) - aff_mask |= 1u << (cpu_id - 1); - #elif defined (_POSIX) - CPU_SET ((cpu_id - 1), &cpuset); + aff_mask = 0; + #else + CPU_ZERO (&cpuset); #endif - } while ((next = strtok (NULL, ",")) != NULL); + break; + } - myfree (devices); + if (cpu_id > 32) + { + event_log_error (hashcat_ctx, "ERROR: Invalid cpu_id %u specified", cpu_id); + + return (-1); + } + + #if defined (_WIN) + aff_mask |= 1u << (cpu_id - 1); + #else + CPU_SET ((cpu_id - 1), &cpuset); + #endif + + } while ((next = strtok (NULL, ",")) != NULL); + + myfree (devices); + + #if defined (_WIN) + + SetProcessAffinityMask (GetCurrentProcess (), aff_mask); + + if (SetThreadAffinityMask (GetCurrentThread (), aff_mask) == 0) + { + event_log_error (hashcat_ctx, "ERROR: %s", "SetThreadAffinityMask()"); + + return -1; } - #if defined( _WIN) - SetProcessAffinityMask (GetCurrentProcess (), aff_mask); - SetThreadAffinityMask (GetCurrentThread (), aff_mask); - #elif defined(__FreeBSD__) + #else + pthread_t thread = pthread_self (); - pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset); - #elif defined(_POSIX) - pthread_t thread = pthread_self (); - pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset); + + if (pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset) == -1) + { + event_log_error (hashcat_ctx, "ERROR: %s", "pthread_setaffinity_np()"); + + return -1; + } + #endif + + return 0; } diff --git a/src/hashcat.c b/src/hashcat.c index 59f0d10c6..0ea3c91ca 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -845,10 +845,24 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options_extra_init (hashcat_ctx); - // from here all user configuration is pre-processed so we can start logging + // from here all user configuration is pre-processed so we can start logging if we want to EVENT (EVENT_LOGFILE_TOP_INITIALIZE); + /** + * cpu affinity + */ + + const int rc_affinity = set_cpu_affinity (hashcat_ctx); + + if (rc_affinity == -1) return -1; + + /** + * prepare seeding for random number generator, required by logfile and rules generator + */ + + setup_seeding (user_options->rp_gen_seed_chgd, user_options->rp_gen_seed); + /** * To help users a bit */ @@ -857,12 +871,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold setup_umask (); - /** - * prepare seeding for random number generator, required by logfile and rules generator - */ - - setup_seeding (user_options->rp_gen_seed_chgd, user_options->rp_gen_seed); - /** * tuning db */ @@ -912,6 +920,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold const int rc_potfile_init = potfile_init (hashcat_ctx); if (rc_potfile_init == -1) return -1; + /** * dictstat init */ @@ -938,15 +947,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_debugfile_init == -1) return -1; - /** - * cpu affinity - */ - - if (user_options->cpu_affinity) - { - set_cpu_affinity (user_options->cpu_affinity); - } - /** * Init OpenCL library loader */ From 25a1f7ab84fef886bde067d32b76897a751d760f Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:44:05 +0200 Subject: [PATCH 007/106] switch autotune.c to event_log_* --- src/autotune.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index 40df5266f..0efeb165b 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -5,7 +5,7 @@ #include "common.h" #include "types.h" -#include "logging.h" +#include "event.h" #include "opencl.h" #include "status.h" #include "terminal.h" @@ -99,7 +99,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -113,7 +113,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -284,10 +284,13 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { clear_prompt (); - log_info ("- Device #%u: autotuned kernel-accel to %u\n" - "- Device #%u: autotuned kernel-loops to %u\n", - device_param->device_id + 1, kernel_accel, - device_param->device_id + 1, kernel_loops); + printf + ( + "- Device #%u: autotuned kernel-accel to %u\n" + "- Device #%u: autotuned kernel-loops to %u\n", + device_param->device_id + 1, kernel_accel, + device_param->device_id + 1, kernel_loops + ); send_prompt (); } @@ -311,7 +314,12 @@ void *thread_autotune (void *p) if (device_param->skipped) return NULL; - autotune (hashcat_ctx, device_param); + const int rc_autotune = autotune (hashcat_ctx, device_param); + + if (rc_autotune == -1) + { + // we should do something here, tell hashcat main that autotune failed to abort + } return NULL; } From ebc8eb74547322ee1ba343904ffa5c8d6dc58ef9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:45:35 +0200 Subject: [PATCH 008/106] switch combinator.c to event_log_* --- src/combinator.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/combinator.c b/src/combinator.c index 66ddf0479..f0f46b2ea 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -5,8 +5,8 @@ #include "common.h" #include "types.h" +#include "event.h" #include "memory.h" -#include "logging.h" #include "combinator.h" #include "wordlist.h" @@ -52,14 +52,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((fp1 = fopen (dictfile1, "rb")) == NULL) { - log_error ("ERROR: %s: %s", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile1, strerror (errno)); return -1; } if (stat (dictfile1, &tmp_stat) == -1) { - log_error ("ERROR: %s: %s", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile1, strerror (errno)); fclose (fp1); @@ -68,7 +68,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s must be a regular file", dictfile1, strerror (errno)); fclose (fp1); @@ -77,7 +77,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((fp2 = fopen (dictfile2, "rb")) == NULL) { - log_error ("ERROR: %s: %s", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile2, strerror (errno)); fclose (fp1); @@ -86,7 +86,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (dictfile2, &tmp_stat) == -1) { - log_error ("ERROR: %s: %s", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile2, strerror (errno)); fclose (fp1); fclose (fp2); @@ -96,7 +96,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s must be a regular file", dictfile2, strerror (errno)); fclose (fp1); fclose (fp2); @@ -110,7 +110,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (words1_cnt == 0) { - log_error ("ERROR: %s: empty file", dictfile1); + event_log_error (hashcat_ctx, "ERROR: %s: empty file", dictfile1); fclose (fp1); fclose (fp2); @@ -124,7 +124,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (words2_cnt == 0) { - log_error ("ERROR: %s: empty file", dictfile2); + event_log_error (hashcat_ctx, "ERROR: %s: empty file", dictfile2); fclose (fp1); fclose (fp2); From fa4de96ab084602ffe4537fbc08a47917113cef8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:53:52 +0200 Subject: [PATCH 009/106] switch cpu_crc32.c to event_log_* --- include/cpu_crc32.h | 2 +- include/interface.h | 2 +- src/common.c | 1 - src/cpt.c | 1 - src/cpu_crc32.c | 10 ++++++---- src/hashes.c | 4 +++- src/interface.c | 8 ++++++-- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/cpu_crc32.h b/include/cpu_crc32.h index 50e4e23b8..a1d86f19e 100644 --- a/include/cpu_crc32.h +++ b/include/cpu_crc32.h @@ -9,6 +9,6 @@ #include #include -void cpu_crc32 (const char *filename, u8 keytab[64]); +int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]); #endif // _CPU_CRC32_H diff --git a/include/interface.h b/include/interface.h index 39d7d1e91..9e65d6a41 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1513,7 +1513,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx); void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); u32 hashconfig_enforce_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param_t *device_param); u32 hashconfig_enforce_kernel_loops (hashcat_ctx_t *hashcat_ctx); -void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx); +int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx); void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt); char *hashconfig_benchmark_mask (hashcat_ctx_t *hashcat_ctx); diff --git a/src/common.c b/src/common.c index 324a1237d..211427cd4 100644 --- a/src/common.c +++ b/src/common.c @@ -4,4 +4,3 @@ */ #include "common.h" - diff --git a/src/cpt.c b/src/cpt.c index 58938b528..7f2f2a263 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -6,7 +6,6 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" #include "cpt.h" int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 282a3ef28..6ff88ac5e 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "cpu_crc32.h" static const u32 crc32tab[256] = @@ -77,7 +77,7 @@ static const u32 crc32tab[256] = 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -void cpu_crc32 (const char *filename, u8 keytab[64]) +int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) { u32 crc = ~0u; @@ -85,9 +85,9 @@ void cpu_crc32 (const char *filename, u8 keytab[64]) if (fd == NULL) { - log_error ("%s: %s", filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno)); - exit (-1); + return (-1); } #define MAX_KEY_SIZE (1024 * 1024) @@ -113,4 +113,6 @@ void cpu_crc32 (const char *filename, u8 keytab[64]) } myfree (buf); + + return 0; } diff --git a/src/hashes.c b/src/hashes.c index 8a8531353..02f292886 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1283,7 +1283,9 @@ int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx) hashes_t *hashes = hashcat_ctx->hashes; user_options_t *user_options = hashcat_ctx->user_options; - hashconfig_general_defaults (hashcat_ctx); + const int rc_defaults = hashconfig_general_defaults (hashcat_ctx); + + if (rc_defaults == -1) return -1; if (hashes->salts_cnt == 1) hashconfig->opti_type |= OPTI_TYPE_SINGLE_SALT; diff --git a/src/interface.c b/src/interface.c index f74199071..df482ec9a 100644 --- a/src/interface.c +++ b/src/interface.c @@ -20190,7 +20190,7 @@ u32 hashconfig_enforce_kernel_loops (hashcat_ctx_t *hashcat_ctx) return kernel_loops_fixed; } -void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) +int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; @@ -20257,12 +20257,16 @@ void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) do { - cpu_crc32 (keyfile, (u8 *) keyfile_buf); + const int rc_crc32 = cpu_crc32 (hashcat_ctx, keyfile, (u8 *) keyfile_buf); + + if (rc_crc32 == -1) return -1; } while ((keyfile = strtok (NULL, ",")) != NULL); free (keyfiles); } + + return 0; } void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt) From 2a2df035e6f52f30f27cf9ef6773c2d92c4a62ba Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:55:05 +0200 Subject: [PATCH 010/106] switch debugfile.c to event_log_* --- src/debugfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debugfile.c b/src/debugfile.c index 36f114b3a..9f08d52fb 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "debugfile.h" static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len) @@ -107,7 +107,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (debugfile_ctx->fp == NULL) { - log_error ("ERROR: Could not open debug-file for writing"); + event_log_error (hashcat_ctx, "ERROR: Could not open debug-file for writing"); return -1; } From 7ed79bf42e40a0f3d084403f1617abbbd4e1e5df Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 8 Oct 2016 23:55:57 +0200 Subject: [PATCH 011/106] switch dictstat.c to event_log_* --- src/dictstat.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dictstat.c b/src/dictstat.c index c6e8827a6..3e13c2fe0 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "dictstat.h" int sort_by_dictstat (const void *s1, const void *s2) @@ -52,7 +52,7 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); return -1; } @@ -101,7 +101,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) if (dictstat_ctx->cnt == MAX_DICTSTAT) { - log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); break; } @@ -120,7 +120,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); return -1; } @@ -153,7 +153,7 @@ void dictstat_append (hashcat_ctx_t *hashcat_ctx, dictstat_t *d) if (dictstat_ctx->cnt == MAX_DICTSTAT) { - log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); return; } From 27bec8be13ec9ae5a4e81f79968ff51d1aa660aa Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 9 Oct 2016 22:41:55 +0200 Subject: [PATCH 012/106] Get rid of logging.c and most exit() calls replaced with return() for true library usage --- include/dynloader.h | 25 +- include/ext_ADL.h | 38 - include/ext_OpenCL.h | 36 - include/ext_nvapi.h | 14 - include/ext_nvml.h | 24 - include/ext_xnvctrl.h | 15 - include/folder.h | 1 - include/hashes.h | 2 +- include/hwmon.h | 103 ++ include/locking.h | 6 +- include/logging.h | 20 - include/memory.h | 1 + include/mpsp.h | 6 +- include/opencl.h | 36 + include/restore.h | 8 +- include/stdout.h | 2 +- include/terminal.h | 2 +- include/thread.h | 12 +- include/types.h | 84 +- include/usage.h | 2 + src/Makefile | 2 +- src/autotune.c | 10 +- src/ext_ADL.c | 603 +--------- src/ext_OpenCL.c | 279 +---- src/ext_nvapi.c | 200 +--- src/ext_nvml.c | 462 +------- src/ext_xnvctrl.c | 213 +--- src/folder.c | 32 +- src/hashcat.c | 20 +- src/hashes.c | 104 +- src/hwmon.c | 2064 +++++++++++++++++++++++++++++++--- src/induct.c | 10 +- src/interface.c | 145 +-- src/locking.c | 15 +- src/logfile.c | 4 +- src/logging.c | 138 --- src/loopback.c | 4 +- src/main.c | 4 +- src/memory.c | 7 +- src/monitor.c | 46 +- src/mpsp.c | 473 ++++---- src/opencl.c | 2480 ++++++++++++++++++++--------------------- src/outfile.c | 6 +- src/outfile_check.c | 10 +- src/potfile.c | 14 +- src/restore.c | 104 +- src/rp.c | 12 +- src/status.c | 132 +-- src/stdout.c | 12 +- src/straight.c | 28 +- src/terminal.c | 72 +- src/thread.c | 32 +- src/tuningdb.c | 14 +- src/usage.c | 5 +- src/user_options.c | 108 +- src/weak_hash.c | 2 +- src/wordlist.c | 12 +- 57 files changed, 4087 insertions(+), 4228 deletions(-) delete mode 100644 include/logging.h delete mode 100644 src/logging.c diff --git a/include/dynloader.h b/include/dynloader.h index d2c35005c..534883afd 100644 --- a/include/dynloader.h +++ b/include/dynloader.h @@ -34,11 +34,11 @@ void *hc_dlsym (void *module, const char *symbol); if (noerr != -1) { \ if (!ptr->name) { \ if (noerr == 1) { \ - log_error ("ERROR: %s is missing from %s shared library.", #name, #libname); \ - exit (-1); \ - } else { \ - log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \ + event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ return -1; \ + } else { \ + event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return 0; \ } \ } \ } @@ -48,11 +48,11 @@ void *hc_dlsym (void *module, const char *symbol); if (noerr != -1) { \ if (!ptr->name) { \ if (noerr == 1) { \ - log_error ("ERROR: %s is missing from %s shared library.", #name, #libname); \ - exit (-1); \ - } else { \ - log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \ + event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ return -1; \ + } else { \ + event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \ + return 0; \ } \ } \ } @@ -61,13 +61,12 @@ void *hc_dlsym (void *module, const char *symbol); ptr->name = (type) (*ptr->func) (addr); \ if (!ptr->name) { \ if (noerr == 1) { \ - log_error ("ERROR: %s at address %08x is missing from %s shared library.", #name, addr, #libname); \ - exit (-1); \ - } else { \ - log_error ("WARNING: %s at address %08x is missing from %s shared library.", #name, addr, #libname); \ + event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ return -1; \ + } else { \ + event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \ + return 0; \ } \ } #endif // _DYNALOADER_H - diff --git a/include/ext_ADL.h b/include/ext_ADL.h index f2f446a4b..5961cbf97 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -352,44 +352,6 @@ typedef struct hm_adl_lib typedef hm_adl_lib_t ADL_PTR; -int adl_init (ADL_PTR *lib); -void adl_close (ADL_PTR *lib); - void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize); -int hm_ADL_Main_Control_Destroy (ADL_PTR *adl); -int hm_ADL_Main_Control_Create (ADL_PTR *adl, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); -int hm_ADL_Adapter_NumberOfAdapters_Get (ADL_PTR *adl, int *lpNumAdapters); -int hm_ADL_Adapter_AdapterInfo_Get (ADL_PTR *adl, LPAdapterInfo lpInfo, int iInputSize); -int hm_ADL_Display_DisplayInfo_Get (ADL_PTR *adl, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect); -int hm_ADL_Overdrive5_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature); -int hm_ADL_Overdrive6_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int *iTemperature); -int hm_ADL_Overdrive_CurrentActivity_Get (ADL_PTR *adl, int iAdapterIndex, ADLPMActivity *lpActivity); -int hm_ADL_Overdrive_ThermalDevices_Enum (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo); -int hm_ADL_Adapter_ID_Get (ADL_PTR *adl, int iAdapterIndex, int *lpAdapterID); -int hm_ADL_Adapter_VideoBiosInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLBiosInfo *lpBiosInfo); -int hm_ADL_Overdrive5_FanSpeedInfo_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex); -int hm_ADL_Overdrive_ODParameters_Get (ADL_PTR *adl, int iAdapterIndex, ADLODParameters *lpOdParameters); -int hm_ADL_Overdrive_ODPerformanceLevels_Get (ADL_PTR *adl, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_ODPerformanceLevels_Set (ADL_PTR *adl, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_PowerControlInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6PowerControlInfo *); -int hm_ADL_Overdrive_PowerControl_Get (ADL_PTR *adl, int iAdapterIndex, int *level); -int hm_ADL_Overdrive_PowerControl_Set (ADL_PTR *adl, int iAdapterIndex, int level); -int hm_ADL_Adapter_Active_Get (ADL_PTR *adl, int iAdapterIndex, int *lpStatus); -//int hm_ADL_DisplayEnable_Set (ADL_PTR *adl, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly); -int hm_ADL_Overdrive_Caps (ADL_PTR *adl, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version); -int hm_ADL_Overdrive_CurrentStatus_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6CurrentStatus *status); -int hm_ADL_Overdrive_StateInfo_Get (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6MemClockState *state); -int hm_ADL_Overdrive_Capabilities_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6Capabilities *caps); -int hm_ADL_Overdrive_State_Set (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6StateInfo *state); -int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *lpSupported); -int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp); -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); -int hm_ADL_Overdrive6_FanSpeed_Reset (ADL_PTR *adl, int iAdapterIndex); - #endif // _EXT_ADL_H diff --git a/include/ext_OpenCL.h b/include/ext_OpenCL.h index 9b56dbaf2..ea288b166 100644 --- a/include/ext_OpenCL.h +++ b/include/ext_OpenCL.h @@ -109,40 +109,4 @@ typedef hc_opencl_lib_t OCL_PTR; const char *val2cstr_cl (cl_int CL_err); -int ocl_init (OCL_PTR *ocl); -void ocl_close (OCL_PTR *ocl); - -cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data); -cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem); -cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue); -cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context); -cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel); -cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program); -cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program); -cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); -cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf); -cl_int hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); -cl_int hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); -cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); -cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); -cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue); -cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue); -cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); -cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms); -cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); -cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret); -cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue); -cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context); -cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event); -cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel); -cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem); -cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program); -cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value); -cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list); - #endif // _EXT_OPENCL_H diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index 3a5c68162..f2883d65a 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -255,18 +255,4 @@ typedef struct hm_nvapi_lib typedef hm_nvapi_lib_t NVAPI_PTR; -int nvapi_init (NVAPI_PTR *nvapi); -void nvapi_close (NVAPI_PTR *nvapi); - -int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, unsigned int offset); -int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc); - -NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi); -NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi); -NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); -NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); -NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); -NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); - #endif // _EXT_NVAPI_H diff --git a/include/ext_nvml.h b/include/ext_nvml.h index ce7df5993..b9ff6444f 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -221,28 +221,4 @@ typedef struct hm_nvml_lib typedef hm_nvml_lib_t NVML_PTR; -int nvml_init (NVML_PTR *lib); -void nvml_close (NVML_PTR *lib); - -const char * hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc); -nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml); -nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml); -nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int, nvmlDevice_t device, char *name, unsigned int length); -nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int, unsigned int index, nvmlDevice_t *device); -nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp); -nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *speed); -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *power); -nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlUtilization_t *utilization); -nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock); -nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *currLinkGen); -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *currLinkWidth); -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned long long *clocksThrottleReasons); -nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons); -nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlComputeMode_t mode); -nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlGpuOperationMode_t mode); -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit); -nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit); -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit); - #endif // _NVML_H diff --git a/include/ext_xnvctrl.h b/include/ext_xnvctrl.h index 6ff1e3caf..1ae36dfcf 100644 --- a/include/ext_xnvctrl.h +++ b/include/ext_xnvctrl.h @@ -72,19 +72,4 @@ typedef struct hm_xnvctrl_lib typedef hm_xnvctrl_lib_t XNVCTRL_PTR; -int xnvctrl_init (XNVCTRL_PTR *xnvctrl); -void xnvctrl_close (XNVCTRL_PTR *xnvctrl); - -int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl); -void hm_XNVCTRL_XCloseDisplay (XNVCTRL_PTR *xnvctrl); - -int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val); - -int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val); -int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val); - -int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val); -int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val); -int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val); - #endif // _EXT_XNVCTRL_H diff --git a/include/folder.h b/include/folder.h index f850ec276..652fe6b52 100644 --- a/include/folder.h +++ b/include/folder.h @@ -29,7 +29,6 @@ int sort_by_stringptr (const void *p1, const void *p2); -char *get_exec_path (void); char *get_install_dir (const char *progname); char *get_profile_dir (const char *homedir); char *get_session_dir (const char *profile_dir); diff --git a/include/hashes.h b/include/hashes.h index 561e7d0cf..79219b38c 100644 --- a/include/hashes.h +++ b/include/hashes.h @@ -11,7 +11,7 @@ int sort_by_salt (const void *v1, const void *v2); int sort_by_hash (const void *v1, const void *v2, void *v3); int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3); -void save_hash (hashcat_ctx_t *hashcat_ctx); +int save_hash (hashcat_ctx_t *hashcat_ctx); void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain); diff --git a/include/hwmon.h b/include/hwmon.h index 1a0db1475..fed552356 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -6,6 +6,109 @@ #ifndef _HWMON_H #define _HWMON_H +// nvml functions + +int nvml_init (hashcat_ctx_t *hashcat_ctx); +void nvml_close (hashcat_ctx_t *hashcat_ctx); + +int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx); +int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx); + +int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device); + +int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length); +int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp); +int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed); +int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power); +int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization); +int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock); +int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); +int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen); +int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth); +int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons); +int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons); +int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode); +int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode); +int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit); +int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit); +int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit); + +// nvapi functions + +int nvapi_init (hashcat_ctx_t *hashcat_ctx); +void nvapi_close (hashcat_ctx_t *hashcat_ctx); + +int hm_NvAPI_QueryInterface (hashcat_ctx_t *hashcat_ctx, unsigned int offset); + +int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx); +int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx); + +int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); +int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); +int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); +int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); +int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); + +// xnvctrl functions + +int xnvctrl_init (hashcat_ctx_t *hashcat_ctx); +void xnvctrl_close (hashcat_ctx_t *hashcat_ctx); + +int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx); +void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx); + +int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); + +int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); +int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); + +int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); +int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); +int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); + +// ADL functions + +int adl_init (hashcat_ctx_t *hashcat_ctx); +void adl_close (hashcat_ctx_t *hashcat_ctx); + +int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx); +int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); + +int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters); +int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize); +int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect); +int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature); +int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature); +int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity); +int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo); +int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID); +int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo); +int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo); +int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); +int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo); +int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); +int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue); +int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex); +int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters); +int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels); +int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels); +int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *); +int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *level); +int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level); +int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus); +//int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly); +int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version); +int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status); +int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state); +int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps); +int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state); +int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported); +int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp); +int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); +int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex); + +// general functions + int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); diff --git a/include/locking.h b/include/locking.h index 9d4a1d68a..c36745c9d 100644 --- a/include/locking.h +++ b/include/locking.h @@ -15,13 +15,13 @@ #if defined (F_SETLKW) -void lock_file (FILE *fp); +int lock_file (FILE *fp); void unlock_file (FILE *fp); #else -#define lock_file(dummy) {} -#define unlock_file(dummy) {} +#define lock_file(dummy) 0 +#define unlock_file(dummy) #endif diff --git a/include/logging.h b/include/logging.h deleted file mode 100644 index 01ee26014..000000000 --- a/include/logging.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#ifndef _LOGGING_H -#define _LOGGING_H - -#include -#include - -int log_out_nn (FILE *fp, const char *fmt, ...); -int log_info_nn (const char *fmt, ...); -int log_error_nn (const char *fmt, ...); - -int log_out (FILE *fp, const char *fmt, ...); -int log_info (const char *fmt, ...); -int log_error (const char *fmt, ...); - -#endif // _LOGGING_H diff --git a/include/memory.h b/include/memory.h index ca59cd756..b68bc526b 100644 --- a/include/memory.h +++ b/include/memory.h @@ -6,6 +6,7 @@ #ifndef _MEMORY_H #define _MEMORY_H +#include #include #include diff --git a/include/mpsp.h b/include/mpsp.h index 54fa909b0..44a6c0dca 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -23,20 +23,18 @@ void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_rl[2]); void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf); void mp_css_unicode_expand (mask_ctx_t *mask_ctx); -void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); +int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); void mp_cut_at (char *mask, u32 max); u32 mp_get_length (char *mask); void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt); -cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options); u64 mp_get_sum (u32 css_cnt, cs_t *css); void mp_setup_sys (cs_t *mp_sys); -void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index, const hashconfig_t *hashconfig, const user_options_t *user_options); +int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index); void mp_reset_usr (cs_t *mp_usr, u32 index); u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); int sp_comp_val (const void *p1, const void *p2); -void sp_setup_tbl (const char *install_dir, char *hcstat, u32 disable, u32 classic, hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf); void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out); void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out); diff --git a/include/opencl.h b/include/opencl.h index dae899ee3..16304eac3 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -18,6 +18,42 @@ static const char CL_VENDOR_MESA[] = "Mesa"; static const char CL_VENDOR_NV[] = "NVIDIA Corporation"; static const char CL_VENDOR_POCL[] = "The pocl project"; +int ocl_init (hashcat_ctx_t *hashcat_ctx); +void ocl_close (hashcat_ctx_t *hashcat_ctx); + +int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data); +int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem); +int hc_clCreateCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue); +int hc_clCreateContext (hashcat_ctx_t *hashcat_ctx, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context); +int hc_clCreateKernel (hashcat_ctx_t *hashcat_ctx, cl_program program, const char *kernel_name, cl_kernel *kernel); +int hc_clCreateProgramWithBinary (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program); +int hc_clCreateProgramWithSource (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program); +int hc_clEnqueueCopyBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); +int hc_clEnqueueMapBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf); +int hc_clEnqueueNDRangeKernel (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); +int hc_clEnqueueReadBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); +int hc_clEnqueueUnmapMemObject (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); +int hc_clEnqueueWriteBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event); +int hc_clFinish (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue); +int hc_clFlush (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue); +int hc_clGetDeviceIDs (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices); +int hc_clGetDeviceInfo (hashcat_ctx_t *hashcat_ctx, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetEventInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetEventProfilingInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetKernelWorkGroupInfo (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetPlatformIDs (hashcat_ctx_t *hashcat_ctx, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms); +int hc_clGetPlatformInfo (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetProgramBuildInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); +int hc_clGetProgramInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret); +int hc_clReleaseCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue); +int hc_clReleaseContext (hashcat_ctx_t *hashcat_ctx, cl_context context); +int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event); +int hc_clReleaseKernel (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel); +int hc_clReleaseMemObject (hashcat_ctx_t *hashcat_ctx, cl_mem mem); +int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program); +int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value); +int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl_event *event_list); + int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw); int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 highest_pw_len, const u32 pws_cnt, const u32 fast_iteration, const u32 salt_pos); int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u32 num, const u32 event_update, const u32 iteration); diff --git a/include/restore.h b/include/restore.h index 72a06955c..f42760638 100644 --- a/include/restore.h +++ b/include/restore.h @@ -25,13 +25,7 @@ u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx); -void init_restore (hashcat_ctx_t *hashcat_ctx); - -void read_restore (hashcat_ctx_t *hashcat_ctx); - -void write_restore (hashcat_ctx_t *hashcat_ctx); - -void cycle_restore (hashcat_ctx_t *hashcat_ctx); +int cycle_restore (hashcat_ctx_t *hashcat_ctx); void unlink_restore (hashcat_ctx_t *hashcat_ctx); diff --git a/include/stdout.h b/include/stdout.h index a40fdb91a..910b9e69c 100644 --- a/include/stdout.h +++ b/include/stdout.h @@ -20,6 +20,6 @@ #include #endif // _POSIX -void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); +int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); #endif // _STDOUT_H diff --git a/include/terminal.h b/include/terminal.h index 6c73e1890..a90ad77a1 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -26,7 +26,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const char *version_tag); void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop); -int setup_console (); +int setup_console (hashcat_ctx_t *hashcat_ctx); void send_prompt (); void clear_prompt (); diff --git a/include/thread.h b/include/thread.h index b73796af3..907af8aaa 100644 --- a/include/thread.h +++ b/include/thread.h @@ -56,12 +56,12 @@ void hc_signal (void (callback) (int)); #endif */ -void mycracked (status_ctx_t *status_ctx); -void myabort (status_ctx_t *status_ctx); -void myquit (status_ctx_t *status_ctx); -void bypass (status_ctx_t *status_ctx); +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 (status_ctx_t *status_ctx); -void ResumeThreads (status_ctx_t *status_ctx); +void SuspendThreads (hashcat_ctx_t *hashcat_ctx); +void ResumeThreads (hashcat_ctx_t *hashcat_ctx); #endif // _THREAD_H diff --git a/include/types.h b/include/types.h index 0aa060ebc..e94ec7fed 100644 --- a/include/types.h +++ b/include/types.h @@ -37,12 +37,6 @@ typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; -#include "ext_OpenCL.h" -#include "ext_ADL.h" -#include "ext_nvapi.h" -#include "ext_nvml.h" -#include "ext_xnvctrl.h" - // timer #if defined (_WIN) @@ -418,6 +412,7 @@ typedef enum parser_rc PARSER_TC_FILE_SIZE = -15, PARSER_VC_FILE_SIZE = -16, PARSER_SIP_AUTH_DIRECTIVE = -17, + PARSER_HASH_FILE = -18, PARSER_UNKNOWN_ERROR = -255 } parser_rc_t; @@ -613,6 +608,8 @@ typedef struct wordr } wordr_t; +#include "ext_OpenCL.h" + typedef struct hc_device_param { cl_device_id device; @@ -819,15 +816,51 @@ typedef struct opencl_ctx double target_ms; - int need_adl; - int need_nvml; - int need_nvapi; - int need_xnvctrl; + bool need_adl; + bool need_nvml; + bool need_nvapi; + bool need_xnvctrl; int force_jit_compilation; } opencl_ctx_t; +#include "ext_ADL.h" +#include "ext_nvapi.h" +#include "ext_nvml.h" +#include "ext_xnvctrl.h" + +typedef struct hm_attrs +{ + HM_ADAPTER_ADL adl; + HM_ADAPTER_NVML nvml; + HM_ADAPTER_NVAPI nvapi; + HM_ADAPTER_XNVCTRL xnvctrl; + + int od_version; + + bool fan_get_supported; + bool fan_set_supported; + +} hm_attrs_t; + +typedef struct hwmon_ctx +{ + bool enabled; + + void *hm_adl; + void *hm_nvml; + void *hm_nvapi; + void *hm_xnvctrl; + + hm_attrs_t *hm_device; + + ADLOD6MemClockState *od_clock_mem_status; + int *od_power_control_status; + unsigned int *nvml_power_limit; + +} hwmon_ctx_t; + #if defined (__APPLE__) typedef struct cpu_set { @@ -888,20 +921,6 @@ typedef struct dictstat_ctx } dictstat_ctx_t; -typedef struct hm_attrs -{ - HM_ADAPTER_ADL adl; - HM_ADAPTER_NVML nvml; - HM_ADAPTER_NVAPI nvapi; - HM_ADAPTER_XNVCTRL xnvctrl; - - int od_version; - - bool fan_get_supported; - bool fan_set_supported; - -} hm_attrs_t; - typedef struct loopback_ctx { bool enabled; @@ -1301,23 +1320,6 @@ typedef struct mask_ctx } mask_ctx_t; -typedef struct hwmon_ctx -{ - bool enabled; - - void *hm_adl; - void *hm_nvml; - void *hm_nvapi; - void *hm_xnvctrl; - - hm_attrs_t *hm_device; - - ADLOD6MemClockState *od_clock_mem_status; - int *od_power_control_status; - unsigned int *nvml_power_limit; - -} hwmon_ctx_t; - typedef struct cpt_ctx { bool enabled; diff --git a/include/usage.h b/include/usage.h index e0cd5a575..6a1b88543 100644 --- a/include/usage.h +++ b/include/usage.h @@ -6,6 +6,8 @@ #ifndef _USAGE_H #define _USAGE_H +#include + void usage_mini_print (const char *progname); void usage_big_print (const char *progname); diff --git a/src/Makefile b/src/Makefile index fa3920d78..f16476458 100644 --- a/src/Makefile +++ b/src/Makefile @@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi ## Objects ## -OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist +OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o) diff --git a/src/autotune.c b/src/autotune.c index 0efeb165b..f0203345e 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -95,7 +95,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->pws_buf[i].pw_len = 7 + (i & 7); } - cl_int CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); if (CL_err != CL_SUCCESS) { @@ -109,7 +109,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { if (straight_ctx->kernel_rules_cnt > 1) { - cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); if (CL_err != CL_SUCCESS) { @@ -248,8 +248,8 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param /* memset (device_param->pws_buf, 0, kernel_power_max * sizeof (pw_t)); - hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); */ run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t)); @@ -280,6 +280,8 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param #if defined (DEBUG) + user_options_t *user_options = hashcat_ctx->user_options; + if (user_options->quiet == false) { clear_prompt (); diff --git a/src/ext_ADL.c b/src/ext_ADL.c index 374673566..b8384997e 100644 --- a/src/ext_ADL.c +++ b/src/ext_ADL.c @@ -4,612 +4,11 @@ */ #include "common.h" -#include "logging.h" +#include "types.h" #include "memory.h" -#include "dynloader.h" #include "ext_ADL.h" -int adl_init (ADL_PTR *adl) -{ - if (!adl) return -1; - - memset (adl, 0, sizeof (ADL_PTR)); - - #if defined (_WIN) - adl->lib = hc_dlopen ("atiadlxx.dll"); - - if (!adl->lib) - { - adl->lib = hc_dlopen ("atiadlxy.dll"); - } - #elif defined (_POSIX) - adl->lib = hc_dlopen ("libatiadlxx.so", RTLD_NOW); - #endif - - if (!adl->lib) - { - //if (user_options->quiet == false) - // log_info ("WARNING: load ADL library failed, proceed without ADL HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Set, ADL_OVERDRIVE5_FANSPEED_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Set, ADL_OVERDRIVE6_FANSPEED_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedToDefault_Set, ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_ODParameters_Get, ADL_OVERDRIVE5_ODPARAMETERS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Get, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Set, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControlInfo_Get, ADL_OVERDRIVE6_POWERCONTROLINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Get, ADL_OVERDRIVE6_POWERCONTROL_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Set, ADL_OVERDRIVE6_POWERCONTROL_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0) - //HC_LOAD_FUNC(adl, ADL_DisplayEnable_Set, ADL_DISPLAYENABLE_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Caps, ADL_OVERDRIVE6_POWERCONTROL_CAPS, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_State_Set, ADL_OVERDRIVE6_STATE_SET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0) - HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Reset, ADL_OVERDRIVE6_FANSPEED_RESET, ADL, 0) - - return 0; -} - -void adl_close (ADL_PTR *adl) -{ - if (adl) - { - if (adl->lib) - hc_dlclose (adl->lib); - - myfree (adl); - } -} - void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize) { return mymalloc ((size_t) iSize); } - -int hm_ADL_Main_Control_Destroy (ADL_PTR *adl) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Main_Control_Destroy (); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Main_Control_Destroy()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Main_Control_Create (ADL_PTR *adl, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Main_Control_Create()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Adapter_NumberOfAdapters_Get (ADL_PTR *adl, int *lpNumAdapters) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Adapter_NumberOfAdapters_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Adapter_AdapterInfo_Get (ADL_PTR *adl, LPAdapterInfo lpInfo, int iInputSize) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Adapter_AdapterInfo_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Display_DisplayInfo_Get (ADL_PTR *adl, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Display_DisplayInfo_Get (iAdapterIndex, iNumDisplays, lppInfo, iForceDetect); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Display_DisplayInfo_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Adapter_ID_Get (ADL_PTR *adl, int iAdapterIndex, int *lpAdapterID) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Adapter_ID_Get (iAdapterIndex, lpAdapterID); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Adapter_ID_Get()", ADL_rc); - } - - return ADL_rc; -} - -int hm_ADL_Adapter_VideoBiosInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Adapter_VideoBiosInfo_Get (iAdapterIndex, lpBiosInfo); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Adapter_VideoBiosInfo_Get()", ADL_rc); - } - - return ADL_rc; -} - -int hm_ADL_Overdrive_ThermalDevices_Enum (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_ThermalDevices_Enum (iAdapterIndex, iThermalControllerIndex, lpThermalControllerInfo); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ThermalDevices_Enum()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive5_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_Temperature_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int *iTemperature) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive6_Temperature_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_CurrentActivity_Get (ADL_PTR *adl, int iAdapterIndex, ADLPMActivity *lpActivity) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_CurrentActivity_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive5_FanSpeedInfo_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_FanSpeedInfo_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedInfo); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeedInfo_Get()", ADL_rc); - } - - return ADL_rc; -} - -int hm_ADL_Overdrive5_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeed_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive6_FanSpeed_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive5_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Set (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeed_Set()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Set (iAdapterIndex, lpFanSpeedValue); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive6_FanSpeed_Set()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_FanSpeedToDefault_Set (iAdapterIndex, iThermalControllerIndex); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeedToDefault_Set()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_ODParameters_Get (ADL_PTR *adl, int iAdapterIndex, ADLODParameters *lpOdParameters) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_ODParameters_Get (iAdapterIndex, lpOdParameters); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODParameters_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_ODPerformanceLevels_Get (ADL_PTR *adl, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Get (iAdapterIndex, iDefault, lpOdPerformanceLevels); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Get()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_ODPerformanceLevels_Set (ADL_PTR *adl, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Set (iAdapterIndex, lpOdPerformanceLevels); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Set()", ADL_rc); - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_PowerControlInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_PowerControlInfo_Get (iAdapterIndex, powertune); - - return (ADL_rc); -} - -int hm_ADL_Overdrive_PowerControl_Get (ADL_PTR *adl, int iAdapterIndex, int *iCurrentValue) -{ - if (!adl) return -1; - - int default_value = 0; - - int ADL_rc = adl->ADL_Overdrive6_PowerControl_Get (iAdapterIndex, iCurrentValue, &default_value); - - return (ADL_rc); -} - -int hm_ADL_Overdrive_PowerControl_Set (ADL_PTR *adl, int iAdapterIndex, int level) -{ - if (!adl) return -1; - - int ADL_rc = ADL_ERR; - - ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; - - if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (adl, iAdapterIndex, &powertune)) != ADL_OK) - { - log_info ("WARN: %s\n", "ADL_Overdrive6_PowerControl_Get", ADL_rc); - } - else - { - int min = powertune.iMinValue; - int max = powertune.iMaxValue; - int step = powertune.iStepValue; - - if (level < min || level > max) - { - log_info ("WARN: ADL PowerControl level invalid"); - - return ADL_ERR; - } - if (level % step != 0) - { - log_info ("WARN: ADL PowerControl step invalid"); - - return ADL_ERR; - } - - ADL_rc = adl->ADL_Overdrive6_PowerControl_Set (iAdapterIndex, level); - } - - return (ADL_rc); -} - -int hm_ADL_Adapter_Active_Get (ADL_PTR *adl, int iAdapterIndex, int *lpStatus) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Adapter_Active_Get (iAdapterIndex, lpStatus); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_Adapter_Active_Get()", ADL_rc); - } - - return (ADL_rc); -} - -/* -int hm_ADL_DisplayEnable_Set (ADL_PTR *adl, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_DisplayEnable_Set (iAdapterIndex, lpDisplayIndexList, iDisplayListSize, bPersistOnly); - - if (ADL_rc != ADL_OK) - { - log_info ("WARN: %s: %d\n", "ADL_DisplayEnable_Set()", ADL_rc); - } - - return (ADL_rc); -} -*/ - -int hm_ADL_Overdrive_Caps (ADL_PTR *adl, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version); - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *lpSupported) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_PowerControl_Caps (iAdapterIndex, lpSupported); - - return (ADL_rc); -} - -int hm_ADL_Overdrive_Capabilities_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6Capabilities *caps) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_Capabilities_Get (iAdapterIndex, caps); - - return (ADL_rc); -} - -int hm_ADL_Overdrive_StateInfo_Get (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6MemClockState *state) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_StateInfo_Get (iAdapterIndex, type, state); - - if (ADL_rc == ADL_OK) - { - // check if clocks are okay with step sizes - // if not run a little hack: adjust the clocks to nearest clock size (clock down just a little bit) - - ADLOD6Capabilities caps; - - if ((hm_ADL_Overdrive_Capabilities_Get (adl, iAdapterIndex, &caps)) != ADL_OK) - { - log_info ("ERROR: failed to get ADL device capabilities"); - - exit (1); - } - - if (state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep != 0) - { - log_info ("WARN: ADL engine step size invalid for performance level 1"); - state->state.aLevels[0].iEngineClock -= state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep; - } - - if (state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0) - { - log_info ("WARN: ADL engine step size invalid for performance level 2"); - state->state.aLevels[1].iEngineClock -= state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep; - } - - if (state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep != 0) - { - log_info ("WARN: ADL memory step size invalid for performance level 1"); - state->state.aLevels[0].iMemoryClock -= state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep; - } - - if (state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0) - { - log_info ("WARN: ADL memory step size invalid for performance level 2"); - state->state.aLevels[1].iMemoryClock -= state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep; - } - } - - return (ADL_rc); -} - -int hm_ADL_Overdrive_CurrentStatus_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6CurrentStatus *status) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_CurrentStatus_Get (iAdapterIndex, status); - - return (ADL_rc); -} - -int hm_ADL_Overdrive_State_Set (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6StateInfo *state) -{ - if (!adl) return -1; - - // sanity checks - - ADLOD6Capabilities caps; - - if ((hm_ADL_Overdrive_Capabilities_Get (adl, iAdapterIndex, &caps)) != ADL_OK) - { - log_info ("ERROR: failed to get ADL device capabilities"); - - exit (1); - } - - if (state->aLevels[0].iEngineClock < caps.sEngineClockRange.iMin || state->aLevels[1].iEngineClock > caps.sEngineClockRange.iMax) - { - log_info ("WARN: ADL engine clock outside valid range"); - - return ADL_ERR; - } - - if (state->aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0) - { - log_info ("WARN: ADL engine step size invalid"); - - return ADL_ERR; - } - - if (state->aLevels[0].iMemoryClock < caps.sMemoryClockRange.iMin || state->aLevels[1].iMemoryClock > caps.sMemoryClockRange.iMax) - { - log_info ("WARN: ADL memory clock outside valid range"); - - return ADL_ERR; - } - - if (state->aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0) - { - log_info ("WARN: ADL memory step size invalid"); - - return ADL_ERR; - } - - int ADL_rc = adl->ADL_Overdrive6_State_Set (iAdapterIndex, type, state); - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp); - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureRangeInfo_Get (iAdapterIndex, lpTargetTemperatureInfo); - - return (ADL_rc); -} - -int hm_ADL_Overdrive6_FanSpeed_Reset (ADL_PTR *adl, int iAdapterIndex) -{ - if (!adl) return -1; - - int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Reset (iAdapterIndex); - - return (ADL_rc); -} diff --git a/src/ext_OpenCL.c b/src/ext_OpenCL.c index dd81a2e5f..89b291c6c 100644 --- a/src/ext_OpenCL.c +++ b/src/ext_OpenCL.c @@ -6,8 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" -#include "dynloader.h" +#include "event.h" #include "ext_OpenCL.h" const char *val2cstr_cl (cl_int CL_err) @@ -58,279 +57,3 @@ const char *val2cstr_cl (cl_int CL_err) return "CL_UNKNOWN_ERROR"; } - -int ocl_init (OCL_PTR *ocl) -{ - if (!ocl) - { - log_error ("ERROR: OpenCL library pointer is null"); - - exit (-1); - } - - memset (ocl, 0, sizeof (hc_opencl_lib_t)); - - #if defined(_WIN) - ocl->lib = hc_dlopen ("OpenCL"); - #elif defined(__APPLE__) - ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW); - #else - ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW); - - if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW); - #endif - - if (ocl->lib == NULL) - { - log_info (""); - log_info ("ATTENTION! Can't find OpenCL ICD loader library"); - log_info (""); - #if defined (__linux__) - log_info ("You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)"); - log_info (" sudo apt-get install ocl-icd-libopencl1"); - log_info (""); - #elif defined (_WIN) - log_info ("You're probably missing the OpenCL runtime installation"); - log_info (" AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); - log_info (" Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); - log_info (" NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); - log_info (""); - #endif - - exit (-1); - } - - HC_LOAD_FUNC(ocl, clBuildProgram, OCL_CLBUILDPROGRAM, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateBuffer, OCL_CLCREATEBUFFER, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateCommandQueue, OCL_CLCREATECOMMANDQUEUE, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateContext, OCL_CLCREATECONTEXT, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateKernel, OCL_CLCREATEKERNEL, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateProgramWithBinary, OCL_CLCREATEPROGRAMWITHBINARY, OpenCL, 1) - HC_LOAD_FUNC(ocl, clCreateProgramWithSource, OCL_CLCREATEPROGRAMWITHSOURCE, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueCopyBuffer, OCL_CLENQUEUECOPYBUFFER, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueMapBuffer, OCL_CLENQUEUEMAPBUFFER, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueNDRangeKernel, OCL_CLENQUEUENDRANGEKERNEL, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueReadBuffer, OCL_CLENQUEUEREADBUFFER, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueUnmapMemObject, OCL_CLENQUEUEUNMAPMEMOBJECT, OpenCL, 1) - HC_LOAD_FUNC(ocl, clEnqueueWriteBuffer, OCL_CLENQUEUEWRITEBUFFER, OpenCL, 1) - HC_LOAD_FUNC(ocl, clFinish, OCL_CLFINISH, OpenCL, 1) - HC_LOAD_FUNC(ocl, clFlush, OCL_CLFLUSH, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetDeviceIDs, OCL_CLGETDEVICEIDS, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetDeviceInfo, OCL_CLGETDEVICEINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetEventInfo, OCL_CLGETEVENTINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetKernelWorkGroupInfo, OCL_CLGETKERNELWORKGROUPINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetPlatformIDs, OCL_CLGETPLATFORMIDS, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetPlatformInfo, OCL_CLGETPLATFORMINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetProgramBuildInfo, OCL_CLGETPROGRAMBUILDINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetProgramInfo, OCL_CLGETPROGRAMINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseCommandQueue, OCL_CLRELEASECOMMANDQUEUE, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseContext, OCL_CLRELEASECONTEXT, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseKernel, OCL_CLRELEASEKERNEL, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseMemObject, OCL_CLRELEASEMEMOBJECT, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseProgram, OCL_CLRELEASEPROGRAM, OpenCL, 1) - HC_LOAD_FUNC(ocl, clSetKernelArg, OCL_CLSETKERNELARG, OpenCL, 1) - HC_LOAD_FUNC(ocl, clWaitForEvents, OCL_CLWAITFOREVENTS, OpenCL, 1) - HC_LOAD_FUNC(ocl, clGetEventProfilingInfo, OCL_CLGETEVENTPROFILINGINFO, OpenCL, 1) - HC_LOAD_FUNC(ocl, clReleaseEvent, OCL_CLRELEASEEVENT, OpenCL, 1) - - return 0; -} - -void ocl_close (OCL_PTR *ocl) -{ - if (ocl) - { - if (ocl->lib) - { - hc_dlclose (ocl->lib); - } - } -} - -cl_int hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) -{ - return ocl->clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event); -} - -cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue) -{ - return ocl->clFlush (command_queue); -} - -cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue) -{ - return ocl->clFinish (command_queue); -} - -cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) -{ - return ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value); -} - -cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) -{ - return ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event); -} - -cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) -{ - return ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event); -} - -cl_int hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) -{ - return ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event); -} - -cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms) -{ - return ocl->clGetPlatformIDs (num_entries, platforms, num_platforms); -} - -cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) -{ - return ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices); -} - -cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context) -{ - cl_int CL_err; - - *context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err); - - return CL_err; -} - -cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue) -{ - cl_int CL_err; - - *command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err); - - return CL_err; -} - -cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem) -{ - cl_int CL_err; - - *mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err); - - return CL_err; -} - -cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program) -{ - cl_int CL_err; - - *program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err); - - return CL_err; -} - -cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program) -{ - cl_int CL_err; - - *program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err); - - return CL_err; -} - -cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data) -{ - return ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data); -} - -cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel) -{ - cl_int CL_err; - - *kernel = ocl->clCreateKernel (program, kernel_name, &CL_err); - - return CL_err; -} - -cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem) -{ - return ocl->clReleaseMemObject (mem); -} - -cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel) -{ - return ocl->clReleaseKernel (kernel); -} - -cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program) -{ - return ocl->clReleaseProgram (program); -} - -cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue) -{ - return ocl->clReleaseCommandQueue (command_queue); -} - -cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context) -{ - return ocl->clReleaseContext (context); -} - -cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf) -{ - cl_int CL_err; - - *buf = ocl->clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &CL_err); - - return CL_err; -} - -cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) -{ - return ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event); -} - -cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list) -{ - return ocl->clWaitForEvents (num_events, event_list); -} - -cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) -{ - return ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret); -} - -cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event) -{ - return ocl->clReleaseEvent (event); -} diff --git a/src/ext_nvapi.c b/src/ext_nvapi.c index b50f08ec4..f366372d4 100644 --- a/src/ext_nvapi.c +++ b/src/ext_nvapi.c @@ -4,203 +4,7 @@ */ #include "common.h" -#include "logging.h" +#include "types.h" +#include "event.h" #include "memory.h" -#include "dynloader.h" #include "ext_nvapi.h" - -int nvapi_init (NVAPI_PTR *nvapi) -{ - if (!nvapi) return -1; - - memset (nvapi, 0, sizeof (NVAPI_PTR)); - - #if defined (_WIN) - #if defined (WIN64) - nvapi->lib = hc_dlopen ("nvapi64.dll"); - #elif defined (WIN32) - nvapi->lib = hc_dlopen ("nvapi.dll"); - #endif - #else - nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah - #endif - - if (!nvapi->lib) - { - //if (user_options->quiet == false) - // log_info ("WARNING: load NVAPI library failed, proceed without NVAPI HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7E, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048C, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921F, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0C, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_SetCoolerLevels, NVAPI_GPU_SETCOOLERLEVELS, nvapi_QueryInterface, 0x891FA0AE, NVAPI, 0) - HC_LOAD_ADDR(nvapi, NvAPI_GPU_RestoreCoolerSettings, NVAPI_GPU_RESTORECOOLERSETTINGS, nvapi_QueryInterface, 0x8F6ED0FB, NVAPI, 0) - - return 0; -} - -void nvapi_close (NVAPI_PTR *nvapi) -{ - if (nvapi) - { - if (nvapi->lib) - hc_dlclose (nvapi->lib); - - myfree (nvapi); - } -} - -int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status NvAPI_rc, NvAPI_ShortString string) -{ - if (!nvapi) return -1; - - return nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); -} - -NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize (); - - if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) NvAPI_rc = NVAPI_OK; // not a bug - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_Initialize()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload (); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_Unload()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_EnumPhysicalGPUs()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_GPU_GetPerfPoliciesInfo()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_GPU_GetPerfPoliciesStatus()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_SetCoolerLevels (hPhysicalGpu, coolerIndex, pCoolerLevels); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_GPU_SetCoolerLevels()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) -{ - if (!nvapi) return (NvAPI_Status) -1; - - NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_RestoreCoolerSettings (hPhysicalGpu, coolerIndex); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - log_info ("WARN: %s %d %s\n", "NvAPI_GPU_RestoreCoolerSettings()", NvAPI_rc, string); - } - - return NvAPI_rc; -} - -#if defined (__MINGW64__) - -void __security_check_cookie (uintptr_t _StackCookie) -{ - (void) _StackCookie; -} - -void __GSHandlerCheck () -{ -} - -#endif diff --git a/src/ext_nvml.c b/src/ext_nvml.c index 9d76f2aba..36e906e28 100644 --- a/src/ext_nvml.c +++ b/src/ext_nvml.c @@ -4,466 +4,8 @@ */ #include "common.h" -#include "logging.h" +#include "types.h" +#include "event.h" #include "memory.h" #include "dynloader.h" #include "ext_nvml.h" - -int nvml_init (NVML_PTR *nvml) -{ - if (!nvml) return -1; - - memset (nvml, 0, sizeof (NVML_PTR)); - - #if defined (_WIN) - nvml->lib = hc_dlopen ("nvml.dll"); - - if (!nvml->lib) - { - DWORD BufferSize = 1024; - - DWORD Type = REG_SZ; - - char *Buffer = (char *) mymalloc (BufferSize + 1); - - HKEY hKey = 0; - - if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS) - { - Buffer[BufferSize] = 0; - } - else - { - //if (user_options->quiet == false) - // log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled."); - - return -1; - } - - RegCloseKey (hKey); - } - else - { - //if (user_options->quiet == false) - // log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled."); - - return -1; - } - - strcat (Buffer, "\\nvml.dll"); - - nvml->lib = hc_dlopen (Buffer); - - myfree (Buffer); - } - - #elif defined (_POSIX) - nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW); - #endif - - if (!nvml->lib) - { - //if (user_options->quiet == false) - // log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceSetComputeMode, NVML_DEVICE_SET_COMPUTEMODE, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceSetGpuOperationMode, NVML_DEVICE_SET_OPERATIONMODE, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimitConstraints, NVML_DEVICE_GET_POWERMANAGEMENTLIMITCONSTRAINTS, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceSetPowerManagementLimit, NVML_DEVICE_SET_POWERMANAGEMENTLIMIT, NVML, 0) - HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimit, NVML_DEVICE_GET_POWERMANAGEMENTLIMIT, NVML, 0) - - return 0; -} - -void nvml_close (NVML_PTR *nvml) -{ - if (nvml) - { - if (nvml->lib) - hc_dlclose (nvml->lib); - - myfree (nvml); - } -} - -const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc) -{ - if (!nvml) return NULL; - - return nvml->nvmlErrorString (nvml_rc); -} - -nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlInit (); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlInit()", nvml_rc, string); - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlShutdown (); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlShutdown()", nvml_rc, string); - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, char *name, unsigned int length) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetName (device, name, length); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int skip_warnings, unsigned int index, nvmlDevice_t *device) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (index, device); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *speed) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *power) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerUsage (device, power); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlUtilization_t *utilization) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetClockInfo()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperatureThreshold()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkGen) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkGeneration (device, currLinkGen); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkGeneration()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkWidth) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkWidth()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrentClocksThrottleReasons (device, clocksThrottleReasons); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrentClocksThrottleReasons()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetSupportedClocksThrottleReasons (device, supportedClocksThrottleReasons); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetSupportedClocksThrottleReasons()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlComputeMode_t mode) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetComputeMode (device, mode); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceSetComputeMode()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlGpuOperationMode_t mode) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetGpuOperationMode (device, mode); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceSetGpuOperationMode()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimitConstraints (device, minLimit, maxLimit); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimitConstraints()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetPowerManagementLimit (device, limit); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceSetPowerManagementLimit()", nvml_rc, string); - } - } - - return nvml_rc; -} - -nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit) -{ - if (!nvml) return (nvmlReturn_t) -1; - - nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimit (device, limit); - - if (nvml_rc != NVML_SUCCESS) - { - if (skip_warnings == 0) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimit()", nvml_rc, string); - } - } - - return nvml_rc; -} diff --git a/src/ext_xnvctrl.c b/src/ext_xnvctrl.c index b63cd90a2..d3e06a904 100644 --- a/src/ext_xnvctrl.c +++ b/src/ext_xnvctrl.c @@ -4,216 +4,7 @@ */ #include "common.h" -#include "logging.h" +#include "types.h" +#include "event.h" #include "memory.h" -#include "dynloader.h" #include "ext_xnvctrl.h" - -int xnvctrl_init (XNVCTRL_PTR *xnvctrl) -{ - if (!xnvctrl) return -1; - - memset (xnvctrl, 0, sizeof (XNVCTRL_PTR)); - - #if defined (_WIN) - - // unsupport platform? - return -1; - - #elif defined (_POSIX) - - xnvctrl->lib_x11 = dlopen ("libX11.so", RTLD_LAZY); - - if (xnvctrl->lib_x11 == NULL) - { - //if (user_options->quiet == false) log_info ("WARNING: Failed loading the X11 library: %s", dlerror()); - //if (user_options->quiet == false) log_info (" Please install libx11-dev package."); - //if (user_options->quiet == false) log_info (""); - - return -1; - } - - xnvctrl->lib_xnvctrl = dlopen ("libXNVCtrl.so", RTLD_LAZY); - - if (xnvctrl->lib_xnvctrl == NULL) - { - //if (user_options->quiet == false) log_info ("WARNING: Failed loading the XNVCTRL library: %s", dlerror()); - //if (user_options->quiet == false) log_info (" Please install libxnvctrl-dev package."); - //if (user_options->quiet == false) log_info (""); - - return -1; - } - - HC_LOAD_FUNC2 (xnvctrl, XOpenDisplay, XOPENDISPLAY, lib_x11, X11, 0); - HC_LOAD_FUNC2 (xnvctrl, XCloseDisplay, XCLOSEDISPLAY, lib_x11, X11, 0); - - HC_LOAD_FUNC2 (xnvctrl, XNVCTRLQueryTargetAttribute, XNVCTRLQUERYTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0); - HC_LOAD_FUNC2 (xnvctrl, XNVCTRLSetTargetAttribute, XNVCTRLSETTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0); - - #endif - - return 0; -} - -void xnvctrl_close (XNVCTRL_PTR *xnvctrl) -{ - if (xnvctrl) - { - #if defined (_POSIX) - - if (xnvctrl->lib_x11) - { - dlclose (xnvctrl->lib_x11); - } - - if (xnvctrl->lib_xnvctrl) - { - dlclose (xnvctrl->lib_xnvctrl); - } - - #endif - - myfree (xnvctrl); - } -} - -int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XOpenDisplay == NULL) return -1; - - void *dpy = xnvctrl->XOpenDisplay (NULL); - - if (dpy == NULL) - { - xnvctrl->dpy = NULL; - - return -1; - } - - xnvctrl->dpy = dpy; - - return 0; -} - -void hm_XNVCTRL_XCloseDisplay (XNVCTRL_PTR *xnvctrl) -{ - if (xnvctrl == NULL) return; - - if (xnvctrl->XCloseDisplay == NULL) return; - - if (xnvctrl->dpy == NULL) return; - - xnvctrl->XCloseDisplay (xnvctrl->dpy); -} - -int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); - - if (!rc) return -1; - - return 0; -} - -int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int cur; - - int rc = get_fan_control (xnvctrl, gpu, &cur); - - if (rc == -1) return -1; - - xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); - - rc = get_fan_control (xnvctrl, gpu, &cur); - - if (rc == -1) return -1; - - if (cur != val) return -1; - - return 0; -} - -int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_CORE_THRESHOLD, val); - - if (!rc) return -1; - - return 0; -} - -int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val); - - if (!rc) return -1; - - return 0; -} - -int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); - - if (!rc) return -1; - - return 0; -} - -int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val) -{ - if (xnvctrl == NULL) return -1; - - if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1; - - if (xnvctrl->dpy == NULL) return -1; - - int cur; - - int rc = get_fan_speed_target (xnvctrl, gpu, &cur); - - if (rc == -1) return -1; - - xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); - - rc = get_fan_speed_target (xnvctrl, gpu, &cur); - - if (rc == -1) return -1; - - if (cur != val) return -1; - - return 0; -} diff --git a/src/folder.c b/src/folder.c index 368df70c8..6e595b3a5 100644 --- a/src/folder.c +++ b/src/folder.c @@ -10,12 +10,12 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "shared.h" #include "folder.h" #if defined (__APPLE__) -#include "logging.h" +#include "event.h" #endif int sort_by_stringptr (const void *p1, const void *p2) @@ -26,7 +26,7 @@ int sort_by_stringptr (const void *p1, const void *p2) return strcmp (*s1, *s2); } -char *get_exec_path () +static char *get_exec_path () { size_t exec_path_len = 1024; @@ -48,12 +48,7 @@ char *get_exec_path () u32 size = (u32) exec_path_len; - if (_NSGetExecutablePath (exec_path, &size) != 0) - { - log_error("! executable path buffer too small\n"); - - exit (-1); - } + if (_NSGetExecutablePath (exec_path, &size) != 0) return NULL; const size_t len = strlen (exec_path); @@ -170,7 +165,7 @@ char **scan_directory (const char *path) if (readdir_r (d, &e, &de) != 0) { - log_error ("ERROR: readdir_r() failed"); + event_log_error (hashcat_ctx, "ERROR: readdir_r() failed"); break; } @@ -251,7 +246,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { - log_error ("ERROR: getcwd(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: getcwd(): %s", strerror (errno)); return -1; } @@ -262,6 +257,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, char *exec_path = get_exec_path (); + if (exec_path == NULL) + { + event_log_error (hashcat_ctx, "ERROR: get_exec_path() failed"); + + return -1; + } + #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) if (install_folder == NULL) install_folder = "/"; // makes library use easier @@ -271,14 +273,14 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, if (resolved_install_folder == NULL) { - log_error ("ERROR: %s: %s", resolved_install_folder, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", resolved_install_folder, strerror (errno)); return -1; } if (resolved_exec_path == NULL) { - log_error ("ERROR: %s: %s", resolved_exec_path, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", resolved_exec_path, strerror (errno)); return -1; } @@ -342,7 +344,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { - log_error ("ERROR: %s: %s", cpath, "GetFullPathName()"); + event_log_error (hashcat_ctx, "ERROR: %s: %s", cpath, "GetFullPathName()"); return -1; } @@ -355,7 +357,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, if (realpath (cpath, cpath_real) == NULL) { - log_error ("ERROR: %s: %s", cpath, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", cpath, strerror (errno)); return -1; } diff --git a/src/hashcat.c b/src/hashcat.c index 0ea3c91ca..6ba021604 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1023,8 +1023,19 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold dictstat_write (hashcat_ctx); + // final logfile entry + + time (&status_ctx->proc_stop); + + logfile_top_uint (status_ctx->proc_start); + logfile_top_uint (status_ctx->proc_stop); + + EVENT (EVENT_LOGFILE_TOP_FINALIZE); + // free memory + EVENT (EVENT_GOODBYE_SCREEN); + debugfile_destroy (hashcat_ctx); tuning_db_destroy (hashcat_ctx); @@ -1051,13 +1062,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold restore_ctx_destroy (hashcat_ctx); - time (&status_ctx->proc_stop); - - logfile_top_uint (status_ctx->proc_start); - logfile_top_uint (status_ctx->proc_stop); - - EVENT (EVENT_LOGFILE_TOP_FINALIZE); - user_options_extra_destroy (hashcat_ctx); user_options_destroy (hashcat_ctx); @@ -1069,8 +1073,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; - EVENT (EVENT_GOODBYE_SCREEN); - event_ctx_destroy (hashcat_ctx); status_ctx_destroy (hashcat_ctx); diff --git a/src/hashes.c b/src/hashes.c index 02f292886..40d9e59d6 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "hashes.h" #include "debugfile.h" @@ -117,7 +117,7 @@ int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3) return sort_by_digest_p0p1 (d1, d2, v3); } -void save_hash (hashcat_ctx_t *hashcat_ctx) +int save_hash (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -139,9 +139,9 @@ void save_hash (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", new_hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", new_hashfile, strerror (errno)); - exit (-1); + return -1; } for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) @@ -198,21 +198,23 @@ void save_hash (hashcat_ctx_t *hashcat_ctx) if (rename (hashfile, old_hashfile) != 0) { - log_error ("ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno)); - exit (-1); + return -1; } unlink (hashfile); if (rename (new_hashfile, hashfile) != 0) { - log_error ("ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno)); - exit (-1); + return -1; } unlink (old_hashfile); + + return 0; } void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain) @@ -309,11 +311,10 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos) { - cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - hashes_t *hashes = hashcat_ctx->hashes; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + hashes_t *hashes = hashcat_ctx->hashes; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; salt_t *salt_buf = &hashes->salts_buf[salt_pos]; @@ -321,11 +322,11 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_int CL_err; - CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL); + CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -334,15 +335,15 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { // display hack (for weak hashes etc, it could be that there is still something to clear on the current line) - log_info_nn (""); + event_log_info_nn (hashcat_ctx, ""); plain_t *cracked = (plain_t *) mycalloc (num_cracked, sizeof (plain_t)); - CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); + CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -375,7 +376,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, } } - if (hashes->salts_done == hashes->salts_cnt) mycracked (status_ctx); + if (hashes->salts_done == hashes->salts_cnt) mycracked (hashcat_ctx); check_hash (hashcat_ctx, device_param, &cracked[i]); } @@ -408,11 +409,11 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, memset (hashes->digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (u32)); - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (u32), salt_buf->digests_cnt * sizeof (u32), &hashes->digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (u32), salt_buf->digests_cnt * sizeof (u32), &hashes->digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -420,11 +421,11 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, num_cracked = 0; - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL); if (CL_err != CL_SUCCESS) { - log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); return -1; } @@ -478,7 +479,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (stat (hashes->hashfile, &st) == -1) { - log_error ("ERROR: %s: %s", hashes->hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", hashes->hashfile, strerror (errno)); return -1; } @@ -500,12 +501,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((fp = fopen (hashfile, "rb")) == NULL) { - log_error ("ERROR: %s: %s", hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", hashfile, strerror (errno)); return -1; } - if (user_options->quiet == false) log_info_nn ("Counting lines in %s", hashfile); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Counting lines in %s", hashfile); hashes_avail = count_lines (fp); @@ -513,7 +514,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (hashes_avail == 0) { - log_error ("ERROR: hashfile is empty or corrupt"); + event_log_error (hashcat_ctx, "ERROR: hashfile is empty or corrupt"); fclose (fp); @@ -524,7 +525,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((user_options->remove == 1) && (hashlist_format != HLFMT_HASHCAT)) { - log_error ("ERROR: remove not supported in native hashfile-format mode"); + event_log_error (hashcat_ctx, "ERROR: remove not supported in native hashfile-format mode"); fclose (fp); @@ -666,7 +667,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (hash_fmt_error) { - log_info ("WARNING: Failed to parse hashes using the '%s' format", strhlfmt (hashlist_format)); + event_log_warning (hashcat_ctx, "Failed to parse hashes using the '%s' format", strhlfmt (hashlist_format)); } else { @@ -688,7 +689,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { if (hash_len == 0) { - log_error ("ERROR: hccap file not specified"); + event_log_error (hashcat_ctx, "ERROR: hccap file not specified"); return -1; } @@ -701,14 +702,14 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", hash_buf, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", hash_buf, strerror (errno)); return -1; } if (hashes_avail < 1) { - log_error ("ERROR: hccap file is empty or corrupt"); + event_log_error (hashcat_ctx, "ERROR: hccap file is empty or corrupt"); fclose (fp); @@ -734,7 +735,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status != PARSER_OK) { - log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hash '%s': %s", hash_buf, strparser (parser_status)); continue; } @@ -806,7 +807,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } parser_status = hashconfig->parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig); @@ -821,7 +822,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } // show / left @@ -848,7 +849,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } } } @@ -868,7 +869,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } } } @@ -881,7 +882,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((fp = fopen (hashfile, "rb")) == NULL) { - log_error ("ERROR: %s: %s", hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", hashfile, strerror (errno)); return -1; } @@ -910,7 +911,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (hash_fmt_error) { - log_info ("WARNING: failed to parse hashes using the '%s' format", strhlfmt (hashlist_format)); + event_log_warning (hashcat_ctx, "failed to parse hashes using the '%s' format", strhlfmt (hashlist_format)); continue; } @@ -963,7 +964,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - log_info ("WARNING: Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); continue; } @@ -976,14 +977,14 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - log_info ("WARNING: Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); continue; } hash_t *lm_hash_right = &hashes_buf[hashes_cnt]; - if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); + if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); hashes_cnt++; @@ -998,12 +999,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - log_info ("WARNING: Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); continue; } - if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); + if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); @@ -1017,12 +1018,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - log_info ("WARNING: Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); continue; } - if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); + if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); @@ -1035,7 +1036,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) fclose (fp); - if (user_options->quiet == false) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00); } } @@ -1043,7 +1044,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (hashes_cnt) { - if (user_options->quiet == false) log_info_nn ("Sorting Hashes..."); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Sorting Hashes..."); if (hashconfig->is_salted) { @@ -1062,7 +1063,6 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; hash_t *hashes_buf = hashes->hashes_buf; @@ -1072,7 +1072,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) * Remove duplicates */ - if (user_options->quiet == false) log_info_nn ("Removing duplicate hashes..."); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Removing duplicate hashes..."); hashes_cnt = 1; @@ -1122,7 +1122,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t)); } - if (user_options->quiet == false) log_info_nn ("Structuring salts for cracking task..."); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task..."); u32 digests_cnt = hashes_cnt; u32 digests_done = 0; @@ -1248,7 +1248,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) salts_done++; } - if (salts_done == salts_cnt) mycracked (status_ctx); + if (salts_done == salts_cnt) mycracked (hashcat_ctx); } myfree (hashes->digests_buf); diff --git a/src/hwmon.c b/src/hwmon.c index e0fc636d1..b83502c7b 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -6,16 +6,133 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" +#include "dynloader.h" #include "hwmon.h" -static int get_adapters_num_adl (ADL_PTR *adl, int *iNumberAdapters) -{ - if (hm_ADL_Adapter_NumberOfAdapters_Get (adl, iNumberAdapters) != ADL_OK) return -1; +// nvml functions - if (iNumberAdapters == 0) +int nvml_init (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + memset (nvml, 0, sizeof (NVML_PTR)); + + #if defined (_WIN) + nvml->lib = hc_dlopen ("nvml.dll"); + + if (!nvml->lib) { - log_info ("WARN: No ADL adapters found."); + DWORD BufferSize = 1024; + + DWORD Type = REG_SZ; + + char *Buffer = (char *) mymalloc (BufferSize + 1); + + HKEY hKey = 0; + + if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS) + { + Buffer[BufferSize] = 0; + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + + return -1; + } + + RegCloseKey (hKey); + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + + return -1; + } + + strcat (Buffer, "\\nvml.dll"); + + nvml->lib = hc_dlopen (Buffer); + + myfree (Buffer); + } + + #elif defined (_POSIX) + nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW); + #endif + + if (!nvml->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceSetComputeMode, NVML_DEVICE_SET_COMPUTEMODE, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceSetGpuOperationMode, NVML_DEVICE_SET_OPERATIONMODE, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimitConstraints, NVML_DEVICE_GET_POWERMANAGEMENTLIMITCONSTRAINTS, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceSetPowerManagementLimit, NVML_DEVICE_SET_POWERMANAGEMENTLIMIT, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimit, NVML_DEVICE_GET_POWERMANAGEMENTLIMIT, NVML, 0) + + return 0; +} + +void nvml_close (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + if (nvml) + { + if (nvml->lib) + hc_dlclose (nvml->lib); + + myfree (nvml); + } +} + +static const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t nvml_rc) +{ + return nvml->nvmlErrorString (nvml_rc); +} + +int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlInit (); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlInit()", nvml_rc, string); return -1; } @@ -23,26 +140,1692 @@ static int get_adapters_num_adl (ADL_PTR *adl, int *iNumberAdapters) return 0; } -static LPAdapterInfo hm_get_adapter_info_adl (ADL_PTR *adl, int iNumberAdapters) +int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlShutdown (); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlShutdown()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (index, device); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetName (device, name, length); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerUsage (device, power); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetClockInfo()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetTemperatureThreshold()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkGeneration (device, currLinkGen); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrPcieLinkGeneration()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrPcieLinkWidth()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrentClocksThrottleReasons (device, clocksThrottleReasons); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrentClocksThrottleReasons()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetSupportedClocksThrottleReasons (device, supportedClocksThrottleReasons); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetSupportedClocksThrottleReasons()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetComputeMode (device, mode); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetComputeMode()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetGpuOperationMode (device, mode); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetGpuOperationMode()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimitConstraints (device, minLimit, maxLimit); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerManagementLimitConstraints()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetPowerManagementLimit (device, limit); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetPowerManagementLimit()", nvml_rc, string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimit (device, limit); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerManagementLimit()", nvml_rc, string); + + return -1; + } + + return 0; +} + +// nvapi functions + +int nvapi_init (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + memset (nvapi, 0, sizeof (NVAPI_PTR)); + + #if defined (_WIN) + #if defined (WIN64) + nvapi->lib = hc_dlopen ("nvapi64.dll"); + #elif defined (WIN32) + nvapi->lib = hc_dlopen ("nvapi.dll"); + #endif + #else + nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah + #endif + + if (!nvapi->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "load NVAPI library failed, proceed without NVAPI HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7E, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048C, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921F, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0C, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_GPU_SetCoolerLevels, NVAPI_GPU_SETCOOLERLEVELS, nvapi_QueryInterface, 0x891FA0AE, NVAPI, 0) + HC_LOAD_ADDR(nvapi, NvAPI_GPU_RestoreCoolerSettings, NVAPI_GPU_RESTORECOOLERSETTINGS, nvapi_QueryInterface, 0x8F6ED0FB, NVAPI, 0) + + return 0; +} + +void nvapi_close (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + if (nvapi) + { + if (nvapi->lib) + hc_dlclose (nvapi->lib); + + myfree (nvapi); + } +} + +static void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI_rc, NvAPI_ShortString string) +{ + nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); +} + +int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize (); + + if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) return -1; + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_Initialize()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload (); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_Unload()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_EnumPhysicalGPUs()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_GetPerfPoliciesInfo()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_GetPerfPoliciesStatus()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_SetCoolerLevels (hPhysicalGpu, coolerIndex, pCoolerLevels); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_SetCoolerLevels()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVAPI_PTR *nvapi = hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_RestoreCoolerSettings (hPhysicalGpu, coolerIndex); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_RestoreCoolerSettings()", NvAPI_rc, string); + + return -1; + } + + return 0; +} + +#if defined (__MINGW64__) + +void __security_check_cookie (uintptr_t _StackCookie) +{ + (void) _StackCookie; +} + +void __GSHandlerCheck () +{ +} + +#endif + +// xnvctrl functions + +int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + memset (xnvctrl, 0, sizeof (XNVCTRL_PTR)); + + #if defined (_WIN) + + // unsupport platform? + return -1; + + #elif defined (_POSIX) + + xnvctrl->lib_x11 = dlopen ("libX11.so", RTLD_LAZY); + + if (xnvctrl->lib_x11 == NULL) + { + //if (user_options->quiet == false) event_log_error (hashcat_ctx, "Failed loading the X11 library: %s", dlerror()); + //if (user_options->quiet == false) event_log_info (hashcat_ctx, " Please install libx11-dev package."); + //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + + return -1; + } + + xnvctrl->lib_xnvctrl = dlopen ("libXNVCtrl.so", RTLD_LAZY); + + if (xnvctrl->lib_xnvctrl == NULL) + { + //if (user_options->quiet == false) event_log_error (hashcat_ctx, "Failed loading the XNVCTRL library: %s", dlerror()); + //if (user_options->quiet == false) event_log_info (hashcat_ctx, " Please install libxnvctrl-dev package."); + //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + + return -1; + } + + HC_LOAD_FUNC2 (xnvctrl, XOpenDisplay, XOPENDISPLAY, lib_x11, X11, 0); + HC_LOAD_FUNC2 (xnvctrl, XCloseDisplay, XCLOSEDISPLAY, lib_x11, X11, 0); + + HC_LOAD_FUNC2 (xnvctrl, XNVCTRLQueryTargetAttribute, XNVCTRLQUERYTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0); + HC_LOAD_FUNC2 (xnvctrl, XNVCTRLSetTargetAttribute, XNVCTRLSETTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0); + + #endif + + return 0; +} + +void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl) + { + #if defined (_POSIX) + + if (xnvctrl->lib_x11) + { + dlclose (xnvctrl->lib_x11); + } + + if (xnvctrl->lib_xnvctrl) + { + dlclose (xnvctrl->lib_xnvctrl); + } + + #endif + + myfree (xnvctrl); + } +} + +int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XOpenDisplay == NULL) return -1; + + void *dpy = xnvctrl->XOpenDisplay (NULL); + + if (dpy == NULL) + { + event_log_error (hashcat_ctx, "%s\n", "XOpenDisplay() failed"); + + return -1; + } + + xnvctrl->dpy = dpy; + + return 0; +} + +void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XCloseDisplay == NULL) return; + + if (xnvctrl->dpy == NULL) return; + + xnvctrl->XCloseDisplay (xnvctrl->dpy); +} + +int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + const bool rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); + + if (rc == false) + { + event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_COOLER_MANUAL_CONTROL) failed"); + + return -1; + } + + return 0; +} + +int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + int cur; + + int rc = get_fan_control (hashcat_ctx, gpu, &cur); + + if (rc == -1) return -1; + + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); + + rc = get_fan_control (hashcat_ctx, gpu, &cur); + + if (rc == -1) return -1; + + if (cur != val) return -1; + + return 0; +} + +int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + const bool rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_CORE_THRESHOLD, val); + + if (rc == false) + { + event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_CORE_THRESHOLD) failed"); + + return -1; + } + + return 0; +} + +int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + const bool rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val); + + if (rc == false) + { + event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) failed"); + + return -1; + } + + return 0; +} + +int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + const int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); + + if (rc == false) + { + event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_LEVEL) failed"); + + return -1; + } + + return 0; +} + +int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + XNVCTRL_PTR *xnvctrl = hwmon_ctx->hm_xnvctrl; + + if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1; + + if (xnvctrl->dpy == NULL) return -1; + + int cur; + + int rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + + if (rc == -1) return -1; + + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); + + rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + + if (rc == -1) return -1; + + if (cur != val) return -1; + + return 0; +} + +// ADL functions + +int adl_init (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + memset (adl, 0, sizeof (ADL_PTR)); + + #if defined (_WIN) + adl->lib = hc_dlopen ("atiadlxx.dll"); + + if (!adl->lib) + { + adl->lib = hc_dlopen ("atiadlxy.dll"); + } + #elif defined (_POSIX) + adl->lib = hc_dlopen ("libatiadlxx.so", RTLD_NOW); + #endif + + if (!adl->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "load ADL library failed, proceed without ADL HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Set, ADL_OVERDRIVE5_FANSPEED_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Set, ADL_OVERDRIVE6_FANSPEED_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedToDefault_Set, ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_ODParameters_Get, ADL_OVERDRIVE5_ODPARAMETERS_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Get, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Set, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControlInfo_Get, ADL_OVERDRIVE6_POWERCONTROLINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Get, ADL_OVERDRIVE6_POWERCONTROL_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Set, ADL_OVERDRIVE6_POWERCONTROL_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0) + //HC_LOAD_FUNC(adl, ADL_DisplayEnable_Set, ADL_DISPLAYENABLE_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Caps, ADL_OVERDRIVE6_POWERCONTROL_CAPS, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_State_Set, ADL_OVERDRIVE6_STATE_SET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0) + HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Reset, ADL_OVERDRIVE6_FANSPEED_RESET, ADL, 0) + + return 0; +} + +void adl_close (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + if (adl) + { + if (adl->lib) + hc_dlclose (adl->lib); + + myfree (adl); + } +} + +int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Main_Control_Destroy (); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Main_Control_Destroy()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Main_Control_Create()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_NumberOfAdapters_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_AdapterInfo_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Display_DisplayInfo_Get (iAdapterIndex, iNumDisplays, lppInfo, iForceDetect); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Display_DisplayInfo_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_ID_Get (iAdapterIndex, lpAdapterID); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_ID_Get()", ADL_rc); + + return -1; + } + + return ADL_rc; +} + +int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_VideoBiosInfo_Get (iAdapterIndex, lpBiosInfo); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_VideoBiosInfo_Get()", ADL_rc); + + return -1; + } + + return ADL_rc; +} + +int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_ThermalDevices_Enum (iAdapterIndex, iThermalControllerIndex, lpThermalControllerInfo); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ThermalDevices_Enum()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_Temperature_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_Temperature_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_CurrentActivity_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_FanSpeedInfo_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedInfo); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeedInfo_Get()", ADL_rc); + + return -1; + } + + return ADL_rc; +} + +int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeed_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Set (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeed_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Set (iAdapterIndex, lpFanSpeedValue); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_FanSpeedToDefault_Set (iAdapterIndex, iThermalControllerIndex); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeedToDefault_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_ODParameters_Get (iAdapterIndex, lpOdParameters); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODParameters_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Get (iAdapterIndex, iDefault, lpOdPerformanceLevels); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Set (iAdapterIndex, lpOdPerformanceLevels); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_PowerControlInfo_Get (iAdapterIndex, powertune); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControlInfo_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iCurrentValue) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + int default_value = 0; + + const int ADL_rc = adl->ADL_Overdrive6_PowerControl_Get (iAdapterIndex, iCurrentValue, &default_value); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; + + const int hm_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx, iAdapterIndex, &powertune); + + if (hm_rc == -1) return -1; + + int min = powertune.iMinValue; + int max = powertune.iMaxValue; + int step = powertune.iStepValue; + + if (level < min || level > max) + { + event_log_error (hashcat_ctx, "ADL PowerControl level invalid"); + + return -1; + } + + if (level % step != 0) + { + event_log_error (hashcat_ctx, "ADL PowerControl step invalid"); + + return -1; + } + + const int ADL_rc = adl->ADL_Overdrive6_PowerControl_Set (iAdapterIndex, level); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_Active_Get (iAdapterIndex, lpStatus); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_Active_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +/* +int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_DisplayEnable_Set (iAdapterIndex, lpDisplayIndexList, iDisplayListSize, bPersistOnly); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_DisplayEnable_Set()", ADL_rc); + + return -1; + } + + return 0; +} +*/ + +int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive_Caps()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_PowerControl_Caps (iAdapterIndex, lpSupported); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Caps()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_Capabilities_Get (iAdapterIndex, caps); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_Capabilities_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_StateInfo_Get (iAdapterIndex, type, state); + + if (ADL_rc == ADL_OK) + { + // check if clocks are okay with step sizes + // if not run a little hack: adjust the clocks to nearest clock size (clock down just a little bit) + + ADLOD6Capabilities caps; + + const int hm_rc = hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx, iAdapterIndex, &caps); + + if (hm_rc == -1) return -1; + + if (state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL engine step size invalid for performance level 1"); + + //state->state.aLevels[0].iEngineClock -= state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep; + + return -1; + } + + if (state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL engine step size invalid for performance level 2"); + + //state->state.aLevels[1].iEngineClock -= state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep; + + return -1; + } + + if (state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL memory step size invalid for performance level 1"); + + //state->state.aLevels[0].iMemoryClock -= state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep; + + return -1; + } + + if (state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL memory step size invalid for performance level 2"); + + //state->state.aLevels[1].iMemoryClock -= state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep; + + return -1; + } + } + else + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_StateInfo_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_CurrentStatus_Get (iAdapterIndex, status); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_CurrentStatus_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + // sanity checks + + ADLOD6Capabilities caps; + + const int hm_rc = hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx, iAdapterIndex, &caps); + + if (hm_rc == -1) return -1; + + if (state->aLevels[0].iEngineClock < caps.sEngineClockRange.iMin || state->aLevels[1].iEngineClock > caps.sEngineClockRange.iMax) + { + event_log_error (hashcat_ctx, "ADL engine clock outside valid range"); + + return -1; + } + + if (state->aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL engine step size invalid"); + + return -1; + } + + if (state->aLevels[0].iMemoryClock < caps.sMemoryClockRange.iMin || state->aLevels[1].iMemoryClock > caps.sMemoryClockRange.iMax) + { + event_log_error (hashcat_ctx, "ADL memory clock outside valid range"); + + return -1; + } + + if (state->aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0) + { + event_log_error (hashcat_ctx, "ADL memory step size invalid"); + + return -1; + } + + const int ADL_rc = adl->ADL_Overdrive6_State_Set (iAdapterIndex, type, state); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_State_Set()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_TargetTemperatureData_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureRangeInfo_Get (iAdapterIndex, lpTargetTemperatureInfo); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_TargetTemperatureRangeInfo_Get()", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + ADL_PTR *adl = hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Reset (iAdapterIndex); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Reset()", ADL_rc); + + return -1; + } + + return 0; +} + +// general functions + +static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapters) +{ + const int hm_rc = hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx, iNumberAdapters); + + if (hm_rc == -1) return -1; + + if (iNumberAdapters == 0) + { + event_log_error (hashcat_ctx, "No ADL adapters found."); + + return -1; + } + + return 0; +} + +static LPAdapterInfo hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters) { size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo); LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) mymalloc (AdapterInfoSize); - if (hm_ADL_Adapter_AdapterInfo_Get (adl, lpAdapterInfo, AdapterInfoSize) != ADL_OK) return NULL; + if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize) == -1) return NULL; return lpAdapterInfo; } -static int hm_get_adapter_index_nvapi (const hwmon_ctx_t *hwmon_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle) +static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle) { NvU32 pGpuCount; - if (hm_NvAPI_EnumPhysicalGPUs (hwmon_ctx->hm_nvapi, nvapiGPUHandle, &pGpuCount) != NVAPI_OK) return 0; + if (hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx, nvapiGPUHandle, &pGpuCount) != NVAPI_OK) return 0; if (pGpuCount == 0) { - log_info ("WARN: No NvAPI adapters found"); + event_log_error (hashcat_ctx, "No NvAPI adapters found"); return 0; } @@ -50,24 +1833,24 @@ static int hm_get_adapter_index_nvapi (const hwmon_ctx_t *hwmon_ctx, HM_ADAPTER_ return (pGpuCount); } -static int hm_get_adapter_index_nvml (const hwmon_ctx_t *hwmon_ctx, HM_ADAPTER_NVML *nvmlGPUHandle) +static int hm_get_adapter_index_nvml (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVML *nvmlGPUHandle) { int pGpuCount = 0; for (u32 i = 0; i < DEVICES_MAX; i++) { - if (hm_NVML_nvmlDeviceGetHandleByIndex (hwmon_ctx->hm_nvml, 1, i, &nvmlGPUHandle[i]) != NVML_SUCCESS) break; + if (hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx, i, &nvmlGPUHandle[i]) == -1) break; // can be used to determine if the device by index matches the cuda device by index // char name[100]; memset (name, 0, sizeof (name)); - // hm_NVML_nvmlDeviceGetName (hwmon_ctx->hm_nvml, nvGPUHandle[i], name, sizeof (name) - 1); + // hm_NVML_nvmlDeviceGetName (hashcat_ctx, nvGPUHandle[i], name, sizeof (name) - 1); pGpuCount++; } if (pGpuCount == 0) { - log_info ("WARN: No NVML adapters found"); + event_log_error (hashcat_ctx, "No NVML adapters found"); return 0; } @@ -188,7 +1971,7 @@ static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_ad return adl_adapters; } -static int hm_check_fanspeed_control (ADL_PTR *adl, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static int hm_check_fanspeed_control (hashcat_ctx_t *hashcat_ctx, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) { // loop through all valid devices @@ -218,7 +2001,7 @@ static int hm_check_fanspeed_control (ADL_PTR *adl, hm_attrs_t *hm_device, u32 * FanSpeedInfo.iSize = sizeof (ADLFanSpeedInfo); - if (hm_ADL_Overdrive5_FanSpeedInfo_Get (adl, info.iAdapterIndex, 0, &FanSpeedInfo) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx, info.iAdapterIndex, 0, &FanSpeedInfo) == -1) return -1; // check read and write capability in fanspeedinfo @@ -238,7 +2021,7 @@ static int hm_check_fanspeed_control (ADL_PTR *adl, hm_attrs_t *hm_device, u32 * memset (&faninfo, 0, sizeof (faninfo)); - if (hm_ADL_Overdrive6_FanSpeed_Get (adl, info.iAdapterIndex, &faninfo) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, info.iAdapterIndex, &faninfo) == -1) return -1; // check read capability in fanspeedinfo @@ -256,7 +2039,7 @@ static int hm_check_fanspeed_control (ADL_PTR *adl, hm_attrs_t *hm_device, u32 * return 0; } -static int hm_get_overdrive_version (ADL_PTR *adl, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static int hm_get_overdrive_version (hashcat_ctx_t *hashcat_ctx, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) { for (int i = 0; i < num_adl_adapters; i++) { @@ -272,7 +2055,7 @@ static int hm_get_overdrive_version (ADL_PTR *adl, hm_attrs_t *hm_device, u32 *v int od_enabled = 0; int od_version = 0; - if (hm_ADL_Overdrive_Caps (adl, info.iAdapterIndex, &od_supported, &od_enabled, &od_version) != ADL_OK) return -1; + if (hm_ADL_Overdrive_Caps (hashcat_ctx, info.iAdapterIndex, &od_supported, &od_enabled, &od_version) == -1) return -1; // store the overdrive version in hm_device @@ -288,11 +2071,15 @@ static int hm_get_overdrive_version (ADL_PTR *adl, hm_attrs_t *hm_device, u32 *v return 0; } -static int hm_get_adapter_index_adl (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static int hm_get_adapter_index_adl (hashcat_ctx_t *hashcat_ctx, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) { + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + hm_attrs_t *hm_device = hwmon_ctx->hm_device; + for (int i = 0; i < num_adl_adapters; i++) { - u32 adapter_index = valid_adl_device_list[i]; + const u32 adapter_index = valid_adl_device_list[i]; // get AdapterInfo @@ -334,7 +2121,7 @@ int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const int CurrentValue = 0; int DefaultValue = 0; - if (hm_ADL_Overdrive6_TargetTemperatureData_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &CurrentValue, &DefaultValue) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &CurrentValue, &DefaultValue) == -1) return -1; // the return value has never been tested since hm_ADL_Overdrive6_TargetTemperatureData_Get() never worked on any system. expect problems. @@ -347,7 +2134,7 @@ int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const { int target = 0; - if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) == -1) return -1; return target; } @@ -383,7 +2170,7 @@ int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const { int target = 0; - if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) == -1) return -1; return target; } @@ -410,7 +2197,7 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev Temperature.iSize = sizeof (ADLTemperature); - if (hm_ADL_Overdrive5_Temperature_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, 0, &Temperature) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, 0, &Temperature) == -1) return -1; return Temperature.iTemperature / 1000; } @@ -418,7 +2205,7 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev { int Temperature = 0; - if (hm_ADL_Overdrive6_Temperature_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &Temperature) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &Temperature) == -1) return -1; return Temperature / 1000; } @@ -429,7 +2216,7 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev { int temperature = 0; - if (hm_NVML_nvmlDeviceGetTemperature (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, NVML_TEMPERATURE_GPU, (u32 *) &temperature) == -1) return -1; return temperature; } @@ -461,7 +2248,7 @@ int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic lpFanSpeedValue.iSize = sizeof (lpFanSpeedValue); lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; - if (hm_ADL_Overdrive5_FanSpeed_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) == -1) return -1; return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1; } @@ -506,7 +2293,7 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT; lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; - if (hm_ADL_Overdrive5_FanSpeed_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) == -1) return -1; return lpFanSpeedValue.iFanSpeed; } @@ -516,7 +2303,7 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device memset (&faninfo, 0, sizeof (faninfo)); - if (hm_ADL_Overdrive6_FanSpeed_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &faninfo) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &faninfo) == -1) return -1; return faninfo.iFanSpeedPercent; } @@ -527,7 +2314,7 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device { int speed = 0; - if (hm_NVML_nvmlDeviceGetFanSpeed (hwmon_ctx->hm_nvml, 0, hwmon_ctx->hm_device[device_id].nvml, (u32 *) &speed) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, (u32 *) &speed) == -1) return -1; return speed; } @@ -553,7 +2340,7 @@ int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device PMActivity.iSize = sizeof (ADLPMActivity); - if (hm_ADL_Overdrive_CurrentActivity_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1; + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &PMActivity) == -1) return -1; return PMActivity.iCurrentBusLanes; } @@ -563,7 +2350,7 @@ int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device { unsigned int currLinkWidth; - if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, &currLinkWidth) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &currLinkWidth) == -1) return -1; return currLinkWidth; } @@ -588,7 +2375,7 @@ int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev PMActivity.iSize = sizeof (ADLPMActivity); - if (hm_ADL_Overdrive_CurrentActivity_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1; + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &PMActivity) == -1) return -1; return PMActivity.iActivityPercent; } @@ -598,7 +2385,7 @@ int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev { nvmlUtilization_t utilization; - if (hm_NVML_nvmlDeviceGetUtilizationRates (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, &utilization) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &utilization) == -1) return -1; return utilization.gpu; } @@ -623,7 +2410,7 @@ int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev PMActivity.iSize = sizeof (ADLPMActivity); - if (hm_ADL_Overdrive_CurrentActivity_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1; + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &PMActivity) == -1) return -1; return PMActivity.iMemoryClock / 100; } @@ -633,7 +2420,7 @@ int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev { unsigned int clock; - if (hm_NVML_nvmlDeviceGetClockInfo (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, NVML_CLOCK_MEM, &clock) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, NVML_CLOCK_MEM, &clock) == -1) return -1; return clock; } @@ -658,7 +2445,7 @@ int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic PMActivity.iSize = sizeof (ADLPMActivity); - if (hm_ADL_Overdrive_CurrentActivity_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1; + if (hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &PMActivity) == -1) return -1; return PMActivity.iEngineClock / 100; } @@ -668,7 +2455,7 @@ int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic { unsigned int clock; - if (hm_NVML_nvmlDeviceGetClockInfo (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, NVML_CLOCK_SM, &clock) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, NVML_CLOCK_SM, &clock) == -1) return -1; return clock; } @@ -695,8 +2482,8 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device unsigned long long clocksThrottleReasons = 0; unsigned long long supportedThrottleReasons = 0; - if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, &clocksThrottleReasons) != NVML_SUCCESS) return -1; - if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hwmon_ctx->hm_nvml, 1, hwmon_ctx->hm_device[device_id].nvml, &supportedThrottleReasons) != NVML_SUCCESS) return -1; + if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &clocksThrottleReasons) == -1) return -1; + if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &supportedThrottleReasons) == -1) return -1; clocksThrottleReasons &= supportedThrottleReasons; clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle; @@ -737,7 +2524,7 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED; lpFanSpeedValue.iFanSpeed = fanspeed; - if (hm_ADL_Overdrive5_FanSpeed_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, 0, &lpFanSpeedValue) == -1) return -1; return 0; } @@ -750,7 +2537,7 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT; fan_speed_value.iFanSpeed = fanspeed; - if (hm_ADL_Overdrive6_FanSpeed_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &fan_speed_value) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &fan_speed_value) == -1) return -1; return 0; } @@ -759,13 +2546,13 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de { if (hwmon_ctx->hm_device[device_id].od_version == 5) { - if (hm_ADL_Overdrive5_FanSpeedToDefault_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, 0) != ADL_OK) return -1; + if (hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, 0) == -1) return -1; return 0; } else // od_version == 6 { - if (hm_ADL_Overdrive6_FanSpeed_Reset (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl) != ADL_OK) return -1; + if (hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl) == -1) return -1; return 0; } @@ -797,13 +2584,13 @@ int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32 CoolerLevels.Levels[0].Level = fanspeed; CoolerLevels.Levels[0].Policy = 1; - if (hm_NvAPI_GPU_SetCoolerLevels (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1; + if (hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1; return 0; } else { - if (hm_NvAPI_GPU_RestoreCoolerSettings (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, 0) != NVAPI_OK) return -1; + if (hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, 0) != NVAPI_OK) return -1; return 0; } @@ -823,7 +2610,7 @@ int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u3 { if (hwmon_ctx->hm_xnvctrl) { - if (set_fan_speed_target (hwmon_ctx->hm_xnvctrl, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) != 0) return -1; + if (set_fan_speed_target (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) == -1) return -1; return 0; } @@ -860,28 +2647,66 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) mymalloc (sizeof (XNVCTRL_PTR)); - hwmon_ctx->hm_adl = NULL; - hwmon_ctx->hm_nvapi = NULL; - hwmon_ctx->hm_nvml = NULL; - hwmon_ctx->hm_xnvctrl = NULL; - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - if ((opencl_ctx->need_nvml == true) && (nvml_init (nvml) == 0)) + if (opencl_ctx->need_nvml == true) { hwmon_ctx->hm_nvml = nvml; + + if (nvml_init (hashcat_ctx) == -1) + { + myfree (hwmon_ctx->hm_nvml); + + hwmon_ctx->hm_nvml = NULL; + } + } + + if (opencl_ctx->need_nvapi == true) + { + hwmon_ctx->hm_nvapi = nvapi; + + if (nvapi_init (hashcat_ctx) == -1) + { + myfree (hwmon_ctx->hm_nvapi); + + hwmon_ctx->hm_nvapi = NULL; + } + } + + if (opencl_ctx->need_xnvctrl == true) + { + hwmon_ctx->hm_xnvctrl = xnvctrl; + + if (xnvctrl_init (hashcat_ctx) == -1) + { + myfree (hwmon_ctx->hm_xnvctrl); + + hwmon_ctx->hm_xnvctrl = NULL; + } + } + + if (opencl_ctx->need_adl == true) + { + hwmon_ctx->hm_adl = adl; + + if (adl_init (hashcat_ctx) == -1) + { + myfree (hwmon_ctx->hm_adl); + + hwmon_ctx->hm_adl = NULL; + } } if (hwmon_ctx->hm_nvml) { - if (hm_NVML_nvmlInit (hwmon_ctx->hm_nvml) == NVML_SUCCESS) + if (hm_NVML_nvmlInit (hashcat_ctx) == 0) { HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); - int tmp_in = hm_get_adapter_index_nvml (hwmon_ctx, nvmlGPUHandle); + int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle); int tmp_out = 0; @@ -894,29 +2719,24 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { unsigned int speed; - if (hm_NVML_nvmlDeviceGetFanSpeed (hwmon_ctx->hm_nvml, 0, hm_adapters_nvml[i].nvml, &speed) == NVML_SUCCESS) hm_adapters_nvml[i].fan_get_supported = true; + if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hm_adapters_nvml[i].nvml, &speed) == 0) hm_adapters_nvml[i].fan_get_supported = true; // doesn't seem to create any advantages - //hm_NVML_nvmlDeviceSetComputeMode (hwmon_ctx->hm_nvml, 1, hm_adapters_nvml[i].nvml, NVML_COMPUTEMODE_EXCLUSIVE_PROCESS); - //hm_NVML_nvmlDeviceSetGpuOperationMode (hwmon_ctx->hm_nvml, 1, hm_adapters_nvml[i].nvml, NVML_GOM_ALL_ON); + //hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_COMPUTEMODE_EXCLUSIVE_PROCESS); + //hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_GOM_ALL_ON); } myfree (nvmlGPUHandle); } } - if ((opencl_ctx->need_nvapi == true) && (nvapi_init (nvapi) == 0)) - { - hwmon_ctx->hm_nvapi = nvapi; - } - if (hwmon_ctx->hm_nvapi) { - if (hm_NvAPI_Initialize (hwmon_ctx->hm_nvapi) == NVAPI_OK) + if (hm_NvAPI_Initialize (hashcat_ctx) == 0) { HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); - int tmp_in = hm_get_adapter_index_nvapi (hwmon_ctx, nvGPUHandle); + int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle); int tmp_out = 0; @@ -929,14 +2749,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - if ((opencl_ctx->need_xnvctrl == true) && (xnvctrl_init (xnvctrl) == 0)) - { - hwmon_ctx->hm_xnvctrl = xnvctrl; - } - if (hwmon_ctx->hm_xnvctrl) { - if (hm_XNVCTRL_XOpenDisplay (hwmon_ctx->hm_xnvctrl) == 0) + if (hm_XNVCTRL_XOpenDisplay (hashcat_ctx) == 0) { for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -948,29 +2763,24 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int speed = 0; - if (get_fan_speed_current (hwmon_ctx->hm_xnvctrl, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; + if (get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; } } } - if ((opencl_ctx->need_adl == true) && (adl_init (adl) == 0)) - { - hwmon_ctx->hm_adl = adl; - } - if (hwmon_ctx->hm_adl) { - if (hm_ADL_Main_Control_Create (hwmon_ctx->hm_adl, ADL_Main_Memory_Alloc, 0) == ADL_OK) + if (hm_ADL_Main_Control_Create (hashcat_ctx, ADL_Main_Memory_Alloc, 0) == 0) { // total number of adapters int hm_adapters_num; - if (get_adapters_num_adl (hwmon_ctx->hm_adl, &hm_adapters_num) != 0) return -1; + if (get_adapters_num_adl (hashcat_ctx, &hm_adapters_num) == -1) return -1; // adapter info - LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_adl (hwmon_ctx->hm_adl, hm_adapters_num); + LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_adl (hashcat_ctx, hm_adapters_num); if (lpAdapterInfo == NULL) return -1; @@ -982,11 +2792,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (num_adl_adapters > 0) { - hm_get_adapter_index_adl (hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); + hm_get_adapter_index_adl (hashcat_ctx, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); - hm_get_overdrive_version (hwmon_ctx->hm_adl, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); + hm_get_overdrive_version (hashcat_ctx, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); - hm_check_fanspeed_control (hwmon_ctx->hm_adl, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); + hm_check_fanspeed_control (hashcat_ctx, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); } myfree (valid_adl_device_list); @@ -1086,9 +2896,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int powertune_supported = 0; - if ((ADL_rc = hm_ADL_Overdrive6_PowerControl_Caps (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) == -1) { - log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); + event_log_error (hashcat_ctx, "ERROR: Failed to get ADL PowerControl Capabilities"); return -1; } @@ -1101,21 +2911,21 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; - if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &powertune)) == ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune)) == ADL_OK) { - ADL_rc = hm_ADL_Overdrive_PowerControl_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &hwmon_ctx->od_power_control_status[device_id]); + ADL_rc = hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &hwmon_ctx->od_power_control_status[device_id]); } - if (ADL_rc != ADL_OK) + if (ADL_rc == -1) { - log_error ("ERROR: Failed to get current ADL PowerControl settings"); + event_log_error (hashcat_ctx, "ERROR: Failed to get current ADL PowerControl settings"); return -1; } - if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) == -1) { - log_error ("ERROR: Failed to set new ADL PowerControl values"); + event_log_error (hashcat_ctx, "ERROR: Failed to set new ADL PowerControl values"); return -1; } @@ -1126,9 +2936,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hwmon_ctx->od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2; - if ((ADL_rc = hm_ADL_Overdrive_StateInfo_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &hwmon_ctx->od_clock_mem_status[device_id])) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &hwmon_ctx->od_clock_mem_status[device_id])) == -1) { - log_error ("ERROR: Failed to get ADL memory and engine clock frequency"); + event_log_error (hashcat_ctx, "ERROR: Failed to get ADL memory and engine clock frequency"); return -1; } @@ -1137,9 +2947,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0}; - if ((ADL_rc = hm_ADL_Overdrive_Capabilities_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &caps)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &caps)) == -1) { - log_error ("ERROR: Failed to get ADL device capabilities"); + event_log_error (hashcat_ctx, "ERROR: Failed to get ADL device capabilities"); return -1; } @@ -1157,12 +2967,12 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine) { - log_info ("WARN: The custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance"); + event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance"); } if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory) { - log_info ("WARN: The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); + event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); } ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); @@ -1174,9 +2984,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max; performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max; - if ((ADL_rc = hm_ADL_Overdrive_State_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - log_info ("ERROR: Failed to set ADL performance state"); + event_log_info (hashcat_ctx, "ERROR: Failed to set ADL performance state"); return -1; } @@ -1191,16 +3001,16 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) // powertune set ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0}; - if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &powertune)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune)) == -1) { - log_error ("ERROR: Failed to get current ADL PowerControl settings"); + event_log_error (hashcat_ctx, "ERROR: Failed to get current ADL PowerControl settings"); return -1; } - if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) != ADL_OK) + if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) == -1) { - log_error ("ERROR: Failed to set new ADL PowerControl values"); + event_log_error (hashcat_ctx, "ERROR: Failed to set new ADL PowerControl values"); return -1; } @@ -1216,7 +3026,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) bool powertune_supported = false; - if (hm_NVML_nvmlDeviceGetPowerManagementLimit (hwmon_ctx->hm_nvml, 0, hwmon_ctx->hm_device[device_id].nvml, &limit) == NVML_SUCCESS) + if (hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &limit) == NVML_SUCCESS) { powertune_supported = true; } @@ -1228,11 +3038,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) unsigned int minLimit; unsigned int maxLimit; - if (hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hwmon_ctx->hm_nvml, 0, hwmon_ctx->hm_device[device_id].nvml, &minLimit, &maxLimit) == NVML_SUCCESS) + if (hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, &minLimit, &maxLimit) == NVML_SUCCESS) { if (maxLimit > 0) { - if (hm_NVML_nvmlDeviceSetPowerManagementLimit (hwmon_ctx->hm_nvml, 0, hwmon_ctx->hm_device[device_id].nvml, maxLimit) == NVML_SUCCESS) + if (hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, maxLimit) == NVML_SUCCESS) { // now we can be sure we need to reset later @@ -1277,7 +3087,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) else if (device_param->device_vendor_id == VENDOR_ID_NV) { #if defined (__linux__) - rc = set_fan_control (hwmon_ctx->hm_xnvctrl, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); + rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); #endif #if defined (_WIN) @@ -1291,7 +3101,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1); + event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1); hwmon_ctx->hm_device[device_id].fan_set_supported = false; } @@ -1336,7 +3146,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) else if (device_param->device_vendor_id == VENDOR_ID_NV) { #if defined (__linux__) - rc = set_fan_control (hwmon_ctx->hm_xnvctrl, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); + rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); #endif #if defined (_WIN) @@ -1344,7 +3154,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) #endif } - if (rc == -1) log_info ("WARNING: Failed to restore default fan speed and policy for device #%", device_id + 1); + if (rc == -1) event_log_error (hashcat_ctx, "Failed to restore default fan speed and policy for device #%", device_id + 1); } } } @@ -1365,9 +3175,9 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) int powertune_supported = 0; - if ((hm_ADL_Overdrive6_PowerControl_Caps (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) != ADL_OK) + if ((hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) == -1) { - log_error ("ERROR: Failed to get ADL PowerControl Capabilities"); + event_log_error (hashcat_ctx, "ERROR: Failed to get ADL PowerControl Capabilities"); continue; } @@ -1376,9 +3186,9 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { // powercontrol settings - if ((hm_ADL_Overdrive_PowerControl_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, hwmon_ctx->od_power_control_status[device_id])) != ADL_OK) + if ((hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, hwmon_ctx->od_power_control_status[device_id])) == -1) { - log_info ("ERROR: Failed to restore the ADL PowerControl values"); + event_log_info (hashcat_ctx, "ERROR: Failed to restore the ADL PowerControl values"); continue; } @@ -1394,9 +3204,9 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) performance_state->aLevels[0].iMemoryClock = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[0].iMemoryClock; performance_state->aLevels[1].iMemoryClock = hwmon_ctx->od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock; - if ((hm_ADL_Overdrive_State_Set (hwmon_ctx->hm_adl, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK) + if ((hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - log_info ("ERROR: Failed to restore ADL performance state"); + event_log_info (hashcat_ctx, "ERROR: Failed to restore ADL performance state"); continue; } @@ -1412,7 +3222,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (power_limit > 0) { - hm_NVML_nvmlDeviceSetPowerManagementLimit (hwmon_ctx->hm_nvml, 0, hwmon_ctx->hm_device[device_id].nvml, power_limit); + hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvml, power_limit); } } } @@ -1421,30 +3231,30 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (hwmon_ctx->hm_nvml) { - hm_NVML_nvmlShutdown (hwmon_ctx->hm_nvml); + hm_NVML_nvmlShutdown (hashcat_ctx); - nvml_close (hwmon_ctx->hm_nvml); + nvml_close (hashcat_ctx); } if (hwmon_ctx->hm_nvapi) { - hm_NvAPI_Unload (hwmon_ctx->hm_nvapi); + hm_NvAPI_Unload (hashcat_ctx); - nvapi_close (hwmon_ctx->hm_nvapi); + nvapi_close (hashcat_ctx); } if (hwmon_ctx->hm_xnvctrl) { - hm_XNVCTRL_XCloseDisplay (hwmon_ctx->hm_xnvctrl); + hm_XNVCTRL_XCloseDisplay (hashcat_ctx); - xnvctrl_close (hwmon_ctx->hm_xnvctrl); + xnvctrl_close (hashcat_ctx); } if (hwmon_ctx->hm_adl) { - hm_ADL_Main_Control_Destroy (hwmon_ctx->hm_adl); + hm_ADL_Main_Control_Destroy (hashcat_ctx); - adl_close (hwmon_ctx->hm_adl); + adl_close (hashcat_ctx); } // free memory diff --git a/src/induct.c b/src/induct.c index 61a0f454e..9a198c585 100644 --- a/src/induct.c +++ b/src/induct.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "folder.h" #include "induct.h" @@ -64,14 +64,14 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (rename (root_directory, root_directory_mv) != 0) { - log_error ("ERROR: Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno)); return -1; } } else { - log_error ("ERROR: %s: %s", root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", root_directory, strerror (errno)); return -1; } @@ -79,7 +79,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (hc_mkdir (root_directory, 0700) == -1) { - log_error ("ERROR: %s: %s", root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", root_directory, strerror (errno)); return -1; } @@ -142,7 +142,7 @@ void induct_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: %s: %s", induct_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", induct_ctx->root_directory, strerror (errno)); //return -1; } diff --git a/src/interface.c b/src/interface.c index df482ec9a..7c3064973 100644 --- a/src/interface.c +++ b/src/interface.c @@ -12,7 +12,7 @@ #include "bitops.h" #include "memory.h" #include "convert.h" -#include "logging.h" +#include "event.h" #include "inc_hash_constants.h" #include "cpu_aes.h" #include "cpu_crc32.h" @@ -59,7 +59,8 @@ static const char PA_013[] = "Invalid psafe2 filesize"; static const char PA_014[] = "Invalid psafe3 filesize"; static const char PA_015[] = "Invalid truecrypt filesize"; static const char PA_016[] = "Invalid veracrypt filesize"; -//static const char PA_017[] = "Invalid SIP directive, only MD5 is supported"; +static const char PA_017[] = "Invalid SIP directive, only MD5 is supported"; +static const char PA_018[] = "Hash-file exception"; static const char PA_255[] = "Unknown error"; static const char HT_00000[] = "MD5"; @@ -2638,12 +2639,7 @@ int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash u32 salt_len = strlen (in.essid); - if (salt_len > 36) - { - log_info ("WARNING: The ESSID length is too long, the hccap file may be invalid or corrupted"); - - return (PARSER_SALT_LENGTH); - } + if (salt_len > 36) return (PARSER_SALT_LENGTH); memcpy (salt->salt_buf, in.essid, salt_len); @@ -2691,11 +2687,12 @@ int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash if (wpa->keyver > 255) { - log_info ("ATTENTION!"); - log_info (" The WPA/WPA2 key version in your .hccap file is invalid!"); - log_info (" This could be due to a recent aircrack-ng bug."); - log_info (" The key version was automatically reset to a reasonable value."); - log_info (""); + // not sure yet how to transport this message + //event_log_warning (hashcat_ctx, "ATTENTION!"); + //event_log_warning (hashcat_ctx, " The WPA/WPA2 key version in your .hccap file is invalid!"); + //event_log_warning (hashcat_ctx, " This could be due to a recent aircrack-ng bug."); + //event_log_warning (hashcat_ctx, " The key version was automatically reset to a reasonable value."); + //event_log_warning (hashcat_ctx, ""); wpa->keyver &= 0xff; } @@ -2746,21 +2743,11 @@ int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h salt_t *salt = hash_buf->salt; - if (input_len == 0) - { - log_error ("Password Safe v2 container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); psafe2_hdr buf; @@ -2793,21 +2780,11 @@ int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h salt_t *salt = hash_buf->salt; - if (input_len == 0) - { - log_error (".psafe3 not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); psafe3_t in; @@ -5122,21 +5099,11 @@ int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, c tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("TrueCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -5171,21 +5138,11 @@ int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, c tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("TrueCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -5220,21 +5177,11 @@ int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_bu tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("VeraCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -5269,21 +5216,11 @@ int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_bu tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("VeraCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -5318,21 +5255,11 @@ int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_bu tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("VeraCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -5367,21 +5294,11 @@ int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_bu tc_t *tc = (tc_t *) hash_buf->esalt; - if (input_len == 0) - { - log_error ("VeraCrypt container not specified"); - - exit (-1); - } + if (input_len == 0) return (PARSER_HASH_LENGTH); FILE *fp = fopen (input_buf, "rb"); - if (fp == NULL) - { - log_error ("%s: %s", input_buf, strerror (errno)); - - exit (-1); - } + if (fp == NULL) return (PARSER_HASH_FILE); char buf[512] = { 0 }; @@ -10810,8 +10727,6 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const if (memcmp (directive_pos, "MD5", 3)) { - log_info ("ERROR: Only the MD5 directive is currently supported\n"); - myfree (temp_input_buf); return (PARSER_SIP_AUTH_DIRECTIVE); @@ -13103,7 +13018,9 @@ char *strparser (const u32 parser_status) case PARSER_PSAFE2_FILE_SIZE: return ((char *) PA_013); case PARSER_PSAFE3_FILE_SIZE: return ((char *) PA_014); case PARSER_TC_FILE_SIZE: return ((char *) PA_015); - case PARSER_SIP_AUTH_DIRECTIVE: return ((char *) PA_016); + case PARSER_VC_FILE_SIZE: return ((char *) PA_016); + case PARSER_SIP_AUTH_DIRECTIVE: return ((char *) PA_017); + case PARSER_HASH_FILE: return ((char *) PA_018); } return ((char *) PA_255); @@ -19814,7 +19731,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->dgst_pos3 = 3; break; - default: log_error ("ERROR: Unknown hash-type '%u' selected", hashconfig->hash_mode); + default: event_log_error (hashcat_ctx, "ERROR: Unknown hash-type '%u' selected", hashconfig->hash_mode); return -1; } @@ -19826,7 +19743,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hashconfig->hash_mode); + event_log_error (hashcat_ctx, "ERROR: Parameter hex-salt not valid for hash-type %u", hashconfig->hash_mode); return -1; } diff --git a/src/locking.c b/src/locking.c index cece6b4c7..f2b80b57e 100644 --- a/src/locking.c +++ b/src/locking.c @@ -4,12 +4,13 @@ */ #include "common.h" -#include "logging.h" +#include "types.h" +#include "event.h" #include "locking.h" #if defined (F_SETLKW) -void lock_file (FILE *fp) +int lock_file (FILE *fp) { struct flock lock; @@ -17,15 +18,9 @@ void lock_file (FILE *fp) lock.l_type = F_WRLCK; - while (fcntl (fileno (fp), F_SETLKW, &lock)) - { - if (errno != EINTR) - { - log_error ("ERROR: Failed acquiring write lock: %s", strerror (errno)); + if (fcntl (fileno (fp), F_SETLKW, &lock)) return -1; - exit (-1); - } - } + return 0; } void unlock_file (FILE *fp) diff --git a/src/logfile.c b/src/logfile.c index abec9dd3b..7f956c28a 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -10,7 +10,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "logfile.h" static int logfile_generate_id () @@ -90,7 +90,7 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", logfile_ctx->logfile, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", logfile_ctx->logfile, strerror (errno)); return -1; } diff --git a/src/logging.c b/src/logging.c deleted file mode 100644 index 6bfcbd3b0..000000000 --- a/src/logging.c +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#if defined (__APPLE__) -#include -#endif - -#include "common.h" -#include "logging.h" - -static int last_len = 0; - -static int log_final (FILE *fp, const char *fmt, va_list ap) -{ - if (last_len) - { - fputc ('\r', fp); - - for (int i = 0; i < last_len; i++) - { - fputc (' ', fp); - } - - fputc ('\r', fp); - } - - char s[4096] = { 0 }; - - const size_t max_len = sizeof (s); - - const int len = vsnprintf (s, max_len, fmt, ap); - - //if (len > max_len) len = max_len; - - fwrite (s, (size_t) len, 1, fp); - - fflush (fp); - - last_len = len; - - return last_len; -} - -int log_out_nn (FILE *fp, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (fp, fmt, ap); - - va_end (ap); - - return len; -} - -int log_info_nn (const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (stdout, fmt, ap); - - va_end (ap); - - return len; -} - -int log_error_nn (const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (stderr, fmt, ap); - - va_end (ap); - - return len; -} - -int log_out (FILE *fp, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (fp, fmt, ap); - - va_end (ap); - - fputc ('\n', fp); - - last_len = 0; - - return len; -} - -int log_info (const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (stdout, fmt, ap); - - va_end (ap); - - fputc ('\n', stdout); - - last_len = 0; - - return len; -} - -int log_error (const char *fmt, ...) -{ - fputc ('\n', stderr); - fputc ('\n', stderr); - - va_list ap; - - va_start (ap, fmt); - - const int len = log_final (stderr, fmt, ap); - - va_end (ap); - - fputc ('\n', stderr); - fputc ('\n', stderr); - - last_len = 0; - - return len; -} diff --git a/src/loopback.c b/src/loopback.c index 79646f84f..63f60de9c 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "shared.h" #include "loopback.h" @@ -105,7 +105,7 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx) if (loopback_ctx->fp == NULL) { - log_error ("ERROR: %s: %s", loopback_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", loopback_ctx->filename, strerror (errno)); return -1; } diff --git a/src/main.c b/src/main.c index 42e193551..a98cb9e8d 100644 --- a/src/main.c +++ b/src/main.c @@ -89,7 +89,7 @@ static int main_welcome_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, con { // sets dos window size (windows only) - setup_console (); + setup_console (hashcat_ctx); // Inform user things getting started @@ -324,7 +324,7 @@ static int main_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx, const void *bu if (user_options->quiet == true) return 0; - event_log_info (hashcat_ctx, "Comparing hashes with potfile entries..."); + event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries..."); return 0; } diff --git a/src/memory.c b/src/memory.c index 506e331a3..12ed019fb 100644 --- a/src/memory.c +++ b/src/memory.c @@ -4,7 +4,6 @@ */ #include "common.h" -#include "logging.h" #include "memory.h" void *mycalloc (size_t nmemb, size_t size) @@ -13,7 +12,7 @@ void *mycalloc (size_t nmemb, size_t size) if (p == NULL) { - log_error ("ERROR: %s", MSG_ENOMEM); + fprintf (stderr, "ERROR: %s", MSG_ENOMEM); exit (-1); } @@ -27,7 +26,7 @@ void *mymalloc (size_t size) if (p == NULL) { - log_error ("ERROR: %s", MSG_ENOMEM); + fprintf (stderr, "ERROR: %s", MSG_ENOMEM); exit (-1); } @@ -50,7 +49,7 @@ void *myrealloc (void *ptr, size_t oldsz, size_t add) if (p == NULL) { - log_error ("ERROR: %s", MSG_ENOMEM); + fprintf (stderr, "ERROR: %s", MSG_ENOMEM); exit (-1); } diff --git a/src/monitor.c b/src/monitor.c index b268d6289..d9da8752b 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -5,7 +5,7 @@ #include "common.h" #include "types.h" -#include "logging.h" +#include "event.h" #include "memory.h" #include "hwmon.h" #include "timer.h" @@ -17,7 +17,7 @@ #include "shared.h" #include "monitor.h" -static void monitor (hashcat_ctx_t *hashcat_ctx) +static int monitor (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -64,7 +64,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if ((runtime_check == false) && (remove_check == false) && (status_check == false) && (restore_check == false) && (hwmon_check == false)) { - return; + return 0; } // these variables are mainly used for fan control @@ -115,11 +115,11 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); - hm_NvAPI_GPU_GetPerfPoliciesInfo (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); + hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); perfPolicies_status.info_value = perfPolicies_info.info_value; - hm_NvAPI_GPU_GetPerfPoliciesStatus (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); + hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); if (perfPolicies_status.throttle & 2) { @@ -127,11 +127,11 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) { if (user_options->quiet == false) clear_prompt (); - log_info ("WARNING: Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); if (slowdown_warnings == 2) { - log_info (""); + event_log_info (hashcat_ctx, ""); } if (user_options->quiet == false) send_prompt (); @@ -174,9 +174,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if (temperature > (int) user_options->gpu_temp_abort) { - log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1); + event_log_error (hashcat_ctx, "ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1); - myabort (status_ctx); + myabort (hashcat_ctx); break; } @@ -259,7 +259,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if (restore_left == 0) { - cycle_restore (hashcat_ctx); + const int rc = cycle_restore (hashcat_ctx); + + if (rc == -1) return -1; restore_left = user_options->restore_timer; } @@ -286,10 +288,10 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) { if (user_options->benchmark == false) { - if (user_options->quiet == false) log_info ("\nNOTE: Runtime limit reached, aborting...\n"); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "\nNOTE: Runtime limit reached, aborting...\n"); } - myabort (status_ctx); + myabort (hashcat_ctx); } } @@ -303,7 +305,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) { hashes->digests_saved = hashes->digests_done; - save_hash (hashcat_ctx); + const int rc = save_hash (hashcat_ctx); + + if (rc == -1) return -1; } remove_left = user_options->remove_timer; @@ -320,11 +324,11 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) clear_prompt (); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); hc_thread_mutex_unlock (status_ctx->mux_display); @@ -339,7 +343,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) { if (hashes->digests_saved != hashes->digests_done) { - save_hash (hashcat_ctx); + const int rc = save_hash (hashcat_ctx); + + if (rc == -1) return -1; } } @@ -347,20 +353,24 @@ static void monitor (hashcat_ctx_t *hashcat_ctx) if (restore_check == true) { - cycle_restore (hashcat_ctx); + const int rc = cycle_restore (hashcat_ctx); + + if (rc == -1) return -1; } myfree (fan_speed_chgd); myfree (temp_diff_old); myfree (temp_diff_sum); + + return 0; } void *thread_monitor (void *p) { hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p; - monitor (hashcat_ctx); + monitor (hashcat_ctx); // we should give back some useful returncode return NULL; } diff --git a/src/mpsp.c b/src/mpsp.c index 432ba01aa..b28d8f43f 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -10,7 +10,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "logfile.h" #include "convert.h" #include "filehandling.h" @@ -130,15 +130,15 @@ void mp_css_unicode_expand (mask_ctx_t *mask_ctx) mask_ctx->css_cnt = css_cnt_unicode; } -void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) +int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { /* generates a lookup table where key is the char itself for fastest possible lookup performance */ if (css_cnt > SP_PW_MAX) { - log_error ("ERROR: Mask length is too long"); + event_log_error (hashcat_ctx, "ERROR: Mask length is too long"); - exit (-1); + return -1; } for (u32 css_pos = 0; css_pos < css_cnt; css_pos++) @@ -155,10 +155,14 @@ void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSI uniq_tbl[c] = 1; } } + + return 0; } -static void mp_add_cs_buf (u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt, const hashconfig_t *hashconfig) +static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + cs_t *cs = &css[css_cnt]; size_t css_uniq_sz = CHARSIZ * sizeof (u32); @@ -192,8 +196,10 @@ static void mp_add_cs_buf (u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt, c myfree (css_uniq); } -static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret, const hashconfig_t *hashconfig, const user_options_t *user_options) +static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret) { + const user_options_t *user_options = hashcat_ctx->user_options; + size_t in_pos; for (in_pos = 0; in_pos < in_len; in_pos++) @@ -210,34 +216,34 @@ static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, switch (p1) { - case 'l': mp_add_cs_buf (mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset); break; - case 'u': mp_add_cs_buf (mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset); break; - case 'd': mp_add_cs_buf (mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset); break; - case 's': mp_add_cs_buf (mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset); break; - case 'a': mp_add_cs_buf (mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset); break; - case 'b': mp_add_cs_buf (mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset, hashconfig); + case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset); break; - case '1': if (mp_usr[0].cs_len == 0) { log_error ("ERROR: Custom-charset 1 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset, hashconfig); + case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 1 is undefined"); return -1; } + mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset); break; - case '2': if (mp_usr[1].cs_len == 0) { log_error ("ERROR: Custom-charset 2 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset, hashconfig); + case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 2 is undefined"); return -1; } + mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset); break; - case '3': if (mp_usr[2].cs_len == 0) { log_error ("ERROR: Custom-charset 3 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset, hashconfig); + case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 3 is undefined"); return -1; } + mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset); break; - case '4': if (mp_usr[3].cs_len == 0) { log_error ("ERROR: Custom-charset 4 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset, hashconfig); + case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 4 is undefined"); return -1; } + mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset); break; - case '?': mp_add_cs_buf (&p0, 1, mp_usr, mp_usr_offset, hashconfig); + case '?': mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); break; - default: log_error ("Syntax error: %s", in_buf); - exit (-1); + default: event_log_error (hashcat_ctx, "Syntax error: %s", in_buf); + return -1; } } else @@ -248,18 +254,18 @@ static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, if (in_pos == in_len) { - log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf); + event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf); - exit (-1); + return -1; } u32 p1 = in_buf[in_pos] & 0xff; if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) { - log_error ("ERROR: Invalid hex character detected in mask %s", in_buf); + event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask %s", in_buf); - exit (-1); + return -1; } u32 chr = 0; @@ -267,32 +273,24 @@ static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, chr = (u32) hex_convert ((u8) p1) << 0; chr |= (u32) hex_convert ((u8) p0) << 4; - mp_add_cs_buf (&chr, 1, mp_usr, mp_usr_offset, hashconfig); + mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); } else { u32 chr = p0; - mp_add_cs_buf (&chr, 1, mp_usr, mp_usr_offset, hashconfig); + mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); } } } + + return 0; } -u64 mp_get_sum (u32 css_cnt, cs_t *css) +static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt) { - u64 sum = 1; + const user_options_t *user_options = hashcat_ctx->user_options; - for (u32 css_pos = 0; css_pos < css_cnt; css_pos++) - { - sum *= css[css_pos].cs_len; - } - - return (sum); -} - -cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options) -{ cs_t *css = (cs_t *) mycalloc (256, sizeof (cs_t)); u32 mask_pos; @@ -314,34 +312,34 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u switch (p1) { - case 'l': mp_add_cs_buf (mp_sys[0].cs_buf, mp_sys[0].cs_len, css, css_pos, hashconfig); + case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css, css_pos); break; - case 'u': mp_add_cs_buf (mp_sys[1].cs_buf, mp_sys[1].cs_len, css, css_pos, hashconfig); + case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css, css_pos); break; - case 'd': mp_add_cs_buf (mp_sys[2].cs_buf, mp_sys[2].cs_len, css, css_pos, hashconfig); + case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css, css_pos); break; - case 's': mp_add_cs_buf (mp_sys[3].cs_buf, mp_sys[3].cs_len, css, css_pos, hashconfig); + case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css, css_pos); break; - case 'a': mp_add_cs_buf (mp_sys[4].cs_buf, mp_sys[4].cs_len, css, css_pos, hashconfig); + case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css, css_pos); break; - case 'b': mp_add_cs_buf (mp_sys[5].cs_buf, mp_sys[5].cs_len, css, css_pos, hashconfig); + case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css, css_pos); break; - case '1': if (mp_usr[0].cs_len == 0) { log_error ("ERROR: Custom-charset 1 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[0].cs_buf, mp_usr[0].cs_len, css, css_pos, hashconfig); + case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 1 is undefined\n"); return NULL; } + mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css, css_pos); break; - case '2': if (mp_usr[1].cs_len == 0) { log_error ("ERROR: Custom-charset 2 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[1].cs_buf, mp_usr[1].cs_len, css, css_pos, hashconfig); + case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 2 is undefined\n"); return NULL; } + mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css, css_pos); break; - case '3': if (mp_usr[2].cs_len == 0) { log_error ("ERROR: Custom-charset 3 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[2].cs_buf, mp_usr[2].cs_len, css, css_pos, hashconfig); + case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 3 is undefined\n"); return NULL; } + mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css, css_pos); break; - case '4': if (mp_usr[3].cs_len == 0) { log_error ("ERROR: Custom-charset 4 is undefined\n"); exit (-1); } - mp_add_cs_buf (mp_usr[3].cs_buf, mp_usr[3].cs_len, css, css_pos, hashconfig); + case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 4 is undefined\n"); return NULL; } + mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css, css_pos); break; - case '?': mp_add_cs_buf (&chr, 1, css, css_pos, hashconfig); + case '?': mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); break; - default: log_error ("ERROR: Syntax error: %s", mask_buf); - exit (-1); + default: event_log_error (hashcat_ctx, "ERROR: Syntax error: %s", mask_buf); + return NULL; } } else @@ -354,9 +352,9 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u if (mask_pos == mask_len) { - log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); + event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); - exit (-1); + return NULL; } char p1 = mask_buf[mask_pos]; @@ -365,9 +363,9 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) { - log_error ("ERROR: Invalid hex character detected in mask %s", mask_buf); + event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask %s", mask_buf); - exit (-1); + return NULL; } u32 chr = 0; @@ -375,22 +373,22 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u chr |= (u32) hex_convert ((u8) p1) << 0; chr |= (u32) hex_convert ((u8) p0) << 4; - mp_add_cs_buf (&chr, 1, css, css_pos, hashconfig); + mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); } else { u32 chr = (u32) p0; - mp_add_cs_buf (&chr, 1, css, css_pos, hashconfig); + mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); } } } if (css_pos == 0) { - log_error ("ERROR: Invalid mask length (0)"); + event_log_error (hashcat_ctx, "ERROR: Invalid mask length (0)"); - exit (-1); + return NULL; } *css_cnt = css_pos; @@ -398,6 +396,80 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u return (css); } +static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + char *new_mask_buf = (char *) mymalloc (256); + + u32 mask_pos; + + u32 css_pos; + + for (mask_pos = 0, css_pos = 0; mask_pos < mask_len; mask_pos++, css_pos++) + { + if (css_pos == len) break; + + char p0 = mask_buf[mask_pos]; + + new_mask_buf[mask_pos] = p0; + + if (p0 == '?') + { + mask_pos++; + + if (mask_pos == mask_len) break; + + new_mask_buf[mask_pos] = mask_buf[mask_pos]; + } + else + { + if (user_options->hex_charset == true) + { + mask_pos++; + + if (mask_pos == mask_len) + { + event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); + + return NULL; + } + + char p1 = mask_buf[mask_pos]; + + // if they are not valid hex character, show an error: + + if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) + { + event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask: %s", mask_buf); + + return NULL; + } + + new_mask_buf[mask_pos] = p1; + } + } + } + + if (css_pos == len) return (new_mask_buf); + + myfree (new_mask_buf); + + return (NULL); +} + +u64 mp_get_sum (u32 css_cnt, cs_t *css) +{ + u64 sum = 1; + + for (u32 css_pos = 0; css_pos < css_cnt; css_pos++) + { + sum *= css[css_pos].cs_len; + } + + return (sum); +} + void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt) { for (int i = 0; i < css_cnt; i++) @@ -469,13 +541,15 @@ void mp_setup_sys (cs_t *mp_sys) mp_sys[5].cs_len = pos; } } -void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index, const hashconfig_t *hashconfig, const user_options_t *user_options) +int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index) { FILE *fp = fopen (buf, "rb"); if (fp == NULL || feof (fp)) // feof() in case if file is empty { - mp_expand (buf, strlen (buf), mp_sys, mp_usr, index, 1, hashconfig, user_options); + const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, index, 1); + + if (rc == -1) return -1; } else { @@ -489,15 +563,21 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index, const hashc if (len == 0) { - log_info ("WARNING: Charset file corrupted"); + event_log_warning (hashcat_ctx, "Charset file corrupted"); - mp_expand (buf, strlen (buf), mp_sys, mp_usr, index, 1, hashconfig, user_options); + const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, index, 1); + + if (rc == -1) return -1; } else { - mp_expand (mp_file, (size_t) len, mp_sys, mp_usr, index, 0, hashconfig, user_options); + const int rc = mp_expand (hashcat_ctx, mp_file, (size_t) len, mp_sys, mp_usr, index, 0); + + if (rc == -1) return -1; } } + + return 0; } void mp_reset_usr (cs_t *mp_usr, u32 index) @@ -507,113 +587,21 @@ void mp_reset_usr (cs_t *mp_usr, u32 index) memset (mp_usr[index].cs_buf, 0, sizeof (mp_usr[index].cs_buf)); } -static char *mp_get_truncated_mask (const char *mask_buf, const size_t mask_len, const u32 len, const user_options_t *user_options) +static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) { - char *new_mask_buf = (char *) mymalloc (256); + folder_config_t *folder_config = hashcat_ctx->folder_config; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + user_options_t *user_options = hashcat_ctx->user_options; - u32 mask_pos; + char *shared_dir = folder_config->shared_dir; - u32 css_pos; + char *hcstat = user_options->markov_hcstat; + u32 disable = user_options->markov_disable; + u32 classic = user_options->markov_classic; - for (mask_pos = 0, css_pos = 0; mask_pos < mask_len; mask_pos++, css_pos++) - { - if (css_pos == len) break; + hcstat_table_t *root_table_buf = mask_ctx->root_table_buf; + hcstat_table_t *markov_table_buf = mask_ctx->markov_table_buf; - char p0 = mask_buf[mask_pos]; - - new_mask_buf[mask_pos] = p0; - - if (p0 == '?') - { - mask_pos++; - - if (mask_pos == mask_len) break; - - new_mask_buf[mask_pos] = mask_buf[mask_pos]; - } - else - { - if (user_options->hex_charset == true) - { - mask_pos++; - - if (mask_pos == mask_len) - { - log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); - - exit (-1); - } - - char p1 = mask_buf[mask_pos]; - - // if they are not valid hex character, show an error: - - if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) - { - log_error ("ERROR: Invalid hex character detected in mask: %s", mask_buf); - - exit (-1); - } - - new_mask_buf[mask_pos] = p1; - } - } - } - - if (css_pos == len) return (new_mask_buf); - - myfree (new_mask_buf); - - return (NULL); -} - -u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) -{ - u64 sum = 1; - - u32 i; - - for (i = start; i < stop; i++) - { - sum *= root_css_buf[i].cs_len; - } - - return (sum); -} - -void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) -{ - u64 v = ctx; - - cs_t *cs = &root_css_buf[start]; - - u32 i; - - for (i = start; i < stop; i++) - { - const u64 m = v % cs->cs_len; - const u64 d = v / cs->cs_len; - - v = d; - - const u32 k = cs->cs_buf[m]; - - pw_buf[i - start] = (char) k; - - cs = &markov_css_buf[(i * CHARSIZ) + k]; - } -} - -int sp_comp_val (const void *p1, const void *p2) -{ - hcstat_table_t *b1 = (hcstat_table_t *) p1; - hcstat_table_t *b2 = (hcstat_table_t *) p2; - - return b2->val - b1->val; -} - -void sp_setup_tbl (const char *shared_dir, char *hcstat, u32 disable, u32 classic, hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf) -{ u32 i; u32 j; u32 k; @@ -668,27 +656,27 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, u32 disable, u32 classi if (fd == NULL) { - log_error ("%s: %s", hcstat, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno)); - exit (-1); + return -1; } if (fread (root_stats_buf, sizeof (u64), SP_ROOT_CNT, fd) != SP_ROOT_CNT) { - log_error ("%s: Could not load data", hcstat); + event_log_error (hashcat_ctx, "%s: Could not load data", hcstat); fclose (fd); - exit (-1); + return -1; } if (fread (markov_stats_buf, sizeof (u64), SP_MARKOV_CNT, fd) != SP_MARKOV_CNT) { - log_error ("%s: Could not load data", hcstat); + event_log_error (hashcat_ctx, "%s: Could not load data", hcstat); fclose (fd); - exit (-1); + return -1; } fclose (fd); @@ -813,6 +801,53 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, u32 disable, u32 classi qsort (markov_table_buf_by_key[i][j], CHARSIZ, sizeof (hcstat_table_t), sp_comp_val); } } + + return 0; +} + +u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) +{ + u64 sum = 1; + + u32 i; + + for (i = start; i < stop; i++) + { + sum *= root_css_buf[i].cs_len; + } + + return (sum); +} + +void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) +{ + u64 v = ctx; + + cs_t *cs = &root_css_buf[start]; + + u32 i; + + for (i = start; i < stop; i++) + { + const u64 m = v % cs->cs_len; + const u64 d = v / cs->cs_len; + + v = d; + + const u32 k = cs->cs_buf[m]; + + pw_buf[i - start] = (char) k; + + cs = &markov_css_buf[(i * CHARSIZ) + k]; + } +} + +int sp_comp_val (const void *p1, const void *p2) +{ + hcstat_table_t *b1 = (hcstat_table_t *) p1; + hcstat_table_t *b2 = (hcstat_table_t *) p2; + + return b2->val - b1->val; } void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) @@ -947,13 +982,16 @@ static void mask_append_final (mask_ctx_t *mask_ctx, const char *mask) mask_ctx->masks_cnt++; } -static void mask_append (mask_ctx_t *mask_ctx, const user_options_t *user_options, const char *mask) +static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + if (user_options->increment == true) { - for (u32 mask_len = user_options->increment_min; mask_len <= user_options->increment_max; mask_len++) + for (u32 increment_len = user_options->increment_min; increment_len <= user_options->increment_max; increment_len++) { - char *mask_truncated = mp_get_truncated_mask (mask, strlen (mask), mask_len, user_options); + char *mask_truncated = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len); if (mask_truncated == NULL) break; @@ -991,11 +1029,13 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (rc_mask_file == -1) return -1; - mask_ctx->css_buf = mp_gen_css (mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt, hashconfig, user_options); + mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt); + + if (mask_ctx->css_buf == NULL) return -1; u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } }; - mp_css_to_uniq_tbl (mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls); + mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls); sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls); @@ -1020,7 +1060,9 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) // always true { - mask_ctx->css_buf = mp_gen_css (mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt, hashconfig, user_options); + mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt); + + if (mask_ctx->css_buf == NULL) return -1; // special case for benchmark @@ -1045,12 +1087,12 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { if (mask_ctx->css_cnt < mask_min) { - log_info ("WARNING: Skipping mask '%s' because it is smaller than the minimum password length", mask_ctx->mask); + event_log_warning (hashcat_ctx, "Skipping mask '%s' because it is smaller than the minimum password length", mask_ctx->mask); } if (mask_ctx->css_cnt > mask_max) { - log_info ("WARNING: Skipping mask '%s' because it is larger than the maximum password length", mask_ctx->mask); + event_log_warning (hashcat_ctx, "Skipping mask '%s' because it is larger than the maximum password length", mask_ctx->mask); } // skip to next mask @@ -1083,7 +1125,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } }; - mp_css_to_uniq_tbl (mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls); + mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls); sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls); @@ -1108,8 +1150,6 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) { - folder_config_t *folder_config = hashcat_ctx->folder_config; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; @@ -1130,7 +1170,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t)); mask_ctx->markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t)); - sp_setup_tbl (folder_config->shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, mask_ctx->root_table_buf, mask_ctx->markov_table_buf); + sp_setup_tbl (hashcat_ctx); mask_ctx->root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t)); mask_ctx->markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t)); @@ -1148,10 +1188,10 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mp_setup_sys (mask_ctx->mp_sys); - if (user_options->custom_charset_1) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0, hashconfig, user_options); - if (user_options->custom_charset_2) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1, hashconfig, user_options); - if (user_options->custom_charset_3) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2, hashconfig, user_options); - if (user_options->custom_charset_4) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3, hashconfig, user_options); + if (user_options->custom_charset_1) mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0); + if (user_options->custom_charset_2) mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1); + if (user_options->custom_charset_3) mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2); + if (user_options->custom_charset_4) mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3); if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -1165,7 +1205,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (mask_ctx, user_options, arg); + mask_append (hashcat_ctx, arg); } else { @@ -1177,7 +1217,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - log_error ("ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); return -1; } @@ -1188,7 +1228,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - log_error ("ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); return -1; } @@ -1203,7 +1243,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (mask_ctx, user_options, line_buf); + mask_append (hashcat_ctx, line_buf); } myfree (line_buf); @@ -1212,7 +1252,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); return -1; } @@ -1223,14 +1263,14 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) { const char *mask = DEF_MASK; - mask_append (mask_ctx, user_options, mask); + mask_append (hashcat_ctx, mask); } } else { const char *mask = hashconfig_benchmark_mask (hashcat_ctx); - mask_append (mask_ctx, user_options, mask); + mask_append (hashcat_ctx, mask); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) @@ -1245,7 +1285,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (mask_ctx, user_options, arg); + mask_append (hashcat_ctx, arg); } else { @@ -1257,7 +1297,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - log_error ("ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); return -1; } @@ -1272,7 +1312,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (mask_ctx, user_options, line_buf); + mask_append (hashcat_ctx, line_buf); } myfree (line_buf); @@ -1281,7 +1321,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); return -1; } @@ -1299,7 +1339,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (mask_ctx, user_options, arg); + mask_append (hashcat_ctx, arg); } else { @@ -1311,7 +1351,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - log_error ("ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); return -1; } @@ -1326,7 +1366,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (mask_ctx, user_options, line_buf); + mask_append (hashcat_ctx, line_buf); } myfree (line_buf); @@ -1335,7 +1375,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); return -1; } @@ -1344,7 +1384,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->masks_cnt == 0) { - log_error ("ERROR: Invalid mask"); + event_log_error (hashcat_ctx, "ERROR: Invalid mask"); return -1; } @@ -1382,7 +1422,6 @@ void mask_ctx_destroy (hashcat_ctx_t *hashcat_ctx) int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -1432,7 +1471,7 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) if (mf_cnt >= MAX_MFS) { - log_error ("ERROR: Invalid line '%s' in maskfile", mask_buf); + event_log_error (hashcat_ctx, "ERROR: Invalid line '%s' in maskfile", mask_buf); return -1; } @@ -1457,25 +1496,25 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) case 0: user_options->custom_charset_1 = mfs[0].mf_buf; mp_reset_usr (mask_ctx->mp_usr, 0); - mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0, hashconfig, user_options); + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0); break; case 1: user_options->custom_charset_2 = mfs[1].mf_buf; mp_reset_usr (mask_ctx->mp_usr, 1); - mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1, hashconfig, user_options); + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1); break; case 2: user_options->custom_charset_3 = mfs[2].mf_buf; mp_reset_usr (mask_ctx->mp_usr, 2); - mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2, hashconfig, user_options); + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2); break; case 3: user_options->custom_charset_4 = mfs[3].mf_buf; mp_reset_usr (mask_ctx->mp_usr, 3); - mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3, hashconfig, user_options); + mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3); break; } } diff --git a/src/opencl.c b/src/opencl.c index 956518c19..85013a8ec 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -24,6 +24,7 @@ #include "hashes.h" #include "cpu_md5.h" #include "event.h" +#include "dynloader.h" #include "opencl.h" static const u32 full01 = 0x01010101; @@ -97,7 +98,7 @@ static void generate_cached_kernel_amp_filename (const u32 attack_kern, char *pr snprintf (cached_file, 255, "%s/kernels/amp_a%d.%s.kernel", profile_dir, attack_kern, device_name_chksum); } -static u32 setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_platforms) +static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_platforms, u32 *out) { u32 opencl_platforms_filter = 0; @@ -115,7 +116,7 @@ static u32 setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char { event_log_error (hashcat_ctx, "ERROR: Invalid OpenCL platform %u specified", platform); - exit (-1); + return -1; } opencl_platforms_filter |= 1u << (platform - 1); @@ -129,10 +130,12 @@ static u32 setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char opencl_platforms_filter = -1u; } - return opencl_platforms_filter; + *out = opencl_platforms_filter; + + return 0; } -static u32 setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_devices) +static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_devices, u32 *out) { u32 devices_filter = 0; @@ -150,7 +153,7 @@ static u32 setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ { event_log_error (hashcat_ctx, "ERROR: Invalid device_id %u specified", device_id); - exit (-1); + return -1; } devices_filter |= 1u << (device_id - 1); @@ -164,10 +167,12 @@ static u32 setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ devices_filter = -1u; } - return devices_filter; + *out = devices_filter; + + return 0; } -static cl_device_type setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_device_types) +static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_device_types, cl_device_type *out) { cl_device_type device_types_filter = 0; @@ -185,7 +190,7 @@ static cl_device_type setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, con { event_log_error (hashcat_ctx, "ERROR: Invalid device_type %u specified", device_type); - exit (-1); + return -1; } device_types_filter |= 1u << device_type; @@ -202,10 +207,12 @@ static cl_device_type setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, con device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_CPU; } - return device_types_filter; + *out = device_types_filter; + + return 0; } -static void read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, int num_devices, size_t *kernel_lengths, char **kernel_sources) +static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, int num_devices, size_t *kernel_lengths, char **kernel_sources) { FILE *fp = fopen (kernel_file, "rb"); @@ -225,7 +232,7 @@ static void read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f { event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); - exit (-1); + return -1; } fclose (fp); @@ -243,13 +250,13 @@ static void read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f { event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); - exit (-1); + return -1; } - return; + return 0; } -static void write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, char *binary, size_t binary_size) +static int write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, char *binary, size_t binary_size) { if (binary_size > 0) { @@ -259,29 +266,707 @@ static void write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, { event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); - exit (-1); + return -1; } - lock_file (fp); - fwrite (binary, sizeof (char), binary_size, fp); + const int rc = lock_file (fp); + if (rc == -1) return -1; + + fwrite (binary, sizeof (char), binary_size, fp); fflush (fp); fclose (fp); + + unlock_file (fp); } + + return 0; +} + +int ocl_init (hashcat_ctx_t *hashcat_ctx) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + memset (ocl, 0, sizeof (OCL_PTR)); + + #if defined(_WIN) + ocl->lib = hc_dlopen ("OpenCL"); + #elif defined(__APPLE__) + ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW); + #else + ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW); + + if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW); + #endif + + if (ocl->lib == NULL) + { + event_log_info (hashcat_ctx, ""); + event_log_info (hashcat_ctx, "ATTENTION! Can't find OpenCL ICD loader library"); + event_log_info (hashcat_ctx, ""); + #if defined (__linux__) + event_log_info (hashcat_ctx, "You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)"); + event_log_info (hashcat_ctx, " sudo apt-get install ocl-icd-libopencl1"); + event_log_info (hashcat_ctx, ""); + #elif defined (_WIN) + event_log_info (hashcat_ctx, "You're probably missing the OpenCL runtime installation"); + event_log_info (hashcat_ctx, " AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); + event_log_info (hashcat_ctx, " Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); + event_log_info (hashcat_ctx, " NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); + event_log_info (hashcat_ctx, ""); + #endif + + return -1; + } + + HC_LOAD_FUNC(ocl, clBuildProgram, OCL_CLBUILDPROGRAM, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateBuffer, OCL_CLCREATEBUFFER, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateCommandQueue, OCL_CLCREATECOMMANDQUEUE, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateContext, OCL_CLCREATECONTEXT, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateKernel, OCL_CLCREATEKERNEL, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateProgramWithBinary, OCL_CLCREATEPROGRAMWITHBINARY, OpenCL, 1) + HC_LOAD_FUNC(ocl, clCreateProgramWithSource, OCL_CLCREATEPROGRAMWITHSOURCE, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueCopyBuffer, OCL_CLENQUEUECOPYBUFFER, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueMapBuffer, OCL_CLENQUEUEMAPBUFFER, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueNDRangeKernel, OCL_CLENQUEUENDRANGEKERNEL, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueReadBuffer, OCL_CLENQUEUEREADBUFFER, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueUnmapMemObject, OCL_CLENQUEUEUNMAPMEMOBJECT, OpenCL, 1) + HC_LOAD_FUNC(ocl, clEnqueueWriteBuffer, OCL_CLENQUEUEWRITEBUFFER, OpenCL, 1) + HC_LOAD_FUNC(ocl, clFinish, OCL_CLFINISH, OpenCL, 1) + HC_LOAD_FUNC(ocl, clFlush, OCL_CLFLUSH, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetDeviceIDs, OCL_CLGETDEVICEIDS, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetDeviceInfo, OCL_CLGETDEVICEINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetEventInfo, OCL_CLGETEVENTINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetKernelWorkGroupInfo, OCL_CLGETKERNELWORKGROUPINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetPlatformIDs, OCL_CLGETPLATFORMIDS, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetPlatformInfo, OCL_CLGETPLATFORMINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetProgramBuildInfo, OCL_CLGETPROGRAMBUILDINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetProgramInfo, OCL_CLGETPROGRAMINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseCommandQueue, OCL_CLRELEASECOMMANDQUEUE, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseContext, OCL_CLRELEASECONTEXT, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseKernel, OCL_CLRELEASEKERNEL, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseMemObject, OCL_CLRELEASEMEMOBJECT, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseProgram, OCL_CLRELEASEPROGRAM, OpenCL, 1) + HC_LOAD_FUNC(ocl, clSetKernelArg, OCL_CLSETKERNELARG, OpenCL, 1) + HC_LOAD_FUNC(ocl, clWaitForEvents, OCL_CLWAITFOREVENTS, OpenCL, 1) + HC_LOAD_FUNC(ocl, clGetEventProfilingInfo, OCL_CLGETEVENTPROFILINGINFO, OpenCL, 1) + HC_LOAD_FUNC(ocl, clReleaseEvent, OCL_CLRELEASEEVENT, OpenCL, 1) + + return 0; +} + +void ocl_close (hashcat_ctx_t *hashcat_ctx) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + if (ocl) + { + if (ocl->lib) + { + hc_dlclose (ocl->lib); + } + } +} + +int hc_clEnqueueNDRangeKernel (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetEventInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetEventInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clFlush (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clFlush (command_queue); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clFlush(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clFinish (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clFinish (command_queue); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clFinish(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clEnqueueWriteBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clEnqueueCopyBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clEnqueueReadBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetPlatformIDs (hashcat_ctx_t *hashcat_ctx, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetPlatformIDs (num_entries, platforms, num_platforms); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetPlatformIDs(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetPlatformInfo (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetDeviceIDs (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetDeviceInfo (hashcat_ctx_t *hashcat_ctx, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateContext (hashcat_ctx_t *hashcat_ctx, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateContext(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateCommandQueue(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateProgramWithSource (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateProgramWithBinary (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clCreateKernel (hashcat_ctx_t *hashcat_ctx, cl_program program, const char *kernel_name, cl_kernel *kernel) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *kernel = ocl->clCreateKernel (program, kernel_name, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseMemObject (hashcat_ctx_t *hashcat_ctx, cl_mem mem) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseMemObject (mem); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseMemObject(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseKernel (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseKernel (kernel); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseKernel(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseProgram (program); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseProgram(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseCommandQueue (command_queue); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseCommandQueue(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseContext (hashcat_ctx_t *hashcat_ctx, cl_context context) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseContext (context); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseContext(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clEnqueueMapBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + cl_int CL_err; + + *buf = ocl->clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &CL_err); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueMapBuffer(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clEnqueueUnmapMemObject (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clEnqueueUnmapMemObject(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetKernelWorkGroupInfo (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetProgramBuildInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetProgramInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl_event *event_list) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clWaitForEvents (num_events, event_list); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clWaitForEvents(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clGetEventProfilingInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clGetEventProfilingInfo(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; +} + +int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + OCL_PTR *ocl = opencl_ctx->ocl; + + const cl_int CL_err = ocl->clReleaseEvent (event); + + if (CL_err != CL_SUCCESS) + { + event_log_error (hashcat_ctx, "ERROR: clReleaseEvent(): %s", val2cstr_cl (CL_err)); + + return -1; + } + + return 0; } int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + cl_int CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL); - cl_int CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err != CL_SUCCESS) return -1; return 0; } @@ -290,7 +975,6 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -298,9 +982,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (hashconfig->hash_mode == 2000) { - process_stdout (hashcat_ctx, device_param, pws_cnt); - - return 0; + return process_stdout (hashcat_ctx, device_param, pws_cnt); } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -315,14 +997,9 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, run_kernel_tm (hashcat_ctx, device_param); - CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); + CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } @@ -349,25 +1026,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { run_kernel (hashcat_ctx, device_param, KERN_RUN_12, pws_cnt, false, 0); - CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; // do something with data - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } u32 iter = hashes->salts_buf[salt_pos].salt_iter; @@ -413,25 +1080,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { run_kernel (hashcat_ctx, device_param, KERN_RUN_23, pws_cnt, false, 0); - CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; // do something with data - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_cnt, false, 0); @@ -443,7 +1100,6 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u32 num, const u32 event_update, const u32 iteration) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -468,24 +1124,19 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con case KERN_RUN_3: kernel = device_param->kernel3; break; } - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; cl_event event; @@ -494,14 +1145,9 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con const size_t global_work_size[3] = { num_elements, 32, 1 }; const size_t local_work_size[3] = { kernel_threads / 32, 32, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, &event); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, &event); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else { @@ -518,24 +1164,14 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &event); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &event); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } - CL_err = hc_clFlush (opencl_ctx->ocl, device_param->command_queue); + CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (device_param->nvidia_spin_damp > 0) { @@ -553,27 +1189,17 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con } } - CL_err = hc_clWaitForEvents (opencl_ctx->ocl, 1, &event); + CL_err = hc_clWaitForEvents (hashcat_ctx, 1, &event); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clWaitForEvents(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; cl_ulong time_start; cl_ulong time_end; - CL_err |= hc_clGetEventProfilingInfo (opencl_ctx->ocl, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); - CL_err |= hc_clGetEventProfilingInfo (opencl_ctx->ocl, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); + CL_err |= hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); + CL_err |= hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetEventProfilingInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; const double exec_us = (double) (time_end - time_start) / 1000; @@ -606,31 +1232,19 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con device_param->exec_pos = exec_pos; } - CL_err = hc_clReleaseEvent (opencl_ctx->ocl, event); + CL_err = hc_clReleaseEvent (hashcat_ctx, event); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clReleaseEvent(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); - CL_err = hc_clFinish (opencl_ctx->ocl, device_param->command_queue); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; return 0; } int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u32 num) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - cl_int CL_err = CL_SUCCESS; u32 num_elements = num; @@ -660,74 +1274,52 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, switch (kern_run) { - case KERN_RUN_MP: CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]); + case KERN_RUN_MP: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]); break; - case KERN_RUN_MP_R: CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]); + case KERN_RUN_MP_R: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]); break; - case KERN_RUN_MP_L: CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]); + case KERN_RUN_MP_L: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]); break; } - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); - CL_err = hc_clFlush (opencl_ctx->ocl, device_param->command_queue); + if (CL_err == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); - return -1; - } - - CL_err = hc_clFinish (opencl_ctx->ocl, device_param->command_queue); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; return 0; } int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - cl_int CL_err = CL_SUCCESS; const u32 num_elements = 1024; // fixed @@ -739,40 +1331,23 @@ int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); - CL_err = hc_clFlush (opencl_ctx->ocl, device_param->command_queue); + if (CL_err == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); - return -1; - } - - CL_err = hc_clFinish (opencl_ctx->ocl, device_param->command_queue); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; return 0; } int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 num) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - cl_int CL_err = CL_SUCCESS; u32 num_elements = num; @@ -788,52 +1363,30 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel = device_param->kernel_amp; - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); - CL_err = hc_clFlush (opencl_ctx->ocl, device_param->command_queue); + if (CL_err == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); - return -1; - } - - CL_err = hc_clFinish (opencl_ctx->ocl, device_param->command_queue); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; return 0; } int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u32 value, const u32 num) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - cl_int CL_err = CL_SUCCESS; const u32 num16d = num / 16; @@ -852,46 +1405,26 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par cl_kernel kernel = device_param->kernel_memset; - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 0, sizeof (cl_mem), (void *) &buf); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 0, sizeof (cl_mem), (void *) &buf); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (opencl_ctx->ocl, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); - CL_err = hc_clFlush (opencl_ctx->ocl, device_param->command_queue); + if (CL_err == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); - return -1; - } - - CL_err = hc_clFinish (opencl_ctx->ocl, device_param->command_queue); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (num16m) @@ -903,14 +1436,9 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par tmp[2] = value; tmp[3] = value; - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, buf, CL_TRUE, num16d * 16, num16m, tmp, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, buf, CL_TRUE, num16d * 16, num16m, tmp, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } return 0; @@ -925,7 +1453,6 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -933,14 +1460,9 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { @@ -998,14 +1520,9 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const } } - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { @@ -1025,7 +1542,6 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -1252,58 +1768,33 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - cl_int CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (comb_t), device_param->combs_buf, 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (comb_t), device_param->combs_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_BF) { - cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); + cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (user_options->benchmark == true) @@ -1397,24 +1888,29 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - opencl_ctx->ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR)); - hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); opencl_ctx->devices_param = devices_param; /** * Load and map OpenCL library calls - * TODO: remove exit() calls in there */ - ocl_init (opencl_ctx->ocl); + OCL_PTR *ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR)); + + opencl_ctx->ocl = ocl; + + ocl_init (hashcat_ctx); /** * OpenCL platform selection */ - u32 opencl_platforms_filter = setup_opencl_platforms_filter (hashcat_ctx, user_options->opencl_platforms); + u32 opencl_platforms_filter; + + const int rc_platforms_filter = setup_opencl_platforms_filter (hashcat_ctx, user_options->opencl_platforms, &opencl_platforms_filter); + + if (rc_platforms_filter == -1) return -1; opencl_ctx->opencl_platforms_filter = opencl_platforms_filter; @@ -1422,7 +1918,11 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL device selection */ - u32 devices_filter = setup_devices_filter (hashcat_ctx, user_options->opencl_devices); + u32 devices_filter; + + const int rc_devices_filter = setup_devices_filter (hashcat_ctx, user_options->opencl_devices, &devices_filter); + + if (rc_devices_filter == -1) return -1; opencl_ctx->devices_filter = devices_filter; @@ -1430,7 +1930,11 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * OpenCL device type selection */ - cl_device_type device_types_filter = setup_device_types_filter (hashcat_ctx, user_options->opencl_device_types); + cl_device_type device_types_filter; + + const int rc_device_types_filter = setup_device_types_filter (hashcat_ctx, user_options->opencl_device_types, &device_types_filter); + + if (rc_device_types_filter == -1) return -1; opencl_ctx->device_types_filter = device_types_filter; @@ -1443,14 +1947,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_uint platform_devices_cnt = 0; cl_device_id *platform_devices = (cl_device_id *) mycalloc (DEVICES_MAX, sizeof (cl_device_id)); - cl_int CL_err = hc_clGetPlatformIDs (opencl_ctx->ocl, CL_PLATFORMS_MAX, platforms, &platforms_cnt); + cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformIDs(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (platforms_cnt == 0) { @@ -1492,18 +1991,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_platform_id platform = platforms[platform_id]; - cl_int CL_err = hc_clGetDeviceIDs (opencl_ctx->ocl, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); + cl_int CL_err = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); - if (CL_err != CL_SUCCESS) - { - //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); - - //return -1; - - // Silently ignore at this point, it will be reused later and create a note for the user at that point - - continue; - } + if (CL_err != CL_SUCCESS) continue; for (u32 platform_devices_id = 0; platform_devices_id < platform_devices_cnt; platform_devices_id++) { @@ -1511,14 +2001,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_device_type device_type; - cl_int CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + cl_int CL_err = hc_clGetDeviceInfo (hashcat_ctx, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_types_all |= device_type; } @@ -1561,12 +2046,10 @@ void opencl_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->enabled == false) return; + ocl_close (hashcat_ctx); + myfree (opencl_ctx->devices_param); - ocl_close (opencl_ctx->ocl); - - myfree (opencl_ctx->ocl); - myfree (opencl_ctx->platforms); myfree (opencl_ctx->platform_devices); @@ -1590,10 +2073,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_uint platform_devices_cnt = opencl_ctx->platform_devices_cnt; cl_device_id *platform_devices = opencl_ctx->platform_devices; - int need_adl = 0; - int need_nvml = 0; - int need_nvapi = 0; - int need_xnvctrl = 0; + bool need_adl = false; + bool need_nvml = false; + bool need_nvapi = false; + bool need_xnvctrl = false; u32 devices_cnt = 0; @@ -1612,14 +2095,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) char platform_vendor[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (opencl_ctx->ocl, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); + CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; // find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl // this causes trouble with vendor id based macros @@ -1666,11 +2144,11 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) u32 platform_skipped = ((opencl_ctx->opencl_platforms_filter & (1u << platform_id)) == 0); - CL_err = hc_clGetDeviceIDs (opencl_ctx->ocl, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); + CL_err = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); if (CL_err != CL_SUCCESS) { - //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s\n", val2cstr_cl (CL_err)); + //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); //return -1; @@ -1681,25 +2159,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { char platform_name[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (opencl_ctx->ocl, platform, CL_PLATFORM_NAME, HCBUFSIZ_TINY, platform_name, NULL); + CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_NAME, HCBUFSIZ_TINY, platform_name, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char platform_version[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (opencl_ctx->ocl, platform, CL_PLATFORM_VERSION, sizeof (platform_version), platform_version, NULL); + CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VERSION, sizeof (platform_version), platform_version, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; fprintf (stdout, "\nPlatform ID #%u\n Vendor : %s\n Name : %s\n Version : %s\n\n", platform_id + 1, platform_vendor, platform_name, platform_version); } @@ -1758,14 +2226,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_device_type device_type; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_type &= ~CL_DEVICE_TYPE_DEFAULT; @@ -1773,49 +2236,29 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_NAME, 0, NULL, ¶m_value_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, 0, NULL, ¶m_value_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *device_name = (char *) mymalloc (param_value_size); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_name = device_name; // device_vendor - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_VENDOR, 0, NULL, ¶m_value_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, 0, NULL, ¶m_value_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *device_vendor = (char *) mymalloc (param_value_size); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_vendor = device_vendor; @@ -1862,49 +2305,29 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_version - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_VERSION, 0, NULL, ¶m_value_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, 0, NULL, ¶m_value_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *device_version = (char *) mymalloc (param_value_size); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_version = device_version; // device_opencl_version - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_OPENCL_C_VERSION, 0, NULL, ¶m_value_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, 0, NULL, ¶m_value_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *device_opencl_version = (char *) mymalloc (param_value_size); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->opencl_v12 = device_opencl_version[9] > '1' || device_opencl_version[11] >= '2'; @@ -1912,14 +2335,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_uint device_processors; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (device_processors), &device_processors, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (device_processors), &device_processors, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_processors = device_processors; @@ -1928,14 +2346,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_maxmem_alloc; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (device_maxmem_alloc), &device_maxmem_alloc, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (device_maxmem_alloc), &device_maxmem_alloc, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_maxmem_alloc = MIN (device_maxmem_alloc, 0x7fffffff); @@ -1943,14 +2356,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_global_mem; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (device_global_mem), &device_global_mem, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (device_global_mem), &device_global_mem, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_global_mem = device_global_mem; @@ -1958,14 +2366,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) size_t device_maxworkgroup_size; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof (device_maxworkgroup_size), &device_maxworkgroup_size, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof (device_maxworkgroup_size), &device_maxworkgroup_size, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_maxworkgroup_size = device_maxworkgroup_size; @@ -1973,14 +2376,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_uint device_maxclock_frequency; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (device_maxclock_frequency), &device_maxclock_frequency, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (device_maxclock_frequency), &device_maxclock_frequency, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->device_maxclock_frequency = device_maxclock_frequency; @@ -1988,14 +2386,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_endian_little; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_ENDIAN_LITTLE, sizeof (device_endian_little), &device_endian_little, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_ENDIAN_LITTLE, sizeof (device_endian_little), &device_endian_little, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (device_endian_little == CL_FALSE) { @@ -2008,14 +2401,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_available; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_AVAILABLE, sizeof (device_available), &device_available, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_AVAILABLE, sizeof (device_available), &device_available, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (device_available == CL_FALSE) { @@ -2028,14 +2416,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_compiler_available; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_COMPILER_AVAILABLE, sizeof (device_compiler_available), &device_compiler_available, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPILER_AVAILABLE, sizeof (device_compiler_available), &device_compiler_available, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (device_compiler_available == CL_FALSE) { @@ -2048,14 +2431,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_device_exec_capabilities device_execution_capabilities; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (device_execution_capabilities), &device_execution_capabilities, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (device_execution_capabilities), &device_execution_capabilities, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if ((device_execution_capabilities & CL_EXEC_KERNEL) == 0) { @@ -2068,25 +2446,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) size_t device_extensions_size; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_EXTENSIONS, 0, NULL, &device_extensions_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, 0, NULL, &device_extensions_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *device_extensions = mymalloc (device_extensions_size + 1); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (strstr (device_extensions, "base_atomics") == 0) { @@ -2108,14 +2476,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_local_mem_size; - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof (device_local_mem_size), &device_local_mem_size, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof (device_local_mem_size), &device_local_mem_size, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (device_local_mem_size < 32768) { @@ -2151,25 +2514,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // driver_version - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DRIVER_VERSION, 0, NULL, ¶m_value_size); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, 0, NULL, ¶m_value_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *driver_version = (char *) mymalloc (param_value_size); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->driver_version = driver_version; @@ -2197,19 +2550,19 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if ((device_param->platform_vendor_id == VENDOR_ID_AMD) && (device_param->device_vendor_id == VENDOR_ID_AMD)) { - need_adl = 1; + need_adl = true; } if ((device_param->platform_vendor_id == VENDOR_ID_NV) && (device_param->device_vendor_id == VENDOR_ID_NV)) { - need_nvml = 1; + need_nvml = true; #if defined (__linux__) - need_xnvctrl = 1; + need_xnvctrl = true; #endif #if defined (_WIN) - need_nvapi = 1; + need_nvapi = true; #endif } } @@ -2222,14 +2575,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->kernel_exec_timeout = kernel_exec_timeout; @@ -2239,23 +2587,13 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; device_param->sm_minor = sm_minor; device_param->sm_major = sm_major; @@ -2431,7 +2769,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (user_options->opencl_info == true) { - exit (0); + return 0; } if (devices_active == 0) @@ -2489,10 +2827,10 @@ void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) opencl_ctx->devices_cnt = 0; opencl_ctx->devices_active = 0; - opencl_ctx->need_adl = 0; - opencl_ctx->need_nvml = 0; - opencl_ctx->need_nvapi = 0; - opencl_ctx->need_xnvctrl = 0; + opencl_ctx->need_adl = false; + opencl_ctx->need_nvml = false; + opencl_ctx->need_nvapi = false; + opencl_ctx->need_xnvctrl = false; } void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) @@ -2640,25 +2978,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64) { - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else { - CL_err = hc_clGetDeviceInfo (opencl_ctx->ocl, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL); + CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } else @@ -2746,30 +3074,20 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) properties[1] = (cl_context_properties) device_param->platform; properties[2] = 0; - CL_err = hc_clCreateContext (opencl_ctx->ocl, properties, 1, &device_param->device, NULL, NULL, &device_param->context); + CL_err = hc_clCreateContext (hashcat_ctx, properties, 1, &device_param->device, NULL, NULL, &device_param->context); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateContext(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; /** * create command-queue */ // not supported with NV - // device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL); + // device_param->command_queue = hc_clCreateCommandQueueWithProperties (hashcat_ctx, device_param->device, NULL); - CL_err = hc_clCreateCommandQueue (opencl_ctx->ocl, device_param->context, device_param->device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue); + CL_err = hc_clCreateCommandQueue (hashcat_ctx, device_param->context, device_param->device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateCommandQueue(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; /** * kernel threads: some algorithms need a fixed kernel-threads count @@ -2926,7 +3244,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) return -1; } - if (user_options->quiet == false) event_log_info (hashcat_ctx, "SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64 "\n", scrypt_tmto_final, size_scrypt); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64, scrypt_tmto_final, size_scrypt); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); } size_t size_scrypt4 = size_scrypt / 4; @@ -3129,7 +3448,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) strncpy (build_opts, build_opts_new, sizeof (build_opts)); #if defined (DEBUG) - event_log_info (hashcat_ctx, "- Device #%u: build_opts '%s'\n", device_id + 1, build_opts); + event_log_info (hashcat_ctx, "- Device #%u: build_opts '%s'", device_id + 1, build_opts); #endif /** @@ -3185,40 +3504,23 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - //return -1; - } + //if (CL_err == -1) return -1; size_t build_log_size = 0; - /* - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } - */ - - hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + //if (CL_err == -1) return -1; #if defined (DEBUG) if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) @@ -3228,14 +3530,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) mymalloc (build_log_size + 1); - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; puts (build_log); @@ -3253,27 +3550,19 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *binary = (char *) mymalloc (binary_size); - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + const int rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + if (rc_write == -1) return -1; myfree (binary); } @@ -3283,25 +3572,17 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } else @@ -3310,16 +3591,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size); #endif - read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); - return -1; - } + if (CL_err == -1) return -1; char build_opts_update[1024] = { 0 }; @@ -3336,29 +3614,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) snprintf (build_opts_update, sizeof (build_opts_update) - 1, "%s", build_opts); } - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - //return -1; - } + //if (CL_err == -1) return -1; size_t build_log_size = 0; - /* - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } - */ - - hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + //if (CL_err == -1) return -1; #if defined (DEBUG) if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) @@ -3368,14 +3632,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) mymalloc (build_log_size + 1); - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; puts (build_log); @@ -3448,40 +3707,23 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_mp); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_mp); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - //return -1; - } + //if (CL_err == -1) return -1; size_t build_log_size = 0; - /* - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } - */ - - hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + //if (CL_err == -1) return -1; #if defined (DEBUG) if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) @@ -3491,14 +3733,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) mymalloc (build_log_size + 1); - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; puts (build_log); @@ -3516,25 +3753,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *binary = (char *) mymalloc (binary_size); - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); @@ -3546,25 +3773,17 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_mp); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_mp); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } myfree (kernel_lengths); @@ -3629,40 +3848,23 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithSource (opencl_ctx->ocl, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_amp); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_amp); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - //return -1; - } + //if (CL_err == -1) return -1; size_t build_log_size = 0; - /* - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } - */ - - hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + //if (CL_err == -1) return -1; #if defined (DEBUG) if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) @@ -3672,14 +3874,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) mymalloc (build_log_size + 1); - CL_err = hc_clGetProgramBuildInfo (opencl_ctx->ocl, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; puts (build_log); @@ -3697,25 +3894,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; char *binary = (char *) mymalloc (binary_size); - CL_err = hc_clGetProgramInfo (opencl_ctx->ocl, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); @@ -3727,25 +3914,17 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif - read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); - CL_err = hc_clCreateProgramWithBinary (opencl_ctx->ocl, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_amp); + if (rc_read_kernel == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s\n", val2cstr_cl (CL_err)); + CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_amp); - return -1; - } + if (CL_err == -1) return -1; - CL_err = hc_clBuildProgram (opencl_ctx->ocl, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } myfree (kernel_lengths); @@ -3776,53 +3955,43 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * global buffers */ - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_amp_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL, &device_param->d_tmps); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL, &device_param->d_hooks); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_plains, NULL, &device_param->d_plain_bufs); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_digests, NULL, &device_param->d_digests_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_salts, NULL, &device_param->d_salt_bufs); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_results, NULL, &device_param->d_result); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV0_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV1_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV2_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV3_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_amp_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL, &device_param->d_tmps); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL, &device_param->d_hooks); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_plains, NULL, &device_param->d_plain_bufs); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_digests, NULL, &device_param->d_digests_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_salts, NULL, &device_param->d_salt_bufs); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_results, NULL, &device_param->d_result); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV0_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV1_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV2_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV3_buf); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_a, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_b, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_c, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_d, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_a, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_b, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_c, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_d, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, hashes->digests_buf, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, hashes->digests_shown, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, hashes->salts_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_a, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_b, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_c, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_d, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_a, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_b, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_c, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_d, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, hashes->digests_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, hashes->digests_shown, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, hashes->salts_buf, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; /** * special buffers @@ -3830,74 +3999,44 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); - CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); + CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (size_esalts) { - CL_err = hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL, &device_param->d_esalt_bufs); + CL_err = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL, &device_param->d_esalt_bufs); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, hashes->esalts_buf, 0, NULL, NULL); - CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, hashes->esalts_buf, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } /** @@ -4058,71 +4197,41 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 4); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel1); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 8); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel2); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 16); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel3); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 4); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel1); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 8); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel2); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 16); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel3); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (user_options->attack_mode == ATTACK_MODE_BF) @@ -4131,23 +4240,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel_tm); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_tm, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_tm, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } } @@ -4155,236 +4254,136 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel1); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel2); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel3); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel12); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel12, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel12, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", hashconfig->kern_type); - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, kernel_name, &device_param->kernel23); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel23, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel23, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } - CL_err |= hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel1, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel2, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel3, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel1, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel2, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel3, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; for (u32 i = 0; i <= 23; i++) { - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } for (u32 i = 24; i <= 34; i++) { - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } // GPU memset - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program, "gpu_memset", &device_param->kernel_memset); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, "gpu_memset", &device_param->kernel_memset); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_memset, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_memset, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + if (CL_err == -1) return -1; - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); - return -1; - } - - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_memset, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; // MP start if (user_options->attack_mode == ATTACK_MODE_BF) { - CL_err |= hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); - CL_err |= hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); + CL_err |= hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); + CL_err |= hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_l, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_r, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_mp_l, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_mp_r, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) { - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "C_markov", &device_param->kernel_mp); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "C_markov", &device_param->kernel_mp); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -4393,23 +4392,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program_amp, "amp", &device_param->kernel_amp); + CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_amp, "amp", &device_param->kernel_amp); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_amp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err = hc_clGetKernelWorkGroupInfo (opencl_ctx->ocl, device_param->kernel_amp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -4420,26 +4409,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { for (u32 i = 0; i < 5; i++) { - CL_err = hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); + CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } for (u32 i = 5; i < 7; i++) { - CL_err = hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); + CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } @@ -4505,14 +4484,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params_mp_buf32[7] = 0; } - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]); + for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -4529,15 +4503,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1; if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1; - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); + for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); + for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } @@ -4564,62 +4533,59 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) myfree (device_param->combs_buf); myfree (device_param->hooks_buf); - if (device_param->d_pws_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_pws_buf); - if (device_param->d_pws_amp_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_pws_amp_buf); - if (device_param->d_rules) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_rules); - if (device_param->d_rules_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_rules_c); - if (device_param->d_combs) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_combs); - if (device_param->d_combs_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_combs_c); - if (device_param->d_bfs) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bfs); - if (device_param->d_bfs_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bfs_c); - if (device_param->d_bitmap_s1_a) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s1_a); - if (device_param->d_bitmap_s1_b) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s1_b); - if (device_param->d_bitmap_s1_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s1_c); - if (device_param->d_bitmap_s1_d) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s1_d); - if (device_param->d_bitmap_s2_a) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s2_a); - if (device_param->d_bitmap_s2_b) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s2_b); - if (device_param->d_bitmap_s2_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s2_c); - if (device_param->d_bitmap_s2_d) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_bitmap_s2_d); - if (device_param->d_plain_bufs) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_plain_bufs); - if (device_param->d_digests_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_digests_buf); - if (device_param->d_digests_shown) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_digests_shown); - if (device_param->d_salt_bufs) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_salt_bufs); - if (device_param->d_esalt_bufs) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_esalt_bufs); - if (device_param->d_tmps) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_tmps); - if (device_param->d_hooks) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_hooks); - if (device_param->d_result) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_result); - if (device_param->d_scryptV0_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_scryptV0_buf); - if (device_param->d_scryptV1_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_scryptV1_buf); - if (device_param->d_scryptV2_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_scryptV2_buf); - if (device_param->d_scryptV3_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_scryptV3_buf); - if (device_param->d_root_css_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_root_css_buf); - if (device_param->d_markov_css_buf) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_markov_css_buf); - if (device_param->d_tm_c) CL_err |= hc_clReleaseMemObject (opencl_ctx->ocl, device_param->d_tm_c); + if (device_param->d_pws_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_buf); + if (device_param->d_pws_amp_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_amp_buf); + if (device_param->d_rules) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules); + if (device_param->d_rules_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules_c); + if (device_param->d_combs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs); + if (device_param->d_combs_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs_c); + if (device_param->d_bfs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs); + if (device_param->d_bfs_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs_c); + if (device_param->d_bitmap_s1_a) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_a); + if (device_param->d_bitmap_s1_b) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_b); + if (device_param->d_bitmap_s1_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_c); + if (device_param->d_bitmap_s1_d) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_d); + if (device_param->d_bitmap_s2_a) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_a); + if (device_param->d_bitmap_s2_b) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_b); + if (device_param->d_bitmap_s2_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_c); + if (device_param->d_bitmap_s2_d) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_d); + if (device_param->d_plain_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_plain_bufs); + if (device_param->d_digests_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_buf); + if (device_param->d_digests_shown) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_shown); + if (device_param->d_salt_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_salt_bufs); + if (device_param->d_esalt_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_esalt_bufs); + if (device_param->d_tmps) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_tmps); + if (device_param->d_hooks) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_hooks); + if (device_param->d_result) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_result); + if (device_param->d_scryptV0_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV0_buf); + if (device_param->d_scryptV1_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV1_buf); + if (device_param->d_scryptV2_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV2_buf); + if (device_param->d_scryptV3_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV3_buf); + if (device_param->d_root_css_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_root_css_buf); + if (device_param->d_markov_css_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_markov_css_buf); + if (device_param->d_tm_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_tm_c); - if (device_param->kernel1) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel1); - if (device_param->kernel12) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel12); - if (device_param->kernel2) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel2); - if (device_param->kernel23) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel23); - if (device_param->kernel3) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel3); - if (device_param->kernel_mp) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_mp); - if (device_param->kernel_mp_l) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_mp_l); - if (device_param->kernel_mp_r) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_mp_r); - if (device_param->kernel_tm) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_tm); - if (device_param->kernel_amp) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_amp); - if (device_param->kernel_memset) CL_err |= hc_clReleaseKernel (opencl_ctx->ocl, device_param->kernel_memset); + if (device_param->kernel1) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel1); + if (device_param->kernel12) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel12); + if (device_param->kernel2) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel2); + if (device_param->kernel23) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel23); + if (device_param->kernel3) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel3); + if (device_param->kernel_mp) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp); + if (device_param->kernel_mp_l) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_l); + if (device_param->kernel_mp_r) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_r); + if (device_param->kernel_tm) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_tm); + if (device_param->kernel_amp) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_amp); + if (device_param->kernel_memset) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_memset); - if (device_param->program) CL_err |= hc_clReleaseProgram (opencl_ctx->ocl, device_param->program); - if (device_param->program_mp) CL_err |= hc_clReleaseProgram (opencl_ctx->ocl, device_param->program_mp); - if (device_param->program_amp) CL_err |= hc_clReleaseProgram (opencl_ctx->ocl, device_param->program_amp); + if (device_param->program) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program); + if (device_param->program_mp) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program_mp); + if (device_param->program_amp) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program_amp); - if (device_param->command_queue) CL_err |= hc_clReleaseCommandQueue (opencl_ctx->ocl, device_param->command_queue); + if (device_param->command_queue) CL_err |= hc_clReleaseCommandQueue (hashcat_ctx, device_param->command_queue); - if (device_param->context) CL_err |= hc_clReleaseContext (opencl_ctx->ocl, device_param->context); + if (device_param->context) CL_err |= hc_clReleaseContext (hashcat_ctx, device_param->context); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: hc_clReleaseContext(): %s\n", val2cstr_cl (CL_err)); - } + //if (CL_err == -1) return -1; device_param->pws_buf = NULL; device_param->combs_buf = NULL; @@ -4735,19 +4701,14 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) cl_int CL_err = CL_SUCCESS; - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel1, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel2, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel3, 33, sizeof (cl_uint), device_param->kernel_params[33]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, 33, sizeof (cl_uint), device_param->kernel_params[33]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, 33, sizeof (cl_uint), device_param->kernel_params[33]); + CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, 33, sizeof (cl_uint), device_param->kernel_params[33]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel12, 33, sizeof (cl_uint), device_param->kernel_params[33]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel23, 33, sizeof (cl_uint), device_param->kernel_params[33]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, 33, sizeof (cl_uint), device_param->kernel_params[33]); + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, 33, sizeof (cl_uint), device_param->kernel_params[33]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; // kernel_params_amp @@ -4755,14 +4716,9 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) { - CL_err = hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); + CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } } @@ -4787,25 +4743,15 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) cl_int CL_err = CL_SUCCESS; - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]); - for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]); + for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]); + for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } return 0; @@ -4833,28 +4779,18 @@ int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l cl_int CL_err = CL_SUCCESS; - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); - for (u32 i = 4; i < 9; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]); + for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); + for (u32 i = 4; i < 9; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]); - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); - for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]); + for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); + for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s\n", val2cstr_cl (CL_err)); + if (CL_err == -1) return -1; - return -1; - } + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); + CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_err == -1) return -1; } return 0; diff --git a/src/outfile.c b/src/outfile.c index 02df40c99..7067d697c 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "interface.h" #include "hashes.h" #include "mpsp.h" @@ -342,7 +342,7 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx) if (outfile_ctx->fp == NULL) { - log_error ("ERROR: %s: %s", outfile_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", outfile_ctx->filename, strerror (errno)); return -1; } @@ -492,7 +492,7 @@ int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx) if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (hc_stat)) == 0) { - log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file"); + event_log_error (hashcat_ctx, "ERROR: Hashfile and Outfile are not allowed to point to the same file"); return -1; } diff --git a/src/outfile_check.c b/src/outfile_check.c index bd0e655a2..0032666b8 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "outfile_check.h" #include "convert.h" @@ -263,7 +263,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) hashes->salts_done++; - if (hashes->salts_done == hashes->salts_cnt) mycracked (status_ctx); + if (hashes->salts_done == hashes->salts_cnt) mycracked (hashcat_ctx); } } } @@ -356,7 +356,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (is_dir == 0) { - log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory); + event_log_error (hashcat_ctx, "ERROR: Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory); return -1; } @@ -365,7 +365,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hc_mkdir (outcheck_ctx->root_directory, 0700) == -1) { - log_error ("ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); return -1; } @@ -394,7 +394,7 @@ void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else { - log_error ("ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); //return -1; } diff --git a/src/potfile.c b/src/potfile.c index d6940947e..1e6597c70 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -7,7 +7,7 @@ #include "types.h" #include "convert.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "interface.h" #include "filehandling.h" #include "outfile.h" @@ -351,7 +351,7 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status)); + // event_log_warning (hashcat_ctx, "Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status)); continue; } @@ -391,7 +391,7 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) { - log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", potfile_ctx->filename, strerror (errno)); return -1; } @@ -503,7 +503,7 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu if (pot_ptr) { - log_info_nn (""); + event_log_info_nn (hashcat_ctx, ""); input_buf[input_len] = 0; @@ -544,7 +544,7 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu if (pot_ptr == NULL) { - log_info_nn (""); + event_log_info_nn (hashcat_ctx, ""); input_buf[input_len] = 0; @@ -605,7 +605,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // at least one half was found: - log_info_nn (""); + event_log_info_nn (hashcat_ctx, ""); input_buf[input_len] = 0; @@ -725,7 +725,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // ... at least one part was not cracked - log_info_nn (""); + event_log_info_nn (hashcat_ctx, ""); input_buf[input_len] = 0; diff --git a/src/restore.c b/src/restore.c index b6be2495c..762cb26d5 100644 --- a/src/restore.c +++ b/src/restore.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "user_options.h" #include "restore.h" @@ -52,7 +52,7 @@ u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx) return words_cur; } -static void check_running_process (hashcat_ctx_t *hashcat_ctx) +static int check_running_process (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; @@ -60,7 +60,7 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx) FILE *fp = fopen (eff_restore_file, "rb"); - if (fp == NULL) return; + if (fp == NULL) return 0; restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t)); @@ -68,9 +68,9 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx) if (nread != 1) { - log_error ("ERROR: Cannot read %s", eff_restore_file); + event_log_error (hashcat_ctx, "ERROR: Cannot read %s", eff_restore_file); - exit (-1); + return -1; } fclose (fp); @@ -104,9 +104,9 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx) if (strcmp (argv0_r, pidbin_r) == 0) { - log_error ("ERROR: Already an instance %s running on pid %d", pidbin, rd->pid); + event_log_error (hashcat_ctx, "ERROR: Already an instance %s running on pid %d", pidbin, rd->pid); - exit (-1); + return -1; } } @@ -127,9 +127,9 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx) { if (strcmp (pidbin, pidbin2) == 0) { - log_error ("ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid); + event_log_error (hashcat_ctx, "ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid); - exit (-1); + return -1; } } @@ -142,15 +142,17 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx) if (rd->version < RESTORE_VERSION_MIN) { - log_error ("ERROR: Cannot use outdated %s. Please remove it.", eff_restore_file); + event_log_error (hashcat_ctx, "ERROR: Cannot use outdated %s. Please remove it.", eff_restore_file); - exit (-1); + return -1; } myfree (rd); + + return 0; } -void init_restore (hashcat_ctx_t *hashcat_ctx) +static int init_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; @@ -158,7 +160,9 @@ void init_restore (hashcat_ctx_t *hashcat_ctx) restore_ctx->rd = rd; - check_running_process (hashcat_ctx); + const int rc = check_running_process (hashcat_ctx); + + if (rc == -1) return -1; rd->version = RESTORE_VERSION_CUR; @@ -173,17 +177,19 @@ void init_restore (hashcat_ctx_t *hashcat_ctx) if (getcwd (rd->cwd, 255) == NULL) { - log_error ("ERROR: getcwd(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: getcwd(): %s", strerror (errno)); - exit (-1); + return -1; } + + return 0; } -void read_restore (hashcat_ctx_t *hashcat_ctx) +static int read_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - if (restore_ctx->enabled == false) return; + if (restore_ctx->enabled == false) return 0; char *eff_restore_file = restore_ctx->eff_restore_file; @@ -191,18 +197,18 @@ void read_restore (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno)); - exit (-1); + return -1; } restore_data_t *rd = restore_ctx->rd; if (fread (rd, sizeof (restore_data_t), 1, fp) != 1) { - log_error ("ERROR: Can't read %s", eff_restore_file); + event_log_error (hashcat_ctx, "ERROR: Can't read %s", eff_restore_file); - exit (-1); + return -1; } rd->argv = (char **) mycalloc (rd->argc, sizeof (char *)); @@ -213,9 +219,9 @@ void read_restore (hashcat_ctx_t *hashcat_ctx) { if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL) { - log_error ("ERROR: Can't read %s", eff_restore_file); + event_log_error (hashcat_ctx, "ERROR: Can't read %s", eff_restore_file); - exit (-1); + return -1; } size_t len = strlen (buf); @@ -229,24 +235,26 @@ void read_restore (hashcat_ctx_t *hashcat_ctx) fclose (fp); - log_info ("INFO: Changing current working directory to the path found within the .restore file: '%s'", rd->cwd); + event_log_info (hashcat_ctx, "INFO: Changing current working directory to the path found within the .restore file: '%s'", rd->cwd); if (chdir (rd->cwd)) { - log_error ("ERROR: The directory '%s' does not exist. It is needed to restore (--restore) the session.\n" + event_log_error (hashcat_ctx, "ERROR: The directory '%s' does not exist. It is needed to restore (--restore) the session.\n" " You could either create this directory (or link it) or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n" " https://github.com/philsmd/analyze_hc_restore\n" " The directory must be relative to (or contain) all files/folders mentioned within the command line.", rd->cwd); - exit (-1); + return -1; } + + return 0; } -void write_restore (hashcat_ctx_t *hashcat_ctx) +static int write_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - if (restore_ctx->enabled == false) return; + if (restore_ctx->enabled == false) return 0; const u64 words_cur = get_lowest_words_done (hashcat_ctx); @@ -260,16 +268,16 @@ void write_restore (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("ERROR: %s: %s", new_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", new_restore_file, strerror (errno)); - exit (-1); + return -1; } if (setvbuf (fp, NULL, _IONBF, 0)) { - log_error ("ERROR: setvbuf file '%s': %s", new_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: setvbuf file '%s': %s", new_restore_file, strerror (errno)); - exit (-1); + return -1; } fwrite (rd, sizeof (restore_data_t), 1, fp); @@ -286,18 +294,22 @@ void write_restore (hashcat_ctx_t *hashcat_ctx) fsync (fileno (fp)); fclose (fp); + + return 0; } -void cycle_restore (hashcat_ctx_t *hashcat_ctx) +int cycle_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - if (restore_ctx->enabled == false) return; + if (restore_ctx->enabled == false) return 0; const char *eff_restore_file = restore_ctx->eff_restore_file; const char *new_restore_file = restore_ctx->new_restore_file; - write_restore (hashcat_ctx); + const int rc_write_restore = write_restore (hashcat_ctx); + + if (rc_write_restore == -1) return -1; struct stat st; @@ -305,14 +317,16 @@ void cycle_restore (hashcat_ctx_t *hashcat_ctx) { if (unlink (eff_restore_file)) { - log_info ("WARN: Unlink file '%s': %s", eff_restore_file, strerror (errno)); + event_log_warning (hashcat_ctx, "Unlink file '%s': %s", eff_restore_file, strerror (errno)); } } if (rename (new_restore_file, eff_restore_file)) { - log_info ("WARN: Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno)); + event_log_warning (hashcat_ctx, "Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno)); } + + return 0; } void unlink_restore (hashcat_ctx_t *hashcat_ctx) @@ -342,7 +356,7 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) if (restore_ctx->enabled == false) { - log_info ("WARNING: This feature is disabled when --restore-disable is specified"); + event_log_warning (hashcat_ctx, "This feature is disabled when --restore-disable is specified"); return; } @@ -357,7 +371,7 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) status_ctx->run_thread_level1 = false; status_ctx->run_thread_level2 = true; - log_info ("Checkpoint enabled: Will quit at next Restore Point update"); + event_log_info (hashcat_ctx, "Checkpoint enabled: Will quit at next Restore Point update"); } else { @@ -367,7 +381,7 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) status_ctx->run_thread_level1 = true; status_ctx->run_thread_level2 = true; - log_info ("Checkpoint disabled: Restore Point updates will no longer be monitored"); + event_log_info (hashcat_ctx, "Checkpoint disabled: Restore Point updates will no longer be monitored"); } } @@ -391,7 +405,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->eff_restore_file = eff_restore_file; restore_ctx->new_restore_file = new_restore_file; - init_restore (hashcat_ctx); + const int rc_init_restore = init_restore (hashcat_ctx); + + if (rc_init_restore == -1) return -1; if (argc == 0) return 0; if (argv == NULL) return 0; @@ -410,13 +426,15 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->restore == true) { - read_restore (hashcat_ctx); + const int rc_read_restore = read_restore (hashcat_ctx); + + if (rc_read_restore == -1) return -1; restore_data_t *rd = restore_ctx->rd; if (rd->version < RESTORE_VERSION_MIN) { - log_error ("ERROR: Incompatible restore-file version"); + event_log_error (hashcat_ctx, "ERROR: Incompatible restore-file version"); return -1; } diff --git a/src/rp.c b/src/rp.c index 82c4224ae..919e33f41 100644 --- a/src/rp.c +++ b/src/rp.c @@ -10,7 +10,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "shared.h" #include "filehandling.h" #include "rp.h" @@ -756,7 +756,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if ((fp = fopen (rp_file, "rb")) == NULL) { - log_error ("ERROR: %s: %s", rp_file, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", rp_file, strerror (errno)); return -1; } @@ -785,14 +785,14 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (result == -1) { - log_info ("WARNING: Skipping invalid or unsupported rule in file %s on line %u: %s", rp_file, rule_line, rule_buf); + event_log_warning (hashcat_ctx, "Skipping invalid or unsupported rule in file %s on line %u: %s", rp_file, rule_line, rule_buf); continue; } if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) { - log_info ("WARNING: Cannot convert rule for use on OpenCL device in file %s on line %u: %s", rp_file, rule_line, rule_buf); + event_log_warning (hashcat_ctx, "Cannot convert rule for use on OpenCL device in file %s on line %u: %s", rp_file, rule_line, rule_buf); memset (&kernel_rules_buf[kernel_rules_cnt], 0, sizeof (kernel_rule_t)); // needs to be cleared otherwise we could have some remaining data @@ -846,7 +846,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 { if (out_pos == RULES_MAX - 1) { - // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off); + // event_log_warning (hashcat_ctx, "Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off); break; } @@ -860,7 +860,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_cnt == 0) { - log_error ("ERROR: No valid rules left"); + event_log_error (hashcat_ctx, "ERROR: No valid rules left"); return -1; } diff --git a/src/status.c b/src/status.c index aed13408d..448f47971 100644 --- a/src/status.c +++ b/src/status.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "convert.h" #include "restore.h" #include "thread.h" @@ -159,14 +159,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - log_error ("ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - log_error ("ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); return; } @@ -326,14 +326,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - log_error ("ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - log_error ("ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); return; } @@ -352,7 +352,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - log_info ("Session.Name...: %s", user_options->session); + event_log_info (hashcat_ctx, "Session.Name...: %s", user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -360,7 +360,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - log_info ("Status.........: %s", status_type); + event_log_info (hashcat_ctx, "Status.........: %s", status_type); /** * show rules @@ -377,18 +377,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - log_info ("Rules.Type.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Rules.Type.....: %s", tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - log_info ("Rules.Type.....: Generated (%u)", user_options->rp_gen); + event_log_info (hashcat_ctx, "Rules.Type.....: Generated (%u)", user_options->rp_gen); if (user_options->rp_gen_seed) { - log_info ("Rules.Seed.....: %u", user_options->rp_gen_seed); + event_log_info (hashcat_ctx, "Rules.Seed.....: %u", user_options->rp_gen_seed); } } @@ -405,17 +405,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - log_info ("Input.Mode.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Mode.....: File (%s)", straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - log_info ("Input.Mode.....: Pipe"); + event_log_info (hashcat_ctx, "Input.Mode.....: Pipe"); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - log_info ("Input.Left.....: File (%s)", combinator_ctx->dict1); - log_info ("Input.Right....: File (%s)", combinator_ctx->dict2); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", combinator_ctx->dict1); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -451,7 +451,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - log_info ("Input.Mode.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Input.Mode.....: %s", tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -460,7 +460,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - log_info ("Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -468,8 +468,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - log_info ("Input.Left.....: File (%s)", straight_ctx->dict); - log_info ("Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -478,13 +478,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - log_info ("Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - log_info ("Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - log_info ("Input.Right....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -493,7 +493,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - log_info ("Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -503,7 +503,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - log_info ("Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + event_log_info (hashcat_ctx, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -520,19 +520,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - log_info ("Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - log_info ("Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - log_info ("Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - log_info ("Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else { @@ -549,7 +549,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - log_info ("Hash.Target....: %s", out_buf); + event_log_info (hashcat_ctx, "Hash.Target....: %s", out_buf); } } else @@ -562,15 +562,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (out_buf1, 0, 0, hashconfig, hashes); ascii_digest (out_buf2, 0, 1, hashconfig, hashes); - log_info ("Hash.Target....: %s, %s", out_buf1, out_buf2); + event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); } else { - log_info ("Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } } - log_info ("Hash.Type......: %s", hash_type); + event_log_info (hashcat_ctx, "Hash.Type......: %s", hash_type); /** * speed new @@ -693,12 +693,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - log_info ("Time.Started...: %s (%s)", start, display_run); + event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); } } else { - log_info ("Time.Started...: 0 secs"); + event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); } /** @@ -786,7 +786,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - log_info ("Time.Estimated.: > 10 Years"); + event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); } else { @@ -849,16 +849,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - log_info ("Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); } else { - log_info ("Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); } } else { - log_info ("Time.Estimated.: %s (%s)", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); } } } @@ -877,11 +877,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - log_info ("Candidates.#%d..: [Generating]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); } else { - log_info ("Candidates.#%d..: [Copying]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); } continue; @@ -919,11 +919,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - log_info ("Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); } else { - log_info ("Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); } } } @@ -940,7 +940,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - log_info ("Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -949,12 +949,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) log_info ("Speed.Dev.#*...: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - log_info ("Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -995,7 +995,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - log_info ("Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -1005,7 +1005,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - log_info ("Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -1014,7 +1014,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - log_info ("Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -1022,7 +1022,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_avg_min, cpt_avg_hour, cpt_avg_day); @@ -1051,14 +1051,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - log_info ("Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - log_info ("Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - log_info ("Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); } } } @@ -1067,24 +1067,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - log_info ("Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - log_info ("Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); if (user_options->restore_disable == false) { - log_info ("Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); } } else { - log_info ("Progress.......: %" PRIu64 "", progress_cur_relative_skip); - log_info ("Rejected.......: %" PRIu64 "", all_rejected); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // log_info ("Restore.Point..: %" PRIu64 "", restore_point); + // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); //} } } @@ -1169,7 +1169,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - log_info ("HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1184,14 +1184,14 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - log_error ("ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - log_error ("ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); return; } @@ -1231,7 +1231,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - log_info ("%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1243,14 +1243,14 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - log_error ("ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - log_error ("ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); return; } @@ -1328,11 +1328,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - log_info ("Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - log_info ("Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1342,7 +1342,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) log_info ("Speed.Dev.#*.: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/stdout.c b/src/stdout.c index 1ebf39c46..96d668e7c 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -5,7 +5,7 @@ #include "common.h" #include "types.h" -#include "logging.h" +#include "event.h" #include "locking.h" #include "rp_kernel_on_cpu.h" #include "mpsp.h" @@ -35,7 +35,7 @@ static void out_push (out_t *out, const u8 *pw_buf, const int pw_len) } } -void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt) +int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -56,11 +56,13 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { if ((out.fp = fopen (filename, "ab")) != NULL) { - lock_file (out.fp); + const int rc = lock_file (out.fp); + + if (rc == -1) return -1; } else { - log_error ("ERROR: %s: %s", filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", filename, strerror (errno)); out.fp = stdout; } @@ -240,4 +242,6 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param fclose (out.fp); } + + return 0; } diff --git a/src/straight.c b/src/straight.c index b00981a4f..e89fa827f 100644 --- a/src/straight.c +++ b/src/straight.c @@ -10,7 +10,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "logfile.h" #include "shared.h" #include "filehandling.h" @@ -69,7 +69,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - log_error ("ERROR: %s: %s", straight_ctx->dict, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", straight_ctx->dict, strerror (errno)); return -1; } @@ -97,7 +97,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - log_error ("ERROR: %s: %s", combinator_ctx->dict1, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict1, strerror (errno)); return -1; } @@ -112,7 +112,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); return -1; } @@ -151,7 +151,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - log_error ("ERROR: %s: %s", straight_ctx->dict, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", straight_ctx->dict, strerror (errno)); return -1; } @@ -272,7 +272,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - log_error ("ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); return -1; } @@ -295,7 +295,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - log_error ("ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); return -1; } @@ -317,7 +317,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - log_error ("ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); return -1; } @@ -341,7 +341,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - log_error ("ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); return -1; } @@ -364,7 +364,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - log_error ("ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); return -1; } @@ -386,7 +386,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - log_error ("ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); return -1; } @@ -401,7 +401,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - log_error ("ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); return -1; } @@ -424,7 +424,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - log_error ("ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); return -1; } @@ -446,7 +446,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - log_error ("ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); return -1; } diff --git a/src/terminal.c b/src/terminal.c index db519f94a..cd0a72bec 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5,7 +5,7 @@ #include "common.h" #include "types.h" -#include "logging.h" +#include "event.h" #include "thread.h" #include "timer.h" #include "status.h" @@ -29,23 +29,23 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const { if (user_options->machine_readable == false) { - log_info ("%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); - log_info (""); + event_log_info (hashcat_ctx, "%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - log_info ("# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start)); + event_log_info (hashcat_ctx, "# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start)); } } else if (user_options->restore == true) { - log_info ("%s (%s) starting in restore-mode...", PROGNAME, version_tag); - log_info (""); + event_log_info (hashcat_ctx, "%s (%s) starting in restore-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - log_info ("%s (%s) starting...", PROGNAME, version_tag); - log_info (""); + event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } } @@ -59,32 +59,32 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const if (user_options->show == true) return; if (user_options->left == true) return; - log_info_nn ("Started: %s", ctime (&proc_start)); - log_info_nn ("Stopped: %s", ctime (&proc_stop)); + event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start)); + event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop)); } -int setup_console () +int setup_console (hashcat_ctx_t *hashcat_ctx) { #if defined (_WIN) SetConsoleWindowSize (132); if (_setmode (_fileno (stdin), _O_BINARY) == -1) { - log_error ("ERROR: %s: %s", "stdin", strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", "stdin", strerror (errno)); return -1; } if (_setmode (_fileno (stdout), _O_BINARY) == -1) { - log_error ("ERROR: %s: %s", "stdout", strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", "stdout", strerror (errno)); return -1; } if (_setmode (_fileno (stderr), _O_BINARY) == -1) { - log_error ("ERROR: %s: %s", "stderr", strerror (errno)); + event_log_error (hashcat_ctx, "ERROR: %s: %s", "stderr", strerror (errno)); return -1; } @@ -141,7 +141,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_lock (status_ctx->mux_display); - log_info (""); + event_log_info (hashcat_ctx, ""); switch (ch) { @@ -149,11 +149,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case '\r': case '\n': - log_info (""); + event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - log_info (""); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -161,11 +161,13 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'b': - log_info (""); + event_log_info (hashcat_ctx, ""); - bypass (status_ctx); + bypass (hashcat_ctx); - log_info (""); + event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one"); + + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -173,11 +175,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'p': - log_info (""); + event_log_info (hashcat_ctx, ""); - SuspendThreads (status_ctx); + SuspendThreads (hashcat_ctx); - log_info (""); + if (status_ctx->devices_status == STATUS_PAUSED) + { + event_log_info (hashcat_ctx, "Paused"); + } + + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -185,11 +192,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'r': - log_info (""); + event_log_info (hashcat_ctx, ""); - ResumeThreads (status_ctx); + ResumeThreads (hashcat_ctx); - log_info (""); + if (status_ctx->devices_status == STATUS_RUNNING) + { + event_log_info (hashcat_ctx, "Resumed"); + } + + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -197,11 +209,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'c': - log_info (""); + event_log_info (hashcat_ctx, ""); stop_at_checkpoint (hashcat_ctx); - log_info (""); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -209,9 +221,9 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'q': - log_info (""); + event_log_info (hashcat_ctx, ""); - myabort (status_ctx); + myabort (hashcat_ctx); break; } diff --git a/src/thread.c b/src/thread.c index 919e09452..bedba5f78 100644 --- a/src/thread.c +++ b/src/thread.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "timer.h" #include "shared.h" #include "thread.h" @@ -116,8 +116,10 @@ void hc_signal (void (callback) (int)) #endif */ -void mycracked (status_ctx_t *status_ctx) +void mycracked (hashcat_ctx_t *hashcat_ctx) { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + //if (status_ctx->devices_status != STATUS_RUNNING) return; status_ctx->devices_status = STATUS_CRACKED; @@ -129,8 +131,10 @@ void mycracked (status_ctx_t *status_ctx) status_ctx->run_thread_level2 = false; } -void myabort (status_ctx_t *status_ctx) +void 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 //if (status_ctx->devices_status != STATUS_RUNNING) return; @@ -143,8 +147,10 @@ void myabort (status_ctx_t *status_ctx) status_ctx->run_thread_level2 = false; } -void myquit (status_ctx_t *status_ctx) +void myquit (hashcat_ctx_t *hashcat_ctx) { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + //if (status_ctx->devices_status != STATUS_RUNNING) return; status_ctx->devices_status = STATUS_QUIT; @@ -156,8 +162,10 @@ void myquit (status_ctx_t *status_ctx) status_ctx->run_thread_level2 = false; } -void bypass (status_ctx_t *status_ctx) +void bypass (hashcat_ctx_t *hashcat_ctx) { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + //if (status_ctx->devices_status != STATUS_RUNNING) return; status_ctx->devices_status = STATUS_BYPASS; @@ -167,23 +175,23 @@ void bypass (status_ctx_t *status_ctx) status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = false; status_ctx->run_thread_level2 = false; - - log_info ("Next dictionary / mask in queue selected, bypassing current one"); } -void SuspendThreads (status_ctx_t *status_ctx) +void SuspendThreads (hashcat_ctx_t *hashcat_ctx) { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + if (status_ctx->devices_status != STATUS_RUNNING) return; hc_timer_set (&status_ctx->timer_paused); status_ctx->devices_status = STATUS_PAUSED; - - log_info ("Paused"); } -void ResumeThreads (status_ctx_t *status_ctx) +void ResumeThreads (hashcat_ctx_t *hashcat_ctx) { + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + if (status_ctx->devices_status != STATUS_PAUSED) return; double ms_paused = hc_timer_get (status_ctx->timer_paused); @@ -191,6 +199,4 @@ void ResumeThreads (status_ctx_t *status_ctx) status_ctx->ms_paused += ms_paused; status_ctx->devices_status = STATUS_RUNNING; - - log_info ("Resumed"); } diff --git a/src/tuningdb.c b/src/tuningdb.c index 88968e470..6aa11307c 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -7,7 +7,7 @@ #include "types.h" #include "interface.h" #include "timer.h" -#include "logging.h" +#include "event.h" #include "memory.h" #include "filehandling.h" #include "ext_OpenCL.h" @@ -75,7 +75,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - log_error ("%s: %s", tuning_db_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", tuning_db_file, strerror (errno)); return -1; } @@ -150,7 +150,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) (token_ptr[1][0] != '3') && (token_ptr[1][0] != '*')) { - log_info ("WARNING: Tuning-db: Invalid attack_mode '%c' in Line '%u'", token_ptr[1][0], line_num); + event_log_warning (hashcat_ctx, "Tuning-db: Invalid attack_mode '%c' in Line '%u'", token_ptr[1][0], line_num); continue; } @@ -161,7 +161,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) (token_ptr[3][0] != '8') && (token_ptr[3][0] != 'N')) { - log_info ("WARNING: Tuning-db: Invalid vector_width '%c' in Line '%u'", token_ptr[3][0], line_num); + event_log_warning (hashcat_ctx, "Tuning-db: Invalid vector_width '%c' in Line '%u'", token_ptr[3][0], line_num); continue; } @@ -184,7 +184,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) if ((kernel_accel < 1) || (kernel_accel > 1024)) { - log_info ("WARNING: Tuning-db: Invalid kernel_accel '%d' in Line '%u'", kernel_accel, line_num); + event_log_warning (hashcat_ctx, "Tuning-db: Invalid kernel_accel '%d' in Line '%u'", kernel_accel, line_num); continue; } @@ -200,7 +200,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) if ((kernel_loops < 1) || (kernel_loops > 1024)) { - log_info ("WARNING: Tuning-db: Invalid kernel_loops '%d' in Line '%u'", kernel_loops, line_num); + event_log_warning (hashcat_ctx, "Tuning-db: Invalid kernel_loops '%d' in Line '%u'", kernel_loops, line_num); continue; } @@ -223,7 +223,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) } else { - log_info ("WARNING: Tuning-db: Invalid number of token in Line '%u'", line_num); + event_log_warning (hashcat_ctx, "Tuning-db: Invalid number of token in Line '%u'", line_num); continue; } diff --git a/src/usage.c b/src/usage.c index 0d4b4d0d8..71de716e4 100644 --- a/src/usage.c +++ b/src/usage.c @@ -4,7 +4,6 @@ */ #include "common.h" -#include "logging.h" #include "usage.h" static const char *USAGE_MINI[] = @@ -411,10 +410,10 @@ static const char *USAGE_BIG[] = void usage_mini_print (const char *progname) { - for (int i = 0; USAGE_MINI[i] != NULL; i++) log_info (USAGE_MINI[i], progname); + for (int i = 0; USAGE_MINI[i] != NULL; i++) printf (USAGE_MINI[i], progname); } void usage_big_print (const char *progname) { - for (int i = 0; USAGE_BIG[i] != NULL; i++) log_info (USAGE_BIG[i], progname); + for (int i = 0; USAGE_BIG[i] != NULL; i++) printf (USAGE_BIG[i], progname); } diff --git a/src/user_options.c b/src/user_options.c index b97775aef..f12e2deb0 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "logfile.h" #include "interface.h" #include "shared.h" @@ -320,7 +320,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) default: { - log_error ("ERROR: Invalid argument specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid argument specified"); return -1; } @@ -329,7 +329,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (optopt != 0) { - log_error ("ERROR: Invalid argument specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid argument specified"); return -1; } @@ -348,14 +348,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->hc_argc < 0) { - log_error ("ERROR: hc_argc %d is invalid", user_options->hc_argc); + event_log_error (hashcat_ctx, "ERROR: hc_argc %d is invalid", user_options->hc_argc); return -1; } if (user_options->hc_argv == NULL) { - log_error ("ERROR: hc_argv is NULL"); + event_log_error (hashcat_ctx, "ERROR: hc_argv is NULL"); return -1; } @@ -367,21 +367,21 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) && (user_options->attack_mode != ATTACK_MODE_HYBRID2) && (user_options->attack_mode != ATTACK_MODE_NONE)) { - log_error ("ERROR: Invalid attack-mode specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid attack-mode specified"); return -1; } if (user_options->runtime_chgd == true && user_options->runtime == 0) { - log_error ("ERROR: Invalid runtime specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid runtime specified"); return -1; } if (user_options->hash_mode > 14100) { - log_error ("ERROR: Invalid hash-type specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid hash-type specified"); return -1; } @@ -393,7 +393,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) || ((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299)) || ((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799))) { - log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode)); + event_log_error (hashcat_ctx, "ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode)); return -1; } @@ -401,7 +401,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_format > 16) { - log_error ("ERROR: Invalid outfile-format specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid outfile-format specified"); return -1; } @@ -410,7 +410,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_format_chgd == true) { - log_error ("ERROR: Mixing outfile-format > 1 with left parameter is not allowed"); + event_log_error (hashcat_ctx, "ERROR: Mixing outfile-format > 1 with left parameter is not allowed"); return -1; } @@ -420,7 +420,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_format_chgd == true) { - log_error ("ERROR: Mixing outfile-format > 7 with show parameter is not allowed"); + event_log_error (hashcat_ctx, "ERROR: Mixing outfile-format > 7 with show parameter is not allowed"); return -1; } @@ -428,49 +428,49 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->increment_min < INCREMENT_MIN) { - log_error ("ERROR: Invalid increment-min specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid increment-min specified"); return -1; } if (user_options->increment_max > INCREMENT_MAX) { - log_error ("ERROR: Invalid increment-max specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid increment-max specified"); return -1; } if (user_options->increment_min > user_options->increment_max) { - log_error ("ERROR: Invalid increment-min specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid increment-min specified"); return -1; } if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT)) { - log_error ("ERROR: Increment is not allowed in attack-mode 0"); + event_log_error (hashcat_ctx, "ERROR: Increment is not allowed in attack-mode 0"); return -1; } if ((user_options->increment == false) && (user_options->increment_min_chgd == true)) { - log_error ("ERROR: Increment-min is only supported combined with increment switch"); + event_log_error (hashcat_ctx, "ERROR: Increment-min is only supported combined with increment switch"); return -1; } if ((user_options->increment == false) && (user_options->increment_max_chgd == true)) { - log_error ("ERROR: Increment-max is only supported combined with increment switch"); + event_log_error (hashcat_ctx, "ERROR: Increment-max is only supported combined with increment switch"); return -1; } if (user_options->rp_files_cnt > 0 && user_options->rp_gen == true) { - log_error ("ERROR: Use of both rules-file and rules-generate is not supported"); + event_log_error (hashcat_ctx, "ERROR: Use of both rules-file and rules-generate is not supported"); return -1; } @@ -479,7 +479,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) { - log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0"); + event_log_error (hashcat_ctx, "ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0"); return -1; } @@ -487,14 +487,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->bitmap_min > user_options->bitmap_max) { - log_error ("ERROR: Invalid bitmap-min specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid bitmap-min specified"); return -1; } if (user_options->rp_gen_func_min > user_options->rp_gen_func_max) { - log_error ("ERROR: Invalid rp-gen-func-min specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid rp-gen-func-min specified"); return -1; } @@ -503,24 +503,24 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->force == false) { - log_info ("The manual use of the -n option (or --kernel-accel) is outdated"); - log_info ("Please consider using the -w option instead"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); + event_log_info (hashcat_ctx, "The manual use of the -n option (or --kernel-accel) is outdated"); + event_log_info (hashcat_ctx, "Please consider using the -w option instead"); + event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, ""); return -1; } if (user_options->kernel_accel < 1) { - log_error ("ERROR: Invalid kernel-accel specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid kernel-accel specified"); return -1; } if (user_options->kernel_accel > 1024) { - log_error ("ERROR: Invalid kernel-accel specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid kernel-accel specified"); return -1; } @@ -530,24 +530,24 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->force == false) { - log_info ("The manual use of the -u option (or --kernel-loops) is outdated"); - log_info ("Please consider using the -w option instead"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); + event_log_info (hashcat_ctx, "The manual use of the -u option (or --kernel-loops) is outdated"); + event_log_info (hashcat_ctx, "Please consider using the -w option instead"); + event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_info (hashcat_ctx, ""); return -1; } if (user_options->kernel_loops < 1) { - log_error ("ERROR: Invalid kernel-loops specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid kernel-loops specified"); return -1; } if (user_options->kernel_loops > 1024) { - log_error ("ERROR: Invalid kernel-loops specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid kernel-loops specified"); return -1; } @@ -555,7 +555,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if ((user_options->workload_profile < 1) || (user_options->workload_profile > 4)) { - log_error ("ERROR: workload-profile %i not available", user_options->workload_profile); + event_log_error (hashcat_ctx, "ERROR: workload-profile %i not available", user_options->workload_profile); return -1; } @@ -564,7 +564,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (is_power_of_2 (user_options->opencl_vector_width) == false || user_options->opencl_vector_width > 16) { - log_error ("ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width); + event_log_error (hashcat_ctx, "ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width); return -1; } @@ -574,14 +574,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->remove == true) { - log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter"); + event_log_error (hashcat_ctx, "ERROR: Mixing remove parameter not allowed with show parameter or left parameter"); return -1; } if (user_options->potfile_disable == true) { - log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter"); + event_log_error (hashcat_ctx, "ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter"); return -1; } @@ -591,7 +591,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_autohex == false) { - log_error ("ERROR: Mixing outfile-autohex-disable parameter not allowed with show parameter"); + event_log_error (hashcat_ctx, "ERROR: Mixing outfile-autohex-disable parameter not allowed with show parameter"); return -1; } @@ -601,13 +601,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->show == true) { - log_error ("ERROR: Combining show parameter with keyspace parameter is not allowed"); + event_log_error (hashcat_ctx, "ERROR: Combining show parameter with keyspace parameter is not allowed"); return -1; } else if (user_options->left == true) { - log_error ("ERROR: Combining left parameter with keyspace parameter is not allowed"); + event_log_error (hashcat_ctx, "ERROR: Combining left parameter with keyspace parameter is not allowed"); return -1; } @@ -617,14 +617,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->remove == false) { - log_error ("ERROR: Parameter remove-timer require parameter remove enabled"); + event_log_error (hashcat_ctx, "ERROR: Parameter remove-timer require parameter remove enabled"); return -1; } if (user_options->remove_timer < 1) { - log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1"); + event_log_error (hashcat_ctx, "ERROR: Parameter remove-timer must have a value greater than or equal to 1"); return -1; } @@ -636,14 +636,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate"); + event_log_error (hashcat_ctx, "ERROR: Parameter loopback not allowed without rules-file or rules-generate"); return -1; } } else { - log_error ("ERROR: Parameter loopback allowed in attack-mode 0 only"); + event_log_error (hashcat_ctx, "ERROR: Parameter loopback allowed in attack-mode 0 only"); return -1; } @@ -654,14 +654,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) { - log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0"); + event_log_error (hashcat_ctx, "ERROR: Parameter debug-mode option is only available with attack-mode 0"); return -1; } if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate"); + event_log_error (hashcat_ctx, "ERROR: Parameter debug-mode not allowed without rules-file or rules-generate"); return -1; } @@ -669,7 +669,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->debug_mode > 4) { - log_error ("ERROR: Invalid debug-mode specified"); + event_log_error (hashcat_ctx, "ERROR: Invalid debug-mode specified"); return -1; } @@ -678,7 +678,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->debug_mode < 1) { - log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set"); + event_log_error (hashcat_ctx, "ERROR: Parameter debug-file requires parameter debug-mode to be set"); return -1; } @@ -688,7 +688,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode == ATTACK_MODE_BF) { - log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks"); + event_log_error (hashcat_ctx, "ERROR: Parameter induction-dir not allowed with brute-force attacks"); return -1; } @@ -698,7 +698,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if ((user_options->weak_hash_threshold != WEAK_HASH_THRESHOLD) && (user_options->weak_hash_threshold != 0)) { - log_error ("ERROR: setting --weak-hash-threshold allowed only in straight-attack mode"); + event_log_error (hashcat_ctx, "ERROR: setting --weak-hash-threshold allowed only in straight-attack mode"); return -1; } @@ -706,7 +706,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->nvidia_spin_damp > 100) { - log_error ("ERROR: setting --nvidia-spin-damp must be between 0 and 100 (inclusive)"); + event_log_error (hashcat_ctx, "ERROR: setting --nvidia-spin-damp must be between 0 and 100 (inclusive)"); return -1; } @@ -715,7 +715,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->gpu_temp_abort < user_options->gpu_temp_retain) { - log_error ("ERROR: Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); + event_log_error (hashcat_ctx, "ERROR: Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); return -1; } @@ -727,7 +727,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_BF) { - log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode"); + event_log_error (hashcat_ctx, "ERROR: Only attack-mode 3 allowed in benchmark mode"); return -1; } diff --git a/src/weak_hash.c b/src/weak_hash.c index a39df35ac..a40e82df9 100644 --- a/src/weak_hash.c +++ b/src/weak_hash.c @@ -5,7 +5,7 @@ #include "common.h" #include "types.h" -#include "logging.h" +#include "event.h" #include "opencl.h" #include "hashes.h" #include "weak_hash.h" diff --git a/src/wordlist.c b/src/wordlist.c index 2e73bc6c6..28e0d23d9 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -6,7 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "logging.h" +#include "event.h" #include "convert.h" #include "dictstat.h" #include "thread.h" @@ -322,8 +322,8 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile) keyspace *= combinator_ctx->combs_cnt; } - if (user_options->quiet == false) log_info ("Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); //hc_signal (sigHandler_default); @@ -399,13 +399,13 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile) double percent = (double) comp / (double) d.stat.st_size; - if (user_options->quiet == false) log_info_nn ("Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt); time (&prev); } - if (user_options->quiet == false) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt); - if (user_options->quiet == false) log_info (""); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt); + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); dictstat_append (hashcat_ctx, &d); From 0f96c57eadcc0e5df59e6a19ff0597209d904045 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 09:12:36 +0200 Subject: [PATCH 013/106] Remove some workarounds to use get rid of unused variable warnings --- include/common.h | 2 + include/folder.h | 4 +- include/interface.h | 316 ++++++++++++++++++++-------------------- include/potfile.h | 4 +- include/terminal.h | 2 +- src/folder.c | 8 +- src/hlfmt.c | 34 ++--- src/interface.c | 323 ++++++++++++++++++++--------------------- src/main.c | 59 ++++---- src/potfile.c | 8 +- src/rp_kernel_on_cpu.c | 87 ++++++----- src/terminal.c | 2 +- 12 files changed, 410 insertions(+), 439 deletions(-) diff --git a/include/common.h b/include/common.h index 0777826f7..cfe5c2d15 100644 --- a/include/common.h +++ b/include/common.h @@ -87,4 +87,6 @@ but this is nededed for VS compiler which doesn't have inline keyword but has __ #define EOL "\n" #endif +#define MAYBE_UNUSED __attribute__((unused)) + #endif // _COMMON_H diff --git a/include/folder.h b/include/folder.h index 652fe6b52..a8042ab65 100644 --- a/include/folder.h +++ b/include/folder.h @@ -37,7 +37,7 @@ int count_dictionaries (char **dictionary_files); char **scan_directory (const char *path); -int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder); +int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder); void folder_config_destroy (hashcat_ctx_t *hashcat_ctx); -int hc_mkdir (const char *name, int mode); +int hc_mkdir (const char *name, MAYBE_UNUSED const int mode); diff --git a/include/interface.h b/include/interface.h index 9e65d6a41..ca5850afa 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1340,162 +1340,162 @@ typedef enum rounds_count * input functions */ -int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); -int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig); +int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); +int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig); /** * output functions @@ -1505,9 +1505,9 @@ char *stroptitype (const u32 opti_type); char *strhashtype (const u32 hash_mode); char *strparser (const u32 parser_status); -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes); +void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes); +void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); int hashconfig_init (hashcat_ctx_t *hashcat_ctx); void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/potfile.h b/include/potfile.h index 3101e414d..2e5a3264c 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -12,8 +12,8 @@ #define INCR_POT 1000 -int sort_by_pot (const void *v1, const void *v2, void *v3); -int sort_by_salt_buf (const void *v1, const void *v2, void *v3); +int sort_by_pot (const void *v1, const void *v2, MAYBE_UNUSED void *v3); +int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED void *v3); int sort_by_hash_t_salt (const void *v1, const void *v2); int sort_by_hash_t_salt_hccap (const void *v1, const void *v2); diff --git a/include/terminal.h b/include/terminal.h index a90ad77a1..7312ba675 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -26,7 +26,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const char *version_tag); void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop); -int setup_console (hashcat_ctx_t *hashcat_ctx); +int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx); void send_prompt (); void clear_prompt (); diff --git a/src/folder.c b/src/folder.c index 6e595b3a5..9b0b7b79b 100644 --- a/src/folder.c +++ b/src/folder.c @@ -231,7 +231,7 @@ char **scan_directory (const char *path) return (files); } -int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder) +int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder) { folder_config_t *folder_config = hashcat_ctx->folder_config; @@ -315,9 +315,6 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, #else - if (install_folder == NULL) install_folder = NULL; // make compiler happy - if (shared_folder == NULL) shared_folder = NULL; // make compiler happy - char *install_dir = get_install_dir (exec_path); char *profile_dir = install_dir; char *session_dir = install_dir; @@ -426,10 +423,9 @@ void folder_config_destroy (hashcat_ctx_t *hashcat_ctx) memset (folder_config, 0, sizeof (folder_config_t)); } -int hc_mkdir (const char *name, int mode) +int hc_mkdir (const char *name, MAYBE_UNUSED const int mode) { #if defined (_WIN) - if (mode == 0) mode = 0; // makes compiler happy return _mkdir (name); #else return mkdir (name, mode); diff --git a/src/hlfmt.c b/src/hlfmt.c index c1a026b0e..e60d0e6f8 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -22,7 +22,7 @@ static const char HLFMT_TEXT_NSLDAPS[] = "nsldaps"; // hlfmt hashcat -static void hlfmt_hash_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) +static void hlfmt_hash_hashcat (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) { const user_options_t *user_options = hashcat_ctx->user_options; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -54,7 +54,7 @@ static void hlfmt_hash_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int } } -static void hlfmt_user_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) +static void hlfmt_user_hashcat (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -86,10 +86,8 @@ static void hlfmt_user_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int // hlfmt pwdump -static int hlfmt_detect_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) +static int hlfmt_detect_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - int sep_cnt = 0; int sep2_len = 0; @@ -113,7 +111,7 @@ static int hlfmt_detect_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int return 0; } -static void hlfmt_hash_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) +static void hlfmt_hash_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -155,10 +153,8 @@ static void hlfmt_hash_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l *hashbuf_len = len; } -static void hlfmt_user_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) +static void hlfmt_user_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - char *pos = NULL; int len = 0; @@ -187,10 +183,8 @@ static void hlfmt_user_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l // hlfmt passwd -static int hlfmt_detect_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) +static int hlfmt_detect_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - int sep_cnt = 0; char sep5_first = 0; @@ -214,10 +208,8 @@ static int hlfmt_detect_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int return 0; } -static void hlfmt_hash_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) +static void hlfmt_hash_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - char *pos = NULL; int len = 0; @@ -244,10 +236,8 @@ static void hlfmt_hash_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l *hashbuf_len = len; } -static void hlfmt_user_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) +static void hlfmt_user_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - char *pos = NULL; int len = 0; @@ -276,10 +266,8 @@ static void hlfmt_user_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l // hlfmt shadow -static int hlfmt_detect_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) +static int hlfmt_detect_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len) { - if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy - int sep_cnt = 0; for (int i = 0; i < line_len; i++) @@ -292,12 +280,12 @@ static int hlfmt_detect_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int return 0; } -static void hlfmt_hash_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) +static void hlfmt_hash_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len) { hlfmt_hash_passwd (hashcat_ctx, line_buf, line_len, hashbuf_pos, hashbuf_len); } -static void hlfmt_user_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) +static void hlfmt_user_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len) { hlfmt_user_passwd (hashcat_ctx, line_buf, line_len, userbuf_pos, userbuf_len); } diff --git a/src/interface.c b/src/interface.c index 7c3064973..0c5924e0b 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2000,7 +2000,7 @@ static void drupal7_encode (u8 digest[64], u8 buf[43]) * parser */ -static u32 parse_and_store_salt (char *out, char *in, u32 salt_len, const hashconfig_t *hashconfig) +static u32 parse_and_store_salt (char *out, char *in, u32 salt_len, MAYBE_UNUSED const hashconfig_t *hashconfig) { u8 tmp[256] = { 0 }; @@ -2115,10 +2115,7 @@ static u32 parse_and_store_salt (char *out, char *in, u32 salt_len, const hashco return (salt_len); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - -int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_3200) || (input_len > DISPLAY_LEN_MAX_3200)) return (PARSER_GLOBAL_LENGTH); @@ -2177,7 +2174,7 @@ int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5700) || (input_len > DISPLAY_LEN_MAX_5700)) return (PARSER_GLOBAL_LENGTH); @@ -2210,7 +2207,7 @@ int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_3000) || (input_len > DISPLAY_LEN_MAX_3000)) return (PARSER_GLOBAL_LENGTH); @@ -2234,7 +2231,7 @@ int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashc return (PARSER_OK); } -int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_125) || (input_len > DISPLAY_LEN_MAX_125)) return (PARSER_GLOBAL_LENGTH); @@ -2271,7 +2268,7 @@ int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_122) || (input_len > DISPLAY_LEN_MAX_122)) return (PARSER_GLOBAL_LENGTH); @@ -2306,7 +2303,7 @@ int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1722) || (input_len > DISPLAY_LEN_MAX_1722)) return (PARSER_GLOBAL_LENGTH); @@ -2347,7 +2344,7 @@ int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -2394,7 +2391,7 @@ int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -2510,7 +2507,7 @@ int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -2554,7 +2551,7 @@ int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -2612,7 +2609,7 @@ int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -2737,7 +2734,7 @@ int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -2774,7 +2771,7 @@ int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -2830,7 +2827,7 @@ int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_400) || (input_len > DISPLAY_LEN_MAX_400)) return (PARSER_GLOBAL_LENGTH); @@ -2865,7 +2862,7 @@ int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (input_len < DISPLAY_LEN_MIN_500) return (PARSER_GLOBAL_LENGTH); @@ -2926,7 +2923,7 @@ int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (memcmp (SIGNATURE_MD5APR1, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED); @@ -2981,7 +2978,7 @@ int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_141) || (input_len > DISPLAY_LEN_MAX_141)) return (PARSER_GLOBAL_LENGTH); @@ -3030,7 +3027,7 @@ int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1500) || (input_len > DISPLAY_LEN_MAX_1500)) return (PARSER_GLOBAL_LENGTH); @@ -3067,7 +3064,7 @@ int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_900) || (input_len > DISPLAY_LEN_MAX_900)) return (PARSER_GLOBAL_LENGTH); @@ -3091,7 +3088,7 @@ int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3138,7 +3135,7 @@ int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_0) || (input_len > DISPLAY_LEN_MAX_0)) return (PARSER_GLOBAL_LENGTH); @@ -3162,7 +3159,7 @@ int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5100) || (input_len > DISPLAY_LEN_MAX_5100)) return (PARSER_GLOBAL_LENGTH); @@ -3179,7 +3176,7 @@ int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3226,7 +3223,7 @@ int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_2400) || (input_len > DISPLAY_LEN_MAX_2400)) return (PARSER_GLOBAL_LENGTH); @@ -3262,7 +3259,7 @@ int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3342,7 +3339,7 @@ static void transform_netntlmv1_key (const u8 *nthash, u8 *key) key[7] |= 0x01; } -int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5500) || (input_len > DISPLAY_LEN_MAX_5500)) return (PARSER_GLOBAL_LENGTH); @@ -3578,7 +3575,7 @@ int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5600) || (input_len > DISPLAY_LEN_MAX_5600)) return (PARSER_GLOBAL_LENGTH); @@ -3756,7 +3753,7 @@ int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3803,7 +3800,7 @@ int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3850,7 +3847,7 @@ int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_2600) || (input_len > DISPLAY_LEN_MAX_2600)) return (PARSER_GLOBAL_LENGTH); @@ -3890,7 +3887,7 @@ int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3937,7 +3934,7 @@ int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -3979,7 +3976,7 @@ int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4026,7 +4023,7 @@ int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4094,7 +4091,7 @@ int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_100) || (input_len > DISPLAY_LEN_MAX_100)) return (PARSER_GLOBAL_LENGTH); @@ -4115,7 +4112,7 @@ int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13300) || (input_len > DISPLAY_LEN_MAX_13300)) return (PARSER_GLOBAL_LENGTH); @@ -4134,7 +4131,7 @@ int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4178,7 +4175,7 @@ int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13500) || (input_len > DISPLAY_LEN_MAX_13500)) return (PARSER_GLOBAL_LENGTH); @@ -4264,7 +4261,7 @@ int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_101) || (input_len > DISPLAY_LEN_MAX_101)) return (PARSER_GLOBAL_LENGTH); @@ -4293,7 +4290,7 @@ int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_111) || (input_len > DISPLAY_LEN_MAX_111)) return (PARSER_GLOBAL_LENGTH); @@ -4341,7 +4338,7 @@ int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_131) || (input_len > DISPLAY_LEN_MAX_131)) return (PARSER_GLOBAL_LENGTH); @@ -4380,7 +4377,7 @@ int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_132) || (input_len > DISPLAY_LEN_MAX_132)) return (PARSER_GLOBAL_LENGTH); @@ -4419,7 +4416,7 @@ int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1731) || (input_len > DISPLAY_LEN_MAX_1731)) return (PARSER_GLOBAL_LENGTH); @@ -4464,7 +4461,7 @@ int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4504,7 +4501,7 @@ int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_112) || (input_len > DISPLAY_LEN_MAX_112)) return (PARSER_GLOBAL_LENGTH); @@ -4541,7 +4538,7 @@ int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12300) || (input_len > DISPLAY_LEN_MAX_12300)) return (PARSER_GLOBAL_LENGTH); @@ -4581,7 +4578,7 @@ int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1400) || (input_len > DISPLAY_LEN_MAX_1400)) return (PARSER_GLOBAL_LENGTH); @@ -4608,7 +4605,7 @@ int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4658,7 +4655,7 @@ int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10800) || (input_len > DISPLAY_LEN_MAX_10800)) return (PARSER_GLOBAL_LENGTH); @@ -4685,7 +4682,7 @@ int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1700) || (input_len > DISPLAY_LEN_MAX_1700)) return (PARSER_GLOBAL_LENGTH); @@ -4712,7 +4709,7 @@ int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -4762,7 +4759,7 @@ int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (memcmp (SIGNATURE_SHA512CRYPT, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED); @@ -4817,7 +4814,7 @@ int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5000) || (input_len > DISPLAY_LEN_MAX_5000)) return (PARSER_GLOBAL_LENGTH); @@ -4841,7 +4838,7 @@ int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5300) || (input_len > DISPLAY_LEN_MAX_5300)) return (PARSER_GLOBAL_LENGTH); @@ -4928,7 +4925,7 @@ int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5400) || (input_len > DISPLAY_LEN_MAX_5400)) return (PARSER_GLOBAL_LENGTH); @@ -5011,7 +5008,7 @@ int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6000) || (input_len > DISPLAY_LEN_MAX_6000)) return (PARSER_GLOBAL_LENGTH); @@ -5032,7 +5029,7 @@ int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6100) || (input_len > DISPLAY_LEN_MAX_6100)) return (PARSER_GLOBAL_LENGTH); @@ -5058,7 +5055,7 @@ int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_5800) || (input_len > DISPLAY_LEN_MAX_5800)) return (PARSER_GLOBAL_LENGTH); @@ -5091,7 +5088,7 @@ int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5130,7 +5127,7 @@ int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, c return (PARSER_OK); } -int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5169,7 +5166,7 @@ int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, c return (PARSER_OK); } -int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5208,7 +5205,7 @@ int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5247,7 +5244,7 @@ int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5286,7 +5283,7 @@ int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -5325,7 +5322,7 @@ int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6300) || (input_len > DISPLAY_LEN_MAX_6300)) return (PARSER_GLOBAL_LENGTH); @@ -5358,7 +5355,7 @@ int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6700) || (input_len > DISPLAY_LEN_MAX_6700)) return (PARSER_GLOBAL_LENGTH); @@ -5407,7 +5404,7 @@ int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6400) || (input_len > DISPLAY_LEN_MAX_6400)) return (PARSER_GLOBAL_LENGTH); @@ -5459,7 +5456,7 @@ int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6500) || (input_len > DISPLAY_LEN_MAX_6500)) return (PARSER_GLOBAL_LENGTH); @@ -5511,7 +5508,7 @@ int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6600) || (input_len > DISPLAY_LEN_MAX_6600)) return (PARSER_GLOBAL_LENGTH); @@ -5627,7 +5624,7 @@ int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6800) || (input_len > DISPLAY_LEN_MAX_6800)) return (PARSER_GLOBAL_LENGTH); @@ -5677,7 +5674,7 @@ int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_6900) || (input_len > DISPLAY_LEN_MAX_6900)) return (PARSER_GLOBAL_LENGTH); @@ -5704,7 +5701,7 @@ int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (memcmp (SIGNATURE_SHA256CRYPT, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED); @@ -5759,7 +5756,7 @@ int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 max_len = DISPLAY_LEN_MAX_7100 + (2 * 128); @@ -5831,7 +5828,7 @@ int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1441) || (input_len > DISPLAY_LEN_MAX_1441)) return (PARSER_GLOBAL_LENGTH); @@ -5886,7 +5883,7 @@ int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 max_len = DISPLAY_LEN_MAX_7200 + (8 * 128); @@ -5950,7 +5947,7 @@ int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1711) || (input_len > DISPLAY_LEN_MAX_1711)) return (PARSER_GLOBAL_LENGTH); @@ -6004,7 +6001,7 @@ int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -6046,7 +6043,7 @@ int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -6084,7 +6081,7 @@ int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -6125,7 +6122,7 @@ int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { @@ -6166,7 +6163,7 @@ int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7500) || (input_len > DISPLAY_LEN_MAX_7500)) return (PARSER_GLOBAL_LENGTH); @@ -6272,7 +6269,7 @@ int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7700) || (input_len > DISPLAY_LEN_MAX_7700)) return (PARSER_GLOBAL_LENGTH); @@ -6342,7 +6339,7 @@ int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7800) || (input_len > DISPLAY_LEN_MAX_7800)) return (PARSER_GLOBAL_LENGTH); @@ -6414,7 +6411,7 @@ int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7900) || (input_len > DISPLAY_LEN_MAX_7900)) return (PARSER_GLOBAL_LENGTH); @@ -6466,7 +6463,7 @@ int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8000) || (input_len > DISPLAY_LEN_MAX_8000)) return (PARSER_GLOBAL_LENGTH); @@ -6502,7 +6499,7 @@ int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_200) || (input_len > DISPLAY_LEN_MAX_200)) return (PARSER_GLOBAL_LENGTH); @@ -6516,7 +6513,7 @@ int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7300) || (input_len > DISPLAY_LEN_MAX_7300)) return (PARSER_GLOBAL_LENGTH); @@ -6585,7 +6582,7 @@ int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8100) || (input_len > DISPLAY_LEN_MAX_8100)) return (PARSER_GLOBAL_LENGTH); @@ -6621,7 +6618,7 @@ int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_4800) || (input_len > DISPLAY_LEN_MAX_4800)) return (PARSER_GLOBAL_LENGTH); @@ -6671,7 +6668,7 @@ int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8200) || (input_len > DISPLAY_LEN_MAX_8200)) return (PARSER_GLOBAL_LENGTH); @@ -6781,7 +6778,7 @@ int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8300) || (input_len > DISPLAY_LEN_MAX_8300)) return (PARSER_GLOBAL_LENGTH); @@ -6895,7 +6892,7 @@ int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8400) || (input_len > DISPLAY_LEN_MAX_8400)) return (PARSER_GLOBAL_LENGTH); @@ -6926,7 +6923,7 @@ int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13900) || (input_len > DISPLAY_LEN_MAX_13900)) return (PARSER_GLOBAL_LENGTH); @@ -6957,7 +6954,7 @@ int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { const u8 ascii_to_ebcdic[] = { @@ -7044,7 +7041,7 @@ int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_14000) || (input_len > DISPLAY_LEN_MAX_14000)) return (PARSER_GLOBAL_LENGTH); @@ -7099,7 +7096,7 @@ int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hash return (PARSER_OK); } -int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8600) || (input_len > DISPLAY_LEN_MAX_8600)) return (PARSER_GLOBAL_LENGTH); @@ -7118,7 +7115,7 @@ int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8700) || (input_len > DISPLAY_LEN_MAX_8700)) return (PARSER_GLOBAL_LENGTH); @@ -7147,7 +7144,7 @@ int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9100) || (input_len > DISPLAY_LEN_MAX_9100)) return (PARSER_GLOBAL_LENGTH); @@ -7203,7 +7200,7 @@ int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_1421) || (input_len > DISPLAY_LEN_MAX_1421)) return (PARSER_GLOBAL_LENGTH); @@ -7244,7 +7241,7 @@ int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_2612) || (input_len > DISPLAY_LEN_MAX_2612)) return (PARSER_GLOBAL_LENGTH); @@ -7290,7 +7287,7 @@ int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_3711) || (input_len > DISPLAY_LEN_MAX_3711)) return (PARSER_GLOBAL_LENGTH); @@ -7338,7 +7335,7 @@ int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_133) || (input_len > DISPLAY_LEN_MAX_133)) return (PARSER_GLOBAL_LENGTH); @@ -7371,7 +7368,7 @@ int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_23) || (input_len > DISPLAY_LEN_MAX_23)) return (PARSER_GLOBAL_LENGTH); @@ -7419,7 +7416,7 @@ int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8800) || (input_len > DISPLAY_LEN_MAX_8800)) return (PARSER_GLOBAL_LENGTH); @@ -7511,7 +7508,7 @@ int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_8900) || (input_len > DISPLAY_LEN_MAX_8900)) return (PARSER_GLOBAL_LENGTH); @@ -7601,7 +7598,7 @@ int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_501) || (input_len > DISPLAY_LEN_MAX_501)) return (PARSER_GLOBAL_LENGTH); @@ -7638,7 +7635,7 @@ int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9200) || (input_len > DISPLAY_LEN_MAX_9200)) return (PARSER_GLOBAL_LENGTH); @@ -7709,7 +7706,7 @@ int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9300) || (input_len > DISPLAY_LEN_MAX_9300)) return (PARSER_GLOBAL_LENGTH); @@ -7764,7 +7761,7 @@ int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9400) || (input_len > DISPLAY_LEN_MAX_9400)) return (PARSER_GLOBAL_LENGTH); @@ -7903,7 +7900,7 @@ int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9500) || (input_len > DISPLAY_LEN_MAX_9500)) return (PARSER_GLOBAL_LENGTH); @@ -8043,7 +8040,7 @@ int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9600) || (input_len > DISPLAY_LEN_MAX_9600)) return (PARSER_GLOBAL_LENGTH); @@ -8183,7 +8180,7 @@ int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9700) || (input_len > DISPLAY_LEN_MAX_9700)) return (PARSER_GLOBAL_LENGTH); @@ -8306,12 +8303,12 @@ int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { return oldoffice01_parse_hash (input_buf, input_len, hash_buf, hashconfig); } -int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9720) || (input_len > DISPLAY_LEN_MAX_9720)) return (PARSER_GLOBAL_LENGTH); @@ -8461,7 +8458,7 @@ int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, return (PARSER_OK); } -int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9800) || (input_len > DISPLAY_LEN_MAX_9800)) return (PARSER_GLOBAL_LENGTH); @@ -8581,14 +8578,14 @@ int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if (memcmp (SIGNATURE_OLDOFFICE3, input_buf, 12)) return (PARSER_SIGNATURE_UNMATCHED); return oldoffice34_parse_hash (input_buf, input_len, hash_buf, hashconfig); } -int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9820) || (input_len > DISPLAY_LEN_MAX_9820)) return (PARSER_GLOBAL_LENGTH); @@ -8735,7 +8732,7 @@ int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, return (PARSER_OK); } -int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_9900) || (input_len > DISPLAY_LEN_MAX_9900)) return (PARSER_GLOBAL_LENGTH); @@ -8754,7 +8751,7 @@ int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_124) || (input_len > DISPLAY_LEN_MAX_124)) return (PARSER_GLOBAL_LENGTH); @@ -8811,7 +8808,7 @@ int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10000) || (input_len > DISPLAY_LEN_MAX_10000)) return (PARSER_GLOBAL_LENGTH); @@ -8890,7 +8887,7 @@ int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, c return (PARSER_OK); } -int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10100) || (input_len > DISPLAY_LEN_MAX_10100)) return (PARSER_GLOBAL_LENGTH); @@ -8934,7 +8931,7 @@ int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10200) || (input_len > DISPLAY_LEN_MAX_10200)) return (PARSER_GLOBAL_LENGTH); @@ -9008,7 +9005,7 @@ int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10300) || (input_len > DISPLAY_LEN_MAX_10300)) return (PARSER_GLOBAL_LENGTH); @@ -9077,7 +9074,7 @@ int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_7600) || (input_len > DISPLAY_LEN_MAX_7600)) return (PARSER_GLOBAL_LENGTH); @@ -9108,7 +9105,7 @@ int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10400) || (input_len > DISPLAY_LEN_MAX_10400)) return (PARSER_GLOBAL_LENGTH); @@ -9312,12 +9309,12 @@ int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { return pdf11_parse_hash (input_buf, input_len, hash_buf, hashconfig); } -int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10420) || (input_len > DISPLAY_LEN_MAX_10420)) return (PARSER_GLOBAL_LENGTH); @@ -9552,7 +9549,7 @@ int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10500) || (input_len > DISPLAY_LEN_MAX_10500)) return (PARSER_GLOBAL_LENGTH); @@ -9817,7 +9814,7 @@ int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { int ret = pdf17l8_parse_hash (input_buf, input_len, hash_buf, hashconfig); @@ -9844,7 +9841,7 @@ int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10600) || (input_len > DISPLAY_LEN_MAX_10600)) return (PARSER_GLOBAL_LENGTH); @@ -10015,7 +10012,7 @@ int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_10900) || (input_len > DISPLAY_LEN_MAX_10900)) return (PARSER_GLOBAL_LENGTH); @@ -10102,7 +10099,7 @@ int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, return (PARSER_OK); } -int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11000) || (input_len > DISPLAY_LEN_MAX_11000)) return (PARSER_GLOBAL_LENGTH); @@ -10137,7 +10134,7 @@ int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11100) || (input_len > DISPLAY_LEN_MAX_11100)) return (PARSER_GLOBAL_LENGTH); @@ -10210,7 +10207,7 @@ int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf return (PARSER_OK); } -int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11200) || (input_len > DISPLAY_LEN_MAX_11200)) return (PARSER_GLOBAL_LENGTH); @@ -10259,7 +10256,7 @@ int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11300) || (input_len > DISPLAY_LEN_MAX_11300)) return (PARSER_GLOBAL_LENGTH); @@ -10406,7 +10403,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, return (PARSER_OK); } -int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11400) || (input_len > DISPLAY_LEN_MAX_11400)) return (PARSER_GLOBAL_LENGTH); @@ -10903,7 +10900,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11500) || (input_len > DISPLAY_LEN_MAX_11500)) return (PARSER_GLOBAL_LENGTH); @@ -10939,7 +10936,7 @@ int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const ha return (PARSER_OK); } -int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11600) || (input_len > DISPLAY_LEN_MAX_11600)) return (PARSER_GLOBAL_LENGTH); @@ -11105,7 +11102,7 @@ int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11700) || (input_len > DISPLAY_LEN_MAX_11700)) return (PARSER_GLOBAL_LENGTH); @@ -11132,7 +11129,7 @@ int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11800) || (input_len > DISPLAY_LEN_MAX_11800)) return (PARSER_GLOBAL_LENGTH); @@ -11175,7 +11172,7 @@ int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_bu return (PARSER_OK); } -int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_11900) || (input_len > DISPLAY_LEN_MAX_11900)) return (PARSER_GLOBAL_LENGTH); @@ -11257,7 +11254,7 @@ int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, con return (PARSER_OK); } -int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12000) || (input_len > DISPLAY_LEN_MAX_12000)) return (PARSER_GLOBAL_LENGTH); @@ -11344,7 +11341,7 @@ int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, co return (PARSER_OK); } -int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12100) || (input_len > DISPLAY_LEN_MAX_12100)) return (PARSER_GLOBAL_LENGTH); @@ -11435,7 +11432,7 @@ int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, return (PARSER_OK); } -int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12200) || (input_len > DISPLAY_LEN_MAX_12200)) return (PARSER_GLOBAL_LENGTH); @@ -11495,7 +11492,7 @@ int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12400) || (input_len > DISPLAY_LEN_MAX_12400)) return (PARSER_GLOBAL_LENGTH); @@ -11543,7 +11540,7 @@ int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, cons return (PARSER_OK); } -int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12500) || (input_len > DISPLAY_LEN_MAX_12500)) return (PARSER_GLOBAL_LENGTH); @@ -11612,7 +11609,7 @@ int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const h return (PARSER_OK); } -int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13000) || (input_len > DISPLAY_LEN_MAX_13000)) return (PARSER_GLOBAL_LENGTH); @@ -11724,7 +11721,7 @@ int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13100) || (input_len > DISPLAY_LEN_MAX_13100)) return (PARSER_GLOBAL_LENGTH); @@ -11823,7 +11820,7 @@ int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13200) || (input_len > DISPLAY_LEN_MAX_13200)) return (PARSER_GLOBAL_LENGTH); @@ -11898,7 +11895,7 @@ int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13400) || (input_len > DISPLAY_LEN_MAX_13400)) return (PARSER_GLOBAL_LENGTH); @@ -12200,7 +12197,7 @@ int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12600) || (input_len > DISPLAY_LEN_MAX_12600)) return (PARSER_GLOBAL_LENGTH); @@ -12279,7 +12276,7 @@ int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12700) || (input_len > DISPLAY_LEN_MAX_12700)) return (PARSER_GLOBAL_LENGTH); @@ -12350,7 +12347,7 @@ int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12800) || (input_len > DISPLAY_LEN_MAX_12800)) return (PARSER_GLOBAL_LENGTH); @@ -12424,7 +12421,7 @@ int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const return (PARSER_OK); } -int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_12900) || (input_len > DISPLAY_LEN_MAX_12900)) return (PARSER_GLOBAL_LENGTH); @@ -12479,7 +12476,7 @@ int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_ return (PARSER_OK); } -int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13600) || (input_len > DISPLAY_LEN_MAX_13600)) return (PARSER_GLOBAL_LENGTH); @@ -12707,7 +12704,7 @@ int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const has return (PARSER_OK); } -int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig) +int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig) { if ((input_len < DISPLAY_LEN_MIN_13800) || (input_len > DISPLAY_LEN_MAX_13800)) return (PARSER_GLOBAL_LENGTH); @@ -13026,7 +13023,7 @@ char *strparser (const u32 parser_status) return ((char *) PA_255); } -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes) +void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) { const void *digests_buf = hashes->digests_buf; const salt_t *salts_buf = hashes->salts_buf; @@ -13089,7 +13086,7 @@ void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, const } } -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes) +void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) { void *digests_buf = hashes->digests_buf; salt_t *salts_buf = hashes->salts_buf; @@ -16073,8 +16070,6 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, cons } } -#pragma GCC diagnostic pop - int hashconfig_init (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; diff --git a/src/main.c b/src/main.c index a98cb9e8d..6b19a9956 100644 --- a/src/main.c +++ b/src/main.c @@ -25,9 +25,6 @@ #include "interface.h" #include "event.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" - static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t len, FILE *fp) { if (len == 0) return; @@ -64,28 +61,28 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t fflush (fp); } -static int main_log_info (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { main_log (hashcat_ctx, buf, len, stdout); return 0; } -static int main_log_warning (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { main_log (hashcat_ctx, buf, len, stdout); return 0; } -static int main_log_error (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { main_log (hashcat_ctx, buf, len, stderr); return 0; } -static int main_welcome_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { // sets dos window size (windows only) @@ -100,7 +97,7 @@ static int main_welcome_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, con return 0; } -static int main_goodbye_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { // Inform user we're done @@ -111,7 +108,7 @@ static int main_goodbye_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, con return 0; } -static int main_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_logfile_top_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -132,7 +129,7 @@ static int main_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx, const void * return 0; } -static int main_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_logfile_top_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -143,7 +140,7 @@ static int main_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx, const void *bu return 0; } -static int main_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_logfile_sub_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -154,7 +151,7 @@ static int main_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx, const void * return 0; } -static int main_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_logfile_sub_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; @@ -163,7 +160,7 @@ static int main_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx, const void *bu return 0; } -static int main_outerloop_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -196,7 +193,7 @@ static int main_outerloop_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, return 0; } -static int main_outerloop_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -217,7 +214,7 @@ static int main_outerloop_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, return 0; } -static int main_cracker_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -242,7 +239,7 @@ static int main_cracker_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, c return 0; } -static int main_cracker_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -252,7 +249,7 @@ static int main_cracker_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, c return 0; } -static int main_cracker_final_stats (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_cracker_final_stats (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -294,7 +291,7 @@ static int main_cracker_final_stats (hashcat_ctx_t *hashcat_ctx, const void *buf return 0; } -static int main_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -305,7 +302,7 @@ static int main_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx, const void *bu return 0; } -static int main_calculated_words_base (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const user_options_t *user_options = hashcat_ctx->user_options; @@ -318,7 +315,7 @@ static int main_calculated_words_base (hashcat_ctx_t *hashcat_ctx, const void *b return 0; } -static int main_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_potfile_remove_parse (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -329,7 +326,7 @@ static int main_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx, const void *bu return 0; } -static int main_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const hashes_t *hashes = hashcat_ctx->hashes; @@ -355,7 +352,7 @@ static int main_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf return 0; } -static int main_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -369,7 +366,7 @@ static int main_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf return 0; } -static int main_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -455,7 +452,7 @@ static int main_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx, const void *bu return 0; } -static int main_opencl_session_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -466,7 +463,7 @@ static int main_opencl_session_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, return 0; } -static int main_opencl_session_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -477,7 +474,7 @@ static int main_opencl_session_post (hashcat_ctx_t *hashcat_ctx, const void *buf return 0; } -static int main_weak_hash_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -488,7 +485,7 @@ static int main_weak_hash_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, cons return 0; } -static int main_weak_hash_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -499,7 +496,7 @@ static int main_weak_hash_post (hashcat_ctx_t *hashcat_ctx, const void *buf, con return 0; } -static int main_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -510,7 +507,7 @@ static int main_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, co return 0; } -static int main_bitmap_init_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -521,7 +518,7 @@ static int main_bitmap_init_post (hashcat_ctx_t *hashcat_ctx, const void *buf, c return 0; } -static int main_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +static int main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -590,8 +587,6 @@ int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size #endif -#pragma GCC diagnostic pop - int main (int argc, char **argv) { // hashcat main context diff --git a/src/potfile.c b/src/potfile.c index 1e6597c70..f8e9f4c37 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -26,7 +26,7 @@ int sort_by_hash (const void *v1, const void *v2, void *v3); int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3); // get rid of this later -int sort_by_pot (const void *v1, const void *v2, void *v3) +int sort_by_pot (const void *v1, const void *v2, MAYBE_UNUSED void *v3) { const pot_t *p1 = (const pot_t *) v1; const pot_t *p2 = (const pot_t *) v2; @@ -37,10 +37,8 @@ int sort_by_pot (const void *v1, const void *v2, void *v3) return sort_by_hash (h1, h2, v3); } -int sort_by_salt_buf (const void *v1, const void *v2, void *v3) +int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED void *v3) { - if (v3 == NULL) v3 = NULL; // make compiler happy - const pot_t *p1 = (const pot_t *) v1; const pot_t *p2 = (const pot_t *) v2; @@ -54,7 +52,7 @@ int sort_by_salt_buf (const void *v1, const void *v2, void *v3) while (n--) { - if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1); + if (s1->salt_buf[n] > s2->salt_buf[n]) return 1; if (s1->salt_buf[n] < s2->salt_buf[n]) return -1; } diff --git a/src/rp_kernel_on_cpu.c b/src/rp_kernel_on_cpu.c index ab0835c15..b479de39d 100644 --- a/src/rp_kernel_on_cpu.c +++ b/src/rp_kernel_on_cpu.c @@ -3,9 +3,6 @@ * License.....: MIT */ -#pragma GCC diagnostic ignored "-Wunused-parameter" -#pragma GCC diagnostic ignored "-Wunused-function" - #include "common.h" #include "types.h" #include "bitops.h" @@ -1069,7 +1066,7 @@ static void reverse_block (u32 in0[4], u32 in1[4], u32 out0[4], u32 out1[4], con out1[3] = swap_workaround (tib41[3]); } -static u32 rule_op_mangle_lrest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_lrest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { buf0[0] |= (generate_cmask (buf0[0])); buf0[1] |= (generate_cmask (buf0[1])); @@ -1083,7 +1080,7 @@ static u32 rule_op_mangle_lrest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu return in_len; } -static u32 rule_op_mangle_urest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_urest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { buf0[0] &= ~(generate_cmask (buf0[0])); buf0[1] &= ~(generate_cmask (buf0[1])); @@ -1097,7 +1094,7 @@ static u32 rule_op_mangle_urest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu return in_len; } -static u32 rule_op_mangle_lrest_ufirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_lrest_ufirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { rule_op_mangle_lrest (p0, p1, buf0, buf1, in_len); @@ -1106,7 +1103,7 @@ static u32 rule_op_mangle_lrest_ufirst (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_urest_lfirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_urest_lfirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { rule_op_mangle_urest (p0, p1, buf0, buf1, in_len); @@ -1115,7 +1112,7 @@ static u32 rule_op_mangle_urest_lfirst (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_trest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_trest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { buf0[0] ^= (generate_cmask (buf0[0])); buf0[1] ^= (generate_cmask (buf0[1])); @@ -1129,7 +1126,7 @@ static u32 rule_op_mangle_trest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu return in_len; } -static u32 rule_op_mangle_toggle_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_toggle_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1150,14 +1147,14 @@ static u32 rule_op_mangle_toggle_at (const u32 p0, const u32 p1, u32 buf0[4], u3 return in_len; } -static u32 rule_op_mangle_reverse (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_reverse (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { reverse_block (buf0, buf1, buf0, buf1, in_len); return in_len; } -static u32 rule_op_mangle_dupeword (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupeword (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ((in_len + in_len) >= 32) return (in_len); @@ -1182,7 +1179,7 @@ static u32 rule_op_mangle_dupeword (const u32 p0, const u32 p1, u32 buf0[4], u32 return out_len; } -static u32 rule_op_mangle_dupeword_times (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupeword_times (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (((in_len * p0) + in_len) >= 32) return (in_len); @@ -1210,7 +1207,7 @@ static u32 rule_op_mangle_dupeword_times (const u32 p0, const u32 p1, u32 buf0[4 return out_len; } -static u32 rule_op_mangle_reflect (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_reflect (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ((in_len + in_len) >= 32) return (in_len); @@ -1228,7 +1225,7 @@ static u32 rule_op_mangle_reflect (const u32 p0, const u32 p1, u32 buf0[4], u32 return out_len; } -static u32 rule_op_mangle_append (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_append (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ((in_len + 1) >= 32) return (in_len); @@ -1241,7 +1238,7 @@ static u32 rule_op_mangle_append (const u32 p0, const u32 p1, u32 buf0[4], u32 b return out_len; } -static u32 rule_op_mangle_prepend (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_prepend (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ((in_len + 1) >= 32) return (in_len); @@ -1256,7 +1253,7 @@ static u32 rule_op_mangle_prepend (const u32 p0, const u32 p1, u32 buf0[4], u32 return out_len; } -static u32 rule_op_mangle_rotate_left (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_rotate_left (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len == 0) return (in_len); @@ -1283,7 +1280,7 @@ static u32 rule_op_mangle_rotate_left (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_rotate_right (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_rotate_right (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len == 0) return (in_len); @@ -1314,7 +1311,7 @@ static u32 rule_op_mangle_rotate_right (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_delete_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_delete_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len == 0) return (in_len); @@ -1325,7 +1322,7 @@ static u32 rule_op_mangle_delete_first (const u32 p0, const u32 p1, u32 buf0[4], return in_len1; } -static u32 rule_op_mangle_delete_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_delete_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len == 0) return (in_len); @@ -1348,7 +1345,7 @@ static u32 rule_op_mangle_delete_last (const u32 p0, const u32 p1, u32 buf0[4], return in_len1; } -static u32 rule_op_mangle_delete_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_delete_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1423,7 +1420,7 @@ static u32 rule_op_mangle_delete_at (const u32 p0, const u32 p1, u32 buf0[4], u3 return out_len; } -static u32 rule_op_mangle_extract (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_extract (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1438,7 +1435,7 @@ static u32 rule_op_mangle_extract (const u32 p0, const u32 p1, u32 buf0[4], u32 return out_len; } -static u32 rule_op_mangle_omit (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_omit (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1524,7 +1521,7 @@ static u32 rule_op_mangle_omit (const u32 p0, const u32 p1, u32 buf0[4], u32 buf return out_len; } -static u32 rule_op_mangle_insert (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_insert (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 > in_len) return (in_len); @@ -1596,7 +1593,7 @@ static u32 rule_op_mangle_insert (const u32 p0, const u32 p1, u32 buf0[4], u32 b return out_len; } -static u32 rule_op_mangle_overstrike (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_overstrike (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1619,7 +1616,7 @@ static u32 rule_op_mangle_overstrike (const u32 p0, const u32 p1, u32 buf0[4], u return in_len; } -static u32 rule_op_mangle_truncate_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -1628,7 +1625,7 @@ static u32 rule_op_mangle_truncate_at (const u32 p0, const u32 p1, u32 buf0[4], return p0; } -static u32 rule_op_mangle_replace (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { for (u32 i = 0; i < in_len; i++) { @@ -1672,7 +1669,7 @@ static u32 rule_op_mangle_replace (const u32 p0, const u32 p1, u32 buf0[4], u32 return in_len; } -static u32 rule_op_mangle_purgechar (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { u32 out_len = 0; @@ -1714,14 +1711,14 @@ static u32 rule_op_mangle_purgechar (const u32 p0, const u32 p1, u32 buf0[4], u3 } /* -static u32 rule_op_mangle_togglecase_rec (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_togglecase_rec (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { // TODO return in_len; } */ -static u32 rule_op_mangle_dupechar_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ( in_len == 0) return (in_len); if ((in_len + p0) >= 32) return (in_len); @@ -1908,7 +1905,7 @@ static u32 rule_op_mangle_dupechar_first (const u32 p0, const u32 p1, u32 buf0[4 return out_len; } -static u32 rule_op_mangle_dupechar_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ( in_len == 0) return (in_len); if ((in_len + p0) >= 32) return (in_len); @@ -1943,7 +1940,7 @@ static u32 rule_op_mangle_dupechar_last (const u32 p0, const u32 p1, u32 buf0[4] return out_len; } -static u32 rule_op_mangle_dupechar_all (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ( in_len == 0) return (in_len); if ((in_len + in_len) >= 32) return (in_len); @@ -1976,7 +1973,7 @@ static u32 rule_op_mangle_dupechar_all (const u32 p0, const u32 p1, u32 buf0[4], return out_len; } -static u32 rule_op_mangle_switch_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_switch_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len < 2) return (in_len); @@ -1985,7 +1982,7 @@ static u32 rule_op_mangle_switch_first (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_switch_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_switch_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (in_len < 2) return (in_len); @@ -2070,7 +2067,7 @@ static u32 rule_op_mangle_switch_last (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_switch_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_switch_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); if (p1 >= in_len) return (in_len); @@ -2317,7 +2314,7 @@ static u32 rule_op_mangle_switch_at (const u32 p0, const u32 p1, u32 buf0[4], u3 return in_len; } -static u32 rule_op_mangle_chr_shiftl (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_chr_shiftl (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -2339,7 +2336,7 @@ static u32 rule_op_mangle_chr_shiftl (const u32 p0, const u32 p1, u32 buf0[4], u return in_len; } -static u32 rule_op_mangle_chr_shiftr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_chr_shiftr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -2361,7 +2358,7 @@ static u32 rule_op_mangle_chr_shiftr (const u32 p0, const u32 p1, u32 buf0[4], u return in_len; } -static u32 rule_op_mangle_chr_incr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_chr_incr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -2385,7 +2382,7 @@ static u32 rule_op_mangle_chr_incr (const u32 p0, const u32 p1, u32 buf0[4], u32 return in_len; } -static u32 rule_op_mangle_chr_decr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_chr_decr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 >= in_len) return (in_len); @@ -2409,7 +2406,7 @@ static u32 rule_op_mangle_chr_decr (const u32 p0, const u32 p1, u32 buf0[4], u32 return in_len; } -static u32 rule_op_mangle_replace_np1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_replace_np1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if ((p0 + 1) >= in_len) return (in_len); @@ -2436,7 +2433,7 @@ static u32 rule_op_mangle_replace_np1 (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_replace_nm1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_replace_nm1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 == 0) return (in_len); @@ -2465,7 +2462,7 @@ static u32 rule_op_mangle_replace_nm1 (const u32 p0, const u32 p1, u32 buf0[4], return in_len; } -static u32 rule_op_mangle_dupeblock_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 > in_len) return (in_len); @@ -2503,7 +2500,7 @@ static u32 rule_op_mangle_dupeblock_first (const u32 p0, const u32 p1, u32 buf0[ return out_len; } -static u32 rule_op_mangle_dupeblock_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_dupeblock_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { if (p0 > in_len) return (in_len); @@ -2532,7 +2529,7 @@ static u32 rule_op_mangle_dupeblock_last (const u32 p0, const u32 p1, u32 buf0[4 return out_len; } -static u32 rule_op_mangle_title (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +static u32 rule_op_mangle_title (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { buf0[0] |= (generate_cmask (buf0[0])); buf0[1] |= (generate_cmask (buf0[1])); @@ -2653,7 +2650,7 @@ static u32 rule_op_mangle_title (const u32 p0, const u32 p1, u32 buf0[4], u32 bu return in_len; } -u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len) +u32 apply_rule (const u32 name, MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len) { u32 out_len = in_len; @@ -2704,7 +2701,7 @@ u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf return out_len; } -u32 apply_rules (u32 *cmds, u32 buf0[4], u32 buf1[4], const u32 len) +u32 apply_rules (u32 *cmds, u32 buf0[4] MAYBE_UNUSED, u32 buf1[4] MAYBE_UNUSED, const u32 len) { u32 out_len = len; diff --git a/src/terminal.c b/src/terminal.c index cd0a72bec..e8505166b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -63,7 +63,7 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop)); } -int setup_console (hashcat_ctx_t *hashcat_ctx) +int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) { #if defined (_WIN) SetConsoleWindowSize (132); From 07f5b2195b85c7dde7794459470a6ba960060526 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 09:18:10 +0200 Subject: [PATCH 014/106] Hopefully fixes some OSX compiler errors --- src/affinity.c | 2 +- src/folder.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/affinity.c b/src/affinity.c index 0837156fe..211baff08 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -29,7 +29,7 @@ static int CPU_ISSET (int num, cpu_set_t *cs) return (cs->count & (1 << num)); } -static int pthread_setaffinity_np (hashcat_ctx_t *hashcat_ctx, pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set) +static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set) { int core; diff --git a/src/folder.c b/src/folder.c index 9b0b7b79b..934475043 100644 --- a/src/folder.c +++ b/src/folder.c @@ -163,12 +163,7 @@ char **scan_directory (const char *path) struct dirent *de = NULL; - if (readdir_r (d, &e, &de) != 0) - { - event_log_error (hashcat_ctx, "ERROR: readdir_r() failed"); - - break; - } + if (readdir_r (d, &e, &de) != 0) break; if (de == NULL) break; From 8fc4da795b4dd4b69bc2f62b9f6ec931bfa6e616 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:03:11 +0200 Subject: [PATCH 015/106] Replace fprintf(stderr, ...) on malloc.c with log_event_error() --- include/ext_ADL.h | 5 + include/filehandling.h | 2 +- include/folder.h | 6 +- include/hwmon.h | 103 ------------ include/interface.h | 4 +- include/memory.h | 10 +- include/mpsp.h | 17 -- src/affinity.c | 4 +- src/bitmap.c | 32 ++-- src/combinator.c | 4 +- src/cpt.c | 4 +- src/cpu_crc32.c | 4 +- src/dictstat.c | 8 +- src/dispatch.c | 12 +- src/ext_ADL.c | 4 +- src/filehandling.c | 6 +- src/folder.c | 72 ++++---- src/hashcat.c | 116 ++++++------- src/hashes.c | 90 +++++----- src/hlfmt.c | 6 +- src/hwmon.c | 367 +++++++++++++++++++++++++---------------- src/induct.c | 10 +- src/interface.c | 253 ++++++---------------------- src/logfile.c | 12 +- src/loopback.c | 2 +- src/main.c | 4 +- src/memory.c | 74 +++++---- src/monitor.c | 65 +++----- src/mpsp.c | 271 +++++++++++------------------- src/opencl.c | 124 +++++++------- src/outfile_check.c | 32 ++-- src/potfile.c | 70 ++++---- src/restore.c | 32 ++-- src/rp.c | 26 +-- src/status.c | 20 +-- src/straight.c | 40 ++--- src/tuningdb.c | 34 ++-- src/user_options.c | 6 +- src/wordlist.c | 6 +- 39 files changed, 837 insertions(+), 1120 deletions(-) diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 5961cbf97..9a3322fe0 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -7,6 +7,11 @@ #define _EXT_ADL_H #include +#include + +#if defined (_WIN) +#include +#endif // _WIN /** * Declarations from adl_sdk.h and subheaders diff --git a/include/filehandling.h b/include/filehandling.h index 582599453..b8f70d40c 100644 --- a/include/filehandling.h +++ b/include/filehandling.h @@ -10,7 +10,7 @@ #include #include -u64 count_lines (FILE *fd); +u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd); int fgetl (FILE *fp, char *line_buf); diff --git a/include/folder.h b/include/folder.h index a8042ab65..d4ddc212b 100644 --- a/include/folder.h +++ b/include/folder.h @@ -29,13 +29,9 @@ int sort_by_stringptr (const void *p1, const void *p2); -char *get_install_dir (const char *progname); -char *get_profile_dir (const char *homedir); -char *get_session_dir (const char *profile_dir); - int count_dictionaries (char **dictionary_files); -char **scan_directory (const char *path); +char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path); int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder); void folder_config_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/hwmon.h b/include/hwmon.h index fed552356..1a0db1475 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -6,109 +6,6 @@ #ifndef _HWMON_H #define _HWMON_H -// nvml functions - -int nvml_init (hashcat_ctx_t *hashcat_ctx); -void nvml_close (hashcat_ctx_t *hashcat_ctx); - -int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx); -int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx); - -int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device); - -int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length); -int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp); -int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed); -int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power); -int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization); -int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock); -int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); -int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen); -int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth); -int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons); -int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons); -int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode); -int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode); -int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit); -int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit); -int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit); - -// nvapi functions - -int nvapi_init (hashcat_ctx_t *hashcat_ctx); -void nvapi_close (hashcat_ctx_t *hashcat_ctx); - -int hm_NvAPI_QueryInterface (hashcat_ctx_t *hashcat_ctx, unsigned int offset); - -int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx); -int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx); - -int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); -int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); -int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); -int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); -int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); - -// xnvctrl functions - -int xnvctrl_init (hashcat_ctx_t *hashcat_ctx); -void xnvctrl_close (hashcat_ctx_t *hashcat_ctx); - -int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx); -void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx); - -int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); - -int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); - -int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val); -int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val); - -// ADL functions - -int adl_init (hashcat_ctx_t *hashcat_ctx); -void adl_close (hashcat_ctx_t *hashcat_ctx); - -int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx); -int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); - -int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters); -int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize); -int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect); -int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature); -int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature); -int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity); -int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo); -int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID); -int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo); -int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo); -int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue); -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex); -int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters); -int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels); -int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *); -int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *level); -int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level); -int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus); -//int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly); -int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version); -int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status); -int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state); -int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps); -int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state); -int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported); -int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp); -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); -int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex); - -// general functions - int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device_id); diff --git a/include/interface.h b/include/interface.h index ca5850afa..e0f1f69ea 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1505,9 +1505,9 @@ char *stroptitype (const u32 opti_type); char *strhashtype (const u32 hash_mode); char *strparser (const u32 parser_status); -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); +void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos); -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes); +void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos); int hashconfig_init (hashcat_ctx_t *hashcat_ctx); void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/memory.h b/include/memory.h index b68bc526b..b8920fa7c 100644 --- a/include/memory.h +++ b/include/memory.h @@ -12,10 +12,10 @@ #define MSG_ENOMEM "Insufficient memory available" -void *mycalloc (size_t nmemb, size_t size); -void myfree (void *ptr); -void *mymalloc (size_t size); -void *myrealloc (void *ptr, size_t oldsz, size_t add); -char *mystrdup (const char *s); +void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz); +void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz); +void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz); +char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s); +void hcfree (void *ptr); #endif // _MEMORY_H diff --git a/include/mpsp.h b/include/mpsp.h index 44a6c0dca..5840704eb 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -20,24 +20,7 @@ #define INCR_MASKS 1000 -void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_rl[2]); -void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf); -void mp_css_unicode_expand (mask_ctx_t *mask_ctx); -int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); -void mp_cut_at (char *mask, u32 max); -u32 mp_get_length (char *mask); -void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt); -u64 mp_get_sum (u32 css_cnt, cs_t *css); -void mp_setup_sys (cs_t *mp_sys); -int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index); -void mp_reset_usr (cs_t *mp_usr, u32 index); - -u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); -int sp_comp_val (const void *p1, const void *p2); -void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); -void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out); -void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out); int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx); int mask_ctx_init (hashcat_ctx_t *hashcat_ctx); diff --git a/src/affinity.c b/src/affinity.c index 211baff08..893ce1250 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -61,7 +61,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) CPU_ZERO (&cpuset); #endif - char *devices = mystrdup (user_options->cpu_affinity); + char *devices = hcstrdup (hashcat_ctx, user_options->cpu_affinity); char *next = strtok (devices, ","); @@ -95,7 +95,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) } while ((next = strtok (NULL, ",")) != NULL); - myfree (devices); + hcfree (devices); #if defined (_WIN) diff --git a/src/bitmap.c b/src/bitmap.c index 0069f0f92..9cae87480 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -77,14 +77,14 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 bitmap_min = user_options->bitmap_min; const u32 bitmap_max = user_options->bitmap_max; - u32 *bitmap_s1_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); u32 bitmap_bits; u32 bitmap_nums; @@ -139,14 +139,14 @@ void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (bitmap_ctx->enabled == false) return; - myfree (bitmap_ctx->bitmap_s1_a); - myfree (bitmap_ctx->bitmap_s1_b); - myfree (bitmap_ctx->bitmap_s1_c); - myfree (bitmap_ctx->bitmap_s1_d); - myfree (bitmap_ctx->bitmap_s2_a); - myfree (bitmap_ctx->bitmap_s2_b); - myfree (bitmap_ctx->bitmap_s2_c); - myfree (bitmap_ctx->bitmap_s2_d); + hcfree (bitmap_ctx->bitmap_s1_a); + hcfree (bitmap_ctx->bitmap_s1_b); + hcfree (bitmap_ctx->bitmap_s1_c); + hcfree (bitmap_ctx->bitmap_s1_d); + hcfree (bitmap_ctx->bitmap_s2_a); + hcfree (bitmap_ctx->bitmap_s2_b); + hcfree (bitmap_ctx->bitmap_s2_c); + hcfree (bitmap_ctx->bitmap_s2_d); memset (bitmap_ctx, 0, sizeof (bitmap_ctx_t)); } diff --git a/src/combinator.c b/src/combinator.c index f0f46b2ea..2bdbe8fa4 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -30,7 +30,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = true; - combinator_ctx->scratch_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { @@ -183,7 +183,7 @@ void combinator_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (combinator_ctx->enabled == false) return; - myfree (combinator_ctx->scratch_buf); + hcfree (combinator_ctx->scratch_buf); memset (combinator_ctx, 0, sizeof (combinator_ctx_t)); } diff --git a/src/cpt.c b/src/cpt.c index 7f2f2a263..8cf5c36b0 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -25,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = true; - cpt_ctx->cpt_buf = (cpt_t *) mycalloc (CPT_BUF, sizeof (cpt_t)); + cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; @@ -40,7 +40,7 @@ void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (cpt_ctx->enabled == false) return; - myfree (cpt_ctx->cpt_buf); + hcfree (cpt_ctx->cpt_buf); memset (cpt_ctx, 0, sizeof (cpt_ctx_t)); } diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 6ff88ac5e..98b248ef0 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -92,7 +92,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) #define MAX_KEY_SIZE (1024 * 1024) - u8 *buf = (u8 *) mymalloc (MAX_KEY_SIZE + 1); + u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); @@ -112,7 +112,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) if (kpos >= 64) kpos = 0; } - myfree (buf); + hcfree (buf); return 0; } diff --git a/src/dictstat.c b/src/dictstat.c index 3e13c2fe0..f6ff41783 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -42,8 +42,8 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) return 0; dictstat_ctx->enabled = true; - dictstat_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); - dictstat_ctx->base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t)); + dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); dictstat_ctx->cnt = 0; snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); @@ -68,8 +68,8 @@ void dictstat_destroy (hashcat_ctx_t *hashcat_ctx) if (dictstat_ctx->enabled == false) return; - myfree (dictstat_ctx->filename); - myfree (dictstat_ctx->base); + hcfree (dictstat_ctx->filename); + hcfree (dictstat_ctx->base); memset (dictstat_ctx, 0, sizeof (dictstat_ctx_t)); } diff --git a/src/dispatch.c b/src/dispatch.c index 5480c8b23..65d01fcbb 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -113,7 +113,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); const u32 attack_kern = user_options_extra->attack_kern; @@ -223,7 +223,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa device_param->kernel_accel = 0; device_param->kernel_loops = 0; - myfree (buf); + hcfree (buf); } void *thread_calc_stdin (void *p) @@ -359,7 +359,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) } } - hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) mymalloc (sizeof (hashcat_ctx_t)); + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); /* hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx; @@ -389,7 +389,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - hashcat_ctx_tmp->wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t)); + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); wl_data_init (hashcat_ctx_tmp); @@ -534,9 +534,9 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) wl_data_destroy (hashcat_ctx_tmp); - myfree (hashcat_ctx_tmp->wl_data); + hcfree (hashcat_ctx_tmp->wl_data); - myfree (hashcat_ctx_tmp); + hcfree (hashcat_ctx_tmp); fclose (fd); } diff --git a/src/ext_ADL.c b/src/ext_ADL.c index b8384997e..ad4de4bd7 100644 --- a/src/ext_ADL.c +++ b/src/ext_ADL.c @@ -4,11 +4,9 @@ */ #include "common.h" -#include "types.h" -#include "memory.h" #include "ext_ADL.h" void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize) { - return mymalloc ((size_t) iSize); + return malloc ((size_t) iSize); } diff --git a/src/filehandling.c b/src/filehandling.c index f4225489c..77708b312 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -8,11 +8,11 @@ #include "memory.h" #include "filehandling.h" -u64 count_lines (FILE *fd) +u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd) { u64 cnt = 0; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); char prev = '\n'; @@ -32,7 +32,7 @@ u64 count_lines (FILE *fd) } } - myfree (buf); + hcfree (buf); return cnt; } diff --git a/src/folder.c b/src/folder.c index 934475043..181342a11 100644 --- a/src/folder.c +++ b/src/folder.c @@ -26,11 +26,11 @@ int sort_by_stringptr (const void *p1, const void *p2) return strcmp (*s1, *s2); } -static char *get_exec_path () +static char *get_exec_path (hashcat_ctx_t *hashcat_ctx) { size_t exec_path_len = 1024; - char *exec_path = (char *) mymalloc (exec_path_len); + char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_len); #if defined (__linux__) @@ -78,9 +78,9 @@ static char *get_exec_path () return exec_path; } -char *get_install_dir (const char *progname) +char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname) { - char *install_dir = mystrdup (progname); + char *install_dir = hcstrdup (hashcat_ctx, progname); char *last_slash = NULL; if ((last_slash = strrchr (install_dir, '/')) != NULL) @@ -100,18 +100,18 @@ char *get_install_dir (const char *progname) return (install_dir); } -char *get_profile_dir (const char *homedir) +char *get_profile_dir (hashcat_ctx_t *hashcat_ctx, const char *homedir) { - char *profile_dir = (char *) mymalloc (HCBUFSIZ_TINY + 1); + char *profile_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY + 1); snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT); return profile_dir; } -char *get_session_dir (const char *profile_dir) +char *get_session_dir (hashcat_ctx_t *hashcat_ctx, const char *profile_dir) { - char *session_dir = (char *) mymalloc (HCBUFSIZ_TINY); + char *session_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); @@ -132,9 +132,9 @@ int count_dictionaries (char **dictionary_files) return (cnt); } -char **scan_directory (const char *path) +char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) { - char *tmp_path = mystrdup (path); + char *tmp_path = hcstrdup (hashcat_ctx, path); size_t tmp_path_len = strlen (tmp_path); @@ -180,7 +180,7 @@ char **scan_directory (const char *path) size_t path_size = strlen (tmp_path) + 1 + strlen (de->d_name); - char *path_file = (char *) mymalloc (path_size + 1); + char *path_file = (char *) hcmalloc (hashcat_ctx, path_size + 1); snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name); @@ -192,11 +192,11 @@ char **scan_directory (const char *path) { closedir (d_test); - myfree (path_file); + hcfree (path_file); } else { - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; @@ -208,20 +208,20 @@ char **scan_directory (const char *path) } else if (errno == ENOTDIR) { - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; - files[num_files - 1] = mystrdup (path); + files[num_files - 1] = hcstrdup (hashcat_ctx, path); } - files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); num_files++; files[num_files - 1] = NULL; - myfree (tmp_path); + hcfree (tmp_path); return (files); } @@ -237,7 +237,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * then chdir() back to where we came from so we need to save it first */ - char *cwd = (char *) mymalloc (HCBUFSIZ_TINY); + char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { @@ -250,7 +250,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * folders, as discussed on https://github.com/hashcat/hashcat/issues/20 */ - char *exec_path = get_exec_path (); + char *exec_path = get_exec_path (hashcat_ctx); if (exec_path == NULL) { @@ -280,7 +280,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - char *install_dir = get_install_dir (resolved_exec_path); + char *install_dir = get_install_dir (hashcat_ctx, resolved_exec_path); char *profile_dir = NULL; char *session_dir = NULL; char *shared_dir = NULL; @@ -291,9 +291,9 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins const char *homedir = pw->pw_dir; - profile_dir = get_profile_dir (homedir); - session_dir = get_session_dir (profile_dir); - shared_dir = mystrdup (shared_folder); + profile_dir = get_profile_dir (hashcat_ctx, homedir); + session_dir = get_session_dir (hashcat_ctx, profile_dir); + shared_dir = hcstrdup (hashcat_ctx, shared_folder); hc_mkdir (profile_dir, 0700); hc_mkdir (session_dir, 0700); @@ -305,19 +305,19 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins shared_dir = install_dir; } - myfree (resolved_install_folder); - myfree (resolved_exec_path); + hcfree (resolved_install_folder); + hcfree (resolved_exec_path); #else - char *install_dir = get_install_dir (exec_path); + char *install_dir = get_install_dir (hashcat_ctx, exec_path); char *profile_dir = install_dir; char *session_dir = install_dir; char *shared_dir = install_dir; #endif - myfree (exec_path); + hcfree (exec_path); /** * There's alot of problem related to bad support -I parameters when building the kernel. @@ -326,13 +326,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load */ - char *cpath = (char *) mymalloc (HCBUFSIZ_TINY); + char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); #if defined (_WIN) snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir); - char *cpath_real = (char *) mymalloc (HCBUFSIZ_TINY); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { @@ -345,7 +345,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir); - char *cpath_real = (char *) mymalloc (PATH_MAX); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); if (realpath (cpath, cpath_real) == NULL) { @@ -356,7 +356,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins #endif - myfree (cpath); + hcfree (cpath); //if (getenv ("TMP") == NULL) if (1) @@ -385,13 +385,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * kernel cache, we need to make sure folder exist */ - char *kernels_folder = (char *) mymalloc (HCBUFSIZ_TINY); + char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir); hc_mkdir (kernels_folder, 0700); - myfree (kernels_folder); + hcfree (kernels_folder); /** * store for later use @@ -411,9 +411,9 @@ void folder_config_destroy (hashcat_ctx_t *hashcat_ctx) { folder_config_t *folder_config = hashcat_ctx->folder_config; - myfree (folder_config->cpath_real); - myfree (folder_config->cwd); - myfree (folder_config->install_dir); + hcfree (folder_config->cpath_real); + hcfree (folder_config->cwd); + hcfree (folder_config->install_dir); memset (folder_config, 0, sizeof (folder_config_t)); } diff --git a/src/hashcat.c b/src/hashcat.c index 6ba021604..eb770acda 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -66,61 +66,61 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, stru hashcat_ctx->event = event; - hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) mymalloc (sizeof (bitmap_ctx_t)); - hashcat_ctx->combinator_ctx = (combinator_ctx_t *) mymalloc (sizeof (combinator_ctx_t)); - hashcat_ctx->cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t)); - hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) mymalloc (sizeof (debugfile_ctx_t)); - hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) mymalloc (sizeof (dictstat_ctx_t)); - hashcat_ctx->event_ctx = (event_ctx_t *) mymalloc (sizeof (event_ctx_t)); - hashcat_ctx->folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t)); - hashcat_ctx->hashcat_user = (hashcat_user_t *) mymalloc (sizeof (hashcat_user_t)); - hashcat_ctx->hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t)); - hashcat_ctx->hashes = (hashes_t *) mymalloc (sizeof (hashes_t)); - hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) mymalloc (sizeof (hwmon_ctx_t)); - hashcat_ctx->induct_ctx = (induct_ctx_t *) mymalloc (sizeof (induct_ctx_t)); - hashcat_ctx->logfile_ctx = (logfile_ctx_t *) mymalloc (sizeof (logfile_ctx_t)); - hashcat_ctx->loopback_ctx = (loopback_ctx_t *) mymalloc (sizeof (loopback_ctx_t)); - hashcat_ctx->mask_ctx = (mask_ctx_t *) mymalloc (sizeof (mask_ctx_t)); - hashcat_ctx->opencl_ctx = (opencl_ctx_t *) mymalloc (sizeof (opencl_ctx_t)); - hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) mymalloc (sizeof (outcheck_ctx_t)); - hashcat_ctx->outfile_ctx = (outfile_ctx_t *) mymalloc (sizeof (outfile_ctx_t)); - hashcat_ctx->potfile_ctx = (potfile_ctx_t *) mymalloc (sizeof (potfile_ctx_t)); - hashcat_ctx->restore_ctx = (restore_ctx_t *) mymalloc (sizeof (restore_ctx_t)); - hashcat_ctx->status_ctx = (status_ctx_t *) mymalloc (sizeof (status_ctx_t)); - hashcat_ctx->straight_ctx = (straight_ctx_t *) mymalloc (sizeof (straight_ctx_t)); - hashcat_ctx->tuning_db = (tuning_db_t *) mymalloc (sizeof (tuning_db_t)); - hashcat_ctx->user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t)); - hashcat_ctx->user_options = (user_options_t *) mymalloc (sizeof (user_options_t)); - hashcat_ctx->wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t)); + hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); + hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); + hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); + hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); + hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); + hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); + hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); + hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); + hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); + hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); + hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); + hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); + hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); + hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); + hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); + hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); + hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); + hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); + hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); + hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); + hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); + hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); + hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); + hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); + hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); + hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); } void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { - myfree (hashcat_ctx->bitmap_ctx); - myfree (hashcat_ctx->combinator_ctx); - myfree (hashcat_ctx->cpt_ctx); - myfree (hashcat_ctx->debugfile_ctx); - myfree (hashcat_ctx->dictstat_ctx); - myfree (hashcat_ctx->event_ctx); - myfree (hashcat_ctx->folder_config); - myfree (hashcat_ctx->hashconfig); - myfree (hashcat_ctx->hashes); - myfree (hashcat_ctx->hwmon_ctx); - myfree (hashcat_ctx->induct_ctx); - myfree (hashcat_ctx->logfile_ctx); - myfree (hashcat_ctx->loopback_ctx); - myfree (hashcat_ctx->mask_ctx); - myfree (hashcat_ctx->opencl_ctx); - myfree (hashcat_ctx->outcheck_ctx); - myfree (hashcat_ctx->outfile_ctx); - myfree (hashcat_ctx->potfile_ctx); - myfree (hashcat_ctx->restore_ctx); - myfree (hashcat_ctx->status_ctx); - myfree (hashcat_ctx->straight_ctx); - myfree (hashcat_ctx->tuning_db); - myfree (hashcat_ctx->user_options_extra); - myfree (hashcat_ctx->user_options); - myfree (hashcat_ctx->wl_data); + 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)); } @@ -227,9 +227,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_AUTOTUNE_STARTING); - thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); + thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); - hc_thread_t *c_threads = (hc_thread_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); status_ctx->devices_status = STATUS_AUTOTUNE; @@ -303,9 +303,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (opencl_ctx->devices_cnt, c_threads); - myfree (c_threads); + hcfree (c_threads); - myfree (threads_param); + hcfree (threads_param); if ((status_ctx->devices_status != STATUS_CRACKED) && (status_ctx->devices_status != STATUS_ABORTED) @@ -367,7 +367,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) unlink (induct_ctx->induction_dictionaries[induct_ctx->induction_dictionaries_pos]); } - myfree (induct_ctx->induction_dictionaries); + hcfree (induct_ctx->induction_dictionaries); induct_ctx_scan (hashcat_ctx); } @@ -692,7 +692,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) int inner_threads_cnt = 0; - hc_thread_t *inner_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t)); + hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); status_ctx->shutdown_inner = false; @@ -762,7 +762,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) hc_thread_wait (1, &inner_threads[thread_idx]); } - myfree (inner_threads); + hcfree (inner_threads); EVENT (EVENT_INNERLOOP1_FINISHED); diff --git a/src/hashes.c b/src/hashes.c index 40d9e59d6..8cccb6dcc 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -173,7 +173,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) out_buf[0] = 0; - ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, salt_pos, digest_pos); fputs (out_buf, fp); @@ -183,7 +183,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) { hccap_t hccap; - to_hccap_t (&hccap, salt_pos, digest_pos, hashconfig, hashes); + to_hccap_t (hashcat_ctx, &hccap, salt_pos, digest_pos); fwrite (&hccap, sizeof (hccap_t), 1, fp); } @@ -220,8 +220,6 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain) { debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - hashes_t *hashes = hashcat_ctx->hashes; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -235,7 +233,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl char out_buf[HCBUFSIZ_LARGE] = { 0 }; - ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, salt_pos, digest_pos); // plain @@ -337,7 +335,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, event_log_info_nn (hashcat_ctx, ""); - plain_t *cracked = (plain_t *) mycalloc (num_cracked, sizeof (plain_t)); + plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); @@ -383,7 +381,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, hc_thread_mutex_unlock (status_ctx->mux_display); - myfree (cracked); + hcfree (cracked); if (cpt_cracked > 0) { @@ -508,7 +506,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Counting lines in %s", hashfile); - hashes_avail = count_lines (fp); + hashes_avail = count_lines (hashcat_ctx, fp); rewind (fp); @@ -556,9 +554,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) salt_t *salts_buf = NULL; void *esalts_buf = NULL; - hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t)); + hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); - digests_buf = (void *) mycalloc (hashes_avail, hashconfig->dgst_size); + digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -566,34 +564,34 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++) { - hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t)); + hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); hashes_buf[hash_pos].hash_info = hash_info; if (user_options->username && (user_options->remove || user_options->show || user_options->left)) { - hash_info->user = (user_t*) mymalloc (sizeof (user_t)); + hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); } if (user_options->benchmark) { - hash_info->orighash = (char *) mymalloc (256); + hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); } } } if (hashconfig->is_salted) { - salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); if (hashconfig->esalt_size) { - esalts_buf = (void *) mycalloc (hashes_avail, hashconfig->esalt_size); + esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); } } else { - salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); } for (u32 hash_pos = 0; hash_pos < hashes_avail; hash_pos++) @@ -675,7 +673,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = mystrdup (hash_buf); + hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); } if (hashconfig->is_salted) @@ -718,7 +716,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 hccap_size = sizeof (hccap_t); - char *in = (char *) mymalloc (hccap_size); + char *in = (char *) hcmalloc (hashcat_ctx, hccap_size); while (!feof (fp)) { @@ -789,7 +787,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) fclose (fp); - myfree (in); + hcfree (in); } else if (hashconfig->hash_mode == 3000) { @@ -889,7 +887,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 line_num = 0; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -927,17 +925,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { user_t **user = &hashes_buf[hashes_cnt].hash_info->user; - *user = (user_t *) mymalloc (sizeof (user_t)); + *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); user_t *user_ptr = *user; if (user_buf != NULL) { - user_ptr->user_name = mystrdup (user_buf); + user_ptr->user_name = hcstrdup (hashcat_ctx, user_buf); } else { - user_ptr->user_name = mystrdup (""); + user_ptr->user_name = hcstrdup (hashcat_ctx, ""); } user_ptr->user_len = user_len; @@ -948,7 +946,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info; - hash_info_tmp->orighash = mystrdup (hash_buf); + hash_info_tmp->orighash = hcstrdup (hashcat_ctx, hash_buf); } if (hashconfig->is_salted) @@ -1032,7 +1030,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } } - myfree (line_buf); + hcfree (line_buf); fclose (fp); @@ -1104,22 +1102,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) * Now generate all the buffers required for later */ - void *digests_buf_new = (void *) mycalloc (hashes_cnt, hashconfig->dgst_size); + void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); salt_t *salts_buf_new = NULL; void *esalts_buf_new = NULL; if (hashconfig->is_salted) { - salts_buf_new = (salt_t *) mycalloc (hashes_cnt, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); if (hashconfig->esalt_size) { - esalts_buf_new = (void *) mycalloc (hashes_cnt, hashconfig->esalt_size); + esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); } } else { - salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); } if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task..."); @@ -1127,8 +1125,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) u32 digests_cnt = hashes_cnt; u32 digests_done = 0; - u32 *digests_shown = (u32 *) mycalloc (digests_cnt, sizeof (u32)); - u32 *digests_shown_tmp = (u32 *) mycalloc (digests_cnt, sizeof (u32)); + u32 *digests_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); + u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); u32 salts_cnt = 0; u32 salts_done = 0; @@ -1137,7 +1135,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { - hash_info = (hashinfo_t **) mycalloc (hashes_cnt, sizeof (hashinfo_t *)); + hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); if (user_options->username && (user_options->remove || user_options->show)) { @@ -1145,14 +1143,14 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) for (user_pos = 0; user_pos < hashes_cnt; user_pos++) { - hash_info[user_pos] = (hashinfo_t *) mycalloc (hashes_cnt, sizeof (hashinfo_t)); + hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); - hash_info[user_pos]->user = (user_t *) mymalloc (sizeof (user_t)); + hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); } } } - u32 *salts_shown = (u32 *) mycalloc (digests_cnt, sizeof (u32)); + u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); salt_t *salt_buf; @@ -1251,10 +1249,10 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if (salts_done == salts_cnt) mycracked (hashcat_ctx); } - myfree (hashes->digests_buf); - myfree (hashes->salts_buf); - myfree (hashes->esalts_buf); - myfree (hashes->hashes_buf); + hcfree (hashes->digests_buf); + hcfree (hashes->salts_buf); + hcfree (hashes->esalts_buf); + hcfree (hashes->hashes_buf); hashes->digests_cnt = digests_cnt; hashes->digests_done = digests_done; @@ -1333,16 +1331,16 @@ void hashes_destroy (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; - myfree (hashes->digests_buf); - myfree (hashes->digests_shown); - myfree (hashes->digests_shown_tmp); + hcfree (hashes->digests_buf); + hcfree (hashes->digests_shown); + hcfree (hashes->digests_shown_tmp); - myfree (hashes->salts_buf); - myfree (hashes->salts_shown); + hcfree (hashes->salts_buf); + hcfree (hashes->salts_shown); - myfree (hashes->esalts_buf); + hcfree (hashes->esalts_buf); - myfree (hashes->hash_info); + hcfree (hashes->hash_info); memset (hashes, 0, sizeof (hashes_t)); } diff --git a/src/hlfmt.c b/src/hlfmt.c index e60d0e6f8..9cad42409 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -342,11 +342,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) if (hashconfig->hash_mode == 5300) return HLFMT_HASHCAT; if (hashconfig->hash_mode == 5400) return HLFMT_HASHCAT; - u32 *formats_cnt = (u32 *) mycalloc (HLFMTS_CNT, sizeof (u32)); + u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); u32 num_check = 0; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -363,7 +363,7 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) num_check++; } - myfree (line_buf); + hcfree (line_buf); u32 hashlist_format = HLFMT_HASHCAT; diff --git a/src/hwmon.c b/src/hwmon.c index b83502c7b..55248235c 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -12,7 +12,7 @@ // nvml functions -int nvml_init (hashcat_ctx_t *hashcat_ctx) +static int nvml_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -29,7 +29,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) DWORD Type = REG_SZ; - char *Buffer = (char *) mymalloc (BufferSize + 1); + char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); HKEY hKey = 0; @@ -61,7 +61,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) nvml->lib = hc_dlopen (Buffer); - myfree (Buffer); + hcfree (Buffer); } #elif defined (_POSIX) @@ -100,7 +100,7 @@ int nvml_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void nvml_close (hashcat_ctx_t *hashcat_ctx) +static void nvml_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -111,7 +111,7 @@ void nvml_close (hashcat_ctx_t *hashcat_ctx) if (nvml->lib) hc_dlclose (nvml->lib); - myfree (nvml); + hcfree (nvml); } } @@ -120,7 +120,7 @@ static const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t n return nvml->nvmlErrorString (nvml_rc); } -int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) +static int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -140,7 +140,7 @@ int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) +static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -160,7 +160,7 @@ int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) +static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -180,7 +180,8 @@ int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int return 0; } -int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length) +/* +static int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, char *name, unsigned int length) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -199,8 +200,9 @@ int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, return 0; } +*/ -int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) +static int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -220,7 +222,7 @@ int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t d return 0; } -int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) +static int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -240,7 +242,8 @@ int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t devi return 0; } -int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power) +/* +static int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *power) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -259,8 +262,9 @@ int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t de return 0; } +*/ -int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) +static int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -280,7 +284,7 @@ int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevic return 0; } -int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) +static int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -300,7 +304,7 @@ int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t dev return 0; } -int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) +static int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -320,7 +324,8 @@ int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlD return 0; } -int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen) +/* +static int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkGen) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -339,8 +344,9 @@ int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_ctx, nvm return 0; } +*/ -int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) +static int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -360,7 +366,8 @@ int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevi return 0; } -int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) +/* +static int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *clocksThrottleReasons) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -379,8 +386,10 @@ int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *hashcat_ct return 0; } +*/ -int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) +/* +static int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -399,8 +408,10 @@ int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *hashcat_ return 0; } +*/ -int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode) +/* +static int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlComputeMode_t mode) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -419,8 +430,10 @@ int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t d return 0; } +*/ -int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode) +/* +static int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlGpuOperationMode_t mode) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -439,8 +452,9 @@ int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nvmlDevic return 0; } +*/ -int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) +static int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -460,7 +474,7 @@ int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t *hashcat return 0; } -int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit) +static int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int limit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -480,7 +494,7 @@ int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlD return 0; } -int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit) +static int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *limit) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -502,7 +516,7 @@ int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx, nvmlD // nvapi functions -int nvapi_init (hashcat_ctx_t *hashcat_ctx) +static int nvapi_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -541,7 +555,7 @@ int nvapi_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void nvapi_close (hashcat_ctx_t *hashcat_ctx) +static void nvapi_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -552,7 +566,7 @@ void nvapi_close (hashcat_ctx_t *hashcat_ctx) if (nvapi->lib) hc_dlclose (nvapi->lib); - myfree (nvapi); + hcfree (nvapi); } } @@ -561,7 +575,7 @@ static void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); } -int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) +static int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -585,7 +599,7 @@ int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) +static int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -607,7 +621,7 @@ int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) +static int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -629,7 +643,7 @@ int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle n return 0; } -int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) +static int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -651,7 +665,7 @@ int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuH return 0; } -int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) +static int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -673,7 +687,7 @@ int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGp return 0; } -int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) +static int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -695,7 +709,7 @@ int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandl return 0; } -int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) +static int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -732,7 +746,7 @@ void __GSHandlerCheck () // xnvctrl functions -int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) +static int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -780,7 +794,7 @@ int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) +static void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -802,11 +816,11 @@ void xnvctrl_close (hashcat_ctx_t *hashcat_ctx) #endif - myfree (xnvctrl); + hcfree (xnvctrl); } } -int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) +static int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -828,7 +842,7 @@ int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) return 0; } -void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) +static void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -841,7 +855,7 @@ void hm_XNVCTRL_XCloseDisplay (hashcat_ctx_t *hashcat_ctx) xnvctrl->XCloseDisplay (xnvctrl->dpy); } -int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -863,7 +877,7 @@ int get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +static int hm_XNVCTRL_set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -875,13 +889,13 @@ int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) int cur; - int rc = get_fan_control (hashcat_ctx, gpu, &cur); + int rc = hm_XNVCTRL_get_fan_control (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); - rc = get_fan_control (hashcat_ctx, gpu, &cur); + rc = hm_XNVCTRL_get_fan_control (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; @@ -890,7 +904,8 @@ int set_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) return 0; } -int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +/* +static int hm_XNVCTRL_get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -911,8 +926,9 @@ int get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } +*/ -int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -934,7 +950,7 @@ int get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) +static int hm_XNVCTRL_get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -956,7 +972,7 @@ int get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) return 0; } -int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) +static int hm_XNVCTRL_set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -968,13 +984,13 @@ int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) int cur; - int rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + int rc = hm_XNVCTRL_get_fan_speed_target (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); - rc = get_fan_speed_target (hashcat_ctx, gpu, &cur); + rc = hm_XNVCTRL_get_fan_speed_target (hashcat_ctx, gpu, &cur); if (rc == -1) return -1; @@ -985,7 +1001,7 @@ int set_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int val) // ADL functions -int adl_init (hashcat_ctx_t *hashcat_ctx) +static int adl_init (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1050,7 +1066,7 @@ int adl_init (hashcat_ctx_t *hashcat_ctx) return 0; } -void adl_close (hashcat_ctx_t *hashcat_ctx) +static void adl_close (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1061,11 +1077,11 @@ void adl_close (hashcat_ctx_t *hashcat_ctx) if (adl->lib) hc_dlclose (adl->lib); - myfree (adl); + hcfree (adl); } } -int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) +static int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1083,7 +1099,7 @@ int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) return 0; } -int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) +static int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1101,7 +1117,7 @@ int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALL return 0; } -int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) +static int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1119,7 +1135,7 @@ int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumA return 0; } -int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) +static int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1137,7 +1153,8 @@ int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lp return 0; } -int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) +/* +static int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1154,8 +1171,10 @@ int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } +*/ -int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID) +/* +static int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpAdapterID) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1172,8 +1191,10 @@ int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *l return ADL_rc; } +*/ -int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) +/* +static int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLBiosInfo *lpBiosInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1190,8 +1211,10 @@ int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIn return ADL_rc; } +*/ -int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) +/* +static int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1208,8 +1231,9 @@ int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int iAdapt return 0; } +*/ -int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) +static int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1227,7 +1251,7 @@ int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) +static int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1245,7 +1269,7 @@ int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) +static int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1263,7 +1287,7 @@ int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapt return 0; } -int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) +static int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1281,7 +1305,7 @@ int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapter return ADL_rc; } -int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1299,7 +1323,7 @@ int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) +static int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1317,7 +1341,7 @@ int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1335,7 +1359,7 @@ int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) +static int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1353,7 +1377,7 @@ int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex) +static int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1371,7 +1395,8 @@ int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, int iAd return 0; } -int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters) +/* +static int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODParameters *lpOdParameters) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1388,8 +1413,10 @@ int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } +*/ -int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) +/* +static int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1406,8 +1433,10 @@ int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, int iA return 0; } +*/ -int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) +/* +static int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1424,8 +1453,9 @@ int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, int iA return 0; } +*/ -int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) +static int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6PowerControlInfo *powertune) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1443,7 +1473,7 @@ int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdap return 0; } -int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iCurrentValue) +static int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iCurrentValue) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1463,7 +1493,7 @@ int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level) +static int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int level) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1505,7 +1535,8 @@ int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus) +/* +static int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpStatus) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1522,9 +1553,10 @@ int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, in return 0; } +*/ /* -int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) +static int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1543,7 +1575,7 @@ int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int } */ -int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) +static int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1561,7 +1593,7 @@ int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *o return 0; } -int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported) +static int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *lpSupported) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1579,7 +1611,7 @@ int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapte return 0; } -int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps) +static int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6Capabilities *caps) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1597,7 +1629,7 @@ int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterI return 0; } -int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state) +static int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6MemClockState *state) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1662,7 +1694,8 @@ int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterInde return 0; } -int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status) +/* +static int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6CurrentStatus *status) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1679,8 +1712,9 @@ int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int iAdapter return 0; } +*/ -int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state) +static int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int type, ADLOD6StateInfo *state) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1734,7 +1768,7 @@ int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, i return 0; } -int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) +static int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1752,7 +1786,8 @@ int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int return 0; } -int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) +/* +static int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1769,8 +1804,9 @@ int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hashcat_ctx return 0; } +*/ -int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex) +static int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1810,7 +1846,7 @@ static LPAdapterInfo hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, int iN { size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo); - LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) mymalloc (AdapterInfoSize); + LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hcmalloc (hashcat_ctx, AdapterInfoSize); if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize) == -1) return NULL; @@ -1907,7 +1943,7 @@ static void hm_sort_adl_adapters_by_busid_devid (u32 *valid_adl_device_list, int } } -static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) +static u32 *hm_get_list_valid_adl_adapters (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo) { *num_adl_adapters = 0; @@ -1946,14 +1982,14 @@ static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_ad // add it to the list - adl_adapters = (u32 *) myrealloc (adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); + adl_adapters = (u32 *) hcrealloc (hashcat_ctx, adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); adl_adapters[*num_adl_adapters] = i; // rest is just bookkeeping - bus_numbers = (int*) myrealloc (bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); - device_numbers = (int*) myrealloc (device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); + bus_numbers = (int*) hcrealloc (hashcat_ctx, bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); + device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); bus_numbers[*num_adl_adapters] = info.iBusNumber; device_numbers[*num_adl_adapters] = info.iDeviceNumber; @@ -1961,8 +1997,8 @@ static u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_ad (*num_adl_adapters)++; } - myfree (bus_numbers); - myfree (device_numbers); + hcfree (bus_numbers); + hcfree (device_numbers); // sort the list by increasing bus id, device id number @@ -2479,6 +2515,7 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { + /* this is triggered by mask generator, too. therefore useless unsigned long long clocksThrottleReasons = 0; unsigned long long supportedThrottleReasons = 0; @@ -2496,6 +2533,27 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device } return (clocksThrottleReasons != nvmlClocksThrottleReasonNone); + */ + + if (hwmon_ctx->hm_nvapi) + { + NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; + NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; + + memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); + memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); + + perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); + perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); + + hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); + + perfPolicies_status.info_value = perfPolicies_info.info_value; + + hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); + + return perfPolicies_status.throttle & 2; + } } return -1; @@ -2610,7 +2668,26 @@ int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u3 { if (hwmon_ctx->hm_xnvctrl) { - if (set_fan_speed_target (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) == -1) return -1; + if (hm_XNVCTRL_set_fan_speed_target (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, fanspeed) == -1) return -1; + + return 0; + } + } + + return -1; +} + +int hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u32 device_id, const int val) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + if (hwmon_ctx->enabled == false) return -1; + + if (hwmon_ctx->hm_device[device_id].fan_set_supported == true) + { + if (hwmon_ctx->hm_xnvctrl) + { + if (hm_XNVCTRL_set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, val) == -1) return -1; return 0; } @@ -2636,21 +2713,21 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->version == true) return 0; if (user_options->gpu_temp_disable == true) return 0; - hwmon_ctx->hm_device = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); /** * Initialize shared libraries */ - ADL_PTR *adl = (ADL_PTR *) mymalloc (sizeof (ADL_PTR)); - NVAPI_PTR *nvapi = (NVAPI_PTR *) mymalloc (sizeof (NVAPI_PTR)); - NVML_PTR *nvml = (NVML_PTR *) mymalloc (sizeof (NVML_PTR)); - XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) mymalloc (sizeof (XNVCTRL_PTR)); + ADL_PTR *adl = (ADL_PTR *) hcmalloc (hashcat_ctx, sizeof (ADL_PTR)); + NVAPI_PTR *nvapi = (NVAPI_PTR *) hcmalloc (hashcat_ctx, sizeof (NVAPI_PTR)); + NVML_PTR *nvml = (NVML_PTR *) hcmalloc (hashcat_ctx, sizeof (NVML_PTR)); + XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (hashcat_ctx, sizeof (XNVCTRL_PTR)); - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) mycalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); if (opencl_ctx->need_nvml == true) { @@ -2658,7 +2735,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (nvml_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_nvml); + hcfree (hwmon_ctx->hm_nvml); hwmon_ctx->hm_nvml = NULL; } @@ -2670,7 +2747,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (nvapi_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_nvapi); + hcfree (hwmon_ctx->hm_nvapi); hwmon_ctx->hm_nvapi = NULL; } @@ -2682,7 +2759,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (xnvctrl_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_xnvctrl); + hcfree (hwmon_ctx->hm_xnvctrl); hwmon_ctx->hm_xnvctrl = NULL; } @@ -2694,7 +2771,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (adl_init (hashcat_ctx) == -1) { - myfree (hwmon_ctx->hm_adl); + hcfree (hwmon_ctx->hm_adl); hwmon_ctx->hm_adl = NULL; } @@ -2704,7 +2781,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NVML_nvmlInit (hashcat_ctx) == 0) { - HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); + HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle); @@ -2726,7 +2803,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) //hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_GOM_ALL_ON); } - myfree (nvmlGPUHandle); + hcfree (nvmlGPUHandle); } } @@ -2734,7 +2811,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NvAPI_Initialize (hashcat_ctx) == 0) { - HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) mycalloc (DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); + HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle); @@ -2745,7 +2822,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_adapters_nvapi[tmp_out++].nvapi = nvGPUHandle[i]; } - myfree (nvGPUHandle); + hcfree (nvGPUHandle); } } @@ -2763,7 +2840,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int speed = 0; - if (get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; + if (hm_XNVCTRL_get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[device_id].fan_get_supported = true; } } } @@ -2788,7 +2865,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) int num_adl_adapters = 0; - u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo); + u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hashcat_ctx, hm_adapters_num, &num_adl_adapters, lpAdapterInfo); if (num_adl_adapters > 0) { @@ -2799,9 +2876,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_check_fanspeed_control (hashcat_ctx, hm_adapters_adl, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); } - myfree (valid_adl_device_list); + hcfree (valid_adl_device_list); - myfree (lpAdapterInfo); + hcfree (lpAdapterInfo); } } @@ -2820,11 +2897,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) * save buffer required for later restores */ - hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); + hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); - hwmon_ctx->od_power_control_status = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + hwmon_ctx->od_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); - hwmon_ctx->nvml_power_limit = (unsigned int *) mycalloc (opencl_ctx->devices_cnt, sizeof (unsigned int)); + hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned int)); /** * HM devices: copy @@ -2863,10 +2940,10 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - myfree (hm_adapters_adl); - myfree (hm_adapters_nvapi); - myfree (hm_adapters_nvml); - myfree (hm_adapters_xnvctrl); + hcfree (hm_adapters_adl); + hcfree (hm_adapters_nvapi); + hcfree (hm_adapters_nvml); + hcfree (hm_adapters_xnvctrl); /** * powertune on user request @@ -2975,7 +3052,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); } - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; @@ -2991,7 +3068,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (performance_state); + hcfree (performance_state); } // set powertune value only @@ -3086,13 +3163,15 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { - #if defined (__linux__) - rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); - #endif + if (hwmon_ctx->hm_xnvctrl) + { + rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); + } - #if defined (_WIN) - rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1); - #endif + if (hwmon_ctx->hm_nvapi) + { + rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1); + } } if (rc == 0) @@ -3101,7 +3180,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1); + //event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1); hwmon_ctx->hm_device[device_id].fan_set_supported = false; } @@ -3145,13 +3224,15 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else if (device_param->device_vendor_id == VENDOR_ID_NV) { - #if defined (__linux__) - rc = set_fan_control (hashcat_ctx, hwmon_ctx->hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); - #endif + if (hwmon_ctx->hm_xnvctrl) + { + rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE); + } - #if defined (_WIN) - rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0); - #endif + if (hwmon_ctx->hm_nvapi) + { + rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0); + } } if (rc == -1) event_log_error (hashcat_ctx, "Failed to restore default fan speed and policy for device #%", device_id + 1); @@ -3195,7 +3276,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) // clocks - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); performance_state->iNumberOfPerformanceLevels = 2; @@ -3211,7 +3292,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) continue; } - myfree (performance_state); + hcfree (performance_state); } } } @@ -3259,11 +3340,11 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) // free memory - myfree (hwmon_ctx->nvml_power_limit); - myfree (hwmon_ctx->od_power_control_status); - myfree (hwmon_ctx->od_clock_mem_status); + hcfree (hwmon_ctx->nvml_power_limit); + hcfree (hwmon_ctx->od_power_control_status); + hcfree (hwmon_ctx->od_clock_mem_status); - myfree (hwmon_ctx->hm_device); + hcfree (hwmon_ctx->hm_device); memset (hwmon_ctx, 0, sizeof (hwmon_ctx_t)); } diff --git a/src/induct.c b/src/induct.c index 9a198c585..5d98a43f5 100644 --- a/src/induct.c +++ b/src/induct.c @@ -46,7 +46,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->induction_dir == NULL) { - char *root_directory = (char *) mymalloc (HCBUFSIZ_TINY); + char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR); @@ -58,7 +58,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (errno == ENOTEMPTY) { - char *root_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY); + char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start); @@ -88,7 +88,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - induct_ctx->root_directory = mystrdup (user_options->induction_dir); + induct_ctx->root_directory = hcstrdup (hashcat_ctx, user_options->induction_dir); } return 0; @@ -100,7 +100,7 @@ void induct_ctx_scan (hashcat_ctx_t *hashcat_ctx) if (induct_ctx->enabled == false) return; - induct_ctx->induction_dictionaries = scan_directory (induct_ctx->root_directory); + induct_ctx->induction_dictionaries = scan_directory (hashcat_ctx, induct_ctx->root_directory); induct_ctx->induction_dictionaries_cnt = count_dictionaries (induct_ctx->induction_dictionaries); @@ -148,7 +148,7 @@ void induct_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } } - myfree (induct_ctx->root_directory); + hcfree (induct_ctx->root_directory); memset (induct_ctx, 0, sizeof (induct_ctx_t)); } diff --git a/src/interface.c b/src/interface.c index 0c5924e0b..6cd957295 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5575,7 +5575,7 @@ int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE * handle cipher encoding */ - u32 *tmp = (u32 *) mymalloc (32); + u32 tmp[32]; char *cipherbuf_ptr = (char *) tmp; @@ -5601,8 +5601,6 @@ int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE salt->salt_buf[10] = byte_swap_32 (tmp[6]); salt->salt_buf[11] = byte_swap_32 (tmp[7]); - myfree (tmp); - for (u32 i = 0, j = 0; i < 1040; i += 1, j += 2) { const char p0 = cipherbuf_pos[j + 0]; @@ -10416,318 +10414,182 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE sip_t *sip = (sip_t *) hash_buf->esalt; // work with a temporary copy of input_buf (s.t. we can manipulate it directly) - - char *temp_input_buf = (char *) mymalloc (input_len + 1); - - memcpy (temp_input_buf, input_buf, input_len); + // why? should be fine to use original buffer + //char *temp_input_buf = (char *) hcmalloc (hashcat_ctx, input_len + 1); + //memcpy (temp_input_buf, input_buf, input_len); // URI_server: - char *URI_server_pos = temp_input_buf + 6; + char *URI_server_pos = input_buf + 6; char *URI_client_pos = strchr (URI_server_pos, '*'); - if (URI_client_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_client_pos[0] = 0; URI_client_pos++; u32 URI_server_len = strlen (URI_server_pos); - if (URI_server_len > 512) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_server_len > 512) return (PARSER_SALT_LENGTH); // URI_client: char *user_pos = strchr (URI_client_pos, '*'); - if (user_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (user_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); user_pos[0] = 0; user_pos++; u32 URI_client_len = strlen (URI_client_pos); - if (URI_client_len > 512) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_client_len > 512) return (PARSER_SALT_LENGTH); // user: char *realm_pos = strchr (user_pos, '*'); - if (realm_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (realm_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); realm_pos[0] = 0; realm_pos++; u32 user_len = strlen (user_pos); - if (user_len > 116) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (user_len > 116) return (PARSER_SALT_LENGTH); // realm: char *method_pos = strchr (realm_pos, '*'); - if (method_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (method_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); method_pos[0] = 0; method_pos++; u32 realm_len = strlen (realm_pos); - if (realm_len > 116) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (realm_len > 116) return (PARSER_SALT_LENGTH); // method: char *URI_prefix_pos = strchr (method_pos, '*'); - if (URI_prefix_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_prefix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_prefix_pos[0] = 0; URI_prefix_pos++; u32 method_len = strlen (method_pos); - if (method_len > 246) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (method_len > 246) return (PARSER_SALT_LENGTH); // URI_prefix: char *URI_resource_pos = strchr (URI_prefix_pos, '*'); - if (URI_resource_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_resource_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_resource_pos[0] = 0; URI_resource_pos++; u32 URI_prefix_len = strlen (URI_prefix_pos); - if (URI_prefix_len > 245) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_prefix_len > 245) return (PARSER_SALT_LENGTH); // URI_resource: char *URI_suffix_pos = strchr (URI_resource_pos, '*'); - if (URI_suffix_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (URI_suffix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); URI_suffix_pos[0] = 0; URI_suffix_pos++; u32 URI_resource_len = strlen (URI_resource_pos); - if (URI_resource_len < 1 || URI_resource_len > 246) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_resource_len < 1 || URI_resource_len > 246) return (PARSER_SALT_LENGTH); // URI_suffix: char *nonce_pos = strchr (URI_suffix_pos, '*'); - if (nonce_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_pos[0] = 0; nonce_pos++; u32 URI_suffix_len = strlen (URI_suffix_pos); - if (URI_suffix_len > 245) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (URI_suffix_len > 245) return (PARSER_SALT_LENGTH); // nonce: char *nonce_client_pos = strchr (nonce_pos, '*'); - if (nonce_client_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_client_pos[0] = 0; nonce_client_pos++; u32 nonce_len = strlen (nonce_pos); - if (nonce_len < 1 || nonce_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_len < 1 || nonce_len > 50) return (PARSER_SALT_LENGTH); // nonce_client: char *nonce_count_pos = strchr (nonce_client_pos, '*'); - if (nonce_count_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (nonce_count_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); nonce_count_pos[0] = 0; nonce_count_pos++; u32 nonce_client_len = strlen (nonce_client_pos); - if (nonce_client_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_client_len > 50) return (PARSER_SALT_LENGTH); // nonce_count: char *qop_pos = strchr (nonce_count_pos, '*'); - if (qop_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (qop_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); qop_pos[0] = 0; qop_pos++; u32 nonce_count_len = strlen (nonce_count_pos); - if (nonce_count_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (nonce_count_len > 50) return (PARSER_SALT_LENGTH); // qop: char *directive_pos = strchr (qop_pos, '*'); - if (directive_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (directive_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); directive_pos[0] = 0; directive_pos++; u32 qop_len = strlen (qop_pos); - if (qop_len > 50) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (qop_len > 50) return (PARSER_SALT_LENGTH); // directive char *digest_pos = strchr (directive_pos, '*'); - if (digest_pos == NULL) - { - myfree (temp_input_buf); - - return (PARSER_SEPARATOR_UNMATCHED); - } + if (digest_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED); digest_pos[0] = 0; digest_pos++; u32 directive_len = strlen (directive_pos); - if (directive_len != 3) - { - myfree (temp_input_buf); + if (directive_len != 3) return (PARSER_SALT_LENGTH); - return (PARSER_SALT_LENGTH); - } - - if (memcmp (directive_pos, "MD5", 3)) - { - myfree (temp_input_buf); - - return (PARSER_SIP_AUTH_DIRECTIVE); - } + if (memcmp (directive_pos, "MD5", 3)) return (PARSER_SIP_AUTH_DIRECTIVE); /* * first (pre-)compute: HA2 = md5 ($method . ":" . $uri) @@ -10799,12 +10661,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE { esalt_len = 1 + nonce_len + 1 + nonce_count_len + 1 + nonce_client_len + 1 + qop_len + 1 + 32; - if (esalt_len > max_esalt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH); snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%s:%s:%s:%08x%08x%08x%08x", nonce_pos, @@ -10820,12 +10677,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE { esalt_len = 1 + nonce_len + 1 + 32; - if (esalt_len > max_esalt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH); snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%08x%08x%08x%08x", nonce_pos, @@ -10851,12 +10703,7 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE u32 max_salt_len = 119; - if (salt_len > max_salt_len) - { - myfree (temp_input_buf); - - return (PARSER_SALT_LENGTH); - } + if (salt_len > max_salt_len) return (PARSER_SALT_LENGTH); snprintf (sip_salt_ptr, max_salt_len + 1, "%s:%s:", user_pos, realm_pos); @@ -10895,8 +10742,6 @@ int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE digest[2] = byte_swap_32 (digest[2]); digest[3] = byte_swap_32 (digest[3]); - myfree (temp_input_buf); - return (PARSER_OK); } @@ -13023,8 +12868,11 @@ char *strparser (const u32 parser_status) return ((char *) PA_255); } -void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) +void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const void *digests_buf = hashes->digests_buf; const salt_t *salts_buf = hashes->salts_buf; const void *esalts_buf = hashes->esalts_buf; @@ -13086,8 +12934,11 @@ void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, MAYBE } } -void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYBE_UNUSED const hashconfig_t *hashconfig, const hashes_t *hashes) +void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos) { + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + void *digests_buf = hashes->digests_buf; salt_t *salts_buf = hashes->salts_buf; void *esalts_buf = hashes->esalts_buf; @@ -15188,9 +15039,9 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB const u32 ckey_len = bitcoin_wallet->ckey_len; const u32 public_key_len = bitcoin_wallet->public_key_len; - char *cry_master_buf = (char *) mymalloc ((cry_master_len * 2) + 1); - char *ckey_buf = (char *) mymalloc ((ckey_len * 2) + 1); - char *public_key_buf = (char *) mymalloc ((public_key_len * 2) + 1); + char *cry_master_buf = (char *) hcmalloc (hashcat_ctx, (cry_master_len * 2) + 1); + char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1); + char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1); for (u32 i = 0, j = 0; i < cry_master_len; i += 1, j += 2) { @@ -15226,9 +15077,9 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB public_key_buf ); - myfree (cry_master_buf); - myfree (ckey_buf); - myfree (public_key_buf); + hcfree (cry_master_buf); + hcfree (ckey_buf); + hcfree (public_key_buf); } else if (hash_mode == 11400) { @@ -15247,7 +15098,7 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB const u32 data_len = seven_zip->data_len; - char *data_buf = (char *) mymalloc ((data_len * 2) + 1); + char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2) { @@ -15272,7 +15123,7 @@ void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, MAYB seven_zip->unpack_size, data_buf); - myfree (data_buf); + hcfree (data_buf); } else if (hash_mode == 11700) { @@ -20163,7 +20014,7 @@ int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) u32 *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; - char *keyfiles = mystrdup (tcvc_keyfiles); + char *keyfiles = hcstrdup (hashcat_ctx, tcvc_keyfiles); char *keyfile = strtok (keyfiles, ","); diff --git a/src/logfile.c b/src/logfile.c index 7f956c28a..0fc3804d9 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -77,12 +77,12 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->logfile_disable == true) return 0; - logfile_ctx->logfile = (char *) mymalloc (HCBUFSIZ_TINY); + logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session); - logfile_ctx->subid = (char *) mymalloc (HCBUFSIZ_TINY); - logfile_ctx->topid = (char *) mymalloc (HCBUFSIZ_TINY); + logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); logfile_ctx->enabled = true; @@ -106,9 +106,9 @@ void logfile_destroy (hashcat_ctx_t *hashcat_ctx) if (logfile_ctx->enabled == false) return; - myfree (logfile_ctx->logfile); - myfree (logfile_ctx->topid); - myfree (logfile_ctx->subid); + hcfree (logfile_ctx->logfile); + hcfree (logfile_ctx->topid); + hcfree (logfile_ctx->subid); memset (logfile_ctx, 0, sizeof (logfile_ctx_t)); } diff --git a/src/loopback.c b/src/loopback.c index 63f60de9c..afbc66941 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -70,7 +70,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = true; loopback_ctx->fp = NULL; - loopback_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); + loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); return 0; } diff --git a/src/main.c b/src/main.c index 6b19a9956..c749e3f7f 100644 --- a/src/main.c +++ b/src/main.c @@ -174,7 +174,7 @@ static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hashcat_user->outer_threads_cnt = 0; - hashcat_user->outer_threads = (hc_thread_t *) mycalloc (2, sizeof (hc_thread_t)); + hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); status_ctx->shutdown_outer = false; @@ -207,7 +207,7 @@ static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hc_thread_wait (1, &hashcat_user->outer_threads[thread_idx]); } - myfree (hashcat_user->outer_threads); + hcfree (hashcat_user->outer_threads); hashcat_user->outer_threads_cnt = 0; diff --git a/src/memory.c b/src/memory.c index 12ed019fb..e02093692 100644 --- a/src/memory.c +++ b/src/memory.c @@ -4,15 +4,17 @@ */ #include "common.h" +#include "types.h" +#include "event.h" #include "memory.h" -void *mycalloc (size_t nmemb, size_t size) +void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) { - void *p = calloc (nmemb, size); + void *p = calloc (nmemb, sz); if (p == NULL) { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); exit (-1); } @@ -20,52 +22,54 @@ void *mycalloc (size_t nmemb, size_t size) return (p); } -void *mymalloc (size_t size) +void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) { - void *p = malloc (size); + void *p = malloc (sz); if (p == NULL) { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); exit (-1); } - memset (p, 0, size); + memset (p, 0, sz); return (p); } -void myfree (void *ptr) +void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz) +{ + void *p = realloc (ptr, oldsz + addsz); + + if (p == NULL) + { + event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); + + exit (-1); + } + + memset ((char *) p + oldsz, 0, addsz); + + return (p); +} + +char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s) +{ + const size_t len = strlen (s); + + char *b = (char *) hcmalloc (hashcat_ctx, len + 1); + + strncpy (b, s, len); + + b[len] = 0; + + return (b); +} + +void hcfree (void *ptr) { if (ptr == NULL) return; free (ptr); } - -void *myrealloc (void *ptr, size_t oldsz, size_t add) -{ - void *p = realloc (ptr, oldsz + add); - - if (p == NULL) - { - fprintf (stderr, "ERROR: %s", MSG_ENOMEM); - - exit (-1); - } - - memset ((char *) p + oldsz, 0, add); - - return (p); -} - -char *mystrdup (const char *s) -{ - const size_t len = strlen (s); - - char *b = (char *) mymalloc (len + 1); - - memcpy (b, s, len); - - return (b); -} diff --git a/src/monitor.c b/src/monitor.c index d9da8752b..edfd24642 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -69,12 +69,12 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) // these variables are mainly used for fan control - int *fan_speed_chgd = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); // temperature controller "loopback" values - int *temp_diff_old = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); - int *temp_diff_sum = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); time_t last_temp_check_time; @@ -102,49 +102,32 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - if (device_param->device_vendor_id == VENDOR_ID_NV) + const int rc_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id); + + if (rc_throttle == -1) continue; + + if (rc_throttle > 0) { - if (hwmon_ctx->hm_nvapi) + if (slowdown_warnings < 3) { - NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info; - NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status; + if (user_options->quiet == false) clear_prompt (); - memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1)); - memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1)); + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); - perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1); - perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1); - - hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info); - - perfPolicies_status.info_value = perfPolicies_info.info_value; - - hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status); - - if (perfPolicies_status.throttle & 2) + if (slowdown_warnings == 2) { - if (slowdown_warnings < 3) - { - if (user_options->quiet == false) clear_prompt (); - - event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); - - if (slowdown_warnings == 2) - { - event_log_info (hashcat_ctx, ""); - } - - if (user_options->quiet == false) send_prompt (); - - slowdown_warnings++; - } - } - else - { - slowdown_warnings = 0; + event_log_info (hashcat_ctx, ""); } + + if (user_options->quiet == false) send_prompt (); + + slowdown_warnings++; } } + else + { + slowdown_warnings = 0; + } } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -358,10 +341,10 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (rc == -1) return -1; } - myfree (fan_speed_chgd); + hcfree (fan_speed_chgd); - myfree (temp_diff_old); - myfree (temp_diff_sum); + hcfree (temp_diff_old); + hcfree (temp_diff_sum); return 0; } diff --git a/src/mpsp.c b/src/mpsp.c index b28d8f43f..8ac698b9b 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -22,8 +22,35 @@ static const char DEF_MASK[] = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; #define MAX_MFS 5 // 4*charset, 1*mask -void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_lr[2]) +static int sp_comp_val (const void *p1, const void *p2) { + hcstat_table_t *b1 = (hcstat_table_t *) p1; + hcstat_table_t *b2 = (hcstat_table_t *) p2; + + return b2->val - b1->val; +} + +static u32 mp_get_length (char *mask) +{ + u32 len = 0; + + u32 mask_len = strlen (mask); + + for (u32 i = 0; i < mask_len; i++) + { + if (mask[i] == '?') i++; + + len++; + } + + return len; +} + +static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig, u32 css_cnt_lr[2]) +{ + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + u32 css_cnt_l = mask_ctx->css_cnt; u32 css_cnt_r; @@ -87,14 +114,16 @@ void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfi css_cnt_lr[1] = css_cnt_r; } -void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf) +static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + u32 salt_len = (u32) salt_buf->salt_len; u8 *salt_buf_ptr = (u8 *) salt_buf->salt_buf; u32 css_cnt_salt = mask_ctx->css_cnt + salt_len; - cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t)); + cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t)); @@ -104,17 +133,19 @@ void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf) css_buf_salt[j].cs_len = 1; } - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); mask_ctx->css_buf = css_buf_salt; mask_ctx->css_cnt = css_cnt_salt; } -void mp_css_unicode_expand (mask_ctx_t *mask_ctx) +static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + u32 css_cnt_unicode = mask_ctx->css_cnt * 2; - cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t)); + cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) { @@ -124,13 +155,13 @@ void mp_css_unicode_expand (mask_ctx_t *mask_ctx) css_buf_unicode[j + 1].cs_len = 1; } - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); mask_ctx->css_buf = css_buf_unicode; mask_ctx->css_cnt = css_cnt_unicode; } -int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) +static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { /* generates a lookup table where key is the char itself for fastest possible lookup performance */ @@ -167,7 +198,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le size_t css_uniq_sz = CHARSIZ * sizeof (u32); - u32 *css_uniq = (u32 *) mymalloc (css_uniq_sz); + u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); size_t i; @@ -193,7 +224,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le cs->cs_len++; } - myfree (css_uniq); + hcfree (css_uniq); } static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret) @@ -291,7 +322,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask { const user_options_t *user_options = hashcat_ctx->user_options; - cs_t *css = (cs_t *) mycalloc (256, sizeof (cs_t)); + cs_t *css = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); u32 mask_pos; u32 css_pos; @@ -400,7 +431,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask { const user_options_t *user_options = hashcat_ctx->user_options; - char *new_mask_buf = (char *) mymalloc (256); + char *new_mask_buf = (char *) hcmalloc (hashcat_ctx, 256); u32 mask_pos; @@ -453,66 +484,12 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask if (css_pos == len) return (new_mask_buf); - myfree (new_mask_buf); + hcfree (new_mask_buf); return (NULL); } -u64 mp_get_sum (u32 css_cnt, cs_t *css) -{ - u64 sum = 1; - - for (u32 css_pos = 0; css_pos < css_cnt; css_pos++) - { - sum *= css[css_pos].cs_len; - } - - return (sum); -} - -void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt) -{ - for (int i = 0; i < css_cnt; i++) - { - u32 len = css[i].cs_len; - u64 next = val / len; - u32 pos = val % len; - buf[i] = (char) (css[i].cs_buf[pos] & 0xff); - val = next; - } -} - -u32 mp_get_length (char *mask) -{ - u32 len = 0; - - u32 mask_len = strlen (mask); - - for (u32 i = 0; i < mask_len; i++) - { - if (mask[i] == '?') i++; - - len++; - } - - return len; -} - -void mp_cut_at (char *mask, u32 max) -{ - u32 i; - u32 j; - u32 mask_len = strlen (mask); - - for (i = 0, j = 0; i < mask_len && j < max; i++, j++) - { - if (mask[i] == '?') i++; - } - - mask[i] = 0; -} - -void mp_setup_sys (cs_t *mp_sys) +static void mp_setup_sys (cs_t *mp_sys) { u32 pos; u32 chr; @@ -541,7 +518,7 @@ void mp_setup_sys (cs_t *mp_sys) mp_sys[5].cs_len = pos; } } -int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index) +static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index) { FILE *fp = fopen (buf, "rb"); @@ -580,7 +557,7 @@ int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, char * return 0; } -void mp_reset_usr (cs_t *mp_usr, u32 index) +static void mp_reset_usr (cs_t *mp_usr, u32 index) { mp_usr[index].cs_len = 0; @@ -610,7 +587,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) * Initialize hcstats */ - u64 *root_stats_buf = (u64 *) mycalloc (SP_ROOT_CNT, sizeof (u64)); + u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); u64 *root_stats_ptr = root_stats_buf; @@ -623,7 +600,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) root_stats_ptr += CHARSIZ; } - u64 *markov_stats_buf = (u64 *) mycalloc (SP_MARKOV_CNT, sizeof (u64)); + u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); u64 *markov_stats_ptr = markov_stats_buf; @@ -782,8 +759,8 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) markov_table_buf[i].val = markov_stats_buf[i]; } - myfree (root_stats_buf); - myfree (markov_stats_buf); + hcfree (root_stats_buf); + hcfree (markov_stats_buf); /** * Finally sort them @@ -805,7 +782,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) return 0; } -u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) +static u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) { u64 sum = 1; @@ -819,38 +796,7 @@ u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf) return (sum); } -void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) -{ - u64 v = ctx; - - cs_t *cs = &root_css_buf[start]; - - u32 i; - - for (i = start; i < stop; i++) - { - const u64 m = v % cs->cs_len; - const u64 d = v / cs->cs_len; - - v = d; - - const u32 k = cs->cs_buf[m]; - - pw_buf[i - start] = (char) k; - - cs = &markov_css_buf[(i * CHARSIZ) + k]; - } -} - -int sp_comp_val (const void *p1, const void *p2) -{ - hcstat_table_t *b1 = (hcstat_table_t *) p1; - hcstat_table_t *b2 = (hcstat_table_t *) p2; - - return b2->val - b1->val; -} - -void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) +static void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { memset (root_css_buf, 0, SP_PW_MAX * sizeof (cs_t)); memset (markov_css_buf, 0, SP_PW_MAX * CHARSIZ * sizeof (cs_t)); @@ -917,74 +863,47 @@ void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table */ } -void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out) +void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop) { - for (u32 i = 0; i < SP_PW_MAX; i += 2) + u64 v = ctx; + + cs_t *cs = &root_css_buf[start]; + + u32 i; + + for (i = start; i < stop; i++) { - memcpy (out, in, CHARSIZ * sizeof (hcstat_table_t)); + const u64 m = v % cs->cs_len; + const u64 d = v / cs->cs_len; - out += CHARSIZ; - in += CHARSIZ; + v = d; - out->key = 0; - out->val = 1; + const u32 k = cs->cs_buf[m]; - out++; + pw_buf[i - start] = (char) k; - for (u32 j = 1; j < CHARSIZ; j++) - { - out->key = j; - out->val = 0; - - out++; - } + cs = &markov_css_buf[(i * CHARSIZ) + k]; } } -void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out) +static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) { - for (u32 i = 0; i < SP_PW_MAX; i += 2) - { - memcpy (out, in, CHARSIZ * CHARSIZ * sizeof (hcstat_table_t)); + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - out += CHARSIZ * CHARSIZ; - in += CHARSIZ * CHARSIZ; - - for (u32 j = 0; j < CHARSIZ; j++) - { - out->key = 0; - out->val = 1; - - out++; - - for (u32 k = 1; k < CHARSIZ; k++) - { - out->key = k; - out->val = 0; - - out++; - } - } - } -} - -static void mask_append_final (mask_ctx_t *mask_ctx, const char *mask) -{ if (mask_ctx->masks_avail == mask_ctx->masks_cnt) { - mask_ctx->masks = (char **) myrealloc (mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); + mask_ctx->masks = (char **) hcrealloc (hashcat_ctx, mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); mask_ctx->masks_avail += INCR_MASKS; } - mask_ctx->masks[mask_ctx->masks_cnt] = mystrdup (mask); + mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (hashcat_ctx, mask); mask_ctx->masks_cnt++; } static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; user_options_t *user_options = hashcat_ctx->user_options; if (user_options->increment == true) @@ -995,12 +914,12 @@ static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) if (mask_truncated == NULL) break; - mask_append_final (mask_ctx, mask_truncated); + mask_append_final (hashcat_ctx, mask_truncated); } } else { - mask_append_final (mask_ctx, mask); + mask_append_final (hashcat_ctx, mask); } } @@ -1110,7 +1029,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) { - mp_css_unicode_expand (mask_ctx); + mp_css_unicode_expand (hashcat_ctx); } u32 css_cnt_orig = mask_ctx->css_cnt; @@ -1119,7 +1038,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) { - mp_css_append_salt (mask_ctx, &hashes->salts_buf[0]); + mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]); } } @@ -1135,7 +1054,7 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) u32 css_cnt_lr[2]; - mp_css_split_cnt (mask_ctx, hashconfig, css_cnt_orig, css_cnt_lr); + mp_css_split_cnt (hashcat_ctx, css_cnt_orig, css_cnt_lr); mask_ctx->bfs_cnt = sp_get_sum (0, css_cnt_lr[1], mask_ctx->root_css_buf); @@ -1167,13 +1086,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; - mask_ctx->root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t)); - mask_ctx->markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t)); + mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (hcstat_table_t)); + mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t)); sp_setup_tbl (hashcat_ctx); - mask_ctx->root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t)); - mask_ctx->markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t)); + mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t)); + mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t)); mask_ctx->css_cnt = 0; mask_ctx->css_buf = NULL; @@ -1184,7 +1103,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = 0; mask_ctx->masks_cnt = 0; - mask_ctx->mfs = (mf_t *) mycalloc (MAX_MFS, sizeof (mf_t)); + mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); mp_setup_sys (mask_ctx->mp_sys); @@ -1233,7 +1152,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1246,7 +1165,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1302,7 +1221,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1315,7 +1234,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1356,7 +1275,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (mask_fp)) { @@ -1369,7 +1288,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_append (hashcat_ctx, line_buf); } - myfree (line_buf); + hcfree (line_buf); fclose (mask_fp); } @@ -1400,22 +1319,22 @@ void mask_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->enabled == false) return; - myfree (mask_ctx->css_buf); + hcfree (mask_ctx->css_buf); - myfree (mask_ctx->root_css_buf); - myfree (mask_ctx->markov_css_buf); + hcfree (mask_ctx->root_css_buf); + hcfree (mask_ctx->markov_css_buf); - myfree (mask_ctx->root_table_buf); - myfree (mask_ctx->markov_table_buf); + hcfree (mask_ctx->root_table_buf); + hcfree (mask_ctx->markov_table_buf); for (u32 mask_pos = 0; mask_pos < mask_ctx->masks_cnt; mask_pos++) { - myfree (mask_ctx->masks[mask_pos]); + hcfree (mask_ctx->masks[mask_pos]); } - myfree (mask_ctx->masks); + hcfree (mask_ctx->masks); - myfree (mask_ctx->mfs); + hcfree (mask_ctx->mfs); memset (mask_ctx, 0, sizeof (mask_ctx_t)); } diff --git a/src/opencl.c b/src/opencl.c index 85013a8ec..a8abf5efb 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -104,7 +104,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char if (opencl_platforms) { - char *platforms = mystrdup (opencl_platforms); + char *platforms = hcstrdup (hashcat_ctx, opencl_platforms); char *next = strtok (platforms, ","); @@ -123,7 +123,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char } while ((next = strtok (NULL, ",")) != NULL); - myfree (platforms); + hcfree (platforms); } else { @@ -141,7 +141,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ if (opencl_devices) { - char *devices = mystrdup (opencl_devices); + char *devices = hcstrdup (hashcat_ctx, opencl_devices); char *next = strtok (devices, ","); @@ -160,7 +160,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ } while ((next = strtok (NULL, ",")) != NULL); - myfree (devices); + hcfree (devices); } else { @@ -178,7 +178,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op if (opencl_device_types) { - char *device_types = mystrdup (opencl_device_types); + char *device_types = hcstrdup (hashcat_ctx, opencl_device_types); char *next = strtok (device_types, ","); @@ -197,7 +197,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op } while ((next = strtok (NULL, ",")) != NULL); - myfree (device_types); + hcfree (device_types); } else { @@ -224,7 +224,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi stat (kernel_file, &st); - char *buf = (char *) mymalloc (st.st_size + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); size_t num_read = fread (buf, sizeof (char), st.st_size, fp); @@ -1888,7 +1888,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (DEVICES_MAX, sizeof (hc_device_param_t)); + hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); opencl_ctx->devices_param = devices_param; @@ -1896,7 +1896,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * Load and map OpenCL library calls */ - OCL_PTR *ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR)); + OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); opencl_ctx->ocl = ocl; @@ -1943,9 +1943,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) */ cl_uint platforms_cnt = 0; - cl_platform_id *platforms = (cl_platform_id *) mycalloc (CL_PLATFORMS_MAX, sizeof (cl_platform_id)); + cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); cl_uint platform_devices_cnt = 0; - cl_device_id *platform_devices = (cl_device_id *) mycalloc (DEVICES_MAX, sizeof (cl_device_id)); + cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); @@ -2048,11 +2048,11 @@ void opencl_ctx_destroy (hashcat_ctx_t *hashcat_ctx) ocl_close (hashcat_ctx); - myfree (opencl_ctx->devices_param); + hcfree (opencl_ctx->devices_param); - myfree (opencl_ctx->platforms); + hcfree (opencl_ctx->platforms); - myfree (opencl_ctx->platform_devices); + hcfree (opencl_ctx->platform_devices); memset (opencl_ctx, 0, sizeof (opencl_ctx_t)); } @@ -2240,7 +2240,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_name = (char *) mymalloc (param_value_size); + char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); @@ -2254,7 +2254,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_vendor = (char *) mymalloc (param_value_size); + char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); @@ -2309,7 +2309,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_version = (char *) mymalloc (param_value_size); + char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); @@ -2323,7 +2323,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_opencl_version = (char *) mymalloc (param_value_size); + char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); @@ -2450,7 +2450,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_extensions = mymalloc (device_extensions_size + 1); + char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); @@ -2470,7 +2470,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->skipped = 1; } - myfree (device_extensions); + hcfree (device_extensions); // device_local_mem_size @@ -2518,7 +2518,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *driver_version = (char *) mymalloc (param_value_size); + char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); @@ -2528,7 +2528,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name_chksum - char *device_name_chksum = (char *) mymalloc (HCBUFSIZ_TINY); + char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); #if defined (__x86_64__) snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); @@ -2641,7 +2641,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_opencl_version); } - myfree (device_opencl_version); + hcfree (device_opencl_version); if ((user_options->benchmark == true || user_options->quiet == false)) { @@ -2818,10 +2818,10 @@ void opencl_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - myfree (device_param->device_name); - myfree (device_param->device_name_chksum); - myfree (device_param->device_version); - myfree (device_param->driver_version); + hcfree (device_param->device_name); + hcfree (device_param->device_name_chksum); + hcfree (device_param->device_version); + hcfree (device_param->driver_version); } opencl_ctx->devices_cnt = 0; @@ -3494,9 +3494,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (opencl_ctx->force_jit_compilation == -1) { @@ -3528,7 +3528,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3536,7 +3536,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3554,7 +3554,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3564,7 +3564,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_write == -1) return -1; - myfree (binary); + hcfree (binary); } else { @@ -3630,7 +3630,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3638,7 +3638,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3649,9 +3649,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } /** @@ -3698,9 +3698,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (cached == 0) { @@ -3731,7 +3731,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3739,7 +3739,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3757,7 +3757,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3765,7 +3765,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - myfree (binary); + hcfree (binary); } else { @@ -3786,9 +3786,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } /** @@ -3839,9 +3839,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); - char **kernel_sources = (char **) mymalloc (sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); if (cached == 0) { @@ -3872,7 +3872,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) mymalloc (build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3880,7 +3880,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) puts (build_log); - myfree (build_log); + hcfree (build_log); } if (CL_err != CL_SUCCESS) @@ -3898,7 +3898,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) mymalloc (binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3906,7 +3906,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - myfree (binary); + hcfree (binary); } else { @@ -3927,9 +3927,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; } - myfree (kernel_lengths); - myfree (kernel_sources[0]); - myfree (kernel_sources); + hcfree (kernel_lengths); + hcfree (kernel_sources[0]); + hcfree (kernel_sources); } // return back to the folder we came from initially (workaround) @@ -4043,15 +4043,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * main host data */ - pw_t *pws_buf = (pw_t *) mymalloc (size_pws); + pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); device_param->pws_buf = pws_buf; - comb_t *combs_buf = (comb_t *) mycalloc (KERNEL_COMBS, sizeof (comb_t)); + comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); device_param->combs_buf = combs_buf; - void *hooks_buf = mymalloc (size_hooks); + void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); device_param->hooks_buf = hooks_buf; @@ -4529,9 +4529,9 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) cl_int CL_err = CL_SUCCESS; - myfree (device_param->pws_buf); - myfree (device_param->combs_buf); - myfree (device_param->hooks_buf); + hcfree (device_param->pws_buf); + hcfree (device_param->combs_buf); + hcfree (device_param->hooks_buf); if (device_param->d_pws_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_buf); if (device_param->d_pws_amp_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_amp_buf); diff --git a/src/outfile_check.c b/src/outfile_check.c index 0032666b8..37b0a7e5c 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -38,10 +38,10 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) // buffers hash_t hash_buf = { 0, 0, 0, 0, 0 }; - hash_buf.digest = mymalloc (dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); - if (is_salted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t)); - if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size); + if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); + if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); u32 digest_buf[64] = { 0 }; @@ -75,7 +75,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) { if (outfile_check_stat.st_mtime > folder_mtime) { - char **out_files_new = scan_directory (root_directory); + char **out_files_new = scan_directory (hashcat_ctx, root_directory); int out_cnt_new = count_dictionaries (out_files_new); @@ -83,7 +83,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) if (out_cnt_new > 0) { - out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t)); + out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); for (int i = 0; i < out_cnt_new; i++) { @@ -110,8 +110,8 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) } } - myfree (out_info); - myfree (out_files); + hcfree (out_info); + hcfree (out_files); out_files = out_files_new; out_cnt = out_cnt_new; @@ -146,7 +146,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) fseek (fp, out_info[j].seek, SEEK_SET); - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -282,7 +282,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_CRACKED) break; } - myfree (line_buf); + hcfree (line_buf); out_info[j].seek = ftell (fp); @@ -298,15 +298,15 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) } } - myfree (hash_buf.esalt); + hcfree (hash_buf.esalt); - myfree (hash_buf.salt); + hcfree (hash_buf.salt); - myfree (hash_buf.digest); + hcfree (hash_buf.digest); - myfree (out_info); + hcfree (out_info); - myfree (out_files); + hcfree (out_files); } void *thread_outfile_remove (void *p) @@ -339,7 +339,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_check_dir == NULL) { - outcheck_ctx->root_directory = (char *) mymalloc (HCBUFSIZ_TINY); + outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR); } @@ -400,7 +400,7 @@ void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } } - myfree (outcheck_ctx->root_directory); + hcfree (outcheck_ctx->root_directory); memset (outcheck_ctx, 0, sizeof (outcheck_ctx_t)); } diff --git a/src/potfile.c b/src/potfile.c index f8e9f4c37..797977a6f 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -206,14 +206,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_path == NULL) { - potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY); + potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); potfile_ctx->fp = NULL; snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir); } else { - potfile_ctx->filename = mystrdup (user_options->potfile_path); + potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); potfile_ctx->fp = NULL; } @@ -267,13 +267,13 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) return; - potfile_ctx->pot_avail = count_lines (potfile_ctx->fp); + potfile_ctx->pot_avail = count_lines (hashcat_ctx, potfile_ctx->fp); - potfile_ctx->pot = (pot_t *) mycalloc (potfile_ctx->pot_avail, sizeof (pot_t)); + potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); rewind (potfile_ctx->fp); - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++) { @@ -363,7 +363,7 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) potfile_ctx->pot_cnt++; } - myfree (line_buf); + hcfree (line_buf); hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); } @@ -440,16 +440,16 @@ void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) hash_t *tmp_hash = &tmp_pot->hash; - tmp_hash->digest = mymalloc (hashconfig->dgst_size); + tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); if (hashconfig->is_salted) { - tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t)); + tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); } if (hashconfig->esalt_size) { - tmp_hash->esalt = mymalloc (hashconfig->esalt_size); + tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); } potfile_ctx->pot_hashes_avail++; @@ -469,20 +469,20 @@ void potfile_hash_free (hashcat_ctx_t *hashcat_ctx) hash_t *hashes_buf = &pot_ptr->hash; - myfree (hashes_buf->digest); + hcfree (hashes_buf->digest); if (hashconfig->is_salted) { - myfree (hashes_buf->salt); + hcfree (hashes_buf->salt); } if (hashconfig->esalt_size) { - myfree (hashes_buf->esalt); + hcfree (hashes_buf->esalt); } } - myfree (potfile_ctx->pot); + hcfree (potfile_ctx->pot); } void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)) @@ -585,7 +585,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { weak_hash_found = 1; - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); // in theory this is not needed, but we are paranoia: @@ -596,7 +596,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i if ((pot_left_ptr == NULL) && (pot_right_ptr == NULL)) { - if (weak_hash_found == 1) myfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure + if (weak_hash_found == 1) hcfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure return; } @@ -635,7 +635,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { left_part_masked = 1; - pot_left_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf)); @@ -647,7 +647,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { right_part_masked = 1; - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); @@ -669,10 +669,10 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len); - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); - if (left_part_masked == 1) myfree (pot_left_ptr); - if (right_part_masked == 1) myfree (pot_right_ptr); + if (left_part_masked == 1) hcfree (pot_left_ptr); + if (right_part_masked == 1) hcfree (pot_right_ptr); } void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) @@ -710,13 +710,13 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // we just need that pot_right_ptr is not a NULL pointer - pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); } } if ((pot_left_ptr != NULL) && (pot_right_ptr != NULL)) { - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); return; } @@ -731,7 +731,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i u32 user_len = (u32)input_len - 32u; - char *hash_output = (char *) mymalloc (33); + char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); memcpy (hash_output, input_buf, input_len); @@ -755,9 +755,9 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0); - myfree (hash_output); + hcfree (hash_output); - if (weak_hash_found == 1) myfree (pot_right_ptr); + if (weak_hash_found == 1) hcfree (pot_right_ptr); } void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) @@ -782,7 +782,7 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) hash_t hash_buf; - hash_buf.digest = mymalloc (hashconfig->dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); hash_buf.salt = NULL; hash_buf.esalt = NULL; hash_buf.hash_info = NULL; @@ -790,25 +790,25 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (hashconfig->is_salted) { - hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t)); + hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); } if (hashconfig->esalt_size) { - hash_buf.esalt = mymalloc (hashconfig->esalt_size); + hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); } const int rc = potfile_read_open (hashcat_ctx); if (rc == -1) return; - char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); // to be safe work with a copy (because of line_len loop, i etc) // moved up here because it's easier to handle continue case // it's just 64kb - char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ_LARGE); + char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (potfile_ctx->fp)) { @@ -945,21 +945,21 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } } - myfree (line_buf_cpy); + hcfree (line_buf_cpy); - myfree (line_buf); + hcfree (line_buf); potfile_read_close (hashcat_ctx); if (hashconfig->esalt_size) { - myfree (hash_buf.esalt); + hcfree (hash_buf.esalt); } if (hashconfig->is_salted) { - myfree (hash_buf.salt); + hcfree (hash_buf.salt); } - myfree (hash_buf.digest); + hcfree (hash_buf.digest); } diff --git a/src/restore.c b/src/restore.c index 762cb26d5..0f708a934 100644 --- a/src/restore.c +++ b/src/restore.c @@ -62,7 +62,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) return 0; - restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp); @@ -77,7 +77,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (rd->pid) { - char *pidbin = (char *) mymalloc (HCBUFSIZ_LARGE); + char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int pidbin_len = -1; @@ -113,7 +113,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) #elif defined (_WIN) HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid); - char *pidbin2 = (char *) mymalloc (HCBUFSIZ_LARGE); + char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int pidbin2_len = -1; @@ -133,11 +133,11 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) } } - myfree (pidbin2); + hcfree (pidbin2); #endif - myfree (pidbin); + hcfree (pidbin); } if (rd->version < RESTORE_VERSION_MIN) @@ -147,7 +147,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (rd); + hcfree (rd); return 0; } @@ -156,7 +156,7 @@ static int init_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); restore_ctx->rd = rd; @@ -211,9 +211,9 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) return -1; } - rd->argv = (char **) mycalloc (rd->argc, sizeof (char *)); + rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); for (u32 i = 0; i < rd->argc; i++) { @@ -228,10 +228,10 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (len) buf[len - 1] = 0; - rd->argv[i] = mystrdup (buf); + rd->argv[i] = hcstrdup (hashcat_ctx, buf); } - myfree (buf); + hcfree (buf); fclose (fp); @@ -393,8 +393,8 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; - char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY); - char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY); + char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *new_restore_file = (char *) hcmalloc (hashcat_ctx, 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); @@ -459,10 +459,10 @@ void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - myfree (restore_ctx->eff_restore_file); - myfree (restore_ctx->new_restore_file); + hcfree (restore_ctx->eff_restore_file); + hcfree (restore_ctx->new_restore_file); - myfree (restore_ctx->rd); + hcfree (restore_ctx->rd); if (restore_ctx->enabled == false) return; diff --git a/src/rp.c b/src/rp.c index 919e33f41..61b47ed5d 100644 --- a/src/rp.c +++ b/src/rp.c @@ -728,12 +728,12 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (user_options->rp_files_cnt) { - all_kernel_rules_cnt = (u32 *) mycalloc (user_options->rp_files_cnt, sizeof (u32)); + all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); - all_kernel_rules_buf = (kernel_rule_t **) mycalloc (user_options->rp_files_cnt, sizeof (kernel_rule_t *)); + all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); } - char *rule_buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); int rule_len = 0; @@ -773,7 +773,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_avail == kernel_rules_cnt) { - kernel_rules_buf = (kernel_rule_t *) myrealloc (kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); + kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); kernel_rules_avail += INCR_RULES; } @@ -808,7 +808,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 all_kernel_rules_buf[i] = kernel_rules_buf; } - myfree (rule_buf); + hcfree (rule_buf); /** * merge rules @@ -816,7 +816,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 u32 kernel_rules_cnt = 1; - u32 *repeats = (u32 *) mycalloc (user_options->rp_files_cnt + 1, sizeof (u32)); + u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); repeats[0] = kernel_rules_cnt; @@ -827,7 +827,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 repeats[i + 1] = kernel_rules_cnt; } - kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) mycalloc (kernel_rules_cnt, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); for (u32 i = 0; i < kernel_rules_cnt; i++) { @@ -856,7 +856,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 } } - myfree (repeats); + hcfree (repeats); if (kernel_rules_cnt == 0) { @@ -865,8 +865,8 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 return -1; } - myfree (all_kernel_rules_cnt); - myfree (all_kernel_rules_buf); + hcfree (all_kernel_rules_cnt); + hcfree (all_kernel_rules_buf); *out_cnt = kernel_rules_cnt; *out_buf = kernel_rules_buf; @@ -879,9 +879,9 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, const user_options_t *user_options = hashcat_ctx->user_options; u32 kernel_rules_cnt = 0; - kernel_rule_t *kernel_rules_buf = mycalloc (user_options->rp_gen, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); - char *rule_buf = (char *) mymalloc (RP_RULE_BUFSIZ); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++) { @@ -892,7 +892,7 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) continue; } - myfree (rule_buf); + hcfree (rule_buf); *out_cnt = kernel_rules_cnt; *out_buf = kernel_rules_buf; diff --git a/src/status.c b/src/status.c index 448f47971..40b152b4a 100644 --- a/src/status.c +++ b/src/status.c @@ -538,7 +538,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { char out_buf[HCBUFSIZ_LARGE] = { 0 }; - ascii_digest (out_buf, 0, 0, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf, 0, 0); // limit length if (strlen (out_buf) > 40) @@ -559,8 +559,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char out_buf1[32] = { 0 }; char out_buf2[32] = { 0 }; - ascii_digest (out_buf1, 0, 0, hashconfig, hashes); - ascii_digest (out_buf2, 0, 1, hashconfig, hashes); + ascii_digest (hashcat_ctx, out_buf1, 0, 0); + ascii_digest (hashcat_ctx, out_buf2, 0, 1); event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); } @@ -1155,7 +1155,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - if (num_throttle == 1) + if (num_throttle >= 0) { snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " *Throttled*"); @@ -1350,9 +1350,9 @@ int status_progress_init (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; hashes_t *hashes = hashcat_ctx->hashes; - status_ctx->words_progress_done = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_rejected = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_restored = (u64 *) mycalloc (hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); return 0; } @@ -1361,9 +1361,9 @@ void status_progress_destroy (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - myfree (status_ctx->words_progress_done); - myfree (status_ctx->words_progress_rejected); - myfree (status_ctx->words_progress_restored); + hcfree (status_ctx->words_progress_done); + hcfree (status_ctx->words_progress_rejected); + hcfree (status_ctx->words_progress_restored); status_ctx->words_progress_done = NULL; status_ctx->words_progress_rejected = NULL; diff --git a/src/straight.c b/src/straight.c index e89fa827f..97132d7ca 100644 --- a/src/straight.c +++ b/src/straight.c @@ -20,16 +20,18 @@ #include "straight.h" #include "wordlist.h" -static void straight_ctx_add_wl (straight_ctx_t *straight_ctx, const char *dict) +static void straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict) { + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt) { - straight_ctx->dicts = (char **) myrealloc (straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); + straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); straight_ctx->dicts_avail += INCR_DICTS; } - straight_ctx->dicts[straight_ctx->dicts_cnt] = mystrdup (dict); + straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); straight_ctx->dicts_cnt++; } @@ -196,7 +198,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - straight_ctx->kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t)); + straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP; @@ -281,7 +283,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -302,16 +304,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -350,7 +352,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -371,16 +373,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -410,7 +412,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) { char **dictionary_files = NULL; - dictionary_files = scan_directory (l0_filename); + dictionary_files = scan_directory (hashcat_ctx, l0_filename); if (dictionary_files != NULL) { @@ -431,16 +433,16 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (straight_ctx, l1_filename); + straight_ctx_add_wl (hashcat_ctx, l1_filename); } } } - myfree (dictionary_files); + hcfree (dictionary_files); } else { - straight_ctx_add_wl (straight_ctx, l0_filename); + straight_ctx_add_wl (hashcat_ctx, l0_filename); } } @@ -463,12 +465,12 @@ void straight_ctx_destroy (hashcat_ctx_t *hashcat_ctx) for (u32 dict_pos = 0; dict_pos < straight_ctx->dicts_cnt; dict_pos++) { - myfree (straight_ctx->dicts[dict_pos]); + hcfree (straight_ctx->dicts[dict_pos]); } - myfree (straight_ctx->dicts); + hcfree (straight_ctx->dicts); - myfree (straight_ctx->kernel_rules_buf); + hcfree (straight_ctx->kernel_rules_buf); memset (straight_ctx, 0, sizeof (straight_ctx_t)); } diff --git a/src/tuningdb.c b/src/tuningdb.c index 6aa11307c..535289446 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -67,7 +67,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = true; - char *tuning_db_file = (char *) mymalloc (HCBUFSIZ_TINY); + char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE); @@ -80,23 +80,23 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) return -1; } - myfree (tuning_db_file); + hcfree (tuning_db_file); - int num_lines = count_lines (fp); + int num_lines = count_lines (hashcat_ctx, fp); // a bit over-allocated - tuning_db->alias_buf = (tuning_db_alias_t *) mycalloc (num_lines + 1, sizeof (tuning_db_alias_t)); + tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); tuning_db->alias_cnt = 0; - tuning_db->entry_buf = (tuning_db_entry_t *) mycalloc (num_lines + 1, sizeof (tuning_db_entry_t)); + tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); tuning_db->entry_cnt = 0; rewind (fp); int line_num = 0; - char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); while (!feof (fp)) { @@ -138,8 +138,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_alias_t *alias = &tuning_db->alias_buf[tuning_db->alias_cnt]; - alias->device_name = mystrdup (device_name); - alias->alias_name = mystrdup (alias_name); + alias->device_name = hcstrdup (hashcat_ctx, device_name); + alias->alias_name = hcstrdup (hashcat_ctx, alias_name); tuning_db->alias_cnt++; } @@ -212,7 +212,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db_entry_t *entry = &tuning_db->entry_buf[tuning_db->entry_cnt]; - entry->device_name = mystrdup (device_name); + entry->device_name = hcstrdup (hashcat_ctx, device_name); entry->attack_mode = attack_mode; entry->hash_type = hash_type; entry->vector_width = vector_width; @@ -229,7 +229,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) } } - myfree (buf); + hcfree (buf); fclose (fp); @@ -255,19 +255,19 @@ void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx) { tuning_db_alias_t *alias = &tuning_db->alias_buf[i]; - myfree (alias->device_name); - myfree (alias->alias_name); + hcfree (alias->device_name); + hcfree (alias->alias_name); } for (i = 0; i < tuning_db->entry_cnt; i++) { tuning_db_entry_t *entry = &tuning_db->entry_buf[i]; - myfree (entry->device_name); + hcfree (entry->device_name); } - myfree (tuning_db->alias_buf); - myfree (tuning_db->entry_buf); + hcfree (tuning_db->alias_buf); + hcfree (tuning_db->entry_buf); memset (tuning_db, 0, sizeof (tuning_db_t)); } @@ -280,7 +280,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev // first we need to convert all spaces in the device_name to underscore - char *device_name_nospace = mystrdup (device_name); + char *device_name_nospace = hcstrdup (hashcat_ctx, device_name); int device_name_length = strlen (device_name_nospace); @@ -364,7 +364,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev // free converted device_name - myfree (device_name_nospace); + hcfree (device_name_nospace); return entry; } diff --git a/src/user_options.c b/src/user_options.c index f12e2deb0..af4271028 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -192,7 +192,7 @@ void user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD; user_options->workload_profile = WORKLOAD_PROFILE; user_options->rp_files_cnt = 0; - user_options->rp_files = (char **) mycalloc (256, sizeof (char *)); + user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); user_options->hc_bin = PROGNAME; user_options->hc_argc = 0; user_options->hc_argv = NULL; @@ -202,7 +202,7 @@ void user_options_destroy (hashcat_ctx_t *hashcat_ctx) { user_options_t *user_options = hashcat_ctx->user_options; - myfree (user_options->rp_files); + hcfree (user_options->rp_files); //do not reset this, it might be used from main.c //memset (user_options, 0, sizeof (user_options_t)); @@ -966,7 +966,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; user_options->opencl_platforms = NULL; user_options->opencl_devices = NULL; - user_options->opencl_device_types = mystrdup ("1,2,3"); + user_options->opencl_device_types = hcstrdup (hashcat_ctx, "1,2,3"); } if (user_options->left == true) diff --git a/src/wordlist.c b/src/wordlist.c index 28e0d23d9..4d8630442 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -78,7 +78,7 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) { if (wl_data->cnt == wl_data->avail) { - wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr); + wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); wl_data->avail += wl_data->incr; } @@ -431,7 +431,7 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = true; - wl_data->buf = (char *) mymalloc (user_options->segment_size); + wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); wl_data->avail = user_options->segment_size; wl_data->incr = user_options->segment_size; wl_data->cnt = 0; @@ -460,7 +460,7 @@ void wl_data_destroy (hashcat_ctx_t *hashcat_ctx) if (wl_data->enabled == false) return; - myfree (wl_data->buf); + hcfree (wl_data->buf); memset (wl_data, 0, sizeof (wl_data_t)); } From f962a38221ce910933513281c5279ddc0612fef6 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:05:41 +0200 Subject: [PATCH 016/106] Remove double message --- src/main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.c b/src/main.c index c749e3f7f..6334fda8d 100644 --- a/src/main.c +++ b/src/main.c @@ -360,8 +360,6 @@ static int main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them."); event_log_info (hashcat_ctx, ""); - event_log_info (hashcat_ctx, "INFO: No more hashes left to crack, exiting..."); - event_log_info (hashcat_ctx, ""); return 0; } From 6d2c58d8dfc76fe65c9f6ed50dee59a540bcc9ef Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:10:04 +0200 Subject: [PATCH 017/106] Add main_potfile_remove_parse_post() --- include/types.h | 67 ++++++++++++++++++++++++------------------------ src/hashcat.c | 4 ++- src/main.c | 68 +++++++++++++++++++++++++++++-------------------- 3 files changed, 77 insertions(+), 62 deletions(-) diff --git a/include/types.h b/include/types.h index e94ec7fed..a71af3800 100644 --- a/include/types.h +++ b/include/types.h @@ -77,39 +77,40 @@ typedef struct stat64 hc_stat; typedef enum event_identifier { - EVENT_LOG_INFO = 0x00000001, - EVENT_LOG_WARNING = 0x00000002, - EVENT_LOG_ERROR = 0x00000003, - EVENT_WELCOME_SCREEN = 0x00000011, - EVENT_GOODBYE_SCREEN = 0x00000012, - EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021, - EVENT_LOGFILE_TOP_FINALIZE = 0x00000022, - EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023, - EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, - EVENT_OUTERLOOP_STARTING = 0x00000031, - EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, - EVENT_OUTERLOOP_FINISHED = 0x00000033, - EVENT_INNERLOOP1_STARTING = 0x00000041, - EVENT_INNERLOOP1_FINISHED = 0x00000042, - EVENT_INNERLOOP2_STARTING = 0x00000051, - EVENT_INNERLOOP2_FINISHED = 0x00000052, - EVENT_CALCULATED_WORDS_BASE = 0x00000059, - EVENT_AUTOTUNE_STARTING = 0x00000053, - EVENT_AUTOTUNE_FINISHED = 0x00000054, - EVENT_CRACKER_STARTING = 0x00000055, - EVENT_CRACKER_FINISHED = 0x00000056, - EVENT_CRACKER_FINAL_STATS = 0x00000057, - EVENT_CRACKER_HASH_CRACKED = 0x00000058, - EVENT_POTFILE_REMOVE_PARSE = 0x00000061, - EVENT_POTFILE_NUM_CRACKED = 0x00000062, - EVENT_POTFILE_ALL_CRACKED = 0x00000063, - EVENT_OPENCL_SESSION_PRE = 0x00000071, - EVENT_OPENCL_SESSION_POST = 0x00000072, - EVENT_BITMAP_INIT_PRE = 0x00000081, - EVENT_BITMAP_INIT_POST = 0x00000082, - EVENT_WEAK_HASH_PRE = 0x00000091, - EVENT_WEAK_HASH_POST = 0x00000092, - EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1, + EVENT_LOG_INFO = 0x00000001, + EVENT_LOG_WARNING = 0x00000002, + EVENT_LOG_ERROR = 0x00000003, + EVENT_WELCOME_SCREEN = 0x00000011, + EVENT_GOODBYE_SCREEN = 0x00000012, + EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021, + EVENT_LOGFILE_TOP_FINALIZE = 0x00000022, + EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023, + EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, + EVENT_OUTERLOOP_STARTING = 0x00000031, + EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, + EVENT_OUTERLOOP_FINISHED = 0x00000033, + EVENT_INNERLOOP1_STARTING = 0x00000041, + EVENT_INNERLOOP1_FINISHED = 0x00000042, + EVENT_INNERLOOP2_STARTING = 0x00000051, + EVENT_INNERLOOP2_FINISHED = 0x00000052, + EVENT_CALCULATED_WORDS_BASE = 0x00000059, + EVENT_AUTOTUNE_STARTING = 0x00000053, + EVENT_AUTOTUNE_FINISHED = 0x00000054, + EVENT_CRACKER_STARTING = 0x00000055, + EVENT_CRACKER_FINISHED = 0x00000056, + EVENT_CRACKER_FINAL_STATS = 0x00000057, + EVENT_CRACKER_HASH_CRACKED = 0x00000058, + EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061, + EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062, + EVENT_POTFILE_NUM_CRACKED = 0x00000063, + EVENT_POTFILE_ALL_CRACKED = 0x00000064, + EVENT_OPENCL_SESSION_PRE = 0x00000071, + EVENT_OPENCL_SESSION_POST = 0x00000072, + EVENT_BITMAP_INIT_PRE = 0x00000081, + EVENT_BITMAP_INIT_POST = 0x00000082, + EVENT_WEAK_HASH_PRE = 0x00000091, + EVENT_WEAK_HASH_POST = 0x00000092, + EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1, // there will be much more event types soon diff --git a/src/hashcat.c b/src/hashcat.c index eb770acda..e99f13a2f 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -511,9 +511,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_disable == 0) { - EVENT (EVENT_POTFILE_REMOVE_PARSE); + EVENT (EVENT_POTFILE_REMOVE_PARSE_PRE); potfile_remove_parse (hashcat_ctx); + + EVENT (EVENT_POTFILE_REMOVE_PARSE_POST); } /** diff --git a/src/main.c b/src/main.c index 6334fda8d..fc4f29eff 100644 --- a/src/main.c +++ b/src/main.c @@ -315,7 +315,7 @@ static int main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, return 0; } -static int main_potfile_remove_parse (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static int main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -326,6 +326,17 @@ static int main_potfile_remove_parse (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M return 0; } +static int main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return 0; + + event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); + + return 0; +} + static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -538,33 +549,34 @@ int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size switch (id) { - case EVENT_LOG_INFO: rc = main_log_info (hashcat_ctx, buf, len); break; - case EVENT_LOG_WARNING: rc = main_log_warning (hashcat_ctx, buf, len); break; - case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break; - case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break; - case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_FINAL_STATS: rc = main_cracker_final_stats (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break; - case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_REMOVE_PARSE: rc = main_potfile_remove_parse (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_NUM_CRACKED: rc = main_potfile_num_cracked (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_ALL_CRACKED: rc = main_potfile_all_cracked (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_PRE: rc = main_opencl_session_pre (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_POST: rc = main_opencl_session_post (hashcat_ctx, buf, len); break; - case EVENT_BITMAP_INIT_PRE: rc = main_bitmap_init_pre (hashcat_ctx, buf, len); break; - case EVENT_BITMAP_INIT_POST: rc = main_bitmap_init_post (hashcat_ctx, buf, len); break; - case EVENT_WEAK_HASH_PRE: rc = main_weak_hash_pre (hashcat_ctx, buf, len); break; - case EVENT_WEAK_HASH_POST: rc = main_weak_hash_post (hashcat_ctx, buf, len); break; - case EVENT_SET_KERNEL_POWER_FINAL: rc = main_set_kernel_power_final (hashcat_ctx, buf, len); break; + case EVENT_LOG_INFO: rc = main_log_info (hashcat_ctx, buf, len); break; + case EVENT_LOG_WARNING: rc = main_log_warning (hashcat_ctx, buf, len); break; + case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break; + case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break; + case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break; + case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_FINAL_STATS: rc = main_cracker_final_stats (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break; + case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_REMOVE_PARSE_PRE: rc = main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_REMOVE_PARSE_POST: rc = main_potfile_remove_parse_post (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_NUM_CRACKED: rc = main_potfile_num_cracked (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_ALL_CRACKED: rc = main_potfile_all_cracked (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_PRE: rc = main_opencl_session_pre (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_POST: rc = main_opencl_session_post (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_PRE: rc = main_bitmap_init_pre (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_POST: rc = main_bitmap_init_post (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_PRE: rc = main_weak_hash_pre (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_POST: rc = main_weak_hash_post (hashcat_ctx, buf, len); break; + case EVENT_SET_KERNEL_POWER_FINAL: rc = main_set_kernel_power_final (hashcat_ctx, buf, len); break; } return rc; From 2a5545d2b7d906b1793687382230927731521af1 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:23:21 +0200 Subject: [PATCH 018/106] Move logfile stuff back to hashcat.c, it's a core feature which should be handled by the library --- include/types.h | 5 ---- src/hashcat.c | 36 +++++++++++++++++++------- src/main.c | 68 ------------------------------------------------- 3 files changed, 27 insertions(+), 82 deletions(-) diff --git a/include/types.h b/include/types.h index a71af3800..5ed9149d7 100644 --- a/include/types.h +++ b/include/types.h @@ -82,10 +82,6 @@ typedef enum event_identifier EVENT_LOG_ERROR = 0x00000003, EVENT_WELCOME_SCREEN = 0x00000011, EVENT_GOODBYE_SCREEN = 0x00000012, - EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021, - EVENT_LOGFILE_TOP_FINALIZE = 0x00000022, - EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023, - EVENT_LOGFILE_SUB_FINALIZE = 0x00000024, EVENT_OUTERLOOP_STARTING = 0x00000031, EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, EVENT_OUTERLOOP_FINISHED = 0x00000033, @@ -98,7 +94,6 @@ typedef enum event_identifier EVENT_AUTOTUNE_FINISHED = 0x00000054, EVENT_CRACKER_STARTING = 0x00000055, EVENT_CRACKER_FINISHED = 0x00000056, - EVENT_CRACKER_FINAL_STATS = 0x00000057, EVENT_CRACKER_HASH_CRACKED = 0x00000058, EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061, EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062, diff --git a/src/hashcat.c b/src/hashcat.c index e99f13a2f..a547a4c4c 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -146,7 +146,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - EVENT (EVENT_LOGFILE_SUB_INITIALIZE); + logfile_generate_subid (hashcat_ctx); + + logfile_sub_msg ("START"); status_progress_reset (hashcat_ctx); @@ -315,8 +317,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_EXHAUSTED; } - EVENT (EVENT_CRACKER_FINISHED); - // update some timer time_t runtime_stop; @@ -330,7 +330,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) time (&status_ctx->prepare_start); - EVENT (EVENT_CRACKER_FINAL_STATS); + EVENT (EVENT_CRACKER_FINISHED); // no more skip and restore from here @@ -339,6 +339,12 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) rd->words_cur = 0; } + // mark sub logfile + + logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); + + logfile_sub_msg ("STOP"); + // stop loopback recording if (user_options->loopback == true) @@ -346,8 +352,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) loopback_write_close (hashcat_ctx); } - EVENT (EVENT_LOGFILE_SUB_FINALIZE); - // New induction folder check if (induct_ctx->induction_dictionaries_cnt == 0) @@ -847,9 +851,21 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options_extra_init (hashcat_ctx); - // from here all user configuration is pre-processed so we can start logging if we want to + /** + * logfile + */ - EVENT (EVENT_LOGFILE_TOP_INITIALIZE); + const int rc_logfile_init = logfile_init (hashcat_ctx); + + if (rc_logfile_init == -1) return -1; + + logfile_generate_topid (hashcat_ctx); + + logfile_top_msg ("START"); + + // add all user options to logfile in case we want to debug some user session + + user_options_logger (hashcat_ctx); /** * cpu affinity @@ -1032,12 +1048,14 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_top_uint (status_ctx->proc_start); logfile_top_uint (status_ctx->proc_stop); - EVENT (EVENT_LOGFILE_TOP_FINALIZE); + logfile_top_msg ("STOP"); // free memory EVENT (EVENT_GOODBYE_SCREEN); + logfile_destroy (hashcat_ctx); + debugfile_destroy (hashcat_ctx); tuning_db_destroy (hashcat_ctx); diff --git a/src/main.c b/src/main.c index fc4f29eff..c584a0190 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,6 @@ #include "memory.h" #include "terminal.h" -#include "logfile.h" #include "thread.h" #include "status.h" #include "interface.h" @@ -108,58 +107,6 @@ static int main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U return 0; } -static int main_logfile_top_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - - // logfile init - - const int rc_logfile_init = logfile_init (hashcat_ctx); - - if (rc_logfile_init == -1) return -1; - - logfile_generate_topid (hashcat_ctx); - - logfile_top_msg ("START"); - - // add all user options to logfile in case we want to debug some user session - - user_options_logger (hashcat_ctx); - - return 0; -} - -static int main_logfile_top_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - - logfile_top_msg ("STOP"); - - logfile_destroy (hashcat_ctx); - - return 0; -} - -static int main_logfile_sub_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - - logfile_generate_subid (hashcat_ctx); - - logfile_sub_msg ("START"); - - return 0; -} - -static int main_logfile_sub_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - - logfile_sub_msg ("STOP"); - - return 0; -} - static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -240,16 +187,6 @@ static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE } static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - - logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); - - return 0; -} - -static int main_cracker_final_stats (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -554,16 +491,11 @@ int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break; case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break; case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break; - case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break; case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break; case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break; case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_FINAL_STATS: rc = main_cracker_final_stats (hashcat_ctx, buf, len); break; case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break; case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break; case EVENT_POTFILE_REMOVE_PARSE_PRE: rc = main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; From 60000136fe4914a9252be6fbe7cbb09137eaebc1 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 11:27:50 +0200 Subject: [PATCH 019/106] Hand merged https://github.com/hashcat/hashcat/pull/533 --- src/Makefile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Makefile b/src/Makefile index f16476458..242a7d100 100644 --- a/src/Makefile +++ b/src/Makefile @@ -102,6 +102,15 @@ CFLAGS += -fsanitize=address -fno-omit-frame-pointer endif endif +## +## Linker flags +## +ifndef DEBUG +LDFLAGS += -s +endif + + + ## ## Native compilation target ## @@ -118,9 +127,6 @@ endif # darwin ifeq ($(UNAME),Linux) CFLAGS_NATIVE := -ifndef DEBUG -CFLAGS_NATIVE += -s -endif CFLAGS_NATIVE += $(CFLAGS) LFLAGS_NATIVE := -lpthread -ldl CFLAGS_NATIVE += -DWITH_HWMON @@ -139,17 +145,11 @@ endif # freebsd ## CFLAGS_CROSS_LINUX := -ifndef DEBUG -CFLAGS_CROSS_LINUX += -s -endif CFLAGS_CROSS_LINUX += $(CFLAGS) CFLAGS_CROSS_LINUX += -DWITH_HWMON #CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1 CFLAGS_CROSS_WIN := -ifndef DEBUG -CFLAGS_CROSS_WIN += -s -endif CFLAGS_CROSS_WIN += $(filter-out -fsanitize=address,$(CFLAGS)) CFLAGS_CROSS_WIN += -DWITH_HWMON From 26fd67d932ae80796c28bf620978530e7a54ee19 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 10 Oct 2016 13:10:50 +0200 Subject: [PATCH 020/106] Inline outfile_format_plain() --- src/outfile.c | 107 ++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/src/outfile.c b/src/outfile.c index 7067d697c..fff42f415 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -7,6 +7,7 @@ #include "types.h" #include "memory.h" #include "event.h" +#include "convert.h" #include "interface.h" #include "hashes.h" #include "mpsp.h" @@ -256,49 +257,6 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para } } -static void outfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len) -{ - outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; - - bool needs_hexify = false; - - if (outfile_ctx->outfile_autohex == true) - { - for (u32 i = 0; i < plain_len; i++) - { - if (plain_ptr[i] < 0x20) - { - needs_hexify = true; - - break; - } - - if (plain_ptr[i] > 0x7f) - { - needs_hexify = true; - - break; - } - } - } - - if (needs_hexify == true) - { - fprintf (outfile_ctx->fp, "$HEX["); - - for (u32 i = 0; i < plain_len; i++) - { - fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]); - } - - fprintf (outfile_ctx->fp, "]"); - } - else - { - fwrite (plain_ptr, plain_len, 1, outfile_ctx->fp); - } -} - int outfile_init (hashcat_ctx_t *hashcat_ctx) { outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; @@ -364,38 +322,69 @@ void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsig hashconfig_t *hashconfig = hashcat_ctx->hashconfig; outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + char tmp_buf[HCBUFSIZ_LARGE]; + int tmp_len = 0; + if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH) { - fprintf (outfile_ctx->fp, "%s", out_buf); + const size_t out_len = strlen (out_buf); + + memcpy (tmp_buf + tmp_len, out_buf, out_len); + + tmp_len += out_len; if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) { - fputc (hashconfig->separator, outfile_ctx->fp); + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; } } else if (user_len) { if (username != NULL) { - for (u32 i = 0; i < user_len; i++) - { - fprintf (outfile_ctx->fp, "%c", username[i]); - } + memcpy (tmp_buf + tmp_len, username, user_len); + + tmp_len += user_len; if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) { - fputc (hashconfig->separator, outfile_ctx->fp); + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; } } } if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN) { - outfile_format_plain (hashcat_ctx, plain_ptr, plain_len); + if (need_hexify (plain_ptr, plain_len) == true) + { + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; + + exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += plain_len * 2; + + tmp_buf[tmp_len++] = ']'; + } + else + { + memcpy (tmp_buf + tmp_len, plain_ptr, plain_len); + + tmp_len += plain_len; + } if (outfile_ctx->outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) { - fputc (hashconfig->separator, outfile_ctx->fp); + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; } } @@ -403,21 +392,27 @@ void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsig { for (u32 i = 0; i < plain_len; i++) { - fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]); + exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += 2; } if (outfile_ctx->outfile_format & (OUTFILE_FMT_CRACKPOS)) { - fputc (hashconfig->separator, outfile_ctx->fp); + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; } } if (outfile_ctx->outfile_format & OUTFILE_FMT_CRACKPOS) { - fprintf (outfile_ctx->fp, "%" PRIu64, crackpos); + sprintf (tmp_buf + tmp_len, "%" PRIu64, crackpos); } - fputs (EOL, outfile_ctx->fp); + tmp_buf[tmp_len] = 0; + + fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf); } int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx) From ab8d2eb33659a3e95f7c0410cd05d8bbd7c0cd20 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 09:46:18 +0200 Subject: [PATCH 021/106] Fix newlines in help menu --- src/outfile.c | 4 ++-- src/usage.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/outfile.c b/src/outfile.c index fff42f415..85f250749 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -319,8 +319,8 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx) void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; char tmp_buf[HCBUFSIZ_LARGE]; int tmp_len = 0; diff --git a/src/usage.c b/src/usage.c index 71de716e4..a7b1d5ca9 100644 --- a/src/usage.c +++ b/src/usage.c @@ -410,10 +410,18 @@ static const char *USAGE_BIG[] = void usage_mini_print (const char *progname) { - for (int i = 0; USAGE_MINI[i] != NULL; i++) printf (USAGE_MINI[i], progname); + for (int i = 0; USAGE_MINI[i] != NULL; i++) + { + printf (USAGE_MINI[i], progname); + printf (EOL); + } } void usage_big_print (const char *progname) { - for (int i = 0; USAGE_BIG[i] != NULL; i++) printf (USAGE_BIG[i], progname); + for (int i = 0; USAGE_BIG[i] != NULL; i++) + { + printf (USAGE_BIG[i], progname); + printf (EOL); + } } From af9de0a7b743fba52bddd4ac8e39cde260027cac Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 10:55:02 +0200 Subject: [PATCH 022/106] Fix some error string formats --- src/affinity.c | 6 +- src/autotune.c | 4 +- src/combinator.c | 16 ++-- src/debugfile.c | 2 +- src/dictstat.c | 8 +- src/dispatch.c | 6 +- src/folder.c | 12 +-- src/hashcat.c | 8 +- src/hashes.c | 30 ++++---- src/hwmon.c | 174 ++++++++++++++++++++++---------------------- src/induct.c | 8 +- src/interface.c | 4 +- src/logfile.c | 2 +- src/loopback.c | 2 +- src/memory.c | 6 +- src/monitor.c | 4 +- src/mpsp.c | 52 ++++++------- src/opencl.c | 106 +++++++++++++-------------- src/outfile.c | 4 +- src/outfile_check.c | 6 +- src/potfile.c | 4 +- src/restore.c | 31 ++++---- src/rp.c | 4 +- src/status.c | 16 ++-- src/stdout.c | 2 +- src/straight.c | 26 +++---- src/terminal.c | 6 +- src/user_options.c | 90 +++++++++++------------ 28 files changed, 319 insertions(+), 320 deletions(-) diff --git a/src/affinity.c b/src/affinity.c index 893ce1250..7f141a4f3 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -82,7 +82,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) if (cpu_id > 32) { - event_log_error (hashcat_ctx, "ERROR: Invalid cpu_id %u specified", cpu_id); + event_log_error (hashcat_ctx, "Invalid cpu_id %u specified", cpu_id); return (-1); } @@ -103,7 +103,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) if (SetThreadAffinityMask (GetCurrentThread (), aff_mask) == 0) { - event_log_error (hashcat_ctx, "ERROR: %s", "SetThreadAffinityMask()"); + event_log_error (hashcat_ctx, "%s", "SetThreadAffinityMask()"); return -1; } @@ -114,7 +114,7 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) if (pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s", "pthread_setaffinity_np()"); + event_log_error (hashcat_ctx, "%s", "pthread_setaffinity_np()"); return -1; } diff --git a/src/autotune.c b/src/autotune.c index f0203345e..9ca5e8955 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -99,7 +99,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -113,7 +113,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); return -1; } diff --git a/src/combinator.c b/src/combinator.c index 2bdbe8fa4..0db247519 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -52,14 +52,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((fp1 = fopen (dictfile1, "rb")) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } if (stat (dictfile1, &tmp_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); fclose (fp1); @@ -68,7 +68,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - event_log_error (hashcat_ctx, "ERROR: %s must be a regular file", dictfile1, strerror (errno)); + event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1, strerror (errno)); fclose (fp1); @@ -77,7 +77,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((fp2 = fopen (dictfile2, "rb")) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); fclose (fp1); @@ -86,7 +86,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (dictfile2, &tmp_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); fclose (fp1); fclose (fp2); @@ -96,7 +96,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISDIR (tmp_stat.st_mode)) { - event_log_error (hashcat_ctx, "ERROR: %s must be a regular file", dictfile2, strerror (errno)); + event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2, strerror (errno)); fclose (fp1); fclose (fp2); @@ -110,7 +110,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (words1_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: %s: empty file", dictfile1); + event_log_error (hashcat_ctx, "%s: empty file", dictfile1); fclose (fp1); fclose (fp2); @@ -124,7 +124,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (words2_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: %s: empty file", dictfile2); + event_log_error (hashcat_ctx, "%s: empty file", dictfile2); fclose (fp1); fclose (fp2); diff --git a/src/debugfile.c b/src/debugfile.c index 9f08d52fb..70614da0a 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -107,7 +107,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (debugfile_ctx->fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: Could not open debug-file for writing"); + event_log_error (hashcat_ctx, "Could not open debug-file for writing"); return -1; } diff --git a/src/dictstat.c b/src/dictstat.c index f6ff41783..6948fc299 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -52,7 +52,7 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno)); return -1; } @@ -101,7 +101,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) if (dictstat_ctx->cnt == MAX_DICTSTAT) { - event_log_error (hashcat_ctx, "ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); break; } @@ -120,7 +120,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictstat_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno)); return -1; } @@ -153,7 +153,7 @@ void dictstat_append (hashcat_ctx_t *hashcat_ctx, dictstat_t *d) if (dictstat_ctx->cnt == MAX_DICTSTAT) { - event_log_error (hashcat_ctx, "ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename); return; } diff --git a/src/dispatch.c b/src/dispatch.c index 65d01fcbb..701a6fe49 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -314,7 +314,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (fd == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); return; } @@ -331,7 +331,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (combs_fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); fclose (fd); @@ -348,7 +348,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (combs_fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfilec, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno)); fclose (fd); diff --git a/src/folder.c b/src/folder.c index 181342a11..5c09b1e2c 100644 --- a/src/folder.c +++ b/src/folder.c @@ -241,7 +241,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { - event_log_error (hashcat_ctx, "ERROR: getcwd(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "getcwd(): %s", strerror (errno)); return -1; } @@ -254,7 +254,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (exec_path == NULL) { - event_log_error (hashcat_ctx, "ERROR: get_exec_path() failed"); + event_log_error (hashcat_ctx, "get_exec_path() failed"); return -1; } @@ -268,14 +268,14 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (resolved_install_folder == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", resolved_install_folder, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", resolved_install_folder, strerror (errno)); return -1; } if (resolved_exec_path == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", resolved_exec_path, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", resolved_exec_path, strerror (errno)); return -1; } @@ -336,7 +336,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", cpath, "GetFullPathName()"); + event_log_error (hashcat_ctx, "%s: %s", cpath, "GetFullPathName()"); return -1; } @@ -349,7 +349,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (realpath (cpath, cpath_real) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", cpath, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", cpath, strerror (errno)); return -1; } diff --git a/src/hashcat.c b/src/hashcat.c index a547a4c4c..f62410354 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -200,7 +200,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->words_cur > status_ctx->words_base) { - event_log_error (hashcat_ctx, "ERROR: Restore value greater keyspace"); + event_log_error (hashcat_ctx, "Restore value greater keyspace"); return -1; } @@ -490,7 +490,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if (hashes->hashes_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: No hashes loaded"); + event_log_error (hashcat_ctx, "No hashes loaded"); return -1; } @@ -613,7 +613,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1)) { - event_log_error (hashcat_ctx, "ERROR: --skip/--limit are not supported with --increment or mask files"); + event_log_error (hashcat_ctx, "--skip/--limit are not supported with --increment or mask files"); return -1; } @@ -627,7 +627,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1)) { - event_log_error (hashcat_ctx, "ERROR: --keyspace is not supported with --increment or mask files"); + event_log_error (hashcat_ctx, "--keyspace is not supported with --increment or mask files"); return -1; } diff --git a/src/hashes.c b/src/hashes.c index 8cccb6dcc..d37f332a5 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -139,7 +139,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", new_hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno)); return -1; } @@ -198,7 +198,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) if (rename (hashfile, old_hashfile) != 0) { - event_log_error (hashcat_ctx, "ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno)); return -1; } @@ -207,7 +207,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) if (rename (new_hashfile, hashfile) != 0) { - event_log_error (hashcat_ctx, "ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno)); return -1; } @@ -324,7 +324,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueReadBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -341,7 +341,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueReadBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -411,7 +411,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -423,7 +423,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -477,7 +477,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (stat (hashes->hashfile, &st) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", hashes->hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", hashes->hashfile, strerror (errno)); return -1; } @@ -499,7 +499,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((fp = fopen (hashfile, "rb")) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); return -1; } @@ -512,7 +512,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (hashes_avail == 0) { - event_log_error (hashcat_ctx, "ERROR: hashfile is empty or corrupt"); + event_log_error (hashcat_ctx, "hashfile is empty or corrupt"); fclose (fp); @@ -523,7 +523,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((user_options->remove == 1) && (hashlist_format != HLFMT_HASHCAT)) { - event_log_error (hashcat_ctx, "ERROR: remove not supported in native hashfile-format mode"); + event_log_error (hashcat_ctx, "remove not supported in native hashfile-format mode"); fclose (fp); @@ -687,7 +687,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { if (hash_len == 0) { - event_log_error (hashcat_ctx, "ERROR: hccap file not specified"); + event_log_error (hashcat_ctx, "hccap file not specified"); return -1; } @@ -700,14 +700,14 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", hash_buf, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", hash_buf, strerror (errno)); return -1; } if (hashes_avail < 1) { - event_log_error (hashcat_ctx, "ERROR: hccap file is empty or corrupt"); + event_log_error (hashcat_ctx, "hccap file is empty or corrupt"); fclose (fp); @@ -880,7 +880,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if ((fp = fopen (hashfile, "rb")) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", hashfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); return -1; } diff --git a/src/hwmon.c b/src/hwmon.c index 55248235c..95ad3d41f 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -42,7 +42,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) else { //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled"); return -1; } @@ -52,7 +52,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) else { //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled"); return -1; } @@ -71,7 +71,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) if (!nvml->lib) { //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled."); + // event_log_error (hashcat_ctx, "NVML library load failed, proceed without NVML HWMon enabled"); return -1; } @@ -132,7 +132,7 @@ static int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlInit()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlInit(): %s", string); return -1; } @@ -152,7 +152,7 @@ static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlShutdown()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlShutdown(): %s", string); return -1; } @@ -172,7 +172,7 @@ static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsig { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetHandleByIndex(): %s", string); return -1; } @@ -193,7 +193,7 @@ static int hm_NVML_nvmlDeviceGetName (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t d { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetName(): %s", string); return -1; } @@ -214,7 +214,7 @@ static int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDev { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetTemperature(): %s", string); return -1; } @@ -234,7 +234,7 @@ static int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetFanSpeed(): %s", string); return -1; } @@ -255,7 +255,7 @@ static int hm_NVML_nvmlDeviceGetPowerUsage (hashcat_ctx_t *hashcat_ctx, nvmlDevi { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetPowerUsage(): %s", string); return -1; } @@ -276,7 +276,7 @@ static int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nv { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetUtilizationRates(): %s", string); return -1; } @@ -296,7 +296,7 @@ static int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevic { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetClockInfo()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetClockInfo(): %s", string); return -1; } @@ -316,7 +316,7 @@ static int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetTemperatureThreshold()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetTemperatureThreshold(): %s", string); return -1; } @@ -337,7 +337,7 @@ static int hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (hashcat_ctx_t *hashcat_c { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrPcieLinkGeneration()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetCurrPcieLinkGeneration(): %s", string); return -1; } @@ -358,7 +358,7 @@ static int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, n { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrPcieLinkWidth()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetCurrPcieLinkWidth(): %s", string); return -1; } @@ -379,7 +379,7 @@ static int hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (hashcat_ctx_t *has { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetCurrentClocksThrottleReasons()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetCurrentClocksThrottleReasons(): %s", string); return -1; } @@ -401,7 +401,7 @@ static int hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (hashcat_ctx_t *h { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetSupportedClocksThrottleReasons()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetSupportedClocksThrottleReasons(): %s", string); return -1; } @@ -423,7 +423,7 @@ static int hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx_t *hashcat_ctx, nvmlDev { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetComputeMode()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceSetComputeMode(): %s", string); return -1; } @@ -445,7 +445,7 @@ static int hm_NVML_nvmlDeviceSetGpuOperationMode (hashcat_ctx_t *hashcat_ctx, nv { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetGpuOperationMode()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceSetGpuOperationMode(): %s", string); return -1; } @@ -466,7 +466,7 @@ static int hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (hashcat_ctx_t * { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerManagementLimitConstraints()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetPowerManagementLimitConstraints(): %s", string); return -1; } @@ -486,7 +486,7 @@ static int hm_NVML_nvmlDeviceSetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceSetPowerManagementLimit()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceSetPowerManagementLimit(): %s", string); return -1; } @@ -506,7 +506,7 @@ static int hm_NVML_nvmlDeviceGetPowerManagementLimit (hashcat_ctx_t *hashcat_ctx { const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - event_log_error (hashcat_ctx, "%s %d %s\n", "nvmlDeviceGetPowerManagementLimit()", nvml_rc, string); + event_log_error (hashcat_ctx, "nvmlDeviceGetPowerManagementLimit(): %s", string); return -1; } @@ -537,7 +537,7 @@ static int nvapi_init (hashcat_ctx_t *hashcat_ctx) if (!nvapi->lib) { //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "load NVAPI library failed, proceed without NVAPI HWMon enabled."); + // event_log_error (hashcat_ctx, "load NVAPI library failed, proceed without NVAPI HWMon enabled"); return -1; } @@ -591,7 +591,7 @@ static int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_Initialize()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_Initialize(): %s", string); return -1; } @@ -613,7 +613,7 @@ static int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_Unload()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_Unload(): %s", string); return -1; } @@ -635,7 +635,7 @@ static int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuH hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_EnumPhysicalGPUs()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_EnumPhysicalGPUs(): %s", string); return -1; } @@ -657,7 +657,7 @@ static int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysi hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_GetPerfPoliciesInfo()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesInfo(): %s", string); return -1; } @@ -679,7 +679,7 @@ static int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhy hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_GetPerfPoliciesStatus()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesStatus(): %s", string); return -1; } @@ -701,7 +701,7 @@ static int hm_NvAPI_GPU_SetCoolerLevels (hashcat_ctx_t *hashcat_ctx, NvPhysicalG hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_SetCoolerLevels()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_GPU_SetCoolerLevels(): %s", string); return -1; } @@ -723,7 +723,7 @@ static int hm_NvAPI_GPU_RestoreCoolerSettings (hashcat_ctx_t *hashcat_ctx, NvPhy hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - event_log_error (hashcat_ctx, "%s %d %s\n", "NvAPI_GPU_RestoreCoolerSettings()", NvAPI_rc, string); + event_log_error (hashcat_ctx, "NvAPI_GPU_RestoreCoolerSettings(): %s", string); return -1; } @@ -765,9 +765,8 @@ static int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) if (xnvctrl->lib_x11 == NULL) { - //if (user_options->quiet == false) event_log_error (hashcat_ctx, "Failed loading the X11 library: %s", dlerror()); - //if (user_options->quiet == false) event_log_info (hashcat_ctx, " Please install libx11-dev package."); - //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + //event_log_error (hashcat_ctx, "Failed loading the X11 library: %s", dlerror()); + //event_log_error (hashcat_ctx, "Please install libx11-dev package"); return -1; } @@ -776,9 +775,8 @@ static int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) if (xnvctrl->lib_xnvctrl == NULL) { - //if (user_options->quiet == false) event_log_error (hashcat_ctx, "Failed loading the XNVCTRL library: %s", dlerror()); - //if (user_options->quiet == false) event_log_info (hashcat_ctx, " Please install libxnvctrl-dev package."); - //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + //event_log_error (hashcat_ctx, "Failed loading the XNVCTRL library: %s", dlerror()); + //event_log_error (hashcat_ctx, "Please install libxnvctrl-dev package"); return -1; } @@ -832,7 +830,7 @@ static int hm_XNVCTRL_XOpenDisplay (hashcat_ctx_t *hashcat_ctx) if (dpy == NULL) { - event_log_error (hashcat_ctx, "%s\n", "XOpenDisplay() failed"); + event_log_error (hashcat_ctx, "XOpenDisplay() failed"); return -1; } @@ -869,7 +867,7 @@ static int hm_XNVCTRL_get_fan_control (hashcat_ctx_t *hashcat_ctx, const int gpu if (rc == false) { - event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_COOLER_MANUAL_CONTROL) failed"); + event_log_error (hashcat_ctx, "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_COOLER_MANUAL_CONTROL) failed"); return -1; } @@ -919,7 +917,7 @@ static int hm_XNVCTRL_get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int if (rc == false) { - event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_CORE_THRESHOLD) failed"); + event_log_error (hashcat_ctx, "XNVCTRLQueryTargetAttribute(NV_CTRL_GPU_CORE_THRESHOLD) failed"); return -1; } @@ -942,7 +940,7 @@ static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const i if (rc == false) { - event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) failed"); + event_log_error (hashcat_ctx, "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL) failed"); return -1; } @@ -964,7 +962,7 @@ static int hm_XNVCTRL_get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const in if (rc == false) { - event_log_error (hashcat_ctx, "%s\n", "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_LEVEL) failed"); + event_log_error (hashcat_ctx, "%s", "XNVCTRLQueryTargetAttribute(NV_CTRL_THERMAL_COOLER_LEVEL) failed"); return -1; } @@ -1023,7 +1021,7 @@ static int adl_init (hashcat_ctx_t *hashcat_ctx) if (!adl->lib) { //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "load ADL library failed, proceed without ADL HWMon enabled."); + // event_log_error (hashcat_ctx, "load ADL library failed, proceed without ADL HWMon enabled"); return -1; } @@ -1091,7 +1089,7 @@ static int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Main_Control_Destroy()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Main_Control_Destroy(): %d", ADL_rc); return -1; } @@ -1109,7 +1107,7 @@ static int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALL if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Main_Control_Create()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Main_Control_Create(): %d", ADL_rc); return -1; } @@ -1127,7 +1125,7 @@ static int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_NumberOfAdapters_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Adapter_NumberOfAdapters_Get(): %d", ADL_rc); return -1; } @@ -1145,7 +1143,7 @@ static int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapter if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_AdapterInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Adapter_AdapterInfo_Get(): %d", ADL_rc); return -1; } @@ -1164,7 +1162,7 @@ static int hm_ADL_Display_DisplayInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdap if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Display_DisplayInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Display_DisplayInfo_Get(): %d", ADL_rc); return -1; } @@ -1184,7 +1182,7 @@ static int hm_ADL_Adapter_ID_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_ID_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Adapter_ID_Get(): %d", ADL_rc); return -1; } @@ -1204,7 +1202,7 @@ static int hm_ADL_Adapter_VideoBiosInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAd if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_VideoBiosInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Adapter_VideoBiosInfo_Get(): %d", ADL_rc); return -1; } @@ -1224,7 +1222,7 @@ static int hm_ADL_Overdrive_ThermalDevices_Enum (hashcat_ctx_t *hashcat_ctx, int if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ThermalDevices_Enum()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_ThermalDevices_Enum(): %d", ADL_rc); return -1; } @@ -1243,7 +1241,7 @@ static int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_Temperature_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_Temperature_Get(): %d", ADL_rc); return -1; } @@ -1261,7 +1259,7 @@ static int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_Temperature_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_Temperature_Get(): %d", ADL_rc); return -1; } @@ -1279,7 +1277,7 @@ static int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_CurrentActivity_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_CurrentActivity_Get(): %d", ADL_rc); return -1; } @@ -1297,7 +1295,7 @@ static int hm_ADL_Overdrive5_FanSpeedInfo_Get (hashcat_ctx_t *hashcat_ctx, int i if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeedInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeedInfo_Get(): %d", ADL_rc); return -1; } @@ -1315,7 +1313,7 @@ static int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdap if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeed_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeed_Get(): %d", ADL_rc); return -1; } @@ -1333,7 +1331,7 @@ static int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdap if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_FanSpeed_Get(): %d", ADL_rc); return -1; } @@ -1351,7 +1349,7 @@ static int hm_ADL_Overdrive5_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdap if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeed_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeed_Set(): %d", ADL_rc); return -1; } @@ -1369,7 +1367,7 @@ static int hm_ADL_Overdrive6_FanSpeed_Set (hashcat_ctx_t *hashcat_ctx, int iAdap if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_FanSpeed_Set(): %d", ADL_rc); return -1; } @@ -1387,7 +1385,7 @@ static int hm_ADL_Overdrive5_FanSpeedToDefault_Set (hashcat_ctx_t *hashcat_ctx, if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_FanSpeedToDefault_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeedToDefault_Set(): %d", ADL_rc); return -1; } @@ -1406,7 +1404,7 @@ static int hm_ADL_Overdrive_ODParameters_Get (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODParameters_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_ODParameters_Get(): %d", ADL_rc); return -1; } @@ -1426,7 +1424,7 @@ static int hm_ADL_Overdrive_ODPerformanceLevels_Get (hashcat_ctx_t *hashcat_ctx, if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_ODPerformanceLevels_Get(): %d", ADL_rc); return -1; } @@ -1446,7 +1444,7 @@ static int hm_ADL_Overdrive_ODPerformanceLevels_Set (hashcat_ctx_t *hashcat_ctx, if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive5_ODPerformanceLevels_Set(): %d", ADL_rc); return -1; } @@ -1465,7 +1463,7 @@ static int hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx_t *hashcat_ctx, in if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControlInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_PowerControlInfo_Get(): %d", ADL_rc); return -1; } @@ -1485,7 +1483,7 @@ static int hm_ADL_Overdrive_PowerControl_Get (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_PowerControl_Get(): %d", ADL_rc); return -1; } @@ -1527,7 +1525,7 @@ static int hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_PowerControl_Set(): %d", ADL_rc); return -1; } @@ -1546,7 +1544,7 @@ static int hm_ADL_Adapter_Active_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIn if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Adapter_Active_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Adapter_Active_Get(): %d", ADL_rc); return -1; } @@ -1566,7 +1564,7 @@ static int hm_ADL_DisplayEnable_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterInd if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_DisplayEnable_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_DisplayEnable_Set(): %d", ADL_rc); return -1; } @@ -1585,7 +1583,7 @@ static int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive_Caps()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive_Caps(): %d", ADL_rc); return -1; } @@ -1603,7 +1601,7 @@ static int hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx_t *hashcat_ctx, int if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_PowerControl_Caps()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_PowerControl_Caps(): %d", ADL_rc); return -1; } @@ -1621,7 +1619,7 @@ static int hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx_t *hashcat_ctx, int iA if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_Capabilities_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_Capabilities_Get(): %d", ADL_rc); return -1; } @@ -1686,7 +1684,7 @@ static int hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx_t *hashcat_ctx, int iAdap } else { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_StateInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_StateInfo_Get(): %d", ADL_rc); return -1; } @@ -1705,7 +1703,7 @@ static int hm_ADL_Overdrive_CurrentStatus_Get (hashcat_ctx_t *hashcat_ctx, int i if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_CurrentStatus_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_CurrentStatus_Get(): %d", ADL_rc); return -1; } @@ -1760,7 +1758,7 @@ static int hm_ADL_Overdrive_State_Set (hashcat_ctx_t *hashcat_ctx, int iAdapterI if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_State_Set()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_State_Set(): %d", ADL_rc); return -1; } @@ -1778,7 +1776,7 @@ static int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_c if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_TargetTemperatureData_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_TargetTemperatureData_Get(): %d", ADL_rc); return -1; } @@ -1797,7 +1795,7 @@ static int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (hashcat_ctx_t *hash if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_TargetTemperatureRangeInfo_Get()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_TargetTemperatureRangeInfo_Get(): %d", ADL_rc); return -1; } @@ -1816,7 +1814,7 @@ static int hm_ADL_Overdrive6_FanSpeed_Reset (hashcat_ctx_t *hashcat_ctx, int iAd if (ADL_rc != ADL_OK) { - event_log_error (hashcat_ctx, "%s: %d\n", "ADL_Overdrive6_FanSpeed_Reset()", ADL_rc); + event_log_error (hashcat_ctx, "ADL_Overdrive6_FanSpeed_Reset(): %d", ADL_rc); return -1; } @@ -1834,7 +1832,7 @@ static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapter if (iNumberAdapters == 0) { - event_log_error (hashcat_ctx, "No ADL adapters found."); + event_log_error (hashcat_ctx, "No ADL adapters found"); return -1; } @@ -2975,7 +2973,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get ADL PowerControl Capabilities"); + event_log_error (hashcat_ctx, "Failed to get ADL PowerControl Capabilities"); return -1; } @@ -2995,14 +2993,14 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (ADL_rc == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get current ADL PowerControl settings"); + event_log_error (hashcat_ctx, "Failed to get current ADL PowerControl settings"); return -1; } if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to set new ADL PowerControl values"); + event_log_error (hashcat_ctx, "Failed to set new ADL PowerControl values"); return -1; } @@ -3015,7 +3013,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive_StateInfo_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &hwmon_ctx->od_clock_mem_status[device_id])) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get ADL memory and engine clock frequency"); + event_log_error (hashcat_ctx, "Failed to get ADL memory and engine clock frequency"); return -1; } @@ -3026,7 +3024,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive_Capabilities_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &caps)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get ADL device capabilities"); + event_log_error (hashcat_ctx, "Failed to get ADL device capabilities"); return -1; } @@ -3063,7 +3061,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - event_log_info (hashcat_ctx, "ERROR: Failed to set ADL performance state"); + event_log_info (hashcat_ctx, "Failed to set ADL performance state"); return -1; } @@ -3080,14 +3078,14 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get current ADL PowerControl settings"); + event_log_error (hashcat_ctx, "Failed to get current ADL PowerControl settings"); return -1; } if ((ADL_rc = hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, powertune.iMaxValue)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to set new ADL PowerControl values"); + event_log_error (hashcat_ctx, "Failed to set new ADL PowerControl values"); return -1; } @@ -3258,7 +3256,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) == -1) { - event_log_error (hashcat_ctx, "ERROR: Failed to get ADL PowerControl Capabilities"); + event_log_error (hashcat_ctx, "Failed to get ADL PowerControl Capabilities"); continue; } @@ -3269,7 +3267,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, hwmon_ctx->od_power_control_status[device_id])) == -1) { - event_log_info (hashcat_ctx, "ERROR: Failed to restore the ADL PowerControl values"); + event_log_info (hashcat_ctx, "Failed to restore the ADL PowerControl values"); continue; } @@ -3287,7 +3285,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - event_log_info (hashcat_ctx, "ERROR: Failed to restore ADL performance state"); + event_log_info (hashcat_ctx, "Failed to restore ADL performance state"); continue; } diff --git a/src/induct.c b/src/induct.c index 5d98a43f5..b2abf03a6 100644 --- a/src/induct.c +++ b/src/induct.c @@ -64,14 +64,14 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (rename (root_directory, root_directory_mv) != 0) { - event_log_error (hashcat_ctx, "ERROR: Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno)); + event_log_error (hashcat_ctx, "Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno)); return -1; } } else { - event_log_error (hashcat_ctx, "ERROR: %s: %s", root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", root_directory, strerror (errno)); return -1; } @@ -79,7 +79,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (hc_mkdir (root_directory, 0700) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", root_directory, strerror (errno)); return -1; } @@ -142,7 +142,7 @@ void induct_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: %s: %s", induct_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", induct_ctx->root_directory, strerror (errno)); //return -1; } diff --git a/src/interface.c b/src/interface.c index 6cd957295..821fb245d 100644 --- a/src/interface.c +++ b/src/interface.c @@ -19577,7 +19577,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->dgst_pos3 = 3; break; - default: event_log_error (hashcat_ctx, "ERROR: Unknown hash-type '%u' selected", hashconfig->hash_mode); + default: event_log_error (hashcat_ctx, "Unknown hash-type '%u' selected", hashconfig->hash_mode); return -1; } @@ -19589,7 +19589,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: Parameter hex-salt not valid for hash-type %u", hashconfig->hash_mode); + event_log_error (hashcat_ctx, "Parameter hex-salt not valid for hash-type %u", hashconfig->hash_mode); return -1; } diff --git a/src/logfile.c b/src/logfile.c index 0fc3804d9..05aff8bc6 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -90,7 +90,7 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", logfile_ctx->logfile, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno)); return -1; } diff --git a/src/loopback.c b/src/loopback.c index afbc66941..7da270eee 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -105,7 +105,7 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx) if (loopback_ctx->fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", loopback_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno)); return -1; } diff --git a/src/memory.c b/src/memory.c index e02093692..fd04c4ab7 100644 --- a/src/memory.c +++ b/src/memory.c @@ -14,7 +14,7 @@ void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) if (p == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); exit (-1); } @@ -28,7 +28,7 @@ void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) if (p == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); exit (-1); } @@ -44,7 +44,7 @@ void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, cons if (p == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s", MSG_ENOMEM); + event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); exit (-1); } diff --git a/src/monitor.c b/src/monitor.c index edfd24642..69e006daa 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -157,7 +157,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (temperature > (int) user_options->gpu_temp_abort) { - event_log_error (hashcat_ctx, "ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1); + event_log_error (hashcat_ctx, "Temperature limit on GPU %d reached, aborting...", device_id + 1); myabort (hashcat_ctx); @@ -271,7 +271,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) { if (user_options->benchmark == false) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "\nNOTE: Runtime limit reached, aborting...\n"); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "NOTE: Runtime limit reached, aborting..."); } myabort (hashcat_ctx); diff --git a/src/mpsp.c b/src/mpsp.c index 8ac698b9b..800fcfb5c 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -167,7 +167,7 @@ static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *cs if (css_cnt > SP_PW_MAX) { - event_log_error (hashcat_ctx, "ERROR: Mask length is too long"); + event_log_error (hashcat_ctx, "Mask length is too long"); return -1; } @@ -259,16 +259,16 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c break; case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset); break; - case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 1 is undefined"); return -1; } + case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return -1; } mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset); break; - case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 2 is undefined"); return -1; } + case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return -1; } mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset); break; - case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 3 is undefined"); return -1; } + case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return -1; } mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset); break; - case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 4 is undefined"); return -1; } + case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return -1; } mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset); break; case '?': mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); @@ -285,7 +285,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c if (in_pos == in_len) { - event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf); + event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf); return -1; } @@ -294,7 +294,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) { - event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask %s", in_buf); + event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", in_buf); return -1; } @@ -355,21 +355,21 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask break; case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css, css_pos); break; - case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 1 is undefined\n"); return NULL; } + case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return NULL; } mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css, css_pos); break; - case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 2 is undefined\n"); return NULL; } + case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return NULL; } mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css, css_pos); break; - case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 3 is undefined\n"); return NULL; } + case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return NULL; } mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css, css_pos); break; - case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "ERROR: Custom-charset 4 is undefined\n"); return NULL; } + case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return NULL; } mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css, css_pos); break; case '?': mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); break; - default: event_log_error (hashcat_ctx, "ERROR: Syntax error: %s", mask_buf); + default: event_log_error (hashcat_ctx, "Syntax error: %s", mask_buf); return NULL; } } @@ -383,7 +383,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask if (mask_pos == mask_len) { - event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); + event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); return NULL; } @@ -394,7 +394,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) { - event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask %s", mask_buf); + event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", mask_buf); return NULL; } @@ -417,7 +417,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask if (css_pos == 0) { - event_log_error (hashcat_ctx, "ERROR: Invalid mask length (0)"); + event_log_error (hashcat_ctx, "Invalid mask length (0)"); return NULL; } @@ -461,7 +461,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask if (mask_pos == mask_len) { - event_log_error (hashcat_ctx, "ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); + event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); return NULL; } @@ -472,7 +472,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false)) { - event_log_error (hashcat_ctx, "ERROR: Invalid hex character detected in mask: %s", mask_buf); + event_log_error (hashcat_ctx, "Invalid hex character detected in mask: %s", mask_buf); return NULL; } @@ -1136,7 +1136,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); return -1; } @@ -1147,7 +1147,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); return -1; } @@ -1171,7 +1171,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "%s: unsupported file-type", arg); return -1; } @@ -1216,7 +1216,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); return -1; } @@ -1240,7 +1240,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "%s: unsupported file-type", arg); return -1; } @@ -1270,7 +1270,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", arg, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); return -1; } @@ -1294,7 +1294,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: %s: unsupported file-type", arg); + event_log_error (hashcat_ctx, "%s: unsupported file-type", arg); return -1; } @@ -1303,7 +1303,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->masks_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: Invalid mask"); + event_log_error (hashcat_ctx, "Invalid mask"); return -1; } @@ -1390,7 +1390,7 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx) if (mf_cnt >= MAX_MFS) { - event_log_error (hashcat_ctx, "ERROR: Invalid line '%s' in maskfile", mask_buf); + event_log_error (hashcat_ctx, "Invalid line '%s' in maskfile", mask_buf); return -1; } diff --git a/src/opencl.c b/src/opencl.c index a8abf5efb..de78d8c6b 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -114,7 +114,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char if (platform < 1 || platform > 32) { - event_log_error (hashcat_ctx, "ERROR: Invalid OpenCL platform %u specified", platform); + event_log_error (hashcat_ctx, "Invalid OpenCL platform %u specified", platform); return -1; } @@ -151,7 +151,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_ if (device_id < 1 || device_id > 32) { - event_log_error (hashcat_ctx, "ERROR: Invalid device_id %u specified", device_id); + event_log_error (hashcat_ctx, "Invalid device_id %u specified", device_id); return -1; } @@ -188,7 +188,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op if (device_type < 1 || device_type > 3) { - event_log_error (hashcat_ctx, "ERROR: Invalid device_type %u specified", device_type); + event_log_error (hashcat_ctx, "Invalid device_type %u specified", device_type); return -1; } @@ -230,7 +230,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi if (num_read != (size_t) st.st_size) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); return -1; } @@ -248,7 +248,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi } else { - event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); return -1; } @@ -264,7 +264,7 @@ static int write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, c if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", kernel_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); return -1; } @@ -382,7 +382,7 @@ int hc_clEnqueueNDRangeKernel (hashcat_ctx_t *hashcat_ctx, cl_command_queue comm if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueNDRangeKernel(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueNDRangeKernel(): %s", val2cstr_cl (CL_err)); return -1; } @@ -400,7 +400,7 @@ int hc_clGetEventInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_event_info if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetEventInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetEventInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -418,7 +418,7 @@ int hc_clFlush (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clFlush(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clFlush(): %s", val2cstr_cl (CL_err)); return -1; } @@ -436,7 +436,7 @@ int hc_clFinish (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clFinish(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clFinish(): %s", val2cstr_cl (CL_err)); return -1; } @@ -454,7 +454,7 @@ int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clSetKernelArg(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clSetKernelArg(): %s", val2cstr_cl (CL_err)); return -1; } @@ -472,7 +472,7 @@ int hc_clEnqueueWriteBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue comman if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -490,7 +490,7 @@ int hc_clEnqueueCopyBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -508,7 +508,7 @@ int hc_clEnqueueReadBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueReadBuffer(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueReadBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -526,7 +526,7 @@ int hc_clGetPlatformIDs (hashcat_ctx_t *hashcat_ctx, cl_uint num_entries, cl_pla if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformIDs(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetPlatformIDs(): %s", val2cstr_cl (CL_err)); return -1; } @@ -544,7 +544,7 @@ int hc_clGetPlatformInfo (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, c if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetPlatformInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetPlatformInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -562,7 +562,7 @@ int hc_clGetDeviceIDs (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_d if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); return -1; } @@ -580,7 +580,7 @@ int hc_clGetDeviceInfo (hashcat_ctx_t *hashcat_ctx, cl_device_id device, cl_devi if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetDeviceInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetDeviceInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -600,7 +600,7 @@ int hc_clCreateContext (hashcat_ctx_t *hashcat_ctx, cl_context_properties *prope if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateContext(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateContext(): %s", val2cstr_cl (CL_err)); return -1; } @@ -620,7 +620,7 @@ int hc_clCreateCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_ if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateCommandQueue(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateCommandQueue(): %s", val2cstr_cl (CL_err)); return -1; } @@ -640,7 +640,7 @@ int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_fl if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateBuffer(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -660,7 +660,7 @@ int hc_clCreateProgramWithSource (hashcat_ctx_t *hashcat_ctx, cl_context context if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithSource(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateProgramWithSource(): %s", val2cstr_cl (CL_err)); return -1; } @@ -680,7 +680,7 @@ int hc_clCreateProgramWithBinary (hashcat_ctx_t *hashcat_ctx, cl_context context if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateProgramWithBinary(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateProgramWithBinary(): %s", val2cstr_cl (CL_err)); return -1; } @@ -698,7 +698,7 @@ int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint n if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clBuildProgram(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clBuildProgram(): %s", val2cstr_cl (CL_err)); return -1; } @@ -718,7 +718,7 @@ int hc_clCreateKernel (hashcat_ctx_t *hashcat_ctx, cl_program program, const cha if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clCreateKernel(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clCreateKernel(): %s", val2cstr_cl (CL_err)); return -1; } @@ -736,7 +736,7 @@ int hc_clReleaseMemObject (hashcat_ctx_t *hashcat_ctx, cl_mem mem) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseMemObject(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseMemObject(): %s", val2cstr_cl (CL_err)); return -1; } @@ -754,7 +754,7 @@ int hc_clReleaseKernel (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseKernel(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseKernel(): %s", val2cstr_cl (CL_err)); return -1; } @@ -772,7 +772,7 @@ int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseProgram(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseProgram(): %s", val2cstr_cl (CL_err)); return -1; } @@ -790,7 +790,7 @@ int hc_clReleaseCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_command_queue comma if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseCommandQueue(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseCommandQueue(): %s", val2cstr_cl (CL_err)); return -1; } @@ -808,7 +808,7 @@ int hc_clReleaseContext (hashcat_ctx_t *hashcat_ctx, cl_context context) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseContext(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseContext(): %s", val2cstr_cl (CL_err)); return -1; } @@ -828,7 +828,7 @@ int hc_clEnqueueMapBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_ if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueMapBuffer(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueMapBuffer(): %s", val2cstr_cl (CL_err)); return -1; } @@ -846,7 +846,7 @@ int hc_clEnqueueUnmapMemObject (hashcat_ctx_t *hashcat_ctx, cl_command_queue com if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clEnqueueUnmapMemObject(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clEnqueueUnmapMemObject(): %s", val2cstr_cl (CL_err)); return -1; } @@ -864,7 +864,7 @@ int hc_clGetKernelWorkGroupInfo (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, c if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetKernelWorkGroupInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetKernelWorkGroupInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -882,7 +882,7 @@ int hc_clGetProgramBuildInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetProgramBuildInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetProgramBuildInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -900,7 +900,7 @@ int hc_clGetProgramInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_prog if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetProgramInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetProgramInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -918,7 +918,7 @@ int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clWaitForEvents(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clWaitForEvents(): %s", val2cstr_cl (CL_err)); return -1; } @@ -936,7 +936,7 @@ int hc_clGetEventProfilingInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_p if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clGetEventProfilingInfo(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clGetEventProfilingInfo(): %s", val2cstr_cl (CL_err)); return -1; } @@ -954,7 +954,7 @@ int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event) if (CL_err != CL_SUCCESS) { - event_log_error (hashcat_ctx, "ERROR: clReleaseEvent(): %s", val2cstr_cl (CL_err)); + event_log_error (hashcat_ctx, "clReleaseEvent(): %s", val2cstr_cl (CL_err)); return -1; } @@ -1970,7 +1970,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (opencl_platforms_filter > platform_cnt_mask) { - event_log_error (hashcat_ctx, "ERROR: The platform selected by the --opencl-platforms parameter is larger than the number of available platforms (%d)", platforms_cnt); + event_log_error (hashcat_ctx, "The platform selected by the --opencl-platforms parameter is larger than the number of available platforms (%d)", platforms_cnt); return -1; } @@ -2148,7 +2148,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err != CL_SUCCESS) { - //event_log_error (hashcat_ctx, "ERROR: clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); + //event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); //return -1; @@ -2774,7 +2774,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (devices_active == 0) { - event_log_error (hashcat_ctx, "ERROR: No devices found/left"); + event_log_error (hashcat_ctx, "No devices found/left"); return -1; } @@ -2787,7 +2787,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (opencl_ctx->devices_filter > devices_cnt_mask) { - event_log_error (hashcat_ctx, "ERROR: The device specified by the --opencl-devices parameter is larger than the number of available devices (%d)", devices_cnt); + event_log_error (hashcat_ctx, "The device specified by the --opencl-devices parameter is larger than the number of available devices (%d)", devices_cnt); return -1; } @@ -3156,7 +3156,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) || (hashes->salts_buf[i].scrypt_r != scrypt_r) || (hashes->salts_buf[i].scrypt_p != scrypt_p)) { - event_log_error (hashcat_ctx, "ERROR: Mixed scrypt settings not supported"); + event_log_error (hashcat_ctx, "Mixed scrypt settings not supported"); return -1; } @@ -3217,14 +3217,14 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if ((size_scrypt / 4) > device_param->device_maxmem_alloc) { - event_log_info (hashcat_ctx, "WARNING: Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_info (hashcat_ctx, "Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } if (size_scrypt > device_param->device_global_mem) { - event_log_info (hashcat_ctx, "WARNING: Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_info (hashcat_ctx, "Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } @@ -3239,7 +3239,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (tmto == tmto_stop) { - event_log_error (hashcat_ctx, "ERROR: Can't allocate enough device memory"); + event_log_error (hashcat_ctx, "Can't allocate enough device memory"); return -1; } @@ -3372,7 +3372,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (chdir (folder_config->cpath_real) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", folder_config->cpath_real, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", folder_config->cpath_real, strerror (errno)); return -1; } @@ -3416,7 +3416,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (fd == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: fopen(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "%s: fopen(): %s", files_names[i], strerror (errno)); return -1; } @@ -3427,7 +3427,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (n != 1) { - event_log_error (hashcat_ctx, "ERROR: %s: fread(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "%s: fread(): %s", files_names[i], strerror (errno)); return -1; } @@ -3468,7 +3468,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); return -1; } @@ -3672,7 +3672,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); return -1; } @@ -3813,7 +3813,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (stat (source_file, &sst) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", source_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); return -1; } @@ -3936,7 +3936,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (chdir (folder_config->cwd) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", folder_config->cwd, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno)); return -1; } diff --git a/src/outfile.c b/src/outfile.c index 85f250749..29f13cacd 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -300,7 +300,7 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx) if (outfile_ctx->fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", outfile_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno)); return -1; } @@ -487,7 +487,7 @@ int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx) if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (hc_stat)) == 0) { - event_log_error (hashcat_ctx, "ERROR: Hashfile and Outfile are not allowed to point to the same file"); + event_log_error (hashcat_ctx, "Hashfile and Outfile are not allowed to point to the same file"); return -1; } diff --git a/src/outfile_check.c b/src/outfile_check.c index 37b0a7e5c..d4abf49a0 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -356,7 +356,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (is_dir == 0) { - event_log_error (hashcat_ctx, "ERROR: Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory); + event_log_error (hashcat_ctx, "Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory); return -1; } @@ -365,7 +365,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hc_mkdir (outcheck_ctx->root_directory, 0700) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno)); return -1; } @@ -394,7 +394,7 @@ void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx) } else { - event_log_error (hashcat_ctx, "ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno)); //return -1; } diff --git a/src/potfile.c b/src/potfile.c index 797977a6f..39f5d40e9 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -250,7 +250,7 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) { - //log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno)); + //log_error ("%s: %s", potfile_ctx->filename, strerror (errno)); return -1; } @@ -389,7 +389,7 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", potfile_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno)); return -1; } diff --git a/src/restore.c b/src/restore.c index 0f708a934..08a89458c 100644 --- a/src/restore.c +++ b/src/restore.c @@ -68,7 +68,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (nread != 1) { - event_log_error (hashcat_ctx, "ERROR: Cannot read %s", eff_restore_file); + event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file); return -1; } @@ -104,7 +104,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (strcmp (argv0_r, pidbin_r) == 0) { - event_log_error (hashcat_ctx, "ERROR: Already an instance %s running on pid %d", pidbin, rd->pid); + event_log_error (hashcat_ctx, "Already an instance %s running on pid %d", pidbin, rd->pid); return -1; } @@ -127,7 +127,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) { if (strcmp (pidbin, pidbin2) == 0) { - event_log_error (hashcat_ctx, "ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid); + event_log_error (hashcat_ctx, "Already an instance %s running on pid %d", pidbin2, rd->pid); return -1; } @@ -142,7 +142,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (rd->version < RESTORE_VERSION_MIN) { - event_log_error (hashcat_ctx, "ERROR: Cannot use outdated %s. Please remove it.", eff_restore_file); + event_log_error (hashcat_ctx, "Cannot use outdated %s. Please remove it.", eff_restore_file); return -1; } @@ -177,7 +177,7 @@ static int init_restore (hashcat_ctx_t *hashcat_ctx) if (getcwd (rd->cwd, 255) == NULL) { - event_log_error (hashcat_ctx, "ERROR: getcwd(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "getcwd(): %s", strerror (errno)); return -1; } @@ -197,7 +197,7 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno)); return -1; } @@ -206,7 +206,7 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (fread (rd, sizeof (restore_data_t), 1, fp) != 1) { - event_log_error (hashcat_ctx, "ERROR: Can't read %s", eff_restore_file); + event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file); return -1; } @@ -219,7 +219,7 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) { if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL) { - event_log_error (hashcat_ctx, "ERROR: Can't read %s", eff_restore_file); + event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file); return -1; } @@ -239,10 +239,11 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) if (chdir (rd->cwd)) { - event_log_error (hashcat_ctx, "ERROR: The directory '%s' does not exist. It is needed to restore (--restore) the session.\n" - " You could either create this directory (or link it) or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n" - " https://github.com/philsmd/analyze_hc_restore\n" - " The directory must be relative to (or contain) all files/folders mentioned within the command line.", rd->cwd); + event_log_error (hashcat_ctx, + "The directory '%s' does not exist. It is needed to restore (--restore) the session.\n" + "You could either create this directory or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n" + "https://github.com/philsmd/analyze_hc_restore\n" + "The directory must contain all files and folders mentioned within the command line.", rd->cwd); return -1; } @@ -268,14 +269,14 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", new_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno)); return -1; } if (setvbuf (fp, NULL, _IONBF, 0)) { - event_log_error (hashcat_ctx, "ERROR: setvbuf file '%s': %s", new_restore_file, strerror (errno)); + event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno)); return -1; } @@ -434,7 +435,7 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (rd->version < RESTORE_VERSION_MIN) { - event_log_error (hashcat_ctx, "ERROR: Incompatible restore-file version"); + event_log_error (hashcat_ctx, "Incompatible restore-file version"); return -1; } diff --git a/src/rp.c b/src/rp.c index 61b47ed5d..b9b84a199 100644 --- a/src/rp.c +++ b/src/rp.c @@ -756,7 +756,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if ((fp = fopen (rp_file, "rb")) == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", rp_file, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno)); return -1; } @@ -860,7 +860,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: No valid rules left"); + event_log_error (hashcat_ctx, "No valid rules left"); return -1; } diff --git a/src/status.c b/src/status.c index 40b152b4a..28d981a85 100644 --- a/src/status.c +++ b/src/status.c @@ -159,14 +159,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -326,14 +326,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1184,14 +1184,14 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1243,14 +1243,14 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during initialization phase"); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "ERROR: status view is not available during autotune phase"); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } diff --git a/src/stdout.c b/src/stdout.c index 96d668e7c..a5f7a37ec 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -62,7 +62,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, } else { - event_log_error (hashcat_ctx, "ERROR: %s: %s", filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno)); out.fp = stdout; } diff --git a/src/straight.c b/src/straight.c index 97132d7ca..a9a2609a5 100644 --- a/src/straight.c +++ b/src/straight.c @@ -71,7 +71,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", straight_ctx->dict, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); return -1; } @@ -99,7 +99,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict1, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict1, strerror (errno)); return -1; } @@ -114,7 +114,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict2, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); return -1; } @@ -153,7 +153,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (fd2 == NULL) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", straight_ctx->dict, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); return -1; } @@ -274,7 +274,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno)); return -1; } @@ -297,7 +297,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno)); return -1; } @@ -319,7 +319,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "No usable dictionary file found."); return -1; } @@ -343,7 +343,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno)); return -1; } @@ -366,7 +366,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno)); return -1; } @@ -388,7 +388,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "No usable dictionary file found."); return -1; } @@ -403,7 +403,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l0_filename, &l0_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l0_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno)); return -1; } @@ -426,7 +426,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (l1_filename, &l1_stat) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", l1_filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno)); return -1; } @@ -448,7 +448,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (straight_ctx->dicts_cnt == 0) { - event_log_error (hashcat_ctx, "ERROR: No usable dictionary file found."); + event_log_error (hashcat_ctx, "No usable dictionary file found."); return -1; } diff --git a/src/terminal.c b/src/terminal.c index e8505166b..09b084045 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -70,21 +70,21 @@ int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) if (_setmode (_fileno (stdin), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", "stdin", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno)); return -1; } if (_setmode (_fileno (stdout), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", "stdout", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno)); return -1; } if (_setmode (_fileno (stderr), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "ERROR: %s: %s", "stderr", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno)); return -1; } diff --git a/src/user_options.c b/src/user_options.c index af4271028..9c4ef6549 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -320,7 +320,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) default: { - event_log_error (hashcat_ctx, "ERROR: Invalid argument specified"); + event_log_error (hashcat_ctx, "Invalid argument specified"); return -1; } @@ -329,7 +329,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (optopt != 0) { - event_log_error (hashcat_ctx, "ERROR: Invalid argument specified"); + event_log_error (hashcat_ctx, "Invalid argument specified"); return -1; } @@ -348,14 +348,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->hc_argc < 0) { - event_log_error (hashcat_ctx, "ERROR: hc_argc %d is invalid", user_options->hc_argc); + event_log_error (hashcat_ctx, "hc_argc %d is invalid", user_options->hc_argc); return -1; } if (user_options->hc_argv == NULL) { - event_log_error (hashcat_ctx, "ERROR: hc_argv is NULL"); + event_log_error (hashcat_ctx, "hc_argv is NULL"); return -1; } @@ -367,21 +367,21 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) && (user_options->attack_mode != ATTACK_MODE_HYBRID2) && (user_options->attack_mode != ATTACK_MODE_NONE)) { - event_log_error (hashcat_ctx, "ERROR: Invalid attack-mode specified"); + event_log_error (hashcat_ctx, "Invalid attack-mode specified"); return -1; } if (user_options->runtime_chgd == true && user_options->runtime == 0) { - event_log_error (hashcat_ctx, "ERROR: Invalid runtime specified"); + event_log_error (hashcat_ctx, "Invalid runtime specified"); return -1; } if (user_options->hash_mode > 14100) { - event_log_error (hashcat_ctx, "ERROR: Invalid hash-type specified"); + event_log_error (hashcat_ctx, "Invalid hash-type specified"); return -1; } @@ -393,7 +393,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) || ((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299)) || ((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799))) { - event_log_error (hashcat_ctx, "ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode)); + event_log_error (hashcat_ctx, "Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode)); return -1; } @@ -401,7 +401,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_format > 16) { - event_log_error (hashcat_ctx, "ERROR: Invalid outfile-format specified"); + event_log_error (hashcat_ctx, "Invalid outfile-format specified"); return -1; } @@ -410,7 +410,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_format_chgd == true) { - event_log_error (hashcat_ctx, "ERROR: Mixing outfile-format > 1 with left parameter is not allowed"); + event_log_error (hashcat_ctx, "Mixing outfile-format > 1 with left parameter is not allowed"); return -1; } @@ -420,7 +420,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_format_chgd == true) { - event_log_error (hashcat_ctx, "ERROR: Mixing outfile-format > 7 with show parameter is not allowed"); + event_log_error (hashcat_ctx, "Mixing outfile-format > 7 with show parameter is not allowed"); return -1; } @@ -428,49 +428,49 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->increment_min < INCREMENT_MIN) { - event_log_error (hashcat_ctx, "ERROR: Invalid increment-min specified"); + event_log_error (hashcat_ctx, "Invalid increment-min specified"); return -1; } if (user_options->increment_max > INCREMENT_MAX) { - event_log_error (hashcat_ctx, "ERROR: Invalid increment-max specified"); + event_log_error (hashcat_ctx, "Invalid increment-max specified"); return -1; } if (user_options->increment_min > user_options->increment_max) { - event_log_error (hashcat_ctx, "ERROR: Invalid increment-min specified"); + event_log_error (hashcat_ctx, "Invalid increment-min specified"); return -1; } if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT)) { - event_log_error (hashcat_ctx, "ERROR: Increment is not allowed in attack-mode 0"); + event_log_error (hashcat_ctx, "Increment is not allowed in attack-mode 0"); return -1; } if ((user_options->increment == false) && (user_options->increment_min_chgd == true)) { - event_log_error (hashcat_ctx, "ERROR: Increment-min is only supported combined with increment switch"); + event_log_error (hashcat_ctx, "Increment-min is only supported combined with increment switch"); return -1; } if ((user_options->increment == false) && (user_options->increment_max_chgd == true)) { - event_log_error (hashcat_ctx, "ERROR: Increment-max is only supported combined with increment switch"); + event_log_error (hashcat_ctx, "Increment-max is only supported combined with increment switch"); return -1; } if (user_options->rp_files_cnt > 0 && user_options->rp_gen == true) { - event_log_error (hashcat_ctx, "ERROR: Use of both rules-file and rules-generate is not supported"); + event_log_error (hashcat_ctx, "Use of both rules-file and rules-generate is not supported"); return -1; } @@ -479,7 +479,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) { - event_log_error (hashcat_ctx, "ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0"); + event_log_error (hashcat_ctx, "Use of rules-file or rules-generate only allowed in attack-mode 0"); return -1; } @@ -487,14 +487,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->bitmap_min > user_options->bitmap_max) { - event_log_error (hashcat_ctx, "ERROR: Invalid bitmap-min specified"); + event_log_error (hashcat_ctx, "Invalid bitmap-min specified"); return -1; } if (user_options->rp_gen_func_min > user_options->rp_gen_func_max) { - event_log_error (hashcat_ctx, "ERROR: Invalid rp-gen-func-min specified"); + event_log_error (hashcat_ctx, "Invalid rp-gen-func-min specified"); return -1; } @@ -513,14 +513,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->kernel_accel < 1) { - event_log_error (hashcat_ctx, "ERROR: Invalid kernel-accel specified"); + event_log_error (hashcat_ctx, "Invalid kernel-accel specified"); return -1; } if (user_options->kernel_accel > 1024) { - event_log_error (hashcat_ctx, "ERROR: Invalid kernel-accel specified"); + event_log_error (hashcat_ctx, "Invalid kernel-accel specified"); return -1; } @@ -540,14 +540,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->kernel_loops < 1) { - event_log_error (hashcat_ctx, "ERROR: Invalid kernel-loops specified"); + event_log_error (hashcat_ctx, "Invalid kernel-loops specified"); return -1; } if (user_options->kernel_loops > 1024) { - event_log_error (hashcat_ctx, "ERROR: Invalid kernel-loops specified"); + event_log_error (hashcat_ctx, "Invalid kernel-loops specified"); return -1; } @@ -555,7 +555,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if ((user_options->workload_profile < 1) || (user_options->workload_profile > 4)) { - event_log_error (hashcat_ctx, "ERROR: workload-profile %i not available", user_options->workload_profile); + event_log_error (hashcat_ctx, "workload-profile %i not available", user_options->workload_profile); return -1; } @@ -564,7 +564,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (is_power_of_2 (user_options->opencl_vector_width) == false || user_options->opencl_vector_width > 16) { - event_log_error (hashcat_ctx, "ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width); + event_log_error (hashcat_ctx, "opencl-vector-width %i not allowed", user_options->opencl_vector_width); return -1; } @@ -574,14 +574,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->remove == true) { - event_log_error (hashcat_ctx, "ERROR: Mixing remove parameter not allowed with show parameter or left parameter"); + event_log_error (hashcat_ctx, "Mixing remove parameter not allowed with show parameter or left parameter"); return -1; } if (user_options->potfile_disable == true) { - event_log_error (hashcat_ctx, "ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter"); + event_log_error (hashcat_ctx, "Mixing potfile-disable parameter not allowed with show parameter or left parameter"); return -1; } @@ -591,7 +591,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->outfile_autohex == false) { - event_log_error (hashcat_ctx, "ERROR: Mixing outfile-autohex-disable parameter not allowed with show parameter"); + event_log_error (hashcat_ctx, "Mixing outfile-autohex-disable parameter not allowed with show parameter"); return -1; } @@ -601,13 +601,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->show == true) { - event_log_error (hashcat_ctx, "ERROR: Combining show parameter with keyspace parameter is not allowed"); + event_log_error (hashcat_ctx, "Combining show parameter with keyspace parameter is not allowed"); return -1; } else if (user_options->left == true) { - event_log_error (hashcat_ctx, "ERROR: Combining left parameter with keyspace parameter is not allowed"); + event_log_error (hashcat_ctx, "Combining left parameter with keyspace parameter is not allowed"); return -1; } @@ -617,14 +617,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->remove == false) { - event_log_error (hashcat_ctx, "ERROR: Parameter remove-timer require parameter remove enabled"); + event_log_error (hashcat_ctx, "Parameter remove-timer require parameter remove enabled"); return -1; } if (user_options->remove_timer < 1) { - event_log_error (hashcat_ctx, "ERROR: Parameter remove-timer must have a value greater than or equal to 1"); + event_log_error (hashcat_ctx, "Parameter remove-timer must have a value greater than or equal to 1"); return -1; } @@ -636,14 +636,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - event_log_error (hashcat_ctx, "ERROR: Parameter loopback not allowed without rules-file or rules-generate"); + event_log_error (hashcat_ctx, "Parameter loopback not allowed without rules-file or rules-generate"); return -1; } } else { - event_log_error (hashcat_ctx, "ERROR: Parameter loopback allowed in attack-mode 0 only"); + event_log_error (hashcat_ctx, "Parameter loopback allowed in attack-mode 0 only"); return -1; } @@ -654,14 +654,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) { - event_log_error (hashcat_ctx, "ERROR: Parameter debug-mode option is only available with attack-mode 0"); + event_log_error (hashcat_ctx, "Parameter debug-mode option is only available with attack-mode 0"); return -1; } if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - event_log_error (hashcat_ctx, "ERROR: Parameter debug-mode not allowed without rules-file or rules-generate"); + event_log_error (hashcat_ctx, "Parameter debug-mode not allowed without rules-file or rules-generate"); return -1; } @@ -669,7 +669,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->debug_mode > 4) { - event_log_error (hashcat_ctx, "ERROR: Invalid debug-mode specified"); + event_log_error (hashcat_ctx, "Invalid debug-mode specified"); return -1; } @@ -678,7 +678,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->debug_mode < 1) { - event_log_error (hashcat_ctx, "ERROR: Parameter debug-file requires parameter debug-mode to be set"); + event_log_error (hashcat_ctx, "Parameter debug-file requires parameter debug-mode to be set"); return -1; } @@ -688,7 +688,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode == ATTACK_MODE_BF) { - event_log_error (hashcat_ctx, "ERROR: Parameter induction-dir not allowed with brute-force attacks"); + event_log_error (hashcat_ctx, "Parameter induction-dir not allowed with brute-force attacks"); return -1; } @@ -698,7 +698,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if ((user_options->weak_hash_threshold != WEAK_HASH_THRESHOLD) && (user_options->weak_hash_threshold != 0)) { - event_log_error (hashcat_ctx, "ERROR: setting --weak-hash-threshold allowed only in straight-attack mode"); + event_log_error (hashcat_ctx, "setting --weak-hash-threshold allowed only in straight-attack mode"); return -1; } @@ -706,7 +706,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->nvidia_spin_damp > 100) { - event_log_error (hashcat_ctx, "ERROR: setting --nvidia-spin-damp must be between 0 and 100 (inclusive)"); + event_log_error (hashcat_ctx, "setting --nvidia-spin-damp must be between 0 and 100 (inclusive)"); return -1; } @@ -715,7 +715,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->gpu_temp_abort < user_options->gpu_temp_retain) { - event_log_error (hashcat_ctx, "ERROR: Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); + event_log_error (hashcat_ctx, "Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain."); return -1; } @@ -727,7 +727,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { if (user_options->attack_mode != ATTACK_MODE_BF) { - event_log_error (hashcat_ctx, "ERROR: Only attack-mode 3 allowed in benchmark mode"); + event_log_error (hashcat_ctx, "Only attack-mode 3 allowed in benchmark mode"); return -1; } From bb4e381d1805dba5fbf8da3212b7748396e242be Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 11:04:13 +0200 Subject: [PATCH 023/106] Do not run keypress thread in case -I is used --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index c584a0190..b986b5eea 100644 --- a/src/main.c +++ b/src/main.c @@ -125,7 +125,7 @@ static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY status_ctx->shutdown_outer = false; - if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false) + if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->opencl_info == false) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { From afd44130fcbccc16fe655752610b574641960b7a Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 11:56:40 +0200 Subject: [PATCH 024/106] Prefix warning and error messages --- src/hashcat.c | 6 +++--- src/hashes.c | 2 ++ src/main.c | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index f62410354..15832edb7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1003,7 +1003,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold { const int rc = outer_loop (hashcat_ctx); - if (rc == -1) return -1; + if (rc == -1) myabort (hashcat_ctx); } else { @@ -1013,7 +1013,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold const int rc = outer_loop (hashcat_ctx); - if (rc == -1) return -1; + if (rc == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level1 == false) break; } @@ -1023,7 +1023,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold { const int rc = outer_loop (hashcat_ctx); - if (rc == -1) return -1; + if (rc == -1) myabort (hashcat_ctx); } EVENT (EVENT_OUTERLOOP_FINISHED); diff --git a/src/hashes.c b/src/hashes.c index d37f332a5..496f25174 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1052,6 +1052,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hc_qsort_r (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt, (void *) hashconfig); } + + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Sorted Hashes..."); } return 0; diff --git a/src/main.c b/src/main.c index b986b5eea..88ef3ba8a 100644 --- a/src/main.c +++ b/src/main.c @@ -69,6 +69,10 @@ static int main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED static int main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { + static const char PREFIX_WARNING[] = "WARNING: "; + + fwrite (PREFIX_WARNING, sizeof (PREFIX_WARNING), 1, stdout); + main_log (hashcat_ctx, buf, len, stdout); return 0; @@ -76,6 +80,10 @@ static int main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS static int main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { + static const char PREFIX_ERROR[] = "ERROR: "; + + fwrite (PREFIX_ERROR, sizeof (PREFIX_ERROR), 1, stderr); + main_log (hashcat_ctx, buf, len, stderr); return 0; From a3bf6fd4ef9f83218511671247b3c10b1405d174 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 12:18:06 +0200 Subject: [PATCH 025/106] Make use of nvmlDeviceGetCount() --- include/ext_nvml.h | 2 ++ src/hwmon.c | 47 +++++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/ext_nvml.h b/include/ext_nvml.h index b9ff6444f..9342b4e6e 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -168,6 +168,7 @@ typedef nvmlDevice_t HM_ADAPTER_NVML; typedef const char * (*NVML_API_CALL NVML_ERROR_STRING) (nvmlReturn_t); typedef int (*NVML_API_CALL NVML_INIT) (void); typedef int (*NVML_API_CALL NVML_SHUTDOWN) (void); +typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_COUNT) (unsigned int *); typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_NAME) (nvmlDevice_t, char *, unsigned int); typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_HANDLE_BY_INDEX) (unsigned int, nvmlDevice_t *); typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_TEMPERATURE) (nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *); @@ -199,6 +200,7 @@ typedef struct hm_nvml_lib NVML_ERROR_STRING nvmlErrorString; NVML_INIT nvmlInit; NVML_SHUTDOWN nvmlShutdown; + NVML_DEVICE_GET_COUNT nvmlDeviceGetCount; NVML_DEVICE_GET_NAME nvmlDeviceGetName; NVML_DEVICE_GET_HANDLE_BY_INDEX nvmlDeviceGetHandleByIndex; NVML_DEVICE_GET_TEMPERATURE nvmlDeviceGetTemperature; diff --git a/src/hwmon.c b/src/hwmon.c index 95ad3d41f..780500479 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -79,6 +79,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0) HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0) HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0) + HC_LOAD_FUNC(nvml, nvmlDeviceGetCount, NVML_DEVICE_GET_COUNT, NVML, 0) HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0) HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0) HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0) @@ -160,6 +161,26 @@ static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) return 0; } +static int hm_NVML_nvmlDeviceGetCount (hashcat_ctx_t *hashcat_ctx, unsigned int *deviceCount) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + NVML_PTR *nvml = hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCount (deviceCount); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetCount(): %s", string); + + return -1; + } + + return 0; +} + static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int index, nvmlDevice_t *device) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -1869,27 +1890,27 @@ static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NV static int hm_get_adapter_index_nvml (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVML *nvmlGPUHandle) { - int pGpuCount = 0; + unsigned int deviceCount = 0; - for (u32 i = 0; i < DEVICES_MAX; i++) - { - if (hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx, i, &nvmlGPUHandle[i]) == -1) break; + hm_NVML_nvmlDeviceGetCount (hashcat_ctx, &deviceCount); - // can be used to determine if the device by index matches the cuda device by index - // char name[100]; memset (name, 0, sizeof (name)); - // hm_NVML_nvmlDeviceGetName (hashcat_ctx, nvGPUHandle[i], name, sizeof (name) - 1); - - pGpuCount++; - } - - if (pGpuCount == 0) + if (deviceCount == 0) { event_log_error (hashcat_ctx, "No NVML adapters found"); return 0; } - return (pGpuCount); + for (u32 i = 0; i < deviceCount; i++) + { + if (hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx, i, &nvmlGPUHandle[i]) == -1) break; + + // can be used to determine if the device by index matches the cuda device by index + // char name[100]; memset (name, 0, sizeof (name)); + // hm_NVML_nvmlDeviceGetName (hashcat_ctx, nvGPUHandle[i], name, sizeof (name) - 1); + } + + return (deviceCount); } static void hm_sort_adl_adapters_by_busid_devid (u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo) From 6a697571fdfc47811450a12f138f02d2f9c13d4e Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 12:23:50 +0200 Subject: [PATCH 026/106] Remove debugging symbols from binary builds --- src/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 242a7d100..ecf889c72 100644 --- a/src/Makefile +++ b/src/Makefile @@ -156,8 +156,13 @@ CFLAGS_CROSS_WIN += -DWITH_HWMON CFLAGS_CROSS_32 := -m32 CFLAGS_CROSS_64 := -m64 -LFLAGS_CROSS_LINUX := -lpthread -ldl -LFLAGS_CROSS_WIN := -lpsapi +LFLAGS_CROSS_LINUX := +LFLAGS_CROSS_LINUX += $(LDFLAGS) +LFLAGS_CROSS_LINUX += -lpthread -ldl + +LFLAGS_CROSS_WIN := +LFLAGS_CROSS_WIN += $(LDFLAGS) +LFLAGS_CROSS_WIN += -lpsapi ## ## Objects From fa70e4487434a9719bf8246dd7f787fc345477b9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 13:38:35 +0200 Subject: [PATCH 027/106] Better handle rc == -1 --- src/hashcat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 15832edb7..d253928d4 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -726,7 +726,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_POTFILE_NUM_CRACKED); - // main call + // main call, also not we have some threads to care about, so don't return with -1 anywhere from here EVENT (EVENT_INNERLOOP1_STARTING); @@ -747,7 +747,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) return -1; + if (rc_inner1_loop == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level2 == false) break; } @@ -756,7 +756,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) return -1; + if (rc_inner1_loop == -1) myabort (hashcat_ctx); } // wait for inner threads From 20832d29d65564888b8389bed6becd130350a0a3 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 11 Oct 2016 15:02:54 +0200 Subject: [PATCH 028/106] Do not reset innerloop_left and outerloop_left too early so we can access it from status display --- src/hashcat.c | 6 +-- src/opencl.c | 10 ++-- src/status.c | 123 ++++++++++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index d253928d4..15832edb7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -726,7 +726,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_POTFILE_NUM_CRACKED); - // main call, also not we have some threads to care about, so don't return with -1 anywhere from here + // main call EVENT (EVENT_INNERLOOP1_STARTING); @@ -747,7 +747,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) myabort (hashcat_ctx); + if (rc_inner1_loop == -1) return -1; if (status_ctx->run_main_level2 == false) break; } @@ -756,7 +756,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) myabort (hashcat_ctx); + if (rc_inner1_loop == -1) return -1; } // wait for inner threads diff --git a/src/opencl.c b/src/opencl.c index de78d8c6b..63c650d14 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1861,14 +1861,16 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (status_ctx->run_thread_level2 == false) break; } - device_param->innerloop_pos = 0; - device_param->innerloop_left = 0; + //status screen makes use of this, can't reset here + //device_param->innerloop_pos = 0; + //device_param->innerloop_left = 0; if (status_ctx->run_thread_level2 == false) break; } - device_param->outerloop_pos = 0; - device_param->outerloop_left = 0; + //status screen makes use of this, can't reset here + //device_param->outerloop_pos = 0; + //device_param->outerloop_left = 0; device_param->speed_pos = speed_pos; diff --git a/src/status.c b/src/status.c index 28d981a85..5dc6217a7 100644 --- a/src/status.c +++ b/src/status.c @@ -865,69 +865,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } } - if (status_ctx->run_main_level1 == true) - { - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) - { - if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); - } - else - { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); - } - - continue; - } - - const u32 outerloop_first = 0; - const u32 outerloop_last = device_param->outerloop_left - 1; - - const u32 innerloop_first = 0; - const u32 innerloop_last = device_param->innerloop_left - 1; - - plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; - plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; - - u32 plain_buf1[16] = { 0 }; - u32 plain_buf2[16] = { 0 }; - - u8 *plain_ptr1 = (u8 *) plain_buf1; - u8 *plain_ptr2 = (u8 *) plain_buf2; - - int plain_len1 = 0; - int plain_len2 = 0; - - build_plain (hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); - build_plain (hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); - - bool need_hex1 = need_hexify (plain_ptr1, plain_len1); - bool need_hex2 = need_hexify (plain_ptr2, plain_len2); - - if ((need_hex1 == true) || (need_hex2 == true)) - { - exec_hexify (plain_ptr1, plain_len1, plain_ptr1); - exec_hexify (plain_ptr2, plain_len2, plain_ptr2); - - plain_ptr1[plain_len1 * 2] = 0; - plain_ptr2[plain_len2 * 2] = 0; - - event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); - } - else - { - event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); - } - } - } - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; @@ -1091,6 +1028,66 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->run_main_level1 == false) return; + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) + { + if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); + } + else + { + event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); + } + + continue; + } + + const u32 outerloop_first = 0; + const u32 outerloop_last = device_param->outerloop_left - 1; + + const u32 innerloop_first = 0; + const u32 innerloop_last = device_param->innerloop_left - 1; + + plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; + plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; + + u32 plain_buf1[16] = { 0 }; + u32 plain_buf2[16] = { 0 }; + + u8 *plain_ptr1 = (u8 *) plain_buf1; + u8 *plain_ptr2 = (u8 *) plain_buf2; + + int plain_len1 = 0; + int plain_len2 = 0; + + build_plain (hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); + build_plain (hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); + + bool need_hex1 = need_hexify (plain_ptr1, plain_len1); + bool need_hex2 = need_hexify (plain_ptr2, plain_len2); + + if ((need_hex1 == true) || (need_hex2 == true)) + { + exec_hexify (plain_ptr1, plain_len1, plain_ptr1); + exec_hexify (plain_ptr2, plain_len2, plain_ptr2); + + plain_ptr1[plain_len1 * 2] = 0; + plain_ptr2[plain_len2 * 2] = 0; + + event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + } + else + { + event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + } + } + if (user_options->gpu_temp_disable == false) { hc_thread_mutex_lock (status_ctx->mux_hwmon); From 386efb7fb5e2cf0cc26eb759a1a63380d1857926 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 11:27:10 +0200 Subject: [PATCH 029/106] Make use of EVENT_CRACKER_HASH_CRACKED, do not print a cracked hash to stdout directly, let the client do it --- include/event.h | 6 +- include/hashcat.h | 2 +- include/outfile.h | 2 +- include/types.h | 2 +- src/event.c | 6 +- src/hashcat.c | 2 +- src/hashes.c | 6 +- src/main.c | 188 +++++++++++++++++----------------------------- src/outfile.c | 27 +++---- src/potfile.c | 24 +++++- 10 files changed, 112 insertions(+), 153 deletions(-) diff --git a/include/event.h b/include/event.h index f3c8d42f9..cac3d15e1 100644 --- a/include/event.h +++ b/include/event.h @@ -9,10 +9,10 @@ #include #include -int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len); +void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len); -#define EVENT(id) { const int rc_event = event_call ((id), hashcat_ctx, NULL, 0); if (rc_event == -1) return -1; } -#define EVENT_DATA(id,buf,len) { const int rc_event = event_call ((id), hashcat_ctx, (buf), (len)); if (rc_event == -1) return -1; } +#define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0) +#define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len)) size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); diff --git a/include/hashcat.h b/include/hashcat.h index 0e01c74d6..3953cecd0 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -8,7 +8,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)); +void 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); #endif // _HASHCAT_H diff --git a/include/outfile.h b/include/outfile.h index af88cb4fc..965c95da1 100644 --- a/include/outfile.h +++ b/include/outfile.h @@ -18,7 +18,7 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx); int outfile_write_open (hashcat_ctx_t *hashcat_ctx); void outfile_write_close (hashcat_ctx_t *hashcat_ctx); -void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len); +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE]); int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx); #endif // _OUTFILE_H diff --git a/include/types.h b/include/types.h index 5ed9149d7..936c1e06c 100644 --- a/include/types.h +++ b/include/types.h @@ -1435,7 +1435,7 @@ typedef struct hashcat_ctx user_options_t *user_options; wl_data_t *wl_data; - int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t); + void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t); } hashcat_ctx_t; diff --git a/src/event.c b/src/event.c index 60a1fd672..63195d520 100644 --- a/src/event.c +++ b/src/event.c @@ -8,7 +8,7 @@ #include "thread.h" #include "event.h" -int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { bool need_mux = true; @@ -26,7 +26,7 @@ int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const hc_thread_mutex_lock (event_ctx->mux_event); } - const int rc = hashcat_ctx->event (id, hashcat_ctx, buf, len); + hashcat_ctx->event (id, hashcat_ctx, buf, len); if (need_mux == true) { @@ -34,8 +34,6 @@ int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const hc_thread_mutex_unlock (event_ctx->mux_event); } - - return rc; } static int event_log (const char *fmt, va_list ap, char *s, const size_t sz) diff --git a/src/hashcat.c b/src/hashcat.c index 15832edb7..c3aff6a30 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -55,7 +55,7 @@ extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)) +void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)) { if (event == NULL) { diff --git a/src/hashes.c b/src/hashes.c index 496f25174..b70af831f 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -272,10 +272,14 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (); - outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0); + char tmp_buf[HCBUFSIZ_LARGE]; + + const int tmp_len = outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, tmp_buf); outfile_write_close (hashcat_ctx); + EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { if ((status_ctx->devices_status != STATUS_CRACKED) && (user_options->status != true)) diff --git a/src/main.c b/src/main.c index 88ef3ba8a..d062d9141 100644 --- a/src/main.c +++ b/src/main.c @@ -60,36 +60,30 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t fflush (fp); } -static int main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { main_log (hashcat_ctx, buf, len, stdout); - - return 0; } -static int main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { static const char PREFIX_WARNING[] = "WARNING: "; fwrite (PREFIX_WARNING, sizeof (PREFIX_WARNING), 1, stdout); main_log (hashcat_ctx, buf, len, stdout); - - return 0; } -static int main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { static const char PREFIX_ERROR[] = "ERROR: "; fwrite (PREFIX_ERROR, sizeof (PREFIX_ERROR), 1, stderr); main_log (hashcat_ctx, buf, len, stderr); - - return 0; } -static int main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { // sets dos window size (windows only) @@ -100,22 +94,18 @@ static int main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; welcome_screen (hashcat_ctx, status_ctx->proc_start, VERSION_TAG); - - return 0; } -static int main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { // Inform user we're done const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop); - - return 0; } -static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -144,11 +134,9 @@ static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hashcat_user->outer_threads_cnt++; } } - - return 0; } -static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -165,16 +153,14 @@ static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY hcfree (hashcat_user->outer_threads); hashcat_user->outer_threads_cnt = 0; - - return 0; } -static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; // Tell the user we're about to start @@ -190,11 +176,9 @@ static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE event_log_info (hashcat_ctx, "Starting attack in stdin mode..."); event_log_info (hashcat_ctx, ""); } - - return 0; } -static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const hashes_t *hashes = hashcat_ctx->hashes; const user_options_t *user_options = hashcat_ctx->user_options; @@ -232,62 +216,52 @@ static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE } } } - - return 0; } -static int main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - const hashes_t *hashes = hashcat_ctx->hashes; - const user_options_t *user_options = hashcat_ctx->user_options; + outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; - if (hashes == NULL) hashes = NULL; - if (user_options == NULL) user_options = NULL; + if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile - return 0; + fwrite (buf, len, 1, stdout); + fwrite (EOL, sizeof (EOL), 1, stdout); } -static int main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->keyspace == true) - { - event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base); - } + if (user_options->keyspace == false) return; - return 0; + event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base); } -static int main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries..."); - - return 0; } -static int main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); - - return 0; } -static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const hashes_t *hashes = hashcat_ctx->hashes; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; const int potfile_remove_cracks = hashes->digests_done; @@ -304,23 +278,19 @@ static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA event_log_info (hashcat_ctx, ""); } } - - return 0; } -static int main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them."); event_log_info (hashcat_ctx, ""); - - return 0; } -static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -344,7 +314,7 @@ static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M } } - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); @@ -402,81 +372,67 @@ static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M #if defined (DEBUG) if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); #endif - - return 0; } -static int main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory..."); - - return 0; } -static int main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory..."); - - return 0; } -static int main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Checking for weak hashes..."); - - return 0; } -static int main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Checked for weak hashes..."); - - return 0; } -static int main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Generating bitmap tables..."); - - return 0; } -static int main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; event_log_info_nn (hashcat_ctx, "Generated bitmap tables..."); - - return 0; } -static int main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->quiet == true) return 0; + if (user_options->quiet == true) return; clear_prompt (); @@ -484,55 +440,45 @@ static int main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, event_log_info (hashcat_ctx, ""); send_prompt (); - - return 0; } -int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { - int rc = 0; - switch (id) { - case EVENT_LOG_INFO: rc = main_log_info (hashcat_ctx, buf, len); break; - case EVENT_LOG_WARNING: rc = main_log_warning (hashcat_ctx, buf, len); break; - case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break; - case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break; - case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break; - case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break; - case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_REMOVE_PARSE_PRE: rc = main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_REMOVE_PARSE_POST: rc = main_potfile_remove_parse_post (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_NUM_CRACKED: rc = main_potfile_num_cracked (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_ALL_CRACKED: rc = main_potfile_all_cracked (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_PRE: rc = main_opencl_session_pre (hashcat_ctx, buf, len); break; - case EVENT_OPENCL_SESSION_POST: rc = main_opencl_session_post (hashcat_ctx, buf, len); break; - case EVENT_BITMAP_INIT_PRE: rc = main_bitmap_init_pre (hashcat_ctx, buf, len); break; - case EVENT_BITMAP_INIT_POST: rc = main_bitmap_init_post (hashcat_ctx, buf, len); break; - case EVENT_WEAK_HASH_PRE: rc = main_weak_hash_pre (hashcat_ctx, buf, len); break; - case EVENT_WEAK_HASH_POST: rc = main_weak_hash_post (hashcat_ctx, buf, len); break; - case EVENT_SET_KERNEL_POWER_FINAL: rc = main_set_kernel_power_final (hashcat_ctx, buf, len); break; + case EVENT_LOG_INFO: main_log_info (hashcat_ctx, buf, len); break; + case EVENT_LOG_WARNING: main_log_warning (hashcat_ctx, buf, len); break; + case EVENT_LOG_ERROR: main_log_error (hashcat_ctx, buf, len); break; + case EVENT_WELCOME_SCREEN: main_welcome_screen (hashcat_ctx, buf, len); break; + case EVENT_GOODBYE_SCREEN: main_goodbye_screen (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break; + case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break; + case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_REMOVE_PARSE_PRE: main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_REMOVE_PARSE_POST: main_potfile_remove_parse_post (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_NUM_CRACKED: main_potfile_num_cracked (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_ALL_CRACKED: main_potfile_all_cracked (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_PRE: main_opencl_session_pre (hashcat_ctx, buf, len); break; + case EVENT_OPENCL_SESSION_POST: main_opencl_session_post (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_PRE: main_bitmap_init_pre (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_INIT_POST: main_bitmap_init_post (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break; + case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break; } - - return rc; } #else -int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { - int rc = 0; - switch (id) { } - - return rc; } #endif diff --git a/src/outfile.c b/src/outfile.c index 29f13cacd..afb568be1 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -262,17 +262,8 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx) outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->outfile == NULL) - { - outfile_ctx->fp = stdout; - outfile_ctx->filename = NULL; - } - else - { - outfile_ctx->fp = NULL; - outfile_ctx->filename = user_options->outfile; - } - + outfile_ctx->fp = NULL; + outfile_ctx->filename = user_options->outfile; outfile_ctx->outfile_format = user_options->outfile_format; outfile_ctx->outfile_autohex = user_options->outfile_autohex; @@ -312,18 +303,17 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx) { outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; - if (outfile_ctx->fp == stdout) return; + if (outfile_ctx->fp == NULL) return; fclose (outfile_ctx->fp); } -void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len) +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE]) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; - char tmp_buf[HCBUFSIZ_LARGE]; - int tmp_len = 0; + int tmp_len = 0; if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH) { @@ -412,7 +402,12 @@ void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsig tmp_buf[tmp_len] = 0; - fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf); + if (outfile_ctx->fp) + { + fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf); + } + + return tmp_len; } int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx) diff --git a/src/potfile.c b/src/potfile.c index 39f5d40e9..80603c80e 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -523,7 +523,11 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu // do output the line - outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len); + char tmp_buf[HCBUFSIZ_LARGE]; + + const int tmp_len = outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, tmp_buf); + + EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); } } @@ -546,7 +550,11 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu input_buf[input_len] = 0; - outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0); + char tmp_buf[HCBUFSIZ_LARGE]; + + const int tmp_len = outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0, tmp_buf); + + EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); } } @@ -667,7 +675,11 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // do output the line - outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len); + char tmp_buf[HCBUFSIZ_LARGE]; + + const int tmp_len = outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, tmp_buf); + + EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); if (weak_hash_found == 1) hcfree (pot_right_ptr); @@ -753,7 +765,11 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i hash_output[user_len + 16] = 0; } - outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0); + char tmp_buf[HCBUFSIZ_LARGE]; + + const int tmp_len = outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0, tmp_buf); + + EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); hcfree (hash_output); From ebc26ecac57659c644726b8ac6e16cc5424c778d Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 11:45:24 +0200 Subject: [PATCH 030/106] Fix some log levels in opencl.c --- src/hwmon.c | 8 ++++---- src/opencl.c | 33 ++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/hwmon.c b/src/hwmon.c index 780500479..7a8375e5a 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -3082,7 +3082,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((ADL_rc = hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - event_log_info (hashcat_ctx, "Failed to set ADL performance state"); + event_log_error (hashcat_ctx, "Failed to set ADL performance state"); return -1; } @@ -3277,7 +3277,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive6_PowerControl_Caps (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, &powertune_supported)) == -1) { - event_log_error (hashcat_ctx, "Failed to get ADL PowerControl Capabilities"); + //event_log_error (hashcat_ctx, "Failed to get ADL PowerControl Capabilities"); continue; } @@ -3288,7 +3288,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive_PowerControl_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, hwmon_ctx->od_power_control_status[device_id])) == -1) { - event_log_info (hashcat_ctx, "Failed to restore the ADL PowerControl values"); + //event_log_error (hashcat_ctx, "Failed to restore the ADL PowerControl values"); continue; } @@ -3306,7 +3306,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) if ((hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1) { - event_log_info (hashcat_ctx, "Failed to restore ADL performance state"); + //event_log_info (hashcat_ctx, "Failed to restore ADL performance state"); continue; } diff --git a/src/opencl.c b/src/opencl.c index 63c650d14..5243a9bfd 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -303,20 +303,21 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) if (ocl->lib == NULL) { - event_log_info (hashcat_ctx, ""); - event_log_info (hashcat_ctx, "ATTENTION! Can't find OpenCL ICD loader library"); - event_log_info (hashcat_ctx, ""); - #if defined (__linux__) - event_log_info (hashcat_ctx, "You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)"); - event_log_info (hashcat_ctx, " sudo apt-get install ocl-icd-libopencl1"); - event_log_info (hashcat_ctx, ""); - #elif defined (_WIN) - event_log_info (hashcat_ctx, "You're probably missing the OpenCL runtime installation"); - event_log_info (hashcat_ctx, " AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); - event_log_info (hashcat_ctx, " Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); - event_log_info (hashcat_ctx, " NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); - event_log_info (hashcat_ctx, ""); - #endif + event_log_warning (hashcat_ctx, + "Can't find OpenCL ICD loader library" EOL + "" EOL + #if defined (__linux__) + "You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)" EOL + "Run: sudo apt-get install ocl-icd-libopencl1" EOL + "" EOL + #elif defined (_WIN) + "You're probably missing the OpenCL runtime installation" EOL + "* AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)" EOL + "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)" EOL + "* NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)" EOL + "" EOL + #endif + ); return -1; } @@ -1902,7 +1903,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) opencl_ctx->ocl = ocl; - ocl_init (hashcat_ctx); + const int rc_ocl_init = ocl_init (hashcat_ctx); + + if (rc_ocl_init == -1) return -1; /** * OpenCL platform selection From 60f6137a3f38ac82a1da7ecc4162839d37c8e055 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 13:08:48 +0200 Subject: [PATCH 031/106] Fix some newlines in restore mode --- src/restore.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/restore.c b/src/restore.c index 08a89458c..be40db0b1 100644 --- a/src/restore.c +++ b/src/restore.c @@ -235,14 +235,15 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) fclose (fp); - event_log_info (hashcat_ctx, "INFO: Changing current working directory to the path found within the .restore file: '%s'", rd->cwd); + event_log_info (hashcat_ctx, "INFO: Changing current working directory to '%s'", rd->cwd); + event_log_info (hashcat_ctx, ""); if (chdir (rd->cwd)) { event_log_error (hashcat_ctx, - "The directory '%s' does not exist. It is needed to restore (--restore) the session.\n" - "You could either create this directory or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n" - "https://github.com/philsmd/analyze_hc_restore\n" + "The directory '%s' does not exist. It is needed to restore (--restore) the session." EOL + "You could either create this directory or update the .restore file using e.g. the analyze_hc_restore.pl tool:" EOL + "https://github.com/philsmd/analyze_hc_restore" EOL "The directory must contain all files and folders mentioned within the command line.", rd->cwd); return -1; From 690b465ddc7de791a302f0e241fb06a9efff1167 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 13:30:59 +0200 Subject: [PATCH 032/106] Use printf() instead of event_log_*() in terminal.c and status.c --- src/status.c | 160 ++++++++++++++++++++++++------------------------- src/terminal.c | 55 +++++++++-------- 2 files changed, 106 insertions(+), 109 deletions(-) diff --git a/src/status.c b/src/status.c index 5dc6217a7..a3b05fb58 100644 --- a/src/status.c +++ b/src/status.c @@ -6,7 +6,6 @@ #include "common.h" #include "types.h" #include "memory.h" -#include "event.h" #include "convert.h" #include "restore.h" #include "thread.h" @@ -159,27 +158,25 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + fprintf (stdout, "Status view is not available during initialization phase" EOL); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + fprintf (stdout, "Status view is not available during autotune phase" EOL); return; } - FILE *out = stdout; - - fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); + fprintf (stdout, "STATUS\t%u\t", status_ctx->devices_status); /** * speed new */ - fprintf (out, "SPEED\t"); + fprintf (stdout, "SPEED\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -199,14 +196,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) speed_cnt /= SPEED_CACHE; speed_ms /= SPEED_CACHE; - fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); + fprintf (stdout, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); } /** * exec time */ - fprintf (out, "EXEC_RUNTIME\t"); + fprintf (stdout, "EXEC_RUNTIME\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -216,7 +213,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - fprintf (out, "%f\t", exec_ms_avg); + fprintf (stdout, "%f\t", exec_ms_avg); } /** @@ -225,7 +222,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 words_cur = get_lowest_words_done (hashcat_ctx); - fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); + fprintf (stdout, "CURKU\t%" PRIu64 "\t", words_cur); /** * counter @@ -270,14 +267,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 progress_cur_relative_skip = progress_cur - progress_skip; u64 progress_end_relative_skip = progress_end - progress_skip; - fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); + fprintf (stdout, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); /** * cracks */ - fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); - fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); + fprintf (stdout, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); + fprintf (stdout, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); /** * temperature @@ -285,7 +282,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (user_options->gpu_temp_disable == false) { - fprintf (out, "TEMP\t"); + fprintf (stdout, "TEMP\t"); hc_thread_mutex_lock (status_ctx->mux_hwmon); @@ -297,7 +294,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - fprintf (out, "%d\t", temp); + fprintf (stdout, "%d\t", temp); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -307,8 +304,9 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) * flush */ - fputs (EOL, out); - fflush (out); + fputs (EOL, stdout); + + fflush (stdout); } void status_display (hashcat_ctx_t *hashcat_ctx) @@ -326,14 +324,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + fprintf (stdout, "Status view is not available during initialization phase" EOL); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + fprintf (stdout, "Status view is not available during autotune phase" EOL); return; } @@ -352,7 +350,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - event_log_info (hashcat_ctx, "Session.Name...: %s", user_options->session); + fprintf (stdout, "Session.Name...: %s", user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -360,7 +358,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - event_log_info (hashcat_ctx, "Status.........: %s", status_type); + fprintf (stdout, "Status.........: %s", status_type); /** * show rules @@ -377,18 +375,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - event_log_info (hashcat_ctx, "Rules.Type.....: %s", tmp_buf); + fprintf (stdout, "Rules.Type.....: %s", tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - event_log_info (hashcat_ctx, "Rules.Type.....: Generated (%u)", user_options->rp_gen); + fprintf (stdout, "Rules.Type.....: Generated (%u)", user_options->rp_gen); if (user_options->rp_gen_seed) { - event_log_info (hashcat_ctx, "Rules.Seed.....: %u", user_options->rp_gen_seed); + fprintf (stdout, "Rules.Seed.....: %u", user_options->rp_gen_seed); } } @@ -405,17 +403,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - event_log_info (hashcat_ctx, "Input.Mode.....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Mode.....: File (%s)", straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - event_log_info (hashcat_ctx, "Input.Mode.....: Pipe"); + fprintf (stdout, "Input.Mode.....: Pipe"); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", combinator_ctx->dict1); - event_log_info (hashcat_ctx, "Input.Right....: File (%s)", combinator_ctx->dict2); + fprintf (stdout, "Input.Left.....: File (%s)", combinator_ctx->dict1); + fprintf (stdout, "Input.Right....: File (%s)", combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -451,7 +449,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - event_log_info (hashcat_ctx, "Input.Mode.....: %s", tmp_buf); + fprintf (stdout, "Input.Mode.....: %s", tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -460,7 +458,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -468,8 +466,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", straight_ctx->dict); - event_log_info (hashcat_ctx, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Left.....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -478,13 +476,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - event_log_info (hashcat_ctx, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - event_log_info (hashcat_ctx, "Input.Right....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Right....: File (%s)", straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -493,7 +491,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -503,7 +501,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - event_log_info (hashcat_ctx, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -520,19 +518,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else { @@ -549,7 +547,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - event_log_info (hashcat_ctx, "Hash.Target....: %s", out_buf); + fprintf (stdout, "Hash.Target....: %s", out_buf); } } else @@ -562,15 +560,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf1, 0, 0); ascii_digest (hashcat_ctx, out_buf2, 0, 1); - event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); + fprintf (stdout, "Hash.Target....: %s, %s", out_buf1, out_buf2); } else { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } } - event_log_info (hashcat_ctx, "Hash.Type......: %s", hash_type); + fprintf (stdout, "Hash.Type......: %s", hash_type); /** * speed new @@ -693,12 +691,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); + fprintf (stdout, "Time.Started...: %s (%s)", start, display_run); } } else { - event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); + fprintf (stdout, "Time.Started...: 0 secs"); } /** @@ -786,7 +784,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); + fprintf (stdout, "Time.Estimated.: > 10 Years"); } else { @@ -849,16 +847,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); } else { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); } } else { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s)", etc, display_etc); } } } @@ -877,7 +875,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -886,12 +884,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s", display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -932,7 +930,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -942,7 +940,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -951,7 +949,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -959,7 +957,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_avg_min, cpt_avg_hour, cpt_avg_day); @@ -988,14 +986,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); } } } @@ -1004,24 +1002,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + fprintf (stdout, "Progress.......: 0/0 (100%%)"); + fprintf (stdout, "Rejected.......: 0/0 (100%%)"); if (user_options->restore_disable == false) { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + fprintf (stdout, "Restore.Point..: 0/0 (100%%)"); } } else { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); + fprintf (stdout, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + fprintf (stdout, "Rejected.......: %" PRIu64 "", all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); + // fprintf (stdout, "Restore.Point..: %" PRIu64 "", restore_point); //} } } @@ -1038,11 +1036,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Generating]", device_id + 1); } else { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Copying]", device_id + 1); } continue; @@ -1080,11 +1078,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); } else { - event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); } } @@ -1166,7 +1164,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + fprintf (stdout, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1181,14 +1179,14 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + fprintf (stdout, "Status view is not available during initialization phase" EOL); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + fprintf (stdout, "Status view is not available during autotune phase" EOL); return; } @@ -1228,7 +1226,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + fprintf (stdout, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1240,14 +1238,14 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + fprintf (stdout, "Status view is not available during initialization phase" EOL); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + fprintf (stdout, "Status view is not available during autotune phase" EOL); return; } @@ -1325,11 +1323,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1339,7 +1337,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s", display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/terminal.c b/src/terminal.c index 09b084045..b0b07ca23 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5,7 +5,6 @@ #include "common.h" #include "types.h" -#include "event.h" #include "thread.h" #include "timer.h" #include "status.h" @@ -29,23 +28,23 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const { if (user_options->machine_readable == false) { - event_log_info (hashcat_ctx, "%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "%s (%s) starting in benchmark-mode..." EOL, PROGNAME, version_tag); + fprintf (stdout, EOL); } else { - event_log_info (hashcat_ctx, "# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start)); + fprintf (stdout, "# %s (%s) %s" EOL, PROGNAME, version_tag, ctime (&proc_start)); } } else if (user_options->restore == true) { - event_log_info (hashcat_ctx, "%s (%s) starting in restore-mode...", PROGNAME, version_tag); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "%s (%s) starting in restore-mode..." EOL, PROGNAME, version_tag); + fprintf (stdout, EOL); } else { - event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "%s (%s) starting..." EOL, PROGNAME, version_tag); + fprintf (stdout, EOL); } } @@ -59,8 +58,8 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const if (user_options->show == true) return; if (user_options->left == true) return; - event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start)); - event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop)); + fprintf (stdout, "Started: %s", ctime (&proc_start)); + fprintf (stdout, "Stopped: %s", ctime (&proc_stop)); } int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) @@ -70,21 +69,21 @@ int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) if (_setmode (_fileno (stdin), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno)); + fprintf (stderr, "_setmode(): %s", strerror (errno)); return -1; } if (_setmode (_fileno (stdout), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno)); + fprintf (stderr, "_setmode(): %s", strerror (errno)); return -1; } if (_setmode (_fileno (stderr), _O_BINARY) == -1) { - event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno)); + fprintf (stderr, "_setmode(): %s", strerror (errno)); return -1; } @@ -141,7 +140,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_lock (status_ctx->mux_display); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); switch (ch) { @@ -149,11 +148,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case '\r': case '\n': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); status_display (hashcat_ctx); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); if (quiet == false) send_prompt (); @@ -161,13 +160,13 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'b': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); bypass (hashcat_ctx); - event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one"); + fprintf (stdout, "Next dictionary / mask in queue selected, bypassing current one" EOL); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); if (quiet == false) send_prompt (); @@ -175,16 +174,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'p': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); SuspendThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_PAUSED) { - event_log_info (hashcat_ctx, "Paused"); + fprintf (stdout, "Paused" EOL); } - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); if (quiet == false) send_prompt (); @@ -192,16 +191,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'r': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); ResumeThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_RUNNING) { - event_log_info (hashcat_ctx, "Resumed"); + fprintf (stdout, "Resumed" EOL); } - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); if (quiet == false) send_prompt (); @@ -209,11 +208,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'c': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); stop_at_checkpoint (hashcat_ctx); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); if (quiet == false) send_prompt (); @@ -221,7 +220,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'q': - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); myabort (hashcat_ctx); From 29c2931b67bf541b592098c3c5da06cc8f840bd6 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 13:35:50 +0200 Subject: [PATCH 033/106] Fix some newlines in status.c --- src/status.c | 114 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/status.c b/src/status.c index a3b05fb58..ae7d5f06e 100644 --- a/src/status.c +++ b/src/status.c @@ -350,7 +350,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - fprintf (stdout, "Session.Name...: %s", user_options->session); + fprintf (stdout, "Session.Name...: %s" EOL, user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -358,7 +358,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - fprintf (stdout, "Status.........: %s", status_type); + fprintf (stdout, "Status.........: %s" EOL, status_type); /** * show rules @@ -375,18 +375,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - fprintf (stdout, "Rules.Type.....: %s", tmp_buf); + fprintf (stdout, "Rules.Type.....: %s" EOL, tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - fprintf (stdout, "Rules.Type.....: Generated (%u)", user_options->rp_gen); + fprintf (stdout, "Rules.Type.....: Generated (%u)" EOL, user_options->rp_gen); if (user_options->rp_gen_seed) { - fprintf (stdout, "Rules.Seed.....: %u", user_options->rp_gen_seed); + fprintf (stdout, "Rules.Seed.....: %u" EOL, user_options->rp_gen_seed); } } @@ -403,17 +403,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - fprintf (stdout, "Input.Mode.....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Mode.....: File (%s)" EOL, straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - fprintf (stdout, "Input.Mode.....: Pipe"); + fprintf (stdout, "Input.Mode.....: Pipe" EOL); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - fprintf (stdout, "Input.Left.....: File (%s)", combinator_ctx->dict1); - fprintf (stdout, "Input.Right....: File (%s)", combinator_ctx->dict2); + fprintf (stdout, "Input.Left.....: File (%s)" EOL, combinator_ctx->dict1); + fprintf (stdout, "Input.Right....: File (%s)" EOL, combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -449,7 +449,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - fprintf (stdout, "Input.Mode.....: %s", tmp_buf); + fprintf (stdout, "Input.Mode.....: %s" EOL, tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -458,7 +458,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -466,8 +466,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - fprintf (stdout, "Input.Left.....: File (%s)", straight_ctx->dict); - fprintf (stdout, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Left.....: File (%s)" EOL, straight_ctx->dict); + fprintf (stdout, "Input.Right....: Mask (%s) [%i]" EOL, mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -476,13 +476,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - fprintf (stdout, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - fprintf (stdout, "Input.Right....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Left.....: Mask (%s) [%i]" EOL, mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Right....: File (%s)" EOL, straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -491,7 +491,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -501,7 +501,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)" EOL, (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -518,19 +518,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); } else { @@ -547,7 +547,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - fprintf (stdout, "Hash.Target....: %s", out_buf); + fprintf (stdout, "Hash.Target....: %s" EOL, out_buf); } } else @@ -560,15 +560,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf1, 0, 0); ascii_digest (hashcat_ctx, out_buf2, 0, 1); - fprintf (stdout, "Hash.Target....: %s, %s", out_buf1, out_buf2); + fprintf (stdout, "Hash.Target....: %s, %s" EOL, out_buf1, out_buf2); } else { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); } } - fprintf (stdout, "Hash.Type......: %s", hash_type); + fprintf (stdout, "Hash.Type......: %s" EOL, hash_type); /** * speed new @@ -691,12 +691,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - fprintf (stdout, "Time.Started...: %s (%s)", start, display_run); + fprintf (stdout, "Time.Started...: %s (%s)" EOL, start, display_run); } } else { - fprintf (stdout, "Time.Started...: 0 secs"); + fprintf (stdout, "Time.Started...: 0 secs" EOL); } /** @@ -784,7 +784,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - fprintf (stdout, "Time.Estimated.: > 10 Years"); + fprintf (stdout, "Time.Estimated.: > 10 Years" EOL); } else { @@ -847,16 +847,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)" EOL, etc, display_etc, display_runtime); } else { - fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded" EOL, etc, display_etc); } } else { - fprintf (stdout, "Time.Estimated.: %s (%s)", etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s)" EOL, etc, display_etc); } } } @@ -875,7 +875,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -884,12 +884,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s" EOL, display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts" EOL, hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -930,7 +930,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -940,7 +940,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -949,7 +949,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -957,7 +957,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, cpt_avg_min, cpt_avg_hour, cpt_avg_day); @@ -986,14 +986,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, restore_point, restore_total, percent_restore * 100); } } } @@ -1002,24 +1002,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - fprintf (stdout, "Progress.......: 0/0 (100%%)"); - fprintf (stdout, "Rejected.......: 0/0 (100%%)"); + fprintf (stdout, "Progress.......: 0/0 (100%%)" EOL); + fprintf (stdout, "Rejected.......: 0/0 (100%%)" EOL); if (user_options->restore_disable == false) { - fprintf (stdout, "Restore.Point..: 0/0 (100%%)"); + fprintf (stdout, "Restore.Point..: 0/0 (100%%)" EOL); } } else { - fprintf (stdout, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - fprintf (stdout, "Rejected.......: %" PRIu64 "", all_rejected); + fprintf (stdout, "Progress.......: %" PRIu64 "" EOL, progress_cur_relative_skip); + fprintf (stdout, "Rejected.......: %" PRIu64 "" EOL, all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // fprintf (stdout, "Restore.Point..: %" PRIu64 "", restore_point); + // fprintf (stdout, "Restore.Point..: %" PRIu64 "" EOL, restore_point); //} } } @@ -1036,11 +1036,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - fprintf (stdout, "Candidates.#%d..: [Generating]", device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Generating]" EOL, device_id + 1); } else { - fprintf (stdout, "Candidates.#%d..: [Copying]", device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Copying]" EOL, device_id + 1); } continue; @@ -1078,11 +1078,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]" EOL, device_id + 1, plain_ptr1, plain_ptr2); } else { - fprintf (stdout, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: %s -> %s" EOL, device_id + 1, plain_ptr1, plain_ptr2); } } @@ -1164,7 +1164,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - fprintf (stdout, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + fprintf (stdout, "HWMon.Dev.#%d...:%s" EOL, device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1226,7 +1226,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - fprintf (stdout, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + fprintf (stdout, "%u:%u:%" PRIu64 "" EOL, device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1323,11 +1323,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1337,7 +1337,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s" EOL, display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) From 358ad9bdbeedf611e3729d7641be7af3c870a9ee Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:17:15 +0200 Subject: [PATCH 034/106] Revert "Fix some newlines in status.c" This reverts commit 29c2931b67bf541b592098c3c5da06cc8f840bd6. --- src/status.c | 114 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/status.c b/src/status.c index ae7d5f06e..a3b05fb58 100644 --- a/src/status.c +++ b/src/status.c @@ -350,7 +350,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - fprintf (stdout, "Session.Name...: %s" EOL, user_options->session); + fprintf (stdout, "Session.Name...: %s", user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -358,7 +358,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - fprintf (stdout, "Status.........: %s" EOL, status_type); + fprintf (stdout, "Status.........: %s", status_type); /** * show rules @@ -375,18 +375,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - fprintf (stdout, "Rules.Type.....: %s" EOL, tmp_buf); + fprintf (stdout, "Rules.Type.....: %s", tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - fprintf (stdout, "Rules.Type.....: Generated (%u)" EOL, user_options->rp_gen); + fprintf (stdout, "Rules.Type.....: Generated (%u)", user_options->rp_gen); if (user_options->rp_gen_seed) { - fprintf (stdout, "Rules.Seed.....: %u" EOL, user_options->rp_gen_seed); + fprintf (stdout, "Rules.Seed.....: %u", user_options->rp_gen_seed); } } @@ -403,17 +403,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - fprintf (stdout, "Input.Mode.....: File (%s)" EOL, straight_ctx->dict); + fprintf (stdout, "Input.Mode.....: File (%s)", straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - fprintf (stdout, "Input.Mode.....: Pipe" EOL); + fprintf (stdout, "Input.Mode.....: Pipe"); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - fprintf (stdout, "Input.Left.....: File (%s)" EOL, combinator_ctx->dict1); - fprintf (stdout, "Input.Right....: File (%s)" EOL, combinator_ctx->dict2); + fprintf (stdout, "Input.Left.....: File (%s)", combinator_ctx->dict1); + fprintf (stdout, "Input.Right....: File (%s)", combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -449,7 +449,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - fprintf (stdout, "Input.Mode.....: %s" EOL, tmp_buf); + fprintf (stdout, "Input.Mode.....: %s", tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -458,7 +458,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -466,8 +466,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - fprintf (stdout, "Input.Left.....: File (%s)" EOL, straight_ctx->dict); - fprintf (stdout, "Input.Right....: Mask (%s) [%i]" EOL, mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Left.....: File (%s)", straight_ctx->dict); + fprintf (stdout, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -476,13 +476,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - fprintf (stdout, "Input.Left.....: Mask (%s) [%i]" EOL, mask_ctx->mask, mask_ctx->css_cnt); - fprintf (stdout, "Input.Right....: File (%s)" EOL, straight_ctx->dict); + fprintf (stdout, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + fprintf (stdout, "Input.Right....: File (%s)", straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -491,7 +491,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s" EOL, custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -501,7 +501,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)" EOL, + fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -518,19 +518,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } else { @@ -547,7 +547,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - fprintf (stdout, "Hash.Target....: %s" EOL, out_buf); + fprintf (stdout, "Hash.Target....: %s", out_buf); } } else @@ -560,15 +560,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf1, 0, 0); ascii_digest (hashcat_ctx, out_buf2, 0, 1); - fprintf (stdout, "Hash.Target....: %s, %s" EOL, out_buf1, out_buf2); + fprintf (stdout, "Hash.Target....: %s, %s", out_buf1, out_buf2); } else { - fprintf (stdout, "Hash.Target....: File (%s)" EOL, hashes->hashfile); + fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); } } - fprintf (stdout, "Hash.Type......: %s" EOL, hash_type); + fprintf (stdout, "Hash.Type......: %s", hash_type); /** * speed new @@ -691,12 +691,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - fprintf (stdout, "Time.Started...: %s (%s)" EOL, start, display_run); + fprintf (stdout, "Time.Started...: %s (%s)", start, display_run); } } else { - fprintf (stdout, "Time.Started...: 0 secs" EOL); + fprintf (stdout, "Time.Started...: 0 secs"); } /** @@ -784,7 +784,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - fprintf (stdout, "Time.Estimated.: > 10 Years" EOL); + fprintf (stdout, "Time.Estimated.: > 10 Years"); } else { @@ -847,16 +847,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)" EOL, etc, display_etc, display_runtime); + fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); } else { - fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded" EOL, etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); } } else { - fprintf (stdout, "Time.Estimated.: %s (%s)" EOL, etc, display_etc); + fprintf (stdout, "Time.Estimated.: %s (%s)", etc, display_etc); } } } @@ -875,7 +875,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -884,12 +884,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s" EOL, display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s", display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts" EOL, hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -930,7 +930,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -940,7 +940,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, + fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -949,7 +949,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, + fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -957,7 +957,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)" EOL, + fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_avg_min, cpt_avg_hour, cpt_avg_day); @@ -986,14 +986,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, all_rejected, progress_cur_relative_skip, percent_rejected * 100); + fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)" EOL, restore_point, restore_total, percent_restore * 100); + fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); } } } @@ -1002,24 +1002,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - fprintf (stdout, "Progress.......: 0/0 (100%%)" EOL); - fprintf (stdout, "Rejected.......: 0/0 (100%%)" EOL); + fprintf (stdout, "Progress.......: 0/0 (100%%)"); + fprintf (stdout, "Rejected.......: 0/0 (100%%)"); if (user_options->restore_disable == false) { - fprintf (stdout, "Restore.Point..: 0/0 (100%%)" EOL); + fprintf (stdout, "Restore.Point..: 0/0 (100%%)"); } } else { - fprintf (stdout, "Progress.......: %" PRIu64 "" EOL, progress_cur_relative_skip); - fprintf (stdout, "Rejected.......: %" PRIu64 "" EOL, all_rejected); + fprintf (stdout, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + fprintf (stdout, "Rejected.......: %" PRIu64 "", all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // fprintf (stdout, "Restore.Point..: %" PRIu64 "" EOL, restore_point); + // fprintf (stdout, "Restore.Point..: %" PRIu64 "", restore_point); //} } } @@ -1036,11 +1036,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - fprintf (stdout, "Candidates.#%d..: [Generating]" EOL, device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Generating]", device_id + 1); } else { - fprintf (stdout, "Candidates.#%d..: [Copying]" EOL, device_id + 1); + fprintf (stdout, "Candidates.#%d..: [Copying]", device_id + 1); } continue; @@ -1078,11 +1078,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]" EOL, device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); } else { - fprintf (stdout, "Candidates.#%d..: %s -> %s" EOL, device_id + 1, plain_ptr1, plain_ptr2); + fprintf (stdout, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); } } @@ -1164,7 +1164,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - fprintf (stdout, "HWMon.Dev.#%d...:%s" EOL, device_id + 1, output_buf); + fprintf (stdout, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1226,7 +1226,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - fprintf (stdout, "%u:%u:%" PRIu64 "" EOL, device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + fprintf (stdout, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1323,11 +1323,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)" EOL, device_id + 1, display_dev_cur, exec_all_ms[device_id]); + fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1337,7 +1337,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s" EOL, display_all_cur); + if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s", display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) From 556c07d8ee225320169ba6bc7d9373b42097de56 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:17:30 +0200 Subject: [PATCH 035/106] Revert "Use printf() instead of event_log_*() in terminal.c and status.c" This reverts commit 690b465ddc7de791a302f0e241fb06a9efff1167. --- src/status.c | 160 +++++++++++++++++++++++++------------------------ src/terminal.c | 55 ++++++++--------- 2 files changed, 109 insertions(+), 106 deletions(-) diff --git a/src/status.c b/src/status.c index a3b05fb58..5dc6217a7 100644 --- a/src/status.c +++ b/src/status.c @@ -6,6 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" +#include "event.h" #include "convert.h" #include "restore.h" #include "thread.h" @@ -158,25 +159,27 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } - fprintf (stdout, "STATUS\t%u\t", status_ctx->devices_status); + FILE *out = stdout; + + fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); /** * speed new */ - fprintf (stdout, "SPEED\t"); + fprintf (out, "SPEED\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -196,14 +199,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) speed_cnt /= SPEED_CACHE; speed_ms /= SPEED_CACHE; - fprintf (stdout, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); + fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); } /** * exec time */ - fprintf (stdout, "EXEC_RUNTIME\t"); + fprintf (out, "EXEC_RUNTIME\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -213,7 +216,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - fprintf (stdout, "%f\t", exec_ms_avg); + fprintf (out, "%f\t", exec_ms_avg); } /** @@ -222,7 +225,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 words_cur = get_lowest_words_done (hashcat_ctx); - fprintf (stdout, "CURKU\t%" PRIu64 "\t", words_cur); + fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); /** * counter @@ -267,14 +270,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 progress_cur_relative_skip = progress_cur - progress_skip; u64 progress_end_relative_skip = progress_end - progress_skip; - fprintf (stdout, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); + fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); /** * cracks */ - fprintf (stdout, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); - fprintf (stdout, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); + fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); + fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); /** * temperature @@ -282,7 +285,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (user_options->gpu_temp_disable == false) { - fprintf (stdout, "TEMP\t"); + fprintf (out, "TEMP\t"); hc_thread_mutex_lock (status_ctx->mux_hwmon); @@ -294,7 +297,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - fprintf (stdout, "%d\t", temp); + fprintf (out, "%d\t", temp); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -304,9 +307,8 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) * flush */ - fputs (EOL, stdout); - - fflush (stdout); + fputs (EOL, out); + fflush (out); } void status_display (hashcat_ctx_t *hashcat_ctx) @@ -324,14 +326,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -350,7 +352,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - fprintf (stdout, "Session.Name...: %s", user_options->session); + event_log_info (hashcat_ctx, "Session.Name...: %s", user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -358,7 +360,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - fprintf (stdout, "Status.........: %s", status_type); + event_log_info (hashcat_ctx, "Status.........: %s", status_type); /** * show rules @@ -375,18 +377,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - fprintf (stdout, "Rules.Type.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Rules.Type.....: %s", tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - fprintf (stdout, "Rules.Type.....: Generated (%u)", user_options->rp_gen); + event_log_info (hashcat_ctx, "Rules.Type.....: Generated (%u)", user_options->rp_gen); if (user_options->rp_gen_seed) { - fprintf (stdout, "Rules.Seed.....: %u", user_options->rp_gen_seed); + event_log_info (hashcat_ctx, "Rules.Seed.....: %u", user_options->rp_gen_seed); } } @@ -403,17 +405,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - fprintf (stdout, "Input.Mode.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Mode.....: File (%s)", straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - fprintf (stdout, "Input.Mode.....: Pipe"); + event_log_info (hashcat_ctx, "Input.Mode.....: Pipe"); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - fprintf (stdout, "Input.Left.....: File (%s)", combinator_ctx->dict1); - fprintf (stdout, "Input.Right....: File (%s)", combinator_ctx->dict2); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", combinator_ctx->dict1); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -449,7 +451,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - fprintf (stdout, "Input.Mode.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Input.Mode.....: %s", tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -458,7 +460,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -466,8 +468,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - fprintf (stdout, "Input.Left.....: File (%s)", straight_ctx->dict); - fprintf (stdout, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -476,13 +478,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - fprintf (stdout, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - fprintf (stdout, "Input.Right....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -491,7 +493,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -501,7 +503,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + event_log_info (hashcat_ctx, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -518,19 +520,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else { @@ -547,7 +549,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - fprintf (stdout, "Hash.Target....: %s", out_buf); + event_log_info (hashcat_ctx, "Hash.Target....: %s", out_buf); } } else @@ -560,15 +562,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf1, 0, 0); ascii_digest (hashcat_ctx, out_buf2, 0, 1); - fprintf (stdout, "Hash.Target....: %s, %s", out_buf1, out_buf2); + event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); } else { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } } - fprintf (stdout, "Hash.Type......: %s", hash_type); + event_log_info (hashcat_ctx, "Hash.Type......: %s", hash_type); /** * speed new @@ -691,12 +693,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - fprintf (stdout, "Time.Started...: %s (%s)", start, display_run); + event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); } } else { - fprintf (stdout, "Time.Started...: 0 secs"); + event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); } /** @@ -784,7 +786,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - fprintf (stdout, "Time.Estimated.: > 10 Years"); + event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); } else { @@ -847,16 +849,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); } else { - fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); } } else { - fprintf (stdout, "Time.Estimated.: %s (%s)", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); } } } @@ -875,7 +877,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -884,12 +886,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -930,7 +932,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -940,7 +942,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -949,7 +951,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -957,7 +959,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_avg_min, cpt_avg_hour, cpt_avg_day); @@ -986,14 +988,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); } } } @@ -1002,24 +1004,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - fprintf (stdout, "Progress.......: 0/0 (100%%)"); - fprintf (stdout, "Rejected.......: 0/0 (100%%)"); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); if (user_options->restore_disable == false) { - fprintf (stdout, "Restore.Point..: 0/0 (100%%)"); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); } } else { - fprintf (stdout, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - fprintf (stdout, "Rejected.......: %" PRIu64 "", all_rejected); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // fprintf (stdout, "Restore.Point..: %" PRIu64 "", restore_point); + // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); //} } } @@ -1036,11 +1038,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - fprintf (stdout, "Candidates.#%d..: [Generating]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); } else { - fprintf (stdout, "Candidates.#%d..: [Copying]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); } continue; @@ -1078,11 +1080,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); } else { - fprintf (stdout, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); } } @@ -1164,7 +1166,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - fprintf (stdout, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1179,14 +1181,14 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1226,7 +1228,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - fprintf (stdout, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1238,14 +1240,14 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1323,11 +1325,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1337,7 +1339,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/terminal.c b/src/terminal.c index b0b07ca23..09b084045 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5,6 +5,7 @@ #include "common.h" #include "types.h" +#include "event.h" #include "thread.h" #include "timer.h" #include "status.h" @@ -28,23 +29,23 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const { if (user_options->machine_readable == false) { - fprintf (stdout, "%s (%s) starting in benchmark-mode..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - fprintf (stdout, "# %s (%s) %s" EOL, PROGNAME, version_tag, ctime (&proc_start)); + event_log_info (hashcat_ctx, "# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start)); } } else if (user_options->restore == true) { - fprintf (stdout, "%s (%s) starting in restore-mode..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting in restore-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - fprintf (stdout, "%s (%s) starting..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } } @@ -58,8 +59,8 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const if (user_options->show == true) return; if (user_options->left == true) return; - fprintf (stdout, "Started: %s", ctime (&proc_start)); - fprintf (stdout, "Stopped: %s", ctime (&proc_stop)); + event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start)); + event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop)); } int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) @@ -69,21 +70,21 @@ int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) if (_setmode (_fileno (stdin), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno)); return -1; } if (_setmode (_fileno (stdout), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno)); return -1; } if (_setmode (_fileno (stderr), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno)); return -1; } @@ -140,7 +141,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_lock (status_ctx->mux_display); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); switch (ch) { @@ -148,11 +149,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case '\r': case '\n': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -160,13 +161,13 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'b': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); bypass (hashcat_ctx); - fprintf (stdout, "Next dictionary / mask in queue selected, bypassing current one" EOL); + event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one"); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -174,16 +175,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'p': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); SuspendThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_PAUSED) { - fprintf (stdout, "Paused" EOL); + event_log_info (hashcat_ctx, "Paused"); } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -191,16 +192,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'r': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); ResumeThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_RUNNING) { - fprintf (stdout, "Resumed" EOL); + event_log_info (hashcat_ctx, "Resumed"); } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -208,11 +209,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'c': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); stop_at_checkpoint (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -220,7 +221,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'q': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); myabort (hashcat_ctx); From 8d3e9fc70cf70fb21f1fabb2b2e7baa0a57fcef8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:19:06 +0200 Subject: [PATCH 036/106] Fix formatstring in CPT display --- src/main.c | 76 ++++++++++++++++++++++++++-------------------------- src/status.c | 6 ++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/main.c b/src/main.c index d062d9141..7d72823fa 100644 --- a/src/main.c +++ b/src/main.c @@ -173,8 +173,8 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - event_log_info (hashcat_ctx, "Starting attack in stdin mode..."); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "Starting attack in stdin mode..." EOL); + fprintf (stdout, EOL); } } @@ -191,7 +191,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->machine_readable == false) { - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); } } else @@ -200,11 +200,11 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { clear_prompt (); - if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); + if (hashes->digests_saved != hashes->digests_done) fprintf (stdout, EOL); status_display (hashcat_ctx); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); } else { @@ -212,7 +212,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { status_display (hashcat_ctx); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); } } } @@ -235,7 +235,7 @@ static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (user_options->keyspace == false) return; - event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base); + fprintf (stdout, "%" PRIu64 "" EOL, status_ctx->words_base); } static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -244,7 +244,7 @@ static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_c if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries..."); + fprintf (stdout, "Comparing hashes with potfile entries..."); } static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -253,7 +253,7 @@ static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); + fprintf (stdout, "Compared hashes with potfile entries..."); } static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -269,13 +269,13 @@ static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M { if (potfile_remove_cracks == 1) { - event_log_info (hashcat_ctx, "INFO: Removed 1 hash found in potfile"); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "INFO: Removed 1 hash found in potfile" EOL); + fprintf (stdout, EOL); } else { - event_log_info (hashcat_ctx, "INFO: Removed %d hashes found in potfile", potfile_remove_cracks); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "INFO: Removed %d hashes found in potfile" EOL, potfile_remove_cracks); + fprintf (stdout, EOL); } } } @@ -286,8 +286,8 @@ static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (user_options->quiet == true) return; - event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them."); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "INFO: All hashes found in potfile! You can use --show to display them." EOL); + fprintf (stdout, EOL); } static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -309,36 +309,36 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, { char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "Hashtype: %s" EOL, hash_type); + fprintf (stdout, EOL); } } if (user_options->quiet == true) return; - event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + fprintf (stdout, "Hashes: %u digests; %u unique digests, %u unique salts" EOL, hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + fprintf (stdout, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates" EOL, bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); + fprintf (stdout, "Rules: %u" EOL, straight_ctx->kernel_rules_cnt); } if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); if (hashconfig->opti_type) { - event_log_info (hashcat_ctx, "Applicable Optimizers:"); + fprintf (stdout, "Applicable Optimizers:" EOL); for (u32 i = 0; i < 32; i++) { const u32 opti_bit = 1u << i; - if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); + if (hashconfig->opti_type & opti_bit) fprintf (stdout, "* %s" EOL, stroptitype (opti_bit)); } } - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); /** * Watchdog and Temperature balance @@ -346,31 +346,31 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) { - event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); + fprintf (stdout, "Watchdog: Hardware Monitoring Interface not found on your system" EOL); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); + fprintf (stdout, "Watchdog: Temperature abort trigger set to %uc" EOL, user_options->gpu_temp_abort); } else { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); + fprintf (stdout, "Watchdog: Temperature abort trigger disabled" EOL); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); + fprintf (stdout, "Watchdog: Temperature retain trigger set to %uc" EOL, user_options->gpu_temp_retain); } else { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); + fprintf (stdout, "Watchdog: Temperature retain trigger disabled" EOL); } - event_log_info (hashcat_ctx, ""); + fprintf (stdout, EOL); #if defined (DEBUG) - if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); + if (user_options->benchmark == true) fprintf (stdout, "Hashmode: %d" EOL, hashconfig->hash_mode); #endif } @@ -380,7 +380,7 @@ static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory..."); + fprintf (stdout, "Initializing device kernels and memory: "); } static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -389,7 +389,7 @@ static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory..."); + fprintf (stdout, "Done" EOL); } static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -398,7 +398,7 @@ static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Checking for weak hashes..."); + fprintf (stdout, "Checking for weak hashes: "); } static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -407,7 +407,7 @@ static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Checked for weak hashes..."); + fprintf (stdout, "Done" EOL); } static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -416,7 +416,7 @@ static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Generating bitmap tables..."); + fprintf (stdout, "Generating bitmap tables: "); } static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -425,7 +425,7 @@ static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->quiet == true) return; - event_log_info_nn (hashcat_ctx, "Generated bitmap tables..."); + fprintf (stdout, "Done" EOL); } static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -436,8 +436,8 @@ static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx clear_prompt (); - event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted"); - event_log_info (hashcat_ctx, ""); + fprintf (stdout, "INFO: approaching final keyspace, workload adjusted" EOL); + fprintf (stdout, EOL); send_prompt (); } diff --git a/src/status.c b/src/status.c index 5dc6217a7..f0c6b1a4f 100644 --- a/src/status.c +++ b/src/status.c @@ -932,7 +932,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -942,7 +942,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -951,7 +951,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, From ee1661b9dbc46acca9906bb44cecb88b110b94d7 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:36:47 +0200 Subject: [PATCH 037/106] Revert "Fix formatstring in CPT display" This reverts commit 8d3e9fc70cf70fb21f1fabb2b2e7baa0a57fcef8. --- src/main.c | 76 ++++++++++++++++++++++++++-------------------------- src/status.c | 6 ++--- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/main.c b/src/main.c index 7d72823fa..d062d9141 100644 --- a/src/main.c +++ b/src/main.c @@ -173,8 +173,8 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - fprintf (stdout, "Starting attack in stdin mode..." EOL); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "Starting attack in stdin mode..."); + event_log_info (hashcat_ctx, ""); } } @@ -191,7 +191,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->machine_readable == false) { - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); } } else @@ -200,11 +200,11 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { clear_prompt (); - if (hashes->digests_saved != hashes->digests_done) fprintf (stdout, EOL); + if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); } else { @@ -212,7 +212,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { status_display (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); } } } @@ -235,7 +235,7 @@ static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (user_options->keyspace == false) return; - fprintf (stdout, "%" PRIu64 "" EOL, status_ctx->words_base); + event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base); } static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -244,7 +244,7 @@ static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_c if (user_options->quiet == true) return; - fprintf (stdout, "Comparing hashes with potfile entries..."); + event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries..."); } static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -253,7 +253,7 @@ static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ if (user_options->quiet == true) return; - fprintf (stdout, "Compared hashes with potfile entries..."); + event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); } static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -269,13 +269,13 @@ static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M { if (potfile_remove_cracks == 1) { - fprintf (stdout, "INFO: Removed 1 hash found in potfile" EOL); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "INFO: Removed 1 hash found in potfile"); + event_log_info (hashcat_ctx, ""); } else { - fprintf (stdout, "INFO: Removed %d hashes found in potfile" EOL, potfile_remove_cracks); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "INFO: Removed %d hashes found in potfile", potfile_remove_cracks); + event_log_info (hashcat_ctx, ""); } } } @@ -286,8 +286,8 @@ static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (user_options->quiet == true) return; - fprintf (stdout, "INFO: All hashes found in potfile! You can use --show to display them." EOL); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them."); + event_log_info (hashcat_ctx, ""); } static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -309,36 +309,36 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, { char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - fprintf (stdout, "Hashtype: %s" EOL, hash_type); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); + event_log_info (hashcat_ctx, ""); } } if (user_options->quiet == true) return; - fprintf (stdout, "Hashes: %u digests; %u unique digests, %u unique salts" EOL, hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - fprintf (stdout, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates" EOL, bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - fprintf (stdout, "Rules: %u" EOL, straight_ctx->kernel_rules_cnt); + event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); } if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); if (hashconfig->opti_type) { - fprintf (stdout, "Applicable Optimizers:" EOL); + event_log_info (hashcat_ctx, "Applicable Optimizers:"); for (u32 i = 0; i < 32; i++) { const u32 opti_bit = 1u << i; - if (hashconfig->opti_type & opti_bit) fprintf (stdout, "* %s" EOL, stroptitype (opti_bit)); + if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); } } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); /** * Watchdog and Temperature balance @@ -346,31 +346,31 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) { - fprintf (stdout, "Watchdog: Hardware Monitoring Interface not found on your system" EOL); + event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) { - fprintf (stdout, "Watchdog: Temperature abort trigger set to %uc" EOL, user_options->gpu_temp_abort); + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); } else { - fprintf (stdout, "Watchdog: Temperature abort trigger disabled" EOL); + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); } if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) { - fprintf (stdout, "Watchdog: Temperature retain trigger set to %uc" EOL, user_options->gpu_temp_retain); + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); } else { - fprintf (stdout, "Watchdog: Temperature retain trigger disabled" EOL); + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); #if defined (DEBUG) - if (user_options->benchmark == true) fprintf (stdout, "Hashmode: %d" EOL, hashconfig->hash_mode); + if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); #endif } @@ -380,7 +380,7 @@ static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA if (user_options->quiet == true) return; - fprintf (stdout, "Initializing device kernels and memory: "); + event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory..."); } static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -389,7 +389,7 @@ static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M if (user_options->quiet == true) return; - fprintf (stdout, "Done" EOL); + event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory..."); } static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -398,7 +398,7 @@ static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U if (user_options->quiet == true) return; - fprintf (stdout, "Checking for weak hashes: "); + event_log_info_nn (hashcat_ctx, "Checking for weak hashes..."); } static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -407,7 +407,7 @@ static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ if (user_options->quiet == true) return; - fprintf (stdout, "Done" EOL); + event_log_info_nn (hashcat_ctx, "Checked for weak hashes..."); } static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -416,7 +416,7 @@ static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE if (user_options->quiet == true) return; - fprintf (stdout, "Generating bitmap tables: "); + event_log_info_nn (hashcat_ctx, "Generating bitmap tables..."); } static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -425,7 +425,7 @@ static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->quiet == true) return; - fprintf (stdout, "Done" EOL); + event_log_info_nn (hashcat_ctx, "Generated bitmap tables..."); } static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -436,8 +436,8 @@ static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx clear_prompt (); - fprintf (stdout, "INFO: approaching final keyspace, workload adjusted" EOL); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted"); + event_log_info (hashcat_ctx, ""); send_prompt (); } diff --git a/src/status.c b/src/status.c index f0c6b1a4f..5dc6217a7 100644 --- a/src/status.c +++ b/src/status.c @@ -932,7 +932,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -942,7 +942,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -951,7 +951,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, From 690ca0219efa6f7f1e7bd75947c9b4ce64f84ddc Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:38:33 +0200 Subject: [PATCH 038/106] Fix formatstring in CPT display and get rid of potfile_format_plain() --- src/potfile.c | 89 ++++++++++++++++++++++++--------------------------- src/status.c | 6 ++-- 2 files changed, 45 insertions(+), 50 deletions(-) diff --git a/src/potfile.c b/src/potfile.c index 80603c80e..ea2fee650 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -144,48 +144,6 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size return (NULL); } -static void potfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len) -{ - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return; - - bool needs_hexify = false; - - for (u32 i = 0; i < plain_len; i++) - { - if (plain_ptr[i] < 0x20) - { - needs_hexify = true; - - break; - } - - if (plain_ptr[i] > 0x7f) - { - needs_hexify = true; - - break; - } - } - - if (needs_hexify == true) - { - fprintf (potfile_ctx->fp, "$HEX["); - - for (u32 i = 0; i < plain_len; i++) - { - fprintf (potfile_ctx->fp, "%02x", plain_ptr[i]); - } - - fprintf (potfile_ctx->fp, "]"); - } - else - { - fwrite (plain_ptr, plain_len, 1, potfile_ctx->fp); - } -} - int potfile_init (hashcat_ctx_t *hashcat_ctx) { folder_config_t *folder_config = hashcat_ctx->folder_config; @@ -412,15 +370,52 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * if (potfile_ctx->enabled == false) return; - FILE *fp = potfile_ctx->fp; + char tmp_buf[HCBUFSIZ_LARGE]; - fprintf (fp, "%s:", out_buf); + int tmp_len = 0; - potfile_format_plain (hashcat_ctx, plain_ptr, plain_len); + if (1) + { + const size_t out_len = strlen (out_buf); - fputc ('\n', fp); + memcpy (tmp_buf + tmp_len, out_buf, out_len); - fflush (fp); + tmp_len += out_len; + + tmp_buf[tmp_len] = ':'; + + tmp_len += 1; + } + + if (1) + { + if (need_hexify (plain_ptr, plain_len) == true) + { + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; + + exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += plain_len * 2; + + tmp_buf[tmp_len++] = ']'; + } + else + { + memcpy (tmp_buf + tmp_len, plain_ptr, plain_len); + + tmp_len += plain_len; + } + } + + tmp_buf[tmp_len] = 0; + + fprintf (potfile_ctx->fp, "%s\n", tmp_buf); + + fflush (potfile_ctx->fp); } void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) diff --git a/src/status.c b/src/status.c index 5dc6217a7..f0c6b1a4f 100644 --- a/src/status.c +++ b/src/status.c @@ -932,7 +932,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -942,7 +942,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -951,7 +951,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, From 62284f79b1321b060d61eb1c98093c28cf87593f Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 12 Oct 2016 14:56:53 +0200 Subject: [PATCH 039/106] Get rid of exit() in hashcat.c --- include/hashcat.h | 4 ++-- src/hashcat.c | 6 ++++-- src/main.c | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/hashcat.h b/include/hashcat.h index 3953cecd0..ed47ab4a4 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -6,9 +6,9 @@ #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 (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)); +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); #endif // _HASHCAT_H diff --git a/src/hashcat.c b/src/hashcat.c index c3aff6a30..e12f95c5a 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -55,13 +55,13 @@ extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; -void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t)) +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"); - exit (-1); + return -1; } hashcat_ctx->event = event; @@ -92,6 +92,8 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, str hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); + + return 0; } void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) diff --git a/src/main.c b/src/main.c index d062d9141..7e1d40585 100644 --- a/src/main.c +++ b/src/main.c @@ -489,7 +489,9 @@ int main (int argc, char **argv) hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); - hashcat_ctx_init (hashcat_ctx, event); + const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event); + + if (rc_hashcat_init == -1) return -1; // initialize the session via getops for commandline use or // alternatively you can set the user_options directly From 8598a797322ea7e8af6531d4e267f53d57ce2fd0 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 10:07:04 +0200 Subject: [PATCH 040/106] Removed exit() from memory.c, resulting in all exit() calls removed from all code in the repository --- include/bitmap.h | 2 +- include/interface.h | 2 +- include/memory.h | 2 + include/potfile.h | 10 +- include/user_options.h | 2 +- include/wordlist.h | 4 +- src/bitmap.c | 32 +++--- src/combinator.c | 2 +- src/cpt.c | 2 +- src/cpu_crc32.c | 2 +- src/dictstat.c | 4 +- src/dispatch.c | 28 +++--- src/filehandling.c | 2 +- src/folder.c | 111 ++++++++++----------- src/hashcat.c | 74 +++++++------- src/hashes.c | 44 ++++----- src/hlfmt.c | 4 +- src/hwmon.c | 46 ++++----- src/induct.c | 4 +- src/interface.c | 12 ++- src/logfile.c | 6 +- src/loopback.c | 2 +- src/main.c | 12 ++- src/memory.c | 10 +- src/monitor.c | 6 +- src/mpsp.c | 218 +++++++++++++++++++++++++---------------- src/opencl.c | 56 +++++------ src/outfile_check.c | 20 ++-- src/potfile.c | 88 ++++++++++------- src/restore.c | 16 +-- src/rp.c | 16 +-- src/status.c | 6 +- src/straight.c | 34 +++++-- src/tuningdb.c | 8 +- src/user_options.c | 6 +- src/wordlist.c | 28 +++--- 36 files changed, 513 insertions(+), 408 deletions(-) diff --git a/include/bitmap.h b/include/bitmap.h index 18b07f329..c12b6889a 100644 --- a/include/bitmap.h +++ b/include/bitmap.h @@ -8,7 +8,7 @@ #include -void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx); +int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx); void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _BITMAP_H diff --git a/include/interface.h b/include/interface.h index e0f1f69ea..6300c2872 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1507,7 +1507,7 @@ char *strparser (const u32 parser_status); void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos); -void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos); +int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos); int hashconfig_init (hashcat_ctx_t *hashcat_ctx); void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/memory.h b/include/memory.h index b8920fa7c..c1193d78c 100644 --- a/include/memory.h +++ b/include/memory.h @@ -12,6 +12,8 @@ #define MSG_ENOMEM "Insufficient memory available" +#define VERIFY_PTR(v) if ((v) == NULL) return -1; + void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz); void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz); void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz); diff --git a/include/potfile.h b/include/potfile.h index 2e5a3264c..85ba9ca1f 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -22,18 +22,18 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size int potfile_init (hashcat_ctx_t *hashcat_ctx); int potfile_read_open (hashcat_ctx_t *hashcat_ctx); -void potfile_read_parse (hashcat_ctx_t *hashcat_ctx); +int potfile_read_parse (hashcat_ctx_t *hashcat_ctx); void potfile_read_close (hashcat_ctx_t *hashcat_ctx); int potfile_write_open (hashcat_ctx_t *hashcat_ctx); void potfile_write_close (hashcat_ctx_t *hashcat_ctx); void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len); -void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num); +int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num); void potfile_hash_free (hashcat_ctx_t *hashcat_ctx); void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); -void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); -void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); -void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); +int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); +int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); +int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); void potfile_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _POTFILE_H diff --git a/include/user_options.h b/include/user_options.h index da54d7d49..81271cd48 100644 --- a/include/user_options.h +++ b/include/user_options.h @@ -156,7 +156,7 @@ typedef enum user_options_map } user_options_map_t; -void user_options_init (hashcat_ctx_t *hashcat_ctx); +int user_options_init (hashcat_ctx_t *hashcat_ctx); void user_options_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/wordlist.h b/include/wordlist.h index fa68bf83c..0efa2221e 100644 --- a/include/wordlist.h +++ b/include/wordlist.h @@ -18,9 +18,9 @@ void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off); void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off); void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len); -void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd); +int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd); u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile); -void wl_data_init (hashcat_ctx_t *hashcat_ctx); +int wl_data_init (hashcat_ctx_t *hashcat_ctx); void wl_data_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _WORDLIST_H diff --git a/src/bitmap.c b/src/bitmap.c index 9cae87480..82f65e677 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -49,7 +49,7 @@ static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u return collisions; } -void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) +int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) { bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -58,12 +58,12 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) bitmap_ctx->enabled = false; - if (user_options->keyspace == true) return; - if (user_options->left == true) return; - if (user_options->opencl_info == true) return; - if (user_options->show == true) return; - if (user_options->usage == true) return; - if (user_options->version == true) return; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->opencl_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; bitmap_ctx->enabled = true; @@ -77,14 +77,14 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 bitmap_min = user_options->bitmap_min; const u32 bitmap_max = user_options->bitmap_max; - u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); - u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); + u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_a); + u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_b); + u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_c); + u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_d); + u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_a); + u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_b); + u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_c); + u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_d); u32 bitmap_bits; u32 bitmap_nums; @@ -131,6 +131,8 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) bitmap_ctx->bitmap_s2_b = bitmap_s2_b; bitmap_ctx->bitmap_s2_c = bitmap_s2_c; bitmap_ctx->bitmap_s2_d = bitmap_s2_d; + + return 0; } void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx) diff --git a/src/combinator.c b/src/combinator.c index 0db247519..e498e7869 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -30,7 +30,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = true; - combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (combinator_ctx->scratch_buf); if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { diff --git a/src/cpt.c b/src/cpt.c index 8cf5c36b0..9386b5d64 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -25,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = true; - cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); + cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf); cpt_ctx->cpt_total = 0; cpt_ctx->cpt_pos = 0; diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 98b248ef0..36a62919d 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -92,7 +92,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]) #define MAX_KEY_SIZE (1024 * 1024) - u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); + u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); VERIFY_PTR (buf); int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); diff --git a/src/dictstat.c b/src/dictstat.c index 6948fc299..0fbe1961f 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -42,8 +42,8 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) return 0; dictstat_ctx->enabled = true; - dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); + dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (dictstat_ctx->filename); + dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); VERIFY_PTR (dictstat_ctx->base); dictstat_ctx->cnt = 0; snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); diff --git a/src/dispatch.c b/src/dispatch.c index 701a6fe49..bb39cd8d0 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -104,7 +104,7 @@ static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param return work; } -static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) +static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -113,7 +113,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); const u32 attack_kern = user_options_extra->attack_kern; @@ -224,6 +224,8 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa device_param->kernel_loops = 0; hcfree (buf); + + return 0; } void *thread_calc_stdin (void *p) @@ -240,12 +242,12 @@ void *thread_calc_stdin (void *p) if (device_param->skipped) return NULL; - calc_stdin (hashcat_ctx, device_param); + calc_stdin (hashcat_ctx, device_param); // we should check the RC here return NULL; } -static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) +static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -316,7 +318,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); - return; + return -1; } if (attack_mode == ATTACK_MODE_COMBI) @@ -335,7 +337,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) fclose (fd); - return; + return -1; } device_param->combs_fp = combs_fp; @@ -352,14 +354,14 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) fclose (fd); - return; + return -1; } device_param->combs_fp = combs_fp; } } - hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx_tmp); /* hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx; @@ -389,9 +391,11 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx_tmp->wl_data); - wl_data_init (hashcat_ctx_tmp); + const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp); + + if (rc_wl_data_init == -1) return -1; u64 words_cur = 0; @@ -543,6 +547,8 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) device_param->kernel_accel = 0; device_param->kernel_loops = 0; + + return 0; } void *thread_calc (void *p) @@ -559,7 +565,7 @@ void *thread_calc (void *p) if (device_param->skipped) return NULL; - calc (hashcat_ctx, device_param); + calc (hashcat_ctx, device_param); // we should check the RC here return NULL; } diff --git a/src/filehandling.c b/src/filehandling.c index 77708b312..67218dba2 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -12,7 +12,7 @@ u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd) { u64 cnt = 0; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); VERIFY_PTR (buf); char prev = '\n'; diff --git a/src/folder.c b/src/folder.c index 5c09b1e2c..a3d41a34a 100644 --- a/src/folder.c +++ b/src/folder.c @@ -26,29 +26,25 @@ int sort_by_stringptr (const void *p1, const void *p2) return strcmp (*s1, *s2); } -static char *get_exec_path (hashcat_ctx_t *hashcat_ctx) +static int get_exec_path (char *exec_path, const size_t exec_path_sz) { - size_t exec_path_len = 1024; - - char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_len); - #if defined (__linux__) char tmp[32] = { 0 }; snprintf (tmp, sizeof (tmp) - 1, "/proc/%d/exe", getpid ()); - const int len = readlink (tmp, exec_path, exec_path_len - 1); + const int len = readlink (tmp, exec_path, exec_path_sz - 1); #elif defined (_WIN) - const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1); + const int len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1); #elif defined (__APPLE__) - u32 size = (u32) exec_path_len; + u32 size = (u32) exec_path_sz; - if (_NSGetExecutablePath (exec_path, &size) != 0) return NULL; + if (_NSGetExecutablePath (exec_path, &size) != 0) return -1; const size_t len = strlen (exec_path); @@ -63,11 +59,11 @@ static char *get_exec_path (hashcat_ctx_t *hashcat_ctx) char tmp[32] = { 0 }; - size_t size = exec_path_len; + size_t size = exec_path_sz; sysctl (mib, 4, exec_path, &size, NULL, 0); - const int len = readlink (tmp, exec_path, exec_path_len - 1); + const int len = readlink (tmp, exec_path, exec_path_sz - 1); #else #error Your Operating System is not supported or detected @@ -75,13 +71,14 @@ static char *get_exec_path (hashcat_ctx_t *hashcat_ctx) exec_path[len] = 0; - return exec_path; + return 0; } -char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname) +static void get_install_dir (char *install_dir, const char *exec_path) { - char *install_dir = hcstrdup (hashcat_ctx, progname); - char *last_slash = NULL; + strncpy (install_dir, exec_path, HCBUFSIZ_TINY - 1); + + char *last_slash = NULL; if ((last_slash = strrchr (install_dir, '/')) != NULL) { @@ -96,26 +93,16 @@ char *get_install_dir (hashcat_ctx_t *hashcat_ctx, const char *progname) install_dir[0] = '.'; install_dir[1] = 0; } - - return (install_dir); } -char *get_profile_dir (hashcat_ctx_t *hashcat_ctx, const char *homedir) +static void get_profile_dir (char *profile_dir, const char *home_dir) { - char *profile_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY + 1); - - snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT); - - return profile_dir; + snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT); } -char *get_session_dir (hashcat_ctx_t *hashcat_ctx, const char *profile_dir) +static void get_session_dir (char *session_dir, const char *profile_dir) { - char *session_dir = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); - - return session_dir; } int count_dictionaries (char **dictionary_files) @@ -147,7 +134,7 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) char **files = NULL; - int num_files = 0; + size_t num_files = 0; DIR *d = NULL; @@ -178,13 +165,9 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue; - size_t path_size = strlen (tmp_path) + 1 + strlen (de->d_name); + char *path_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - char *path_file = (char *) hcmalloc (hashcat_ctx, path_size + 1); - - snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name); - - path_file[path_size] = 0; + snprintf (path_file, HCBUFSIZ_TINY - 1, "%s/%s", tmp_path, de->d_name); DIR *d_test; @@ -196,11 +179,11 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) } else { - files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + + files[num_files] = path_file; num_files++; - - files[num_files - 1] = path_file; } } @@ -208,19 +191,19 @@ char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path) } else if (errno == ENOTDIR) { - files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + + files[num_files] = hcstrdup (hashcat_ctx, path); num_files++; - - files[num_files - 1] = hcstrdup (hashcat_ctx, path); } - files = (char **) hcrealloc (hashcat_ctx, files, (size_t) num_files * sizeof (char *), sizeof (char *)); + files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *)); + + files[num_files] = NULL; num_files++; - files[num_files - 1] = NULL; - hcfree (tmp_path); return (files); @@ -237,7 +220,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * then chdir() back to where we came from so we need to save it first */ - char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cwd); if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL) { @@ -250,9 +233,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * folders, as discussed on https://github.com/hashcat/hashcat/issues/20 */ - char *exec_path = get_exec_path (hashcat_ctx); + const size_t exec_path_sz = 1024; - if (exec_path == NULL) + char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_sz); VERIFY_PTR (exec_path); + + const int rc = get_exec_path (exec_path, exec_path_sz); + + if (rc == -1) { event_log_error (hashcat_ctx, "get_exec_path() failed"); @@ -280,7 +267,10 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - char *install_dir = get_install_dir (hashcat_ctx, resolved_exec_path); + char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir); + + get_install_dir (install_dir, resolved_exec_path); + char *profile_dir = NULL; char *session_dir = NULL; char *shared_dir = NULL; @@ -289,11 +279,15 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins { struct passwd *pw = getpwuid (getuid ()); - const char *homedir = pw->pw_dir; + const char *home_dir = pw->pw_dir; - profile_dir = get_profile_dir (hashcat_ctx, homedir); - session_dir = get_session_dir (hashcat_ctx, profile_dir); - shared_dir = hcstrdup (hashcat_ctx, shared_folder); + profile_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (profile_dir); + session_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (session_dir); + + get_profile_dir (profile_dir, home_dir); + get_session_dir (session_dir, profile_dir); + + shared_dir = hcstrdup (hashcat_ctx, shared_folder); hc_mkdir (profile_dir, 0700); hc_mkdir (session_dir, 0700); @@ -310,7 +304,10 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins #else - char *install_dir = get_install_dir (hashcat_ctx, exec_path); + char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir); + + get_install_dir (install_dir, exec_path); + char *profile_dir = install_dir; char *session_dir = install_dir; char *shared_dir = install_dir; @@ -326,13 +323,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load */ - char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath); #if defined (_WIN) snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir); - char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath_real); if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) { @@ -345,7 +342,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir); - char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); + char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); VERIFY_PTR (cpath_real); if (realpath (cpath, cpath_real) == NULL) { @@ -385,7 +382,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * kernel cache, we need to make sure folder exist */ - char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (kernels_folder); snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir); diff --git a/src/hashcat.c b/src/hashcat.c index e12f95c5a..f532ee365 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -66,32 +66,32 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru hashcat_ctx->event = event; - hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (hashcat_ctx, sizeof (bitmap_ctx_t)); - hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (hashcat_ctx, sizeof (combinator_ctx_t)); - hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (hashcat_ctx, sizeof (cpt_ctx_t)); - hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (debugfile_ctx_t)); - hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (dictstat_ctx_t)); - hashcat_ctx->event_ctx = (event_ctx_t *) hcmalloc (hashcat_ctx, sizeof (event_ctx_t)); - hashcat_ctx->folder_config = (folder_config_t *) hcmalloc (hashcat_ctx, sizeof (folder_config_t)); - hashcat_ctx->hashcat_user = (hashcat_user_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_user_t)); - hashcat_ctx->hashconfig = (hashconfig_t *) hcmalloc (hashcat_ctx, sizeof (hashconfig_t)); - hashcat_ctx->hashes = (hashes_t *) hcmalloc (hashcat_ctx, sizeof (hashes_t)); - hashcat_ctx->hwmon_ctx = (hwmon_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hwmon_ctx_t)); - hashcat_ctx->induct_ctx = (induct_ctx_t *) hcmalloc (hashcat_ctx, sizeof (induct_ctx_t)); - hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (logfile_ctx_t)); - hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (hashcat_ctx, sizeof (loopback_ctx_t)); - hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (hashcat_ctx, sizeof (mask_ctx_t)); - hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (hashcat_ctx, sizeof (opencl_ctx_t)); - hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outcheck_ctx_t)); - hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (outfile_ctx_t)); - hashcat_ctx->potfile_ctx = (potfile_ctx_t *) hcmalloc (hashcat_ctx, sizeof (potfile_ctx_t)); - hashcat_ctx->restore_ctx = (restore_ctx_t *) hcmalloc (hashcat_ctx, sizeof (restore_ctx_t)); - hashcat_ctx->status_ctx = (status_ctx_t *) hcmalloc (hashcat_ctx, sizeof (status_ctx_t)); - hashcat_ctx->straight_ctx = (straight_ctx_t *) hcmalloc (hashcat_ctx, sizeof (straight_ctx_t)); - hashcat_ctx->tuning_db = (tuning_db_t *) hcmalloc (hashcat_ctx, sizeof (tuning_db_t)); - hashcat_ctx->user_options_extra = (user_options_extra_t *) hcmalloc (hashcat_ctx, sizeof (user_options_extra_t)); - hashcat_ctx->user_options = (user_options_t *) hcmalloc (hashcat_ctx, sizeof (user_options_t)); - hashcat_ctx->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); + 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; } @@ -231,9 +231,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_AUTOTUNE_STARTING); - thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); + thread_param_t *threads_param = (thread_param_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (thread_param_t)); VERIFY_PTR (threads_param); - hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); + hc_thread_t *c_threads = (hc_thread_t *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (hc_thread_t)); VERIFY_PTR (c_threads); status_ctx->devices_status = STATUS_AUTOTUNE; @@ -475,8 +475,12 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { outfile_write_open (hashcat_ctx); - potfile_read_open (hashcat_ctx); - potfile_read_parse (hashcat_ctx); + potfile_read_open (hashcat_ctx); + + const int rc = potfile_read_parse (hashcat_ctx); + + if (rc == -1) return -1; + potfile_read_close (hashcat_ctx); } @@ -567,7 +571,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_BITMAP_INIT_PRE); - bitmap_ctx_init (hashcat_ctx); + const int rc_bitmap_init = bitmap_ctx_init (hashcat_ctx); + + if (rc_bitmap_init == -1) return -1; EVENT (EVENT_BITMAP_INIT_POST); @@ -581,7 +587,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * Wordlist allocate buffer */ - wl_data_init (hashcat_ctx); + const int rc_wl_data_init = wl_data_init (hashcat_ctx); + + if (rc_wl_data_init == -1) return -1; /** * straight mode init @@ -700,7 +708,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) int inner_threads_cnt = 0; - hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); + hc_thread_t *inner_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 10, sizeof (hc_thread_t)); VERIFY_PTR (inner_threads); status_ctx->shutdown_inner = false; diff --git a/src/hashes.c b/src/hashes.c index b70af831f..832a979fc 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -339,7 +339,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, event_log_info_nn (hashcat_ctx, ""); - plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); + plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); VERIFY_PTR (cracked); CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL); @@ -558,9 +558,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) salt_t *salts_buf = NULL; void *esalts_buf = NULL; - hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); + hashes_buf = (hash_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (hash_t)); VERIFY_PTR (hashes_buf); - digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); + digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); VERIFY_PTR (digests_buf); if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -568,34 +568,34 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++) { - hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); + hashinfo_t *hash_info = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info); hashes_buf[hash_pos].hash_info = hash_info; if (user_options->username && (user_options->remove || user_options->show || user_options->left)) { - hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); + hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info->user); } if (user_options->benchmark) { - hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); + hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (hash_info->orighash); } } } if (hashconfig->is_salted) { - salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, hashes_avail, sizeof (salt_t)); VERIFY_PTR (salts_buf); if (hashconfig->esalt_size) { - esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); + esalts_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->esalt_size); VERIFY_PTR (esalts_buf); } } else { - salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); + salts_buf = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf); } for (u32 hash_pos = 0; hash_pos < hashes_avail; hash_pos++) @@ -720,7 +720,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 hccap_size = sizeof (hccap_t); - char *in = (char *) hcmalloc (hashcat_ctx, hccap_size); + char *in = (char *) hcmalloc (hashcat_ctx, hccap_size); VERIFY_PTR (in); while (!feof (fp)) { @@ -891,7 +891,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) u32 line_num = 0; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (fp)) { @@ -929,7 +929,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { user_t **user = &hashes_buf[hashes_cnt].hash_info->user; - *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); + *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (*user); user_t *user_ptr = *user; @@ -1108,22 +1108,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) * Now generate all the buffers required for later */ - void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); + void *digests_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->dgst_size); VERIFY_PTR (digests_buf_new); salt_t *salts_buf_new = NULL; void *esalts_buf_new = NULL; if (hashconfig->is_salted) { - salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (salt_t)); VERIFY_PTR (salts_buf_new); if (hashconfig->esalt_size) { - esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); + esalts_buf_new = (void *) hccalloc (hashcat_ctx, hashes_cnt, hashconfig->esalt_size); VERIFY_PTR (esalts_buf_new); } } else { - salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); + salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf_new); } if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task..."); @@ -1131,8 +1131,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) u32 digests_cnt = hashes_cnt; u32 digests_done = 0; - u32 *digests_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); - u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); + u32 *digests_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (digests_shown); + u32 *digests_shown_tmp = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (digests_shown_tmp); u32 salts_cnt = 0; u32 salts_done = 0; @@ -1141,7 +1141,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { - hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); + hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); VERIFY_PTR (hash_info); if (user_options->username && (user_options->remove || user_options->show)) { @@ -1149,14 +1149,14 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) for (user_pos = 0; user_pos < hashes_cnt; user_pos++) { - hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); + hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]); - hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); + hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info[user_pos]->user); } } } - u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); + u32 *salts_shown = (u32 *) hccalloc (hashcat_ctx, digests_cnt, sizeof (u32)); VERIFY_PTR (salts_shown); salt_t *salt_buf; diff --git a/src/hlfmt.c b/src/hlfmt.c index 9cad42409..835092eda 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -342,11 +342,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) if (hashconfig->hash_mode == 5300) return HLFMT_HASHCAT; if (hashconfig->hash_mode == 5400) return HLFMT_HASHCAT; - u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); + u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); VERIFY_PTR (formats_cnt); u32 num_check = 0; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (fp)) { diff --git a/src/hwmon.c b/src/hwmon.c index 7a8375e5a..e53ea223f 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -29,7 +29,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) DWORD Type = REG_SZ; - char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); + char *Buffer = (char *) hcmalloc (hashcat_ctx, BufferSize + 1); VERIFY_PTR (Buffer); HKEY hKey = 0; @@ -1861,15 +1861,9 @@ static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapter return 0; } -static LPAdapterInfo hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, int iNumberAdapters) +static int hm_get_adapter_info_adl (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpAdapterInfo, const size_t AdapterInfoSize) { - size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo); - - LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hcmalloc (hashcat_ctx, AdapterInfoSize); - - if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize) == -1) return NULL; - - return lpAdapterInfo; + return hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, AdapterInfoSize); } static int hm_get_adapter_index_nvapi (hashcat_ctx_t *hashcat_ctx, HM_ADAPTER_NVAPI *nvapiGPUHandle) @@ -2001,14 +1995,14 @@ static u32 *hm_get_list_valid_adl_adapters (hashcat_ctx_t *hashcat_ctx, int iNum // add it to the list - adl_adapters = (u32 *) hcrealloc (hashcat_ctx, adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); + adl_adapters = (u32 *) hcrealloc (hashcat_ctx, adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check adl_adapters[*num_adl_adapters] = i; // rest is just bookkeeping - bus_numbers = (int*) hcrealloc (hashcat_ctx, bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); - device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); + bus_numbers = (int*) hcrealloc (hashcat_ctx, bus_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check + device_numbers = (int*) hcrealloc (hashcat_ctx, device_numbers, (*num_adl_adapters) * sizeof (int), sizeof (int)); // need check bus_numbers[*num_adl_adapters] = info.iBusNumber; device_numbers[*num_adl_adapters] = info.iDeviceNumber; @@ -2732,7 +2726,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->version == true) return 0; if (user_options->gpu_temp_disable == true) return 0; - hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hwmon_ctx->hm_device); /** * Initialize shared libraries @@ -2743,10 +2737,10 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) NVML_PTR *nvml = (NVML_PTR *) hcmalloc (hashcat_ctx, sizeof (NVML_PTR)); XNVCTRL_PTR *xnvctrl = (XNVCTRL_PTR *) hcmalloc (hashcat_ctx, sizeof (XNVCTRL_PTR)); - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_adl); + hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_nvapi); + hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_nvml); + hm_attrs_t *hm_adapters_xnvctrl = (hm_attrs_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hm_attrs_t)); VERIFY_PTR (hm_adapters_xnvctrl); if (opencl_ctx->need_nvml == true) { @@ -2800,7 +2794,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NVML_nvmlInit (hashcat_ctx) == 0) { - HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); + HM_ADAPTER_NVML *nvmlGPUHandle = (HM_ADAPTER_NVML *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVML)); VERIFY_PTR (nvmlGPUHandle); int tmp_in = hm_get_adapter_index_nvml (hashcat_ctx, nvmlGPUHandle); @@ -2830,7 +2824,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { if (hm_NvAPI_Initialize (hashcat_ctx) == 0) { - HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); + HM_ADAPTER_NVAPI *nvGPUHandle = (HM_ADAPTER_NVAPI *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (HM_ADAPTER_NVAPI)); VERIFY_PTR (nvGPUHandle); int tmp_in = hm_get_adapter_index_nvapi (hashcat_ctx, nvGPUHandle); @@ -2876,9 +2870,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) // adapter info - LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_adl (hashcat_ctx, hm_adapters_num); + LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (hashcat_ctx, hm_adapters_num, sizeof (AdapterInfo)); VERIFY_PTR (lpAdapterInfo); - if (lpAdapterInfo == NULL) return -1; + const int rc_adapter_info_adl = hm_get_adapter_info_adl (hashcat_ctx, lpAdapterInfo, hm_adapters_num * sizeof (AdapterInfo)); + + if (rc_adapter_info_adl == -1) return -1; // get a list (of ids of) valid/usable adapters @@ -2916,11 +2912,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) * save buffer required for later restores */ - hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); + hwmon_ctx->od_clock_mem_status = (ADLOD6MemClockState *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (ADLOD6MemClockState)); VERIFY_PTR (hwmon_ctx->od_clock_mem_status); - hwmon_ctx->od_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); + hwmon_ctx->od_power_control_status = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (hwmon_ctx->od_power_control_status); - hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned int)); + hwmon_ctx->nvml_power_limit = (unsigned int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (unsigned int)); VERIFY_PTR (hwmon_ctx->nvml_power_limit); /** * HM devices: copy @@ -3071,7 +3067,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) event_log_error (hashcat_ctx, "The custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance"); } - ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); + ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) hccalloc (hashcat_ctx, 1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel)); VERIFY_PTR (performance_state); performance_state->iNumberOfPerformanceLevels = 2; diff --git a/src/induct.c b/src/induct.c index b2abf03a6..441a71bf5 100644 --- a/src/induct.c +++ b/src/induct.c @@ -46,7 +46,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->induction_dir == NULL) { - char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory); snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR); @@ -58,7 +58,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) } else if (errno == ENOTEMPTY) { - char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory_mv); snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start); diff --git a/src/interface.c b/src/interface.c index 821fb245d..4638139d5 100644 --- a/src/interface.c +++ b/src/interface.c @@ -12934,7 +12934,7 @@ void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, } } -void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos) +int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const hashes_t *hashes = hashcat_ctx->hashes; @@ -15039,9 +15039,9 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos const u32 ckey_len = bitcoin_wallet->ckey_len; const u32 public_key_len = bitcoin_wallet->public_key_len; - char *cry_master_buf = (char *) hcmalloc (hashcat_ctx, (cry_master_len * 2) + 1); - char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1); - char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1); + char *cry_master_buf = (char *) hcmalloc (hashcat_ctx, (cry_master_len * 2) + 1); VERIFY_PTR (cry_master_buf); + char *ckey_buf = (char *) hcmalloc (hashcat_ctx, (ckey_len * 2) + 1); VERIFY_PTR (ckey_buf); + char *public_key_buf = (char *) hcmalloc (hashcat_ctx, (public_key_len * 2) + 1); VERIFY_PTR (public_key_buf); for (u32 i = 0, j = 0; i < cry_master_len; i += 1, j += 2) { @@ -15098,7 +15098,7 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos const u32 data_len = seven_zip->data_len; - char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); + char *data_buf = (char *) hcmalloc (hashcat_ctx, (data_len * 2) + 1); VERIFY_PTR (data_buf); for (u32 i = 0, j = 0; i < data_len; i += 1, j += 2) { @@ -15919,6 +15919,8 @@ void ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos out_buf[pos + 1 + salt.salt_len] = 0; } + + return 0; } int hashconfig_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/logfile.c b/src/logfile.c index 05aff8bc6..cac3fc743 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -77,12 +77,12 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->logfile_disable == true) return 0; - logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->logfile); snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session); - logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->subid); + logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->topid); logfile_ctx->enabled = true; diff --git a/src/loopback.c b/src/loopback.c index 7da270eee..f26d7ddbf 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -70,7 +70,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = true; loopback_ctx->fp = NULL; - loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (loopback_ctx->filename); return 0; } diff --git a/src/main.c b/src/main.c index 7e1d40585..71c7ce498 100644 --- a/src/main.c +++ b/src/main.c @@ -119,7 +119,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA hashcat_user->outer_threads_cnt = 0; - hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); + hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); if (hashcat_user->outer_threads == NULL) return; status_ctx->shutdown_outer = false; @@ -487,7 +487,7 @@ int main (int argc, char **argv) { // hashcat main context - hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); + 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); @@ -513,7 +513,9 @@ int main (int argc, char **argv) // initialize the user options with some defaults (you can override them later) - user_options_init (hashcat_ctx); + const int rc_options_init = user_options_init (hashcat_ctx); + + if (rc_options_init == -1) return -1; // parse commandline parameters and check them @@ -558,7 +560,9 @@ int main (int argc, char **argv) // initialize the user options with some defaults (you can override them later) - user_options_init (hashcat_ctx); + const int rc_options_init = user_options_init (hashcat_ctx); + + if (rc_options_init == -1) return -1; // your own stuff diff --git a/src/memory.c b/src/memory.c index fd04c4ab7..a566914b2 100644 --- a/src/memory.c +++ b/src/memory.c @@ -16,7 +16,7 @@ void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz) { event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); - exit (-1); + return (NULL); } return (p); @@ -30,7 +30,7 @@ void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz) { event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); - exit (-1); + return (NULL); } memset (p, 0, sz); @@ -46,7 +46,7 @@ void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, cons { event_log_error (hashcat_ctx, "%s", MSG_ENOMEM); - exit (-1); + return (NULL); } memset ((char *) p + oldsz, 0, addsz); @@ -60,7 +60,9 @@ char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s) char *b = (char *) hcmalloc (hashcat_ctx, len + 1); - strncpy (b, s, len); + if (b == NULL) return (NULL); + + memcpy (b, s, len); b[len] = 0; diff --git a/src/monitor.c b/src/monitor.c index 69e006daa..e7c7b8a5c 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -69,12 +69,12 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) // these variables are mainly used for fan control - int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); + int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (fan_speed_chgd); // temperature controller "loopback" values - int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); - int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); + int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_old); + int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_sum); time_t last_temp_check_time; diff --git a/src/mpsp.c b/src/mpsp.c index 800fcfb5c..7bb31973f 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -114,7 +114,7 @@ static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig css_cnt_lr[1] = css_cnt_r; } -static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) +static int mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) { mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; @@ -123,7 +123,7 @@ static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) u32 css_cnt_salt = mask_ctx->css_cnt + salt_len; - cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); + cs_t *css_buf_salt = (cs_t *) hccalloc (hashcat_ctx, css_cnt_salt, sizeof (cs_t)); VERIFY_PTR (css_buf_salt); memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t)); @@ -137,15 +137,17 @@ static void mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf) mask_ctx->css_buf = css_buf_salt; mask_ctx->css_cnt = css_cnt_salt; + + return 0; } -static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) +static int mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) { mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; u32 css_cnt_unicode = mask_ctx->css_cnt * 2; - cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); + cs_t *css_buf_unicode = (cs_t *) hccalloc (hashcat_ctx, css_cnt_unicode, sizeof (cs_t)); VERIFY_PTR (css_buf_unicode); for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) { @@ -159,6 +161,8 @@ static void mp_css_unicode_expand (hashcat_ctx_t *hashcat_ctx) mask_ctx->css_buf = css_buf_unicode; mask_ctx->css_cnt = css_cnt_unicode; + + return 0; } static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) @@ -190,7 +194,7 @@ static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *cs return 0; } -static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt) +static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -198,7 +202,7 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le size_t css_uniq_sz = CHARSIZ * sizeof (u32); - u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); + u32 *css_uniq = (u32 *) hcmalloc (hashcat_ctx, css_uniq_sz); VERIFY_PTR (css_uniq); size_t i; @@ -225,6 +229,8 @@ static void mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, u32 *in_buf, size_t in_le } hcfree (css_uniq); + + return 0; } static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret) @@ -245,37 +251,41 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c u32 p1 = in_buf[in_pos] & 0xff; + int rc = 0; + switch (p1) { - case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset); + case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset); break; - case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset); + case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset); break; - case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset); + case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset); break; - case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset); + case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset); break; - case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset); + case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset); break; - case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset); + case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset); break; case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return -1; } - mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset); + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset); break; case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return -1; } - mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset); + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset); break; case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return -1; } - mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset); + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset); break; case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return -1; } - mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset); + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset); break; - case '?': mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); + case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset); break; default: event_log_error (hashcat_ctx, "Syntax error: %s", in_buf); return -1; } + + if (rc == -1) return -1; } else { @@ -304,13 +314,17 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c chr = (u32) hex_convert ((u8) p1) << 0; chr |= (u32) hex_convert ((u8) p0) << 4; - mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); + const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); + + if (rc == -1) return -1; } else { u32 chr = p0; - mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); + const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset); + + if (rc == -1) return -1; } } } @@ -318,12 +332,10 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, char *in_buf, size_t in_len, c return 0; } -static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt) +static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, cs_t *css_buf, u32 *css_cnt) { const user_options_t *user_options = hashcat_ctx->user_options; - cs_t *css = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); - u32 mask_pos; u32 css_pos; @@ -341,37 +353,41 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask u32 chr = (u32) p1; + int rc = 0; + switch (p1) { - case 'l': mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css, css_pos); + case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css_buf, css_pos); break; - case 'u': mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css, css_pos); + case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css_buf, css_pos); break; - case 'd': mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css, css_pos); + case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css_buf, css_pos); break; - case 's': mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css, css_pos); + case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css_buf, css_pos); break; - case 'a': mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css, css_pos); + case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css_buf, css_pos); break; - case 'b': mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css, css_pos); + case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css_buf, css_pos); break; - case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return NULL; } - mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css, css_pos); + case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined"); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css_buf, css_pos); break; - case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return NULL; } - mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css, css_pos); + case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined"); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css_buf, css_pos); break; - case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return NULL; } - mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css, css_pos); + case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined"); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css_buf, css_pos); break; - case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return NULL; } - mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css, css_pos); + case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined"); return -1; } + rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css_buf, css_pos); break; - case '?': mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); + case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos); break; default: event_log_error (hashcat_ctx, "Syntax error: %s", mask_buf); - return NULL; + return -1; } + + if (rc == -1) return -1; } else { @@ -385,7 +401,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask { event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); - return NULL; + return -1; } char p1 = mask_buf[mask_pos]; @@ -396,7 +412,7 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask { event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", mask_buf); - return NULL; + return -1; } u32 chr = 0; @@ -404,13 +420,17 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask chr |= (u32) hex_convert ((u8) p1) << 0; chr |= (u32) hex_convert ((u8) p0) << 4; - mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); + const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos); + + if (rc == -1) return -1; } else { u32 chr = (u32) p0; - mp_add_cs_buf (hashcat_ctx, &chr, 1, css, css_pos); + const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos); + + if (rc == -1) return -1; } } } @@ -419,20 +439,18 @@ static cs_t *mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask { event_log_error (hashcat_ctx, "Invalid mask length (0)"); - return NULL; + return -1; } *css_cnt = css_pos; - return (css); + return 0; } -static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len) +static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len, char *new_mask_buf) { const user_options_t *user_options = hashcat_ctx->user_options; - char *new_mask_buf = (char *) hcmalloc (hashcat_ctx, 256); - u32 mask_pos; u32 css_pos; @@ -463,7 +481,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask { event_log_error (hashcat_ctx, "The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf); - return NULL; + return -1; } char p1 = mask_buf[mask_pos]; @@ -474,7 +492,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask { event_log_error (hashcat_ctx, "Invalid hex character detected in mask: %s", mask_buf); - return NULL; + return -1; } new_mask_buf[mask_pos] = p1; @@ -482,11 +500,7 @@ static char *mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask } } - if (css_pos == len) return (new_mask_buf); - - hcfree (new_mask_buf); - - return (NULL); + return 0; } static void mp_setup_sys (cs_t *mp_sys) @@ -587,7 +601,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) * Initialize hcstats */ - u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); + u64 *root_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (u64)); VERIFY_PTR (root_stats_buf); u64 *root_stats_ptr = root_stats_buf; @@ -600,7 +614,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) root_stats_ptr += CHARSIZ; } - u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); + u64 *markov_stats_buf = (u64 *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (u64)); VERIFY_PTR (markov_stats_buf); u64 *markov_stats_ptr = markov_stats_buf; @@ -886,13 +900,13 @@ void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u } } -static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) +static int mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) { mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; if (mask_ctx->masks_avail == mask_ctx->masks_cnt) { - mask_ctx->masks = (char **) hcrealloc (hashcat_ctx, mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); + mask_ctx->masks = (char **) hcrealloc (hashcat_ctx, mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *)); VERIFY_PTR (mask_ctx->masks); mask_ctx->masks_avail += INCR_MASKS; } @@ -900,9 +914,11 @@ static void mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (hashcat_ctx, mask); mask_ctx->masks_cnt++; + + return 0; } -static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) +static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { user_options_t *user_options = hashcat_ctx->user_options; @@ -910,17 +926,25 @@ static void mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { for (u32 increment_len = user_options->increment_min; increment_len <= user_options->increment_max; increment_len++) { - char *mask_truncated = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len); + char *mask_truncated = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (mask_truncated); - if (mask_truncated == NULL) break; + const int rc_truncated_mask = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len, mask_truncated); - mask_append_final (hashcat_ctx, mask_truncated); + if (rc_truncated_mask == -1) break; + + const int rc = mask_append_final (hashcat_ctx, mask_truncated); + + if (rc == -1) return -1; } } else { - mask_append_final (hashcat_ctx, mask); + const int rc = mask_append_final (hashcat_ctx, mask); + + if (rc == -1) return -1; } + + return 0; } int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) @@ -948,9 +972,11 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (rc_mask_file == -1) return -1; - mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt); + mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf); - if (mask_ctx->css_buf == NULL) return -1; + const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt); + + if (rc_gen_css == -1) return -1; u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } }; @@ -979,9 +1005,11 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) // always true { - mask_ctx->css_buf = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt); + mask_ctx->css_buf = (cs_t *) hccalloc (hashcat_ctx, 256, sizeof (cs_t)); VERIFY_PTR (mask_ctx->css_buf); - if (mask_ctx->css_buf == NULL) return -1; + const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt); + + if (rc_gen_css == -1) return -1; // special case for benchmark @@ -1029,7 +1057,9 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) { - mp_css_unicode_expand (hashcat_ctx); + const int rc = mp_css_unicode_expand (hashcat_ctx); + + if (rc == -1) return -1; } u32 css_cnt_orig = mask_ctx->css_cnt; @@ -1038,7 +1068,9 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) { - mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]); + const int rc = mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]); + + if (rc == -1) return -1; } } @@ -1086,13 +1118,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = true; - mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (hcstat_table_t)); - mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t)); + mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_ROOT_CNT, sizeof (hcstat_table_t)); VERIFY_PTR (mask_ctx->root_table_buf); + mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (hashcat_ctx, SP_MARKOV_CNT, sizeof (hcstat_table_t)); VERIFY_PTR (mask_ctx->markov_table_buf); sp_setup_tbl (hashcat_ctx); - mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t)); - mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t)); + mask_ctx->root_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX, sizeof (cs_t)); VERIFY_PTR (mask_ctx->root_css_buf); + mask_ctx->markov_css_buf = (cs_t *) hccalloc (hashcat_ctx, SP_PW_MAX * CHARSIZ, sizeof (cs_t)); VERIFY_PTR (mask_ctx->markov_css_buf); mask_ctx->css_cnt = 0; mask_ctx->css_buf = NULL; @@ -1103,7 +1135,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = 0; mask_ctx->masks_cnt = 0; - mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); + mask_ctx->mfs = (mf_t *) hccalloc (hashcat_ctx, MAX_MFS, sizeof (mf_t)); VERIFY_PTR (mask_ctx->mfs); mp_setup_sys (mask_ctx->mp_sys); @@ -1124,7 +1156,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (hashcat_ctx, arg); + const int rc = mask_append (hashcat_ctx, arg); + + if (rc == -1) return -1; } else { @@ -1152,7 +1186,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (mask_fp)) { @@ -1162,7 +1196,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (hashcat_ctx, line_buf); + const int rc = mask_append (hashcat_ctx, line_buf); + + if (rc == -1) return -1; } hcfree (line_buf); @@ -1182,14 +1218,18 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) { const char *mask = DEF_MASK; - mask_append (hashcat_ctx, mask); + const int rc = mask_append (hashcat_ctx, mask); + + if (rc == -1) return -1; } } else { const char *mask = hashconfig_benchmark_mask (hashcat_ctx); - mask_append (hashcat_ctx, mask); + const int rc = mask_append (hashcat_ctx, mask); + + if (rc == -1) return -1; } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) @@ -1204,7 +1244,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (hashcat_ctx, arg); + const int rc = mask_append (hashcat_ctx, arg); + + if (rc == -1) return -1; } else { @@ -1221,7 +1263,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (mask_fp)) { @@ -1231,7 +1273,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (hashcat_ctx, line_buf); + const int rc = mask_append (hashcat_ctx, line_buf); + + if (rc == -1) return -1; } hcfree (line_buf); @@ -1258,7 +1302,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (stat (arg, &file_stat) == -1) { - mask_append (hashcat_ctx, arg); + const int rc = mask_append (hashcat_ctx, arg); + + if (rc == -1) return -1; } else { @@ -1275,7 +1321,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (mask_fp)) { @@ -1285,7 +1331,9 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (line_buf[0] == '#') continue; - mask_append (hashcat_ctx, line_buf); + const int rc = mask_append (hashcat_ctx, line_buf); + + if (rc == -1) return -1; } hcfree (line_buf); diff --git a/src/opencl.c b/src/opencl.c index 5243a9bfd..434f258e2 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -224,7 +224,7 @@ static int read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_fi stat (kernel_file, &st); - char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); + char *buf = (char *) hcmalloc (hashcat_ctx, st.st_size + 1); VERIFY_PTR (buf); size_t num_read = fread (buf, sizeof (char), st.st_size, fp); @@ -1891,7 +1891,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); + hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (hc_device_param_t)); VERIFY_PTR (devices_param); opencl_ctx->devices_param = devices_param; @@ -1899,7 +1899,7 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) * Load and map OpenCL library calls */ - OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); + OCL_PTR *ocl = (OCL_PTR *) hcmalloc (hashcat_ctx, sizeof (OCL_PTR)); VERIFY_PTR (ocl); opencl_ctx->ocl = ocl; @@ -1948,9 +1948,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) */ cl_uint platforms_cnt = 0; - cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); + cl_platform_id *platforms = (cl_platform_id *) hccalloc (hashcat_ctx, CL_PLATFORMS_MAX, sizeof (cl_platform_id)); VERIFY_PTR (platforms); cl_uint platform_devices_cnt = 0; - cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); + cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); VERIFY_PTR (platform_devices); cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); @@ -2245,7 +2245,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); + char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_name); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); @@ -2259,7 +2259,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); + char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_vendor); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); @@ -2314,7 +2314,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); + char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_version); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); @@ -2328,7 +2328,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); + char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_opencl_version); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); @@ -2455,7 +2455,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); + char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); VERIFY_PTR (device_extensions); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); @@ -2523,7 +2523,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (CL_err == -1) return -1; - char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); + char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (driver_version); CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); @@ -2533,7 +2533,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name_chksum - char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *device_name_chksum = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (device_name_chksum); #if defined (__x86_64__) snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, comptime); @@ -3499,9 +3499,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); if (opencl_ctx->force_jit_compilation == -1) { @@ -3533,7 +3533,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3559,7 +3559,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3635,7 +3635,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3703,9 +3703,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); if (cached == 0) { @@ -3736,7 +3736,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3762,7 +3762,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -3844,9 +3844,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * kernel compile or load */ - size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); + size_t *kernel_lengths = (size_t *) hcmalloc (hashcat_ctx, sizeof (size_t)); VERIFY_PTR (kernel_lengths); - char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); + char **kernel_sources = (char **) hcmalloc (hashcat_ctx, sizeof (char *)); VERIFY_PTR (kernel_sources); if (cached == 0) { @@ -3877,7 +3877,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err != CL_SUCCESS) #endif { - char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); + char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); @@ -3903,7 +3903,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_err == -1) return -1; - char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); + char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); @@ -4048,15 +4048,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * main host data */ - pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); + pw_t *pws_buf = (pw_t *) hcmalloc (hashcat_ctx, size_pws); VERIFY_PTR (pws_buf); device_param->pws_buf = pws_buf; - comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); + comb_t *combs_buf = (comb_t *) hccalloc (hashcat_ctx, KERNEL_COMBS, sizeof (comb_t)); VERIFY_PTR (combs_buf); device_param->combs_buf = combs_buf; - void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); + void *hooks_buf = hcmalloc (hashcat_ctx, size_hooks); VERIFY_PTR (hooks_buf); device_param->hooks_buf = hooks_buf; diff --git a/src/outfile_check.c b/src/outfile_check.c index d4abf49a0..f86241979 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -16,7 +16,7 @@ #include "shared.h" #include "thread.h" -static void outfile_remove (hashcat_ctx_t *hashcat_ctx) +static int outfile_remove (hashcat_ctx_t *hashcat_ctx) { // some hash-dependent constants @@ -38,10 +38,10 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) // buffers hash_t hash_buf = { 0, 0, 0, 0, 0 }; - hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest); - if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); - if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); + if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt); + if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); VERIFY_PTR (hash_buf.esalt); u32 digest_buf[64] = { 0 }; @@ -83,7 +83,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) if (out_cnt_new > 0) { - out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); + out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); VERIFY_PTR (out_info_new); for (int i = 0; i < out_cnt_new; i++) { @@ -146,7 +146,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) fseek (fp, out_info[j].seek, SEEK_SET); - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); while (!feof (fp)) { @@ -307,13 +307,17 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx) hcfree (out_info); hcfree (out_files); + + return 0; } void *thread_outfile_remove (void *p) { hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p; - outfile_remove (hashcat_ctx); + const int rc = outfile_remove (hashcat_ctx); + + if (rc == -1) return NULL; return NULL; } @@ -339,7 +343,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->outfile_check_dir == NULL) { - outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (outcheck_ctx->root_directory); snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR); } diff --git a/src/potfile.c b/src/potfile.c index ea2fee650..9fd1b9923 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -164,14 +164,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->potfile_path == NULL) { - potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (potfile_ctx->filename); potfile_ctx->fp = NULL; snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir); } else { - potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); + potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); VERIFY_PTR (potfile_ctx->filename); potfile_ctx->fp = NULL; } @@ -216,22 +216,22 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) return 0; } -void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) +int potfile_read_parse (hashcat_ctx_t *hashcat_ctx) { potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - if (potfile_ctx->enabled == false) return; + if (potfile_ctx->enabled == false) return 0; - if (potfile_ctx->fp == NULL) return; + if (potfile_ctx->fp == NULL) return 0; potfile_ctx->pot_avail = count_lines (hashcat_ctx, potfile_ctx->fp); - potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); + potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); VERIFY_PTR (potfile_ctx->pot); rewind (potfile_ctx->fp); - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++) { @@ -246,7 +246,9 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail) { - potfile_hash_alloc (hashcat_ctx, INCR_POT); + const int rc = potfile_hash_alloc (hashcat_ctx, INCR_POT); + + if (rc == -1) return -1; } int parser_status; @@ -324,6 +326,8 @@ void potfile_read_parse (hashcat_ctx_t *hashcat_ctx) hcfree (line_buf); hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + return 0; } void potfile_read_close (hashcat_ctx_t *hashcat_ctx) @@ -418,12 +422,12 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * fflush (potfile_ctx->fp); } -void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) +int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) { potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - if (potfile_ctx->enabled == false) return; + if (potfile_ctx->enabled == false) return 0; u32 pos = 0; @@ -435,20 +439,22 @@ void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) hash_t *tmp_hash = &tmp_pot->hash; - tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); + tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (tmp_hash->digest); if (hashconfig->is_salted) { - tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); + tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (tmp_hash->salt); } if (hashconfig->esalt_size) { - tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); + tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (tmp_hash->esalt); } potfile_ctx->pot_hashes_avail++; } + + return 0; } void potfile_hash_free (hashcat_ctx_t *hashcat_ctx) @@ -553,12 +559,12 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu } } -void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) +int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - if (potfile_ctx->enabled == false) return; + if (potfile_ctx->enabled == false) return 0; // left @@ -588,11 +594,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { weak_hash_found = 1; - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); // in theory this is not needed, but we are paranoia: memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); + pot_right_ptr->plain_len = 0; } } @@ -601,7 +608,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { if (weak_hash_found == 1) hcfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure - return; + return 0; } // at least one half was found: @@ -613,6 +620,7 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // user unsigned char *username = NULL; + u32 user_len = 0; if (hash_left->hash_info) @@ -638,11 +646,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { left_part_masked = 1; - pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); + pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_left_ptr); memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf)); memcpy (pot_left_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len); + pot_left_ptr->plain_len = mask_plain_len; } @@ -650,11 +659,12 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { right_part_masked = 1; - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); memcpy (pot_right_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len); + pot_right_ptr->plain_len = mask_plain_len; } @@ -680,14 +690,16 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i if (left_part_masked == 1) hcfree (pot_left_ptr); if (right_part_masked == 1) hcfree (pot_right_ptr); + + return 0; } -void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) +int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - if (potfile_ctx->enabled == false) return; + if (potfile_ctx->enabled == false) return 0; // left @@ -717,7 +729,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i // we just need that pot_right_ptr is not a NULL pointer - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); + pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); } } @@ -725,7 +737,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i { if (weak_hash_found == 1) hcfree (pot_right_ptr); - return; + return 0; } // ... at least one part was not cracked @@ -738,7 +750,7 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i u32 user_len = (u32)input_len - 32u; - char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); + char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); VERIFY_PTR (hash_output); memcpy (hash_output, input_buf, input_len); @@ -769,31 +781,33 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i hcfree (hash_output); if (weak_hash_found == 1) hcfree (pot_right_ptr); + + return 0; } -void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) +int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - if (potfile_ctx->enabled == false) return; + if (potfile_ctx->enabled == false) return 0; hash_t *hashes_buf = hashes->hashes_buf; u32 hashes_cnt = hashes->hashes_cnt; // no solution for these special hash types (for instane because they use hashfile in output etc) - if (hashconfig->hash_mode == 5200) return; + if (hashconfig->hash_mode == 5200) return 0; if ((hashconfig->hash_mode >= 6200) - && (hashconfig->hash_mode <= 6299)) return; - if (hashconfig->hash_mode == 9000) return; + && (hashconfig->hash_mode <= 6299)) return 0; + if (hashconfig->hash_mode == 9000) return 0; if ((hashconfig->hash_mode >= 13700) - && (hashconfig->hash_mode <= 13799)) return; + && (hashconfig->hash_mode <= 13799)) return 0; hash_t hash_buf; - hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); + hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (hash_buf.digest); hash_buf.salt = NULL; hash_buf.esalt = NULL; hash_buf.hash_info = NULL; @@ -801,25 +815,25 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (hashconfig->is_salted) { - hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); + hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt); } if (hashconfig->esalt_size) { - hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); + hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (hash_buf.esalt); } const int rc = potfile_read_open (hashcat_ctx); - if (rc == -1) return; + if (rc == -1) return -1; - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); // to be safe work with a copy (because of line_len loop, i etc) // moved up here because it's easier to handle continue case // it's just 64kb - char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf_cpy); while (!feof (potfile_ctx->fp)) { @@ -973,4 +987,6 @@ void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } hcfree (hash_buf.digest); + + return 0; } diff --git a/src/restore.c b/src/restore.c index be40db0b1..f5513cbc6 100644 --- a/src/restore.c +++ b/src/restore.c @@ -62,7 +62,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (fp == NULL) return 0; - restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd); const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp); @@ -77,7 +77,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (rd->pid) { - char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin); int pidbin_len = -1; @@ -113,7 +113,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) #elif defined (_WIN) HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid); - char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2); int pidbin2_len = -1; @@ -156,7 +156,7 @@ static int init_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); + restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd); restore_ctx->rd = rd; @@ -211,9 +211,9 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) return -1; } - rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); + rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); VERIFY_PTR (rd->argv); - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); for (u32 i = 0; i < rd->argc; i++) { @@ -395,8 +395,8 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; - char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); - char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (eff_restore_file); + char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (new_restore_file); 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); diff --git a/src/rp.c b/src/rp.c index b9b84a199..9049fcd84 100644 --- a/src/rp.c +++ b/src/rp.c @@ -728,12 +728,12 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (user_options->rp_files_cnt) { - all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); + all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); VERIFY_PTR (all_kernel_rules_cnt); - all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); + all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); VERIFY_PTR (all_kernel_rules_buf); } - char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (rule_buf); int rule_len = 0; @@ -773,7 +773,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 if (kernel_rules_avail == kernel_rules_cnt) { - kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); + kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); kernel_rules_avail += INCR_RULES; } @@ -816,7 +816,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 u32 kernel_rules_cnt = 1; - u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); + u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); VERIFY_PTR (repeats); repeats[0] = kernel_rules_cnt; @@ -827,7 +827,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 repeats[i + 1] = kernel_rules_cnt; } - kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); for (u32 i = 0; i < kernel_rules_cnt; i++) { @@ -879,9 +879,9 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, const user_options_t *user_options = hashcat_ctx->user_options; u32 kernel_rules_cnt = 0; - kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); + kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf); - char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); + char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); VERIFY_PTR (rule_buf); for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++) { diff --git a/src/status.c b/src/status.c index f0c6b1a4f..1a63841e0 100644 --- a/src/status.c +++ b/src/status.c @@ -1347,9 +1347,9 @@ int status_progress_init (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; hashes_t *hashes = hashcat_ctx->hashes; - status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); - status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); + status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_done); + status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_rejected); + status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_restored); return 0; } diff --git a/src/straight.c b/src/straight.c index a9a2609a5..5b2af2e43 100644 --- a/src/straight.c +++ b/src/straight.c @@ -20,20 +20,22 @@ #include "straight.h" #include "wordlist.h" -static void straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict) +static int straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict) { straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt) { - straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); + straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); VERIFY_PTR (straight_ctx->dicts); straight_ctx->dicts_avail += INCR_DICTS; } - straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); + straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); VERIFY_PTR (straight_ctx->dicts[straight_ctx->dicts_cnt]); straight_ctx->dicts_cnt++; + + return 0; } int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) @@ -198,7 +200,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0)) { - straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); + straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); VERIFY_PTR (straight_ctx->kernel_rules_buf); straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP; @@ -304,7 +306,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (hashcat_ctx, l1_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename); + + if (rc == -1) return -1; } } } @@ -313,7 +317,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - straight_ctx_add_wl (hashcat_ctx, l0_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename); + + if (rc == -1) return -1; } } @@ -373,7 +379,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (hashcat_ctx, l1_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename); + + if (rc == -1) return -1; } } } @@ -382,7 +390,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - straight_ctx_add_wl (hashcat_ctx, l0_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename); + + if (rc == -1) return -1; } } @@ -433,7 +443,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (S_ISREG (l1_stat.st_mode)) { - straight_ctx_add_wl (hashcat_ctx, l1_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename); + + if (rc == -1) return -1; } } } @@ -442,7 +454,9 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) } else { - straight_ctx_add_wl (hashcat_ctx, l0_filename); + const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename); + + if (rc == -1) return -1; } } diff --git a/src/tuningdb.c b/src/tuningdb.c index 535289446..9153d53b1 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -67,7 +67,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = true; - char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); + char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (tuning_db_file); snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE); @@ -86,17 +86,17 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) // a bit over-allocated - tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); + tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); VERIFY_PTR (tuning_db->alias_buf); tuning_db->alias_cnt = 0; - tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); + tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); VERIFY_PTR (tuning_db->entry_buf); tuning_db->entry_cnt = 0; rewind (fp); int line_num = 0; - char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); + char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf); while (!feof (fp)) { diff --git a/src/user_options.c b/src/user_options.c index 9c4ef6549..2e0c92e2d 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -108,7 +108,7 @@ static char DEF_MASK_CS_1[] = "?l?d?u"; static char DEF_MASK_CS_2[] = "?l?d"; static char DEF_MASK_CS_3[] = "?l?d*!$@_"; -void user_options_init (hashcat_ctx_t *hashcat_ctx) +int user_options_init (hashcat_ctx_t *hashcat_ctx) { user_options_t *user_options = hashcat_ctx->user_options; @@ -192,10 +192,12 @@ void user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD; user_options->workload_profile = WORKLOAD_PROFILE; user_options->rp_files_cnt = 0; - user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); + user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); VERIFY_PTR (user_options->rp_files); user_options->hc_bin = PROGNAME; user_options->hc_argc = 0; user_options->hc_argv = NULL; + + return 0; } void user_options_destroy (hashcat_ctx_t *hashcat_ctx) diff --git a/src/wordlist.c b/src/wordlist.c index 4d8630442..afdc4dce7 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -58,7 +58,7 @@ u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line return (line_len); } -void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) +int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) { wl_data_t *wl_data = hashcat_ctx->wl_data; @@ -70,15 +70,15 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) wl_data->buf[wl_data->cnt] = 0; - if (wl_data->cnt == 0) return; + if (wl_data->cnt == 0) return 0; - if (wl_data->buf[wl_data->cnt - 1] == '\n') return; + if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0; while (!feof (fd)) { if (wl_data->cnt == wl_data->avail) { - wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); + wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); VERIFY_PTR (wl_data->buf); wl_data->avail += wl_data->incr; } @@ -103,7 +103,7 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) wl_data->buf[wl_data->cnt - 1] = '\n'; } - return; + return 0; } void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off) @@ -414,7 +414,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile) return (cnt); } -void wl_data_init (hashcat_ctx_t *hashcat_ctx) +int wl_data_init (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; user_options_t *user_options = hashcat_ctx->user_options; @@ -422,16 +422,16 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = false; - if (user_options->benchmark == true) return; - if (user_options->keyspace == true) return; - if (user_options->left == true) return; - if (user_options->opencl_info == true) return; - if (user_options->usage == true) return; - if (user_options->version == true) return; + if (user_options->benchmark == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->opencl_info == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; wl_data->enabled = true; - wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); + wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); VERIFY_PTR (wl_data->buf); wl_data->avail = user_options->segment_size; wl_data->incr = user_options->segment_size; wl_data->cnt = 0; @@ -452,6 +452,8 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx) { wl_data->func = get_next_word_lm; } + + return 0; } void wl_data_destroy (hashcat_ctx_t *hashcat_ctx) From 10dfea61adbe10e480a2e36ac1ca9d264fef978c Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 17:27:09 +0200 Subject: [PATCH 041/106] Add main_shared Makefile target, create main_shared.c out of main.c library use example --- src/Makefile | 58 ++++++++++++++++++++--------- src/main.c | 56 +--------------------------- src/main_shared.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 73 deletions(-) create mode 100644 src/main_shared.c diff --git a/src/Makefile b/src/Makefile index ecf889c72..aae87603f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -91,7 +91,9 @@ VERSION_TAG := $(shell test -d .git && git describe --tags --dirty= ## Compiler flags ## -CFLAGS += -pipe -W -Wall -std=c99 -Iinclude/ -IOpenCL/ -I$(OPENCL_HEADERS_KHRONOS)/ +INCLUDE_PATHS := -Iinclude/ -IOpenCL/ -I$(OPENCL_HEADERS_KHRONOS)/ + +CFLAGS += -pipe -W -Wall -std=c99 ifndef DEBUG CFLAGS += -O2 @@ -105,12 +107,11 @@ endif ## ## Linker flags ## + ifndef DEBUG LDFLAGS += -s endif - - ## ## Native compilation target ## @@ -128,8 +129,8 @@ endif # darwin ifeq ($(UNAME),Linux) CFLAGS_NATIVE := CFLAGS_NATIVE += $(CFLAGS) -LFLAGS_NATIVE := -lpthread -ldl CFLAGS_NATIVE += -DWITH_HWMON +LFLAGS_NATIVE := -lpthread -ldl LFLAGS_NATIVE += $(LDFLAGS) endif # linux @@ -140,6 +141,14 @@ LFLAGS_NATIVE := -lpthread LFLAGS_NATIVE += $(LDFLAGS) endif # freebsd +CFLAGS_NATIVE_SHARED := +CFLAGS_NATIVE_SHARED += $(CFLAGS) +CFLAGS_NATIVE_SHARED += -DWITH_HWMON -fpic +LFLAGS_NATIVE_SHARED := -L. -lhashcat +LFLAGS_NATIVE_SHARED += -Wl,-rpath=. +LFLAGS_NATIVE_SHARED += -lpthread -ldl +LFLAGS_NATIVE_SHARED += $(LDFLAGS) + ## ## Cross compilation target ## @@ -148,7 +157,6 @@ CFLAGS_CROSS_LINUX := CFLAGS_CROSS_LINUX += $(CFLAGS) CFLAGS_CROSS_LINUX += -DWITH_HWMON -#CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1 CFLAGS_CROSS_WIN := CFLAGS_CROSS_WIN += $(filter-out -fsanitize=address,$(CFLAGS)) CFLAGS_CROSS_WIN += -DWITH_HWMON @@ -171,6 +179,7 @@ LFLAGS_CROSS_WIN += -lpsapi OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o) +NATIVE_SHARED_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.SHARED.o) LINUX_32_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).LINUX.32.o) LINUX_64_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).LINUX.64.o) @@ -195,7 +204,7 @@ native: hashcat binaries: linux32 linux64 win32 win64 clean: - $(RM) -f obj/*.o *.bin *.exe *.restore *.out *.pot *.log hashcat core + $(RM) -f obj/*.o *.bin *.exe *.restore *.out *.pot *.log hashcat hashcat_shared libhashcat.so core $(RM) -rf *.induct $(RM) -rf *.outfiles $(RM) -rf *.dSYM @@ -259,36 +268,49 @@ uninstall: ## native compiled hashcat ## -obj/%.NATIVE.o: src/%.c - $(CC) $(CFLAGS_NATIVE) -c -o $@ $< +obj/%.NATIVE.o: src/%.c + $(CC) -c $(CFLAGS_NATIVE) $(INCLUDE_PATHS) -o $@ $^ -$(BINARY_NATIVE): src/main.c $(NATIVE_OBJS) - $(CC) $(CFLAGS_NATIVE) -o $(BINARY_NATIVE) $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" +$(BINARY_NATIVE): $(NATIVE_OBJS) src/main.c + $(CC) $(CFLAGS_NATIVE) $(INCLUDE_PATHS) -o $@ $^ -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" $(LFLAGS_NATIVE) + +## +## native compiled hashcat (shared) +## + +obj/%.NATIVE.SHARED.o: src/%.c + $(CC) -c $(CFLAGS_NATIVE_SHARED) $(INCLUDE_PATHS) -o $@ $^ + +lib$(BINARY_NATIVE).so: $(NATIVE_SHARED_OBJS) + $(CC) -o $@ $^ -shared + +$(BINARY_NATIVE)_shared: lib$(BINARY_NATIVE).so src/main_shared.c + $(CC) $(CFLAGS_NATIVE_SHARED) $(INCLUDE_PATHS) -o $@ $^ -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" $(LFLAGS_NATIVE_SHARED) ## ## cross compiled hashcat for binary release version ## obj/%.LINUX.32.o: src/%.c - $(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $< + $(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -c -o $@ $< obj/%.LINUX.64.o: src/%.c - $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $< + $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -c -o $@ $< obj/%.WIN.32.o: src/%.c - $(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $< + $(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -c -o $@ $< obj/%.WIN.64.o: src/%.c - $(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $< + $(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -c -o $@ $< hashcat32.bin: src/main.c $(LINUX_32_OBJS) - $(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" + $(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" hashcat64.bin: src/main.c $(LINUX_64_OBJS) - $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" + $(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" hashcat32.exe: src/main.c $(WIN_32_OBJS) - $(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" + $(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" hashcat64.exe: src/main.c $(WIN_64_OBJS) - $(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" + $(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" diff --git a/src/main.c b/src/main.c index 71c7ce498..527b0ba7d 100644 --- a/src/main.c +++ b/src/main.c @@ -11,13 +11,8 @@ #include "types.h" #include "user_options.h" #include "usage.h" -#include "hashcat.h" - -#define RUN_AS_COMMANDLINE - -#if defined (RUN_AS_COMMANDLINE) - #include "memory.h" +#include "hashcat.h" #include "terminal.h" #include "thread.h" #include "status.h" @@ -472,17 +467,6 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz } } -#else - -void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) -{ - switch (id) - { - } -} - -#endif - int main (int argc, char **argv) { // hashcat main context @@ -493,11 +477,6 @@ int main (int argc, char **argv) if (rc_hashcat_init == -1) return -1; - // initialize the session via getops for commandline use or - // alternatively you can set the user_options directly - - #if defined (RUN_AS_COMMANDLINE) - // install and shared folder need to be set to recognize "make install" use char *install_folder = NULL; @@ -549,39 +528,6 @@ int main (int argc, char **argv) const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); - #else - - // this is a bit ugly, but it's the example you're looking for - - char *hash = "8743b52063cd84097a65d1633f5c74f5"; - char *mask = "?l?l?l?l?l?l?l"; - - char *hc_argv[] = { hash, mask, NULL }; - - // initialize the user options with some defaults (you can override them later) - - const int rc_options_init = user_options_init (hashcat_ctx); - - if (rc_options_init == -1) return -1; - - // your own stuff - - user_options_t *user_options = hashcat_ctx->user_options; - - user_options->hc_argv = hc_argv; - user_options->hc_argc = 2; - user_options->quiet = true; - user_options->potfile_disable = true; - user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3 - user_options->hash_mode = 0; // MD5 - user_options->workload_profile = 3; - - // now run hashcat - - const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); - - #endif - // finished with hashcat, clean up hashcat_ctx_destroy (hashcat_ctx); diff --git a/src/main_shared.c b/src/main_shared.c new file mode 100644 index 000000000..446c375f6 --- /dev/null +++ b/src/main_shared.c @@ -0,0 +1,93 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include +#include +#include + +#include "common.h" +#include "types.h" +#include "user_options.h" +#include "usage.h" +#include "memory.h" +#include "hashcat.h" +#include "event.h" + +static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + + if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile + + fwrite (buf, len, 1, stdout); + fwrite (EOL, sizeof (EOL), 1, stdout); +} + +void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) +{ + switch (id) + { + case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break; + } +} + +int main () +{ + // hashcat main context + + 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); + + if (rc_hashcat_init == -1) return -1; + + // install and shared folder need to be set to recognize "make install" use + + char *install_folder = NULL; + char *shared_folder = NULL; + + #if defined (INSTALL_FOLDER) + install_folder = INSTALL_FOLDER; + #endif + + #if defined (SHARED_FOLDER) + shared_folder = SHARED_FOLDER; + #endif + + // this is a bit ugly, but it's the example you're looking for + + char *hash = "8743b52063cd84097a65d1633f5c74f5"; + char *mask = "?l?l?l?l?l?l?l"; + + char *hc_argv[] = { hash, mask, NULL }; + + // initialize the user options with some defaults (you can override them later) + + const int rc_options_init = user_options_init (hashcat_ctx); + + if (rc_options_init == -1) return -1; + + // your own stuff + + user_options_t *user_options = hashcat_ctx->user_options; + + user_options->hc_argv = hc_argv; + user_options->hc_argc = 2; + user_options->quiet = true; + user_options->potfile_disable = true; + user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3 + user_options->hash_mode = 0; // MD5 + user_options->workload_profile = 3; + + // now run hashcat + + const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, 0, NULL, 0); + + hashcat_ctx_destroy (hashcat_ctx); + + free (hashcat_ctx); + + return rc_hashcat; +} From e4718dc5825a23ac3c2b32b57e070595e4578132 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 17:33:23 +0200 Subject: [PATCH 042/106] Make some more useful example for returncode in main_shared.c --- src/main_shared.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main_shared.c b/src/main_shared.c index 446c375f6..43531bec7 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -85,9 +85,14 @@ int main () const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, 0, NULL, 0); + if (rc_hashcat == 0) + { + puts ("YAY, all hashes cracked!!"); + } + hashcat_ctx_destroy (hashcat_ctx); free (hashcat_ctx); - return rc_hashcat; + return 0; } From c826dc0e4d35f846180358bee34f1a72567ba660 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 17:36:18 +0200 Subject: [PATCH 043/106] install_folder and shared_folder are not mandatory, remove them from main_shared.c to make the example more easy to understand --- src/main_shared.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main_shared.c b/src/main_shared.c index 43531bec7..3ffc9feb3 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -43,19 +43,6 @@ int main () if (rc_hashcat_init == -1) return -1; - // install and shared folder need to be set to recognize "make install" use - - char *install_folder = NULL; - char *shared_folder = NULL; - - #if defined (INSTALL_FOLDER) - install_folder = INSTALL_FOLDER; - #endif - - #if defined (SHARED_FOLDER) - shared_folder = SHARED_FOLDER; - #endif - // this is a bit ugly, but it's the example you're looking for char *hash = "8743b52063cd84097a65d1633f5c74f5"; @@ -83,7 +70,7 @@ int main () // now run hashcat - const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, 0, NULL, 0); + const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); if (rc_hashcat == 0) { From fc2d242f50fc13b987b4866c7b124f75fbd230e3 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 17:45:09 +0200 Subject: [PATCH 044/106] Remove some unneeded includes from main_shared.c --- src/main_shared.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main_shared.c b/src/main_shared.c index 3ffc9feb3..fd1ebca40 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -5,15 +5,13 @@ #include #include -#include #include "common.h" #include "types.h" -#include "user_options.h" -#include "usage.h" #include "memory.h" -#include "hashcat.h" #include "event.h" +#include "user_options.h" +#include "hashcat.h" static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { From 8de576f5e95d2e7f0c63bb60a106d2558e7f43b9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 19:16:24 +0200 Subject: [PATCH 045/106] Make it possible to access error messages without using an event --- include/types.h | 6 ++- src/event.c | 109 ++++++++++++++++++++-------------------------- src/main.c | 33 +++++++++----- src/main_shared.c | 13 ++++-- 4 files changed, 83 insertions(+), 78 deletions(-) diff --git a/include/types.h b/include/types.h index 936c1e06c..739a88f27 100644 --- a/include/types.h +++ b/include/types.h @@ -1400,7 +1400,11 @@ typedef struct hashcat_user typedef struct event_ctx { - int last_len; + char msg_buf[HCBUFSIZ_TINY]; + int msg_len; + bool msg_newline; + + int prev_len; hc_thread_mutex_t mux_event; diff --git a/src/event.c b/src/event.c index 63195d520..8a1f339bf 100644 --- a/src/event.c +++ b/src/event.c @@ -47,15 +47,19 @@ size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len); + event_ctx->msg_newline = false; - return len; + event_call (EVENT_LOG_INFO, hashcat_ctx, NULL, 0); + + return event_ctx->msg_len; } size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) @@ -64,15 +68,19 @@ size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len); + event_ctx->msg_newline = false; - return len; + event_call (EVENT_LOG_WARNING, hashcat_ctx, NULL, 0); + + return event_ctx->msg_len; } size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) @@ -81,15 +89,19 @@ size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len); + event_ctx->msg_newline = false; - return len; + event_call (EVENT_LOG_ERROR, hashcat_ctx, NULL, 0); + + return event_ctx->msg_len; } size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) @@ -98,28 +110,19 @@ size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - #if defined (_WIN) + event_ctx->msg_newline = true; - buf[len + 0] = '\r'; - buf[len + 1] = '\n'; + event_call (EVENT_LOG_INFO, hashcat_ctx, NULL, 0); - event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 2); - - #else - - buf[len] = '\n'; - - event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 1); - - #endif - - return len; + return event_ctx->msg_len; } size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) @@ -128,28 +131,19 @@ size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - #if defined (_WIN) + event_ctx->msg_newline = true; - buf[len + 0] = '\r'; - buf[len + 1] = '\n'; + event_call (EVENT_LOG_WARNING, hashcat_ctx, NULL, 0); - event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 2); - - #else - - buf[len] = '\n'; - - event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 1); - - #endif - - return len; + return event_ctx->msg_len; } size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) @@ -158,28 +152,19 @@ size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_start (ap, fmt); - char buf[BUFSIZ]; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - const size_t len = event_log (fmt, ap, buf, sizeof (buf)); + event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1); + + event_ctx->msg_buf[event_ctx->msg_len] = 0; va_end (ap); - #if defined (_WIN) + event_ctx->msg_newline = true; - buf[len + 0] = '\r'; - buf[len + 1] = '\n'; + event_call (EVENT_LOG_ERROR, hashcat_ctx, NULL, 0); - event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 2); - - #else - - buf[len] = '\n'; - - event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 1); - - #endif - - return len; + return event_ctx->msg_len; } int event_ctx_init (hashcat_ctx_t *hashcat_ctx) @@ -188,7 +173,7 @@ int event_ctx_init (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_init (event_ctx->mux_event); - event_ctx->last_len = 0; + event_ctx->msg_len = 0; return 0; } @@ -199,5 +184,5 @@ void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_delete (event_ctx->mux_event); - event_ctx->last_len = 0; + event_ctx->msg_len = 0; } diff --git a/src/main.c b/src/main.c index 527b0ba7d..d857ba3e8 100644 --- a/src/main.c +++ b/src/main.c @@ -19,19 +19,23 @@ #include "interface.h" #include "event.h" -static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t len, FILE *fp) +static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) { - if (len == 0) return; + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + const char *msg_buf = event_ctx->msg_buf; + const int msg_len = event_ctx->msg_len; + const bool msg_newline = event_ctx->msg_newline; // handle last_len - event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + const int prev_len = event_ctx->prev_len; - if (event_ctx->last_len) + if (prev_len) { fputc ('\r', fp); - for (int i = 0; i < event_ctx->last_len; i++) + for (int i = 0; i < prev_len; i++) { fputc (' ', fp); } @@ -39,25 +43,30 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t fputc ('\r', fp); } - if (buf[len - 1] == '\n') + if (msg_newline == true) { - event_ctx->last_len = 0; + event_ctx->prev_len = 0; } else { - event_ctx->last_len = len; + event_ctx->prev_len = msg_len; } // finally, print - fwrite (buf, len, 1, fp); + fwrite (msg_buf, msg_len, 1, fp); + + if (msg_newline == true) + { + fwrite (EOL, sizeof (EOL), 1, fp); + } fflush (fp); } static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - main_log (hashcat_ctx, buf, len, stdout); + main_log (hashcat_ctx, stdout); } static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -66,7 +75,7 @@ static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNU fwrite (PREFIX_WARNING, sizeof (PREFIX_WARNING), 1, stdout); - main_log (hashcat_ctx, buf, len, stdout); + main_log (hashcat_ctx, stdout); } static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -75,7 +84,7 @@ static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSE fwrite (PREFIX_ERROR, sizeof (PREFIX_ERROR), 1, stderr); - main_log (hashcat_ctx, buf, len, stderr); + main_log (hashcat_ctx, stderr); } static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) diff --git a/src/main_shared.c b/src/main_shared.c index fd1ebca40..4d43c82fa 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -4,12 +4,11 @@ */ #include -#include +#include #include "common.h" #include "types.h" #include "memory.h" -#include "event.h" #include "user_options.h" #include "hashcat.h" @@ -35,7 +34,9 @@ int main () { // hashcat main context - hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx); + hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); + + assert (hashcat_ctx); const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event); @@ -74,6 +75,12 @@ int main () { puts ("YAY, all hashes cracked!!"); } + else if (rc_hashcat == -1) + { + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + + fprintf (stderr, "%s\n", event_ctx->msg_buf); + } hashcat_ctx_destroy (hashcat_ctx); From 757dc088ffefb28651e40aa94e468927538e0690 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 19:23:10 +0200 Subject: [PATCH 046/106] Transport back errors from outer_loop() --- src/hashcat.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index f532ee365..94777ff1b 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1005,15 +1005,17 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold EVENT (EVENT_OUTERLOOP_STARTING); + int rc_final = -1; + if (user_options->benchmark == true) { user_options->quiet = true; if (user_options->hash_mode_chgd == true) { - const int rc = outer_loop (hashcat_ctx); + rc_final = outer_loop (hashcat_ctx); - if (rc == -1) myabort (hashcat_ctx); + if (rc_final == -1) myabort (hashcat_ctx); } else { @@ -1021,9 +1023,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold { user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos]; - const int rc = outer_loop (hashcat_ctx); + rc_final = outer_loop (hashcat_ctx); - if (rc == -1) myabort (hashcat_ctx); + if (rc_final == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level1 == false) break; } @@ -1031,9 +1033,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold } else { - const int rc = outer_loop (hashcat_ctx); + rc_final = outer_loop (hashcat_ctx); - if (rc == -1) myabort (hashcat_ctx); + if (rc_final == -1) myabort (hashcat_ctx); } EVENT (EVENT_OUTERLOOP_FINISHED); @@ -1096,12 +1098,13 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options_destroy (hashcat_ctx); - int rc_final = -1; - - if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; - if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2; - if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; - if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; + if (rc_final == 0) + { + if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; + if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2; + if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; + if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; + } event_ctx_destroy (hashcat_ctx); From 9f59f7766e7bbd4676a97de309351f4b91812a52 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 19:31:08 +0200 Subject: [PATCH 047/106] fix newline handling on windows --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index d857ba3e8..8ffcb8c0a 100644 --- a/src/main.c +++ b/src/main.c @@ -58,7 +58,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) if (msg_newline == true) { - fwrite (EOL, sizeof (EOL), 1, fp); + fwrite (EOL, strlen (EOL), 1, fp); } fflush (fp); From a3fa435f4faf03cd811bb60129f88d7c248d27c7 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 19:44:22 +0200 Subject: [PATCH 048/106] Use \b instead a combination of \r and space --- src/main.c | 8 ++------ src/main_shared.c | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index 8ffcb8c0a..2f1aa25e1 100644 --- a/src/main.c +++ b/src/main.c @@ -33,14 +33,10 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) if (prev_len) { - fputc ('\r', fp); - for (int i = 0; i < prev_len; i++) { - fputc (' ', fp); + fputc ('\b', fp); } - - fputc ('\r', fp); } if (msg_newline == true) @@ -229,7 +225,7 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile fwrite (buf, len, 1, stdout); - fwrite (EOL, sizeof (EOL), 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); } static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) diff --git a/src/main_shared.c b/src/main_shared.c index 4d43c82fa..328165e8b 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -19,7 +19,7 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile fwrite (buf, len, 1, stdout); - fwrite (EOL, sizeof (EOL), 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); } void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) From 742b9c8404391b4148bfc3558762d5491f4aee21 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 13 Oct 2016 19:52:27 +0200 Subject: [PATCH 049/106] Fix clear line system --- src/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 2f1aa25e1..eaeef94de 100644 --- a/src/main.c +++ b/src/main.c @@ -33,10 +33,22 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) if (prev_len) { + #if defined (_WIN) + + fputc ('\r', fp); + for (int i = 0; i < prev_len; i++) { - fputc ('\b', fp); + fputc (' ', fp); } + + fputc ('\r', fp); + + #else + + printf ("\033[2K\r"); + + #endif } if (msg_newline == true) From 0179097a53c5bafbe2bade00b3fa055a1c195f62 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 13:27:35 +0200 Subject: [PATCH 050/106] Prepare for hashcat_ctx_run_session() --- include/hashcat.h | 9 +- include/types.h | 7 +- src/hashcat.c | 283 +++++++++++++++++++++------------------------- src/main.c | 251 ++++++++++++++++++++++++---------------- src/main_shared.c | 49 +++++--- src/restore.c | 2 - src/status.c | 7 +- src/thread.c | 4 - 8 files changed, 320 insertions(+), 292 deletions(-) diff --git a/include/hashcat.h b/include/hashcat.h index ed47ab4a4..45b2ae5c0 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -6,9 +6,10 @@ #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_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); +char *hashcat_ctx_last_error (hashcat_ctx_t *hashcat_ctx); +int hashcat_ctx_run_session (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), char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); +int hashcat_ctx_alloc (hashcat_ctx_t *hashcat_ctx); +void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _HASHCAT_H diff --git a/include/types.h b/include/types.h index 739a88f27..0519d0d9f 100644 --- a/include/types.h +++ b/include/types.h @@ -82,9 +82,9 @@ typedef enum event_identifier EVENT_LOG_ERROR = 0x00000003, EVENT_WELCOME_SCREEN = 0x00000011, EVENT_GOODBYE_SCREEN = 0x00000012, - EVENT_OUTERLOOP_STARTING = 0x00000031, - EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, - EVENT_OUTERLOOP_FINISHED = 0x00000033, + EVENT_SESSION_STARTING = 0x00000031, + EVENT_SESSION_MAINSCREEN = 0x00000032, + EVENT_SESSION_FINISHED = 0x00000033, EVENT_INNERLOOP1_STARTING = 0x00000041, EVENT_INNERLOOP1_FINISHED = 0x00000042, EVENT_INNERLOOP2_STARTING = 0x00000051, @@ -1339,7 +1339,6 @@ typedef struct status_ctx * thread control */ - bool run_main_level1; bool run_main_level2; bool run_main_level3; bool run_thread_level1; diff --git a/src/hashcat.c b/src/hashcat.c index 94777ff1b..a1716674a 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -52,81 +52,6 @@ #include "weak_hash.h" #include "wordlist.h" -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) @@ -140,7 +65,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; - //status_ctx->run_main_level1 = true; //status_ctx->run_main_level2 = true; //status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -390,7 +314,6 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - //status_ctx->run_main_level1 = true; //status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -431,10 +354,16 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) return 0; } -// outer_loop iterates through hash_modes (in benchmark mode) -// also initializes stuff that depend on hash mode +char *hashcat_ctx_last_error (hashcat_ctx_t *hashcat_ctx) +{ + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; -static int outer_loop (hashcat_ctx_t *hashcat_ctx) + return event_ctx->msg_buf; +} + +// hashcat_ctx_run_session also initializes stuff that depend on hash mode + +int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; @@ -447,7 +376,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - //status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -655,7 +583,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * main screen */ - EVENT (EVENT_OUTERLOOP_MAINSCREEN); + EVENT (EVENT_SESSION_MAINSCREEN); /** * inform the user @@ -740,6 +668,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_INNERLOOP1_STARTING); + int rc_inner1_loop = -1; + if (mask_ctx->masks_cnt) { restore_data_t *rd = restore_ctx->rd; @@ -755,20 +685,20 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = masks_pos; - const int rc_inner1_loop = inner1_loop (hashcat_ctx); + rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) return -1; + if (rc_inner1_loop == -1) break; if (status_ctx->run_main_level2 == false) break; } } else { - const int rc_inner1_loop = inner1_loop (hashcat_ctx); - - if (rc_inner1_loop == -1) return -1; + rc_inner1_loop = inner1_loop (hashcat_ctx); } + EVENT (EVENT_INNERLOOP1_FINISHED); + // wait for inner threads status_ctx->shutdown_inner = true; @@ -780,8 +710,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) hcfree (inner_threads); - EVENT (EVENT_INNERLOOP1_FINISHED); - // finalize potfile potfile_write_close (hashcat_ctx); @@ -810,15 +738,38 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) cpt_ctx_destroy (hashcat_ctx); - return 0; + // something for the user + + if (rc_inner1_loop == 0) + { + if (status_ctx->devices_status == STATUS_ABORTED) rc_inner1_loop = 2; + if (status_ctx->devices_status == STATUS_QUIT) rc_inner1_loop = 2; + if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_inner1_loop = 1; + if (status_ctx->devices_status == STATUS_CRACKED) rc_inner1_loop = 0; + } + + return rc_inner1_loop; } -int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime) +// hashcat_ctx_init initializes opencl, sensors, everything that can be reused if we want to run hashcat multiple times + +int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t), char *install_folder, char *shared_folder, int argc, char **argv, const int comptime) { + if (event == NULL) + { + fprintf (stderr, "Event callback function is mandatory\n"); + + return -1; + } + + hashcat_ctx->event = event; + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; + time (&status_ctx->proc_start); + /** * event init (needed for logging so should be first) */ @@ -827,6 +778,10 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_event_init == -1) return -1; + // say hello to user + + EVENT (EVENT_WELCOME_SCREEN); + /** * status init */ @@ -835,8 +790,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_status_init == -1) return -1; - EVENT (EVENT_WELCOME_SCREEN); - /** * folder */ @@ -853,14 +806,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_restore_init == -1) return -1; - /** - * process user input - */ - - user_options_preprocess (hashcat_ctx); - - user_options_extra_init (hashcat_ctx); - /** * logfile */ @@ -873,6 +818,14 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_top_msg ("START"); + /** + * final process user input (argc/argv related) + */ + + user_options_preprocess (hashcat_ctx); + + user_options_extra_init (hashcat_ctx); + // add all user options to logfile in case we want to debug some user session user_options_logger (hashcat_ctx); @@ -942,7 +895,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold /** * potfile init * this is only setting path because potfile can be used in read and write mode depending on user options - * plus it depends on hash_mode, so we continue using it in outer_loop + * plus it depends on hash_mode, so we continue using it in hashcat_ctx_run_session */ const int rc_potfile_init = potfile_init (hashcat_ctx); @@ -999,51 +952,62 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (rc_hwmon_init == -1) return -1; + return 0; +} + +int hashcat_ctx_alloc (hashcat_ctx_t *hashcat_ctx) +{ /** - * outer loop + * allocate main work objects */ - EVENT (EVENT_OUTERLOOP_STARTING); + 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); - int rc_final = -1; + return 0; +} - if (user_options->benchmark == true) - { - user_options->quiet = true; +void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) +{ + // final logfile entry - if (user_options->hash_mode_chgd == true) - { - rc_final = outer_loop (hashcat_ctx); + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (rc_final == -1) myabort (hashcat_ctx); - } - else - { - for (u32 algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++) - { - user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos]; + time (&status_ctx->proc_stop); - rc_final = outer_loop (hashcat_ctx); + logfile_top_uint (status_ctx->proc_start); + logfile_top_uint (status_ctx->proc_stop); - if (rc_final == -1) myabort (hashcat_ctx); + logfile_top_msg ("STOP"); - if (status_ctx->run_main_level1 == false) break; - } - } - } - else - { - rc_final = outer_loop (hashcat_ctx); + // say goodbye to user - if (rc_final == -1) myabort (hashcat_ctx); - } - - EVENT (EVENT_OUTERLOOP_FINISHED); - - if (user_options->benchmark == true) - { - user_options->quiet = false; - } + EVENT (EVENT_GOODBYE_SCREEN); // if exhausted or cracked, unlink the restore file @@ -1053,19 +1017,8 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold dictstat_write (hashcat_ctx); - // final logfile entry - - time (&status_ctx->proc_stop); - - logfile_top_uint (status_ctx->proc_start); - logfile_top_uint (status_ctx->proc_stop); - - logfile_top_msg ("STOP"); - // free memory - EVENT (EVENT_GOODBYE_SCREEN); - logfile_destroy (hashcat_ctx); debugfile_destroy (hashcat_ctx); @@ -1098,19 +1051,35 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold user_options_destroy (hashcat_ctx); - if (rc_final == 0) - { - if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; - if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2; - if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; - if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; - } - event_ctx_destroy (hashcat_ctx); status_ctx_destroy (hashcat_ctx); - // done + 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); - return rc_final; + memset (hashcat_ctx, 0, sizeof (hashcat_ctx_t)); } diff --git a/src/main.c b/src/main.c index eaeef94de..ca587ce06 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "common.h" #include "types.h" @@ -17,8 +18,12 @@ #include "thread.h" #include "status.h" #include "interface.h" +#include "benchmark.h" #include "event.h" +extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; +extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; + static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) { event_ctx_t *event_ctx = hashcat_ctx->event_ctx; @@ -117,7 +122,7 @@ static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop); } -static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_session_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -148,7 +153,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA } } -static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_session_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -167,6 +172,90 @@ static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA hashcat_user->outer_threads_cnt = 0; } +static void main_session_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + /** + * In benchmark-mode, inform user which algorithm is checked + */ + + if (user_options->benchmark == true) + { + if (user_options->machine_readable == false) + { + char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug + + event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); + event_log_info (hashcat_ctx, ""); + } + } + + if (user_options->quiet == true) return; + + event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); + } + + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + + if (hashconfig->opti_type) + { + event_log_info (hashcat_ctx, "Applicable Optimizers:"); + + for (u32 i = 0; i < 32; i++) + { + const u32 opti_bit = 1u << i; + + if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); + } + } + + event_log_info (hashcat_ctx, ""); + + /** + * Watchdog and Temperature balance + */ + + if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) + { + event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) + { + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); + } + else + { + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) + { + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); + } + else + { + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); + } + + event_log_info (hashcat_ctx, ""); + + #if defined (DEBUG) + if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); + #endif +} + static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -302,90 +391,6 @@ static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M event_log_info (hashcat_ctx, ""); } -static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - const hashes_t *hashes = hashcat_ctx->hashes; - const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - const user_options_t *user_options = hashcat_ctx->user_options; - - /** - * In benchmark-mode, inform user which algorithm is checked - */ - - if (user_options->benchmark == true) - { - if (user_options->machine_readable == false) - { - char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - - event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); - event_log_info (hashcat_ctx, ""); - } - } - - if (user_options->quiet == true) return; - - event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); - - if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) - { - event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); - } - - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - - if (hashconfig->opti_type) - { - event_log_info (hashcat_ctx, "Applicable Optimizers:"); - - for (u32 i = 0; i < 32; i++) - { - const u32 opti_bit = 1u << i; - - if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); - } - } - - event_log_info (hashcat_ctx, ""); - - /** - * Watchdog and Temperature balance - */ - - if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) - { - event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) - { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); - } - else - { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) - { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); - } - else - { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); - } - - event_log_info (hashcat_ctx, ""); - - #if defined (DEBUG) - if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); - #endif -} - static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -463,9 +468,9 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz case EVENT_LOG_ERROR: main_log_error (hashcat_ctx, buf, len); break; case EVENT_WELCOME_SCREEN: main_welcome_screen (hashcat_ctx, buf, len); break; case EVENT_GOODBYE_SCREEN: main_goodbye_screen (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break; - case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break; + case EVENT_SESSION_STARTING: main_session_starting (hashcat_ctx, buf, len); break; + case EVENT_SESSION_FINISHED: main_session_finished (hashcat_ctx, buf, len); break; + case EVENT_SESSION_MAINSCREEN: main_session_mainscreen (hashcat_ctx, buf, len); break; case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break; case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break; case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break; @@ -486,14 +491,6 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz int main (int argc, char **argv) { - // hashcat main context - - 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); - - if (rc_hashcat_init == -1) return -1; - // install and shared folder need to be set to recognize "make install" use char *install_folder = NULL; @@ -507,7 +504,17 @@ int main (int argc, char **argv) shared_folder = SHARED_FOLDER; #endif - // initialize the user options with some defaults (you can override them later) + // hashcat main context + + hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); + + assert (hashcat_ctx); + + const int rc_hashcat_alloc = hashcat_ctx_alloc (hashcat_ctx); + + if (rc_hashcat_alloc == -1) return -1; + + // initialize the user options with some defaults const int rc_options_init = user_options_init (hashcat_ctx); @@ -541,11 +548,55 @@ int main (int argc, char **argv) return 0; } + // initialize hashcat and check for errors + + const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event, install_folder, shared_folder, argc, argv, COMPTIME); + + if (rc_hashcat_init == -1) + { + hashcat_ctx_destroy (hashcat_ctx); + + free (hashcat_ctx); + + return -1; + } + // now run hashcat - const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); + EVENT (EVENT_SESSION_STARTING); - // finished with hashcat, clean up + int rc_hashcat = -1; + + if (user_options->benchmark == true) + { + user_options->quiet = true; + + if (user_options->hash_mode_chgd == true) + { + rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); + } + else + { + for (u32 algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++) + { + user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos]; + + rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); + + if (rc_hashcat == -1) break; + } + } + + user_options->quiet = false; + } + else + { + rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); + } + + EVENT (EVENT_SESSION_FINISHED); + + // clean up hashcat_ctx_destroy (hashcat_ctx); diff --git a/src/main_shared.c b/src/main_shared.c index 328165e8b..46f43e845 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -32,30 +32,30 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz int main () { - // hashcat main context + // hashcat context hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); assert (hashcat_ctx); - const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event); + const int rc_hashcat_alloc = hashcat_ctx_alloc (hashcat_ctx); - if (rc_hashcat_init == -1) return -1; + if (rc_hashcat_alloc == -1) return -1; - // this is a bit ugly, but it's the example you're looking for + // initialize the user options with some defaults (you can override them later) ... + + const int rc_options_init = user_options_init (hashcat_ctx); + + if (rc_options_init == -1) return -1; + + // hashcat session char *hash = "8743b52063cd84097a65d1633f5c74f5"; char *mask = "?l?l?l?l?l?l?l"; char *hc_argv[] = { hash, mask, NULL }; - // initialize the user options with some defaults (you can override them later) - - const int rc_options_init = user_options_init (hashcat_ctx); - - if (rc_options_init == -1) return -1; - - // your own stuff + // ... and add your own stuff user_options_t *user_options = hashcat_ctx->user_options; @@ -67,21 +67,36 @@ int main () user_options->hash_mode = 0; // MD5 user_options->workload_profile = 3; - // now run hashcat + // initialize hashcat and check for errors - const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); + const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event, NULL, NULL, 0, NULL, 0); - if (rc_hashcat == 0) + if (rc_hashcat_init == -1) + { + const char *error = hashcat_ctx_last_error (hashcat_ctx); + + fprintf (stderr, "%s\n", error); + + return -1; + } + + // now run hashcat and check for errors + + const int rc_session = hashcat_ctx_run_session (hashcat_ctx); + + if (rc_session == 0) { puts ("YAY, all hashes cracked!!"); } - else if (rc_hashcat == -1) + else if (rc_session == -1) { - event_ctx_t *event_ctx = hashcat_ctx->event_ctx; + const char *error = hashcat_ctx_last_error (hashcat_ctx); - fprintf (stderr, "%s\n", event_ctx->msg_buf); + fprintf (stderr, "%s\n", error); } + // clean up + hashcat_ctx_destroy (hashcat_ctx); free (hashcat_ctx); diff --git a/src/restore.c b/src/restore.c index f5513cbc6..6070f7dee 100644 --- a/src/restore.c +++ b/src/restore.c @@ -367,7 +367,6 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) 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; @@ -377,7 +376,6 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) } 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; diff --git a/src/status.c b/src/status.c index 1a63841e0..eb144451d 100644 --- a/src/status.c +++ b/src/status.c @@ -444,9 +444,9 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->masks_cnt > 1) { - const int maks_pos_done = ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_main_level1 == true)) ? 1 : 0; + const int mask_pos_done = ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_main_level2 == true)) ? 1 : 0; - double mask_percentage = (double) (mask_ctx->masks_pos + maks_pos_done) / (double) mask_ctx->masks_cnt; + double mask_percentage = (double) (mask_ctx->masks_pos + mask_pos_done) / (double) mask_ctx->masks_cnt; tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } @@ -1026,7 +1026,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } } - if (status_ctx->run_main_level1 == false) return; + if (status_ctx->run_main_level2 == false) return; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1383,7 +1383,6 @@ int status_ctx_init (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; diff --git a/src/thread.c b/src/thread.c index bedba5f78..c1fbb5f33 100644 --- a/src/thread.c +++ b/src/thread.c @@ -124,7 +124,6 @@ void mycracked (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_CRACKED; - status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -140,7 +139,6 @@ void myabort (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_ABORTED; - status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -155,7 +153,6 @@ void myquit (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_QUIT; - status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -170,7 +167,6 @@ void bypass (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_BYPASS; - status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = false; From 056083fdba0622434727981c5d03f27fee532f76 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 19:25:13 +0200 Subject: [PATCH 051/106] Revert "Prepare for hashcat_ctx_run_session()" This reverts commit 0179097a53c5bafbe2bade00b3fa055a1c195f62. --- include/hashcat.h | 9 +- include/types.h | 7 +- src/hashcat.c | 283 +++++++++++++++++++++++++--------------------- src/main.c | 251 ++++++++++++++++------------------------ src/main_shared.c | 49 +++----- src/restore.c | 2 + src/status.c | 7 +- src/thread.c | 4 + 8 files changed, 292 insertions(+), 320 deletions(-) diff --git a/include/hashcat.h b/include/hashcat.h index 45b2ae5c0..ed47ab4a4 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -6,10 +6,9 @@ #ifndef _HASHCAT_H #define _HASHCAT_H -char *hashcat_ctx_last_error (hashcat_ctx_t *hashcat_ctx); -int hashcat_ctx_run_session (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), char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); -int hashcat_ctx_alloc (hashcat_ctx_t *hashcat_ctx); -void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx); +int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime); + +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); #endif // _HASHCAT_H diff --git a/include/types.h b/include/types.h index 0519d0d9f..739a88f27 100644 --- a/include/types.h +++ b/include/types.h @@ -82,9 +82,9 @@ typedef enum event_identifier EVENT_LOG_ERROR = 0x00000003, EVENT_WELCOME_SCREEN = 0x00000011, EVENT_GOODBYE_SCREEN = 0x00000012, - EVENT_SESSION_STARTING = 0x00000031, - EVENT_SESSION_MAINSCREEN = 0x00000032, - EVENT_SESSION_FINISHED = 0x00000033, + EVENT_OUTERLOOP_STARTING = 0x00000031, + EVENT_OUTERLOOP_MAINSCREEN = 0x00000032, + EVENT_OUTERLOOP_FINISHED = 0x00000033, EVENT_INNERLOOP1_STARTING = 0x00000041, EVENT_INNERLOOP1_FINISHED = 0x00000042, EVENT_INNERLOOP2_STARTING = 0x00000051, @@ -1339,6 +1339,7 @@ typedef struct status_ctx * thread control */ + bool run_main_level1; bool run_main_level2; bool run_main_level3; bool run_thread_level1; diff --git a/src/hashcat.c b/src/hashcat.c index a1716674a..94777ff1b 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -52,6 +52,81 @@ #include "weak_hash.h" #include "wordlist.h" +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) @@ -65,6 +140,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; + //status_ctx->run_main_level1 = true; //status_ctx->run_main_level2 = true; //status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -314,6 +390,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) status_ctx_t *status_ctx = hashcat_ctx->status_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + //status_ctx->run_main_level1 = true; //status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -354,16 +431,10 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) return 0; } -char *hashcat_ctx_last_error (hashcat_ctx_t *hashcat_ctx) -{ - event_ctx_t *event_ctx = hashcat_ctx->event_ctx; +// outer_loop iterates through hash_modes (in benchmark mode) +// also initializes stuff that depend on hash mode - return event_ctx->msg_buf; -} - -// hashcat_ctx_run_session also initializes stuff that depend on hash mode - -int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) +static int outer_loop (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; @@ -376,6 +447,7 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; + //status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; @@ -583,7 +655,7 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) * main screen */ - EVENT (EVENT_SESSION_MAINSCREEN); + EVENT (EVENT_OUTERLOOP_MAINSCREEN); /** * inform the user @@ -668,8 +740,6 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_INNERLOOP1_STARTING); - int rc_inner1_loop = -1; - if (mask_ctx->masks_cnt) { restore_data_t *rd = restore_ctx->rd; @@ -685,19 +755,19 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) mask_ctx->masks_pos = masks_pos; - rc_inner1_loop = inner1_loop (hashcat_ctx); + const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) break; + if (rc_inner1_loop == -1) return -1; if (status_ctx->run_main_level2 == false) break; } } else { - rc_inner1_loop = inner1_loop (hashcat_ctx); - } + const int rc_inner1_loop = inner1_loop (hashcat_ctx); - EVENT (EVENT_INNERLOOP1_FINISHED); + if (rc_inner1_loop == -1) return -1; + } // wait for inner threads @@ -710,6 +780,8 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) hcfree (inner_threads); + EVENT (EVENT_INNERLOOP1_FINISHED); + // finalize potfile potfile_write_close (hashcat_ctx); @@ -738,38 +810,15 @@ int hashcat_ctx_run_session (hashcat_ctx_t *hashcat_ctx) cpt_ctx_destroy (hashcat_ctx); - // something for the user - - if (rc_inner1_loop == 0) - { - if (status_ctx->devices_status == STATUS_ABORTED) rc_inner1_loop = 2; - if (status_ctx->devices_status == STATUS_QUIT) rc_inner1_loop = 2; - if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_inner1_loop = 1; - if (status_ctx->devices_status == STATUS_CRACKED) rc_inner1_loop = 0; - } - - return rc_inner1_loop; + return 0; } -// hashcat_ctx_init initializes opencl, sensors, everything that can be reused if we want to run hashcat multiple times - -int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t), char *install_folder, char *shared_folder, int argc, char **argv, const int comptime) +int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime) { - if (event == NULL) - { - fprintf (stderr, "Event callback function is mandatory\n"); - - return -1; - } - - hashcat_ctx->event = event; - logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; - time (&status_ctx->proc_start); - /** * event init (needed for logging so should be first) */ @@ -778,10 +827,6 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru if (rc_event_init == -1) return -1; - // say hello to user - - EVENT (EVENT_WELCOME_SCREEN); - /** * status init */ @@ -790,6 +835,8 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru if (rc_status_init == -1) return -1; + EVENT (EVENT_WELCOME_SCREEN); + /** * folder */ @@ -806,6 +853,14 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru if (rc_restore_init == -1) return -1; + /** + * process user input + */ + + user_options_preprocess (hashcat_ctx); + + user_options_extra_init (hashcat_ctx); + /** * logfile */ @@ -818,14 +873,6 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru logfile_top_msg ("START"); - /** - * final process user input (argc/argv related) - */ - - user_options_preprocess (hashcat_ctx); - - user_options_extra_init (hashcat_ctx); - // add all user options to logfile in case we want to debug some user session user_options_logger (hashcat_ctx); @@ -895,7 +942,7 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru /** * potfile init * this is only setting path because potfile can be used in read and write mode depending on user options - * plus it depends on hash_mode, so we continue using it in hashcat_ctx_run_session + * plus it depends on hash_mode, so we continue using it in outer_loop */ const int rc_potfile_init = potfile_init (hashcat_ctx); @@ -952,62 +999,51 @@ int hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, stru if (rc_hwmon_init == -1) return -1; - return 0; -} - -int hashcat_ctx_alloc (hashcat_ctx_t *hashcat_ctx) -{ /** - * allocate main work objects + * outer loop */ - 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); + EVENT (EVENT_OUTERLOOP_STARTING); - return 0; -} + int rc_final = -1; -void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) -{ - // final logfile entry + if (user_options->benchmark == true) + { + user_options->quiet = true; - logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + if (user_options->hash_mode_chgd == true) + { + rc_final = outer_loop (hashcat_ctx); - time (&status_ctx->proc_stop); + if (rc_final == -1) myabort (hashcat_ctx); + } + else + { + for (u32 algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++) + { + user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos]; - logfile_top_uint (status_ctx->proc_start); - logfile_top_uint (status_ctx->proc_stop); + rc_final = outer_loop (hashcat_ctx); - logfile_top_msg ("STOP"); + if (rc_final == -1) myabort (hashcat_ctx); - // say goodbye to user + if (status_ctx->run_main_level1 == false) break; + } + } + } + else + { + rc_final = outer_loop (hashcat_ctx); - EVENT (EVENT_GOODBYE_SCREEN); + if (rc_final == -1) myabort (hashcat_ctx); + } + + EVENT (EVENT_OUTERLOOP_FINISHED); + + if (user_options->benchmark == true) + { + user_options->quiet = false; + } // if exhausted or cracked, unlink the restore file @@ -1017,8 +1053,19 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) dictstat_write (hashcat_ctx); + // final logfile entry + + time (&status_ctx->proc_stop); + + logfile_top_uint (status_ctx->proc_start); + logfile_top_uint (status_ctx->proc_stop); + + logfile_top_msg ("STOP"); + // free memory + EVENT (EVENT_GOODBYE_SCREEN); + logfile_destroy (hashcat_ctx); debugfile_destroy (hashcat_ctx); @@ -1051,35 +1098,19 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx) user_options_destroy (hashcat_ctx); + if (rc_final == 0) + { + if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; + if (status_ctx->devices_status == STATUS_QUIT) rc_final = 2; + if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1; + if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; + } + event_ctx_destroy (hashcat_ctx); status_ctx_destroy (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); + // done - memset (hashcat_ctx, 0, sizeof (hashcat_ctx_t)); + return rc_final; } diff --git a/src/main.c b/src/main.c index ca587ce06..eaeef94de 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "common.h" #include "types.h" @@ -18,12 +17,8 @@ #include "thread.h" #include "status.h" #include "interface.h" -#include "benchmark.h" #include "event.h" -extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT; -extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[]; - static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) { event_ctx_t *event_ctx = hashcat_ctx->event_ctx; @@ -122,7 +117,7 @@ static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop); } -static void main_session_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -153,7 +148,7 @@ static void main_session_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB } } -static void main_session_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -172,90 +167,6 @@ static void main_session_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB hashcat_user->outer_threads_cnt = 0; } -static void main_session_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) -{ - const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - const hashes_t *hashes = hashcat_ctx->hashes; - const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - const user_options_t *user_options = hashcat_ctx->user_options; - - /** - * In benchmark-mode, inform user which algorithm is checked - */ - - if (user_options->benchmark == true) - { - if (user_options->machine_readable == false) - { - char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug - - event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); - event_log_info (hashcat_ctx, ""); - } - } - - if (user_options->quiet == true) return; - - event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); - event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); - - if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) - { - event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); - } - - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - - if (hashconfig->opti_type) - { - event_log_info (hashcat_ctx, "Applicable Optimizers:"); - - for (u32 i = 0; i < 32; i++) - { - const u32 opti_bit = 1u << i; - - if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); - } - } - - event_log_info (hashcat_ctx, ""); - - /** - * Watchdog and Temperature balance - */ - - if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) - { - event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) - { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); - } - else - { - event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); - } - - if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) - { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); - } - else - { - event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); - } - - event_log_info (hashcat_ctx, ""); - - #if defined (DEBUG) - if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); - #endif -} - static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -391,6 +302,90 @@ static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M event_log_info (hashcat_ctx, ""); } +static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + /** + * In benchmark-mode, inform user which algorithm is checked + */ + + if (user_options->benchmark == true) + { + if (user_options->machine_readable == false) + { + char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug + + event_log_info (hashcat_ctx, "Hashtype: %s", hash_type); + event_log_info (hashcat_ctx, ""); + } + } + + if (user_options->quiet == true) return; + + event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt); + event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2); + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt); + } + + if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + + if (hashconfig->opti_type) + { + event_log_info (hashcat_ctx, "Applicable Optimizers:"); + + for (u32 i = 0; i < 32; i++) + { + const u32 opti_bit = 1u << i; + + if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit)); + } + } + + event_log_info (hashcat_ctx, ""); + + /** + * Watchdog and Temperature balance + */ + + if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false) + { + event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0) + { + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort); + } + else + { + event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled"); + } + + if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0) + { + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain); + } + else + { + event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled"); + } + + event_log_info (hashcat_ctx, ""); + + #if defined (DEBUG) + if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode); + #endif +} + static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -468,9 +463,9 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz case EVENT_LOG_ERROR: main_log_error (hashcat_ctx, buf, len); break; case EVENT_WELCOME_SCREEN: main_welcome_screen (hashcat_ctx, buf, len); break; case EVENT_GOODBYE_SCREEN: main_goodbye_screen (hashcat_ctx, buf, len); break; - case EVENT_SESSION_STARTING: main_session_starting (hashcat_ctx, buf, len); break; - case EVENT_SESSION_FINISHED: main_session_finished (hashcat_ctx, buf, len); break; - case EVENT_SESSION_MAINSCREEN: main_session_mainscreen (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break; + case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break; case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break; case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break; case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break; @@ -491,6 +486,14 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz int main (int argc, char **argv) { + // hashcat main context + + 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); + + if (rc_hashcat_init == -1) return -1; + // install and shared folder need to be set to recognize "make install" use char *install_folder = NULL; @@ -504,17 +507,7 @@ int main (int argc, char **argv) shared_folder = SHARED_FOLDER; #endif - // hashcat main context - - hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); - - assert (hashcat_ctx); - - const int rc_hashcat_alloc = hashcat_ctx_alloc (hashcat_ctx); - - if (rc_hashcat_alloc == -1) return -1; - - // initialize the user options with some defaults + // initialize the user options with some defaults (you can override them later) const int rc_options_init = user_options_init (hashcat_ctx); @@ -548,55 +541,11 @@ int main (int argc, char **argv) return 0; } - // initialize hashcat and check for errors - - const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event, install_folder, shared_folder, argc, argv, COMPTIME); - - if (rc_hashcat_init == -1) - { - hashcat_ctx_destroy (hashcat_ctx); - - free (hashcat_ctx); - - return -1; - } - // now run hashcat - EVENT (EVENT_SESSION_STARTING); + const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME); - int rc_hashcat = -1; - - if (user_options->benchmark == true) - { - user_options->quiet = true; - - if (user_options->hash_mode_chgd == true) - { - rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); - } - else - { - for (u32 algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++) - { - user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos]; - - rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); - - if (rc_hashcat == -1) break; - } - } - - user_options->quiet = false; - } - else - { - rc_hashcat = hashcat_ctx_run_session (hashcat_ctx); - } - - EVENT (EVENT_SESSION_FINISHED); - - // clean up + // finished with hashcat, clean up hashcat_ctx_destroy (hashcat_ctx); diff --git a/src/main_shared.c b/src/main_shared.c index 46f43e845..328165e8b 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -32,30 +32,30 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz int main () { - // hashcat context + // hashcat main context hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); assert (hashcat_ctx); - const int rc_hashcat_alloc = hashcat_ctx_alloc (hashcat_ctx); + const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event); - if (rc_hashcat_alloc == -1) return -1; + if (rc_hashcat_init == -1) return -1; - // initialize the user options with some defaults (you can override them later) ... - - const int rc_options_init = user_options_init (hashcat_ctx); - - if (rc_options_init == -1) return -1; - - // hashcat session + // this is a bit ugly, but it's the example you're looking for char *hash = "8743b52063cd84097a65d1633f5c74f5"; char *mask = "?l?l?l?l?l?l?l"; char *hc_argv[] = { hash, mask, NULL }; - // ... and add your own stuff + // initialize the user options with some defaults (you can override them later) + + const int rc_options_init = user_options_init (hashcat_ctx); + + if (rc_options_init == -1) return -1; + + // your own stuff user_options_t *user_options = hashcat_ctx->user_options; @@ -67,36 +67,21 @@ int main () user_options->hash_mode = 0; // MD5 user_options->workload_profile = 3; - // initialize hashcat and check for errors + // now run hashcat - const int rc_hashcat_init = hashcat_ctx_init (hashcat_ctx, event, NULL, NULL, 0, NULL, 0); + const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0); - if (rc_hashcat_init == -1) - { - const char *error = hashcat_ctx_last_error (hashcat_ctx); - - fprintf (stderr, "%s\n", error); - - return -1; - } - - // now run hashcat and check for errors - - const int rc_session = hashcat_ctx_run_session (hashcat_ctx); - - if (rc_session == 0) + if (rc_hashcat == 0) { puts ("YAY, all hashes cracked!!"); } - else if (rc_session == -1) + else if (rc_hashcat == -1) { - const char *error = hashcat_ctx_last_error (hashcat_ctx); + event_ctx_t *event_ctx = hashcat_ctx->event_ctx; - fprintf (stderr, "%s\n", error); + fprintf (stderr, "%s\n", event_ctx->msg_buf); } - // clean up - hashcat_ctx_destroy (hashcat_ctx); free (hashcat_ctx); diff --git a/src/restore.c b/src/restore.c index 6070f7dee..f5513cbc6 100644 --- a/src/restore.c +++ b/src/restore.c @@ -367,6 +367,7 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) 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; @@ -376,6 +377,7 @@ void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) } 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; diff --git a/src/status.c b/src/status.c index eb144451d..1a63841e0 100644 --- a/src/status.c +++ b/src/status.c @@ -444,9 +444,9 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (mask_ctx->masks_cnt > 1) { - const int mask_pos_done = ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_main_level2 == true)) ? 1 : 0; + const int maks_pos_done = ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_main_level1 == true)) ? 1 : 0; - double mask_percentage = (double) (mask_ctx->masks_pos + mask_pos_done) / (double) mask_ctx->masks_cnt; + double mask_percentage = (double) (mask_ctx->masks_pos + maks_pos_done) / (double) mask_ctx->masks_cnt; tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } @@ -1026,7 +1026,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } } - if (status_ctx->run_main_level2 == false) return; + if (status_ctx->run_main_level1 == false) return; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1383,6 +1383,7 @@ int status_ctx_init (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; + status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = true; diff --git a/src/thread.c b/src/thread.c index c1fbb5f33..bedba5f78 100644 --- a/src/thread.c +++ b/src/thread.c @@ -124,6 +124,7 @@ void mycracked (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_CRACKED; + status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -139,6 +140,7 @@ void myabort (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_ABORTED; + status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -153,6 +155,7 @@ void myquit (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_QUIT; + status_ctx->run_main_level1 = false; status_ctx->run_main_level2 = false; status_ctx->run_main_level3 = false; status_ctx->run_thread_level1 = false; @@ -167,6 +170,7 @@ void bypass (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_BYPASS; + status_ctx->run_main_level1 = true; status_ctx->run_main_level2 = true; status_ctx->run_main_level3 = true; status_ctx->run_thread_level1 = false; From ef80e3f0748c8ea2f8bc9476aaf95335eed061fd Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 20:18:45 +0200 Subject: [PATCH 052/106] Some newline fixes --- src/main.c | 4 +++- src/opencl.c | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index eaeef94de..3488d3f51 100644 --- a/src/main.c +++ b/src/main.c @@ -180,7 +180,9 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false)) { - send_prompt (); + event_log_info_nn (hashcat_ctx, ""); + + send_prompt (); } } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) diff --git a/src/opencl.c b/src/opencl.c index 434f258e2..fca84fe5e 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3507,7 +3507,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (cached == 0) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3709,8 +3709,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3850,8 +3849,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); From 9d4f9f56981f9f718d1ddd3c57840ea4ec78b7cc Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 20:29:21 +0200 Subject: [PATCH 053/106] Fix dictstat and logfile --- src/dictstat.c | 2 +- src/logfile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dictstat.c b/src/dictstat.c index 0fbe1961f..b240da726 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -48,7 +48,7 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); - FILE *fp = fopen (dictstat_ctx->filename, "wb"); + FILE *fp = fopen (dictstat_ctx->filename, "ab"); if (fp == NULL) { diff --git a/src/logfile.c b/src/logfile.c index cac3fc743..51514ab45 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -86,7 +86,7 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx) logfile_ctx->enabled = true; - FILE *fp = fopen (logfile_ctx->logfile, "wb"); + FILE *fp = fopen (logfile_ctx->logfile, "ab"); if (fp == NULL) { From 191269f4f0c19ee5109acb2f3bf2b5a460a22020 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 21:38:52 +0200 Subject: [PATCH 054/106] Add --speed-only mode --- include/types.h | 171 ++++++++++++------------- include/user_options.h | 68 +++++----- src/debugfile.c | 1 + src/dispatch.c | 13 +- src/hashcat.c | 13 +- src/induct.c | 1 + src/loopback.c | 1 + src/main.c | 6 +- src/monitor.c | 4 +- src/opencl.c | 14 +-- src/outfile_check.c | 1 + src/potfile.c | 1 + src/restore.c | 1 + src/status.c | 12 +- src/terminal.c | 9 +- src/usage.c | 1 + src/user_options.c | 278 +++++++++++++++++++++-------------------- 17 files changed, 310 insertions(+), 285 deletions(-) diff --git a/include/types.h b/include/types.h index 739a88f27..24f4fdef4 100644 --- a/include/types.h +++ b/include/types.h @@ -1082,87 +1082,10 @@ typedef struct wl_data typedef struct user_options { - bool usage; - bool version; - bool quiet; - bool benchmark; - bool stdout_flag; - bool show; - bool left; - bool username; - bool remove; - u32 remove_timer; - u64 skip; - u64 limit; - bool force; - bool keyspace; - bool potfile_disable; - char *potfile_path; - u32 debug_mode; - char *debug_file; - char *induction_dir; - char *outfile_check_dir; - u32 runtime; - u32 hash_mode; - u32 attack_mode; - char *outfile; - u32 outfile_format; - bool outfile_autohex; - u32 outfile_check_timer; - bool restore; - u32 restore_timer; - bool restore_disable; - bool status; - u32 status_timer; - bool machine_readable; - bool loopback; - u32 weak_hash_threshold; - char *session; - bool hex_charset; - bool hex_salt; - bool hex_wordlist; - u32 rp_gen; - u32 rp_gen_func_min; - u32 rp_gen_func_max; - u32 rp_gen_seed; - char *rule_buf_l; - char *rule_buf_r; - bool increment; - u32 increment_min; - u32 increment_max; - char *cpu_affinity; - bool opencl_info; - char *opencl_devices; - char *opencl_platforms; - char *opencl_device_types; - u32 opencl_vector_width; - char *truecrypt_keyfiles; - char *veracrypt_keyfiles; - u32 veracrypt_pim; - u32 workload_profile; - u32 kernel_accel; - u32 kernel_loops; - u32 nvidia_spin_damp; - bool gpu_temp_disable; - u32 gpu_temp_abort; - u32 gpu_temp_retain; - bool powertune_enable; - bool logfile_disable; - u32 segment_size; - u32 scrypt_tmto; - char separator; - u32 bitmap_min; - u32 bitmap_max; - bool markov_disable; - bool markov_classic; - u32 markov_threshold; - char *markov_hcstat; - char *custom_charset_1; - char *custom_charset_2; - char *custom_charset_3; - char *custom_charset_4; - u32 rp_files_cnt; - char **rp_files; + char *hc_bin; + + int hc_argc; + char **hc_argv; bool attack_mode_chgd; bool hash_mode_chgd; @@ -1179,10 +1102,88 @@ typedef struct user_options bool workload_profile_chgd; bool segment_size_chgd; - char *hc_bin; - - int hc_argc; - char **hc_argv; + bool benchmark; + bool force; + bool gpu_temp_disable; + bool hex_charset; + bool hex_salt; + bool hex_wordlist; + bool increment; + bool keyspace; + bool left; + bool logfile_disable; + bool loopback; + bool machine_readable; + bool markov_classic; + bool markov_disable; + bool opencl_info; + bool outfile_autohex; + bool potfile_disable; + bool powertune_enable; + bool quiet; + bool remove; + bool restore; + bool restore_disable; + bool show; + bool status; + bool stdout_flag; + bool speed_only; + bool usage; + bool username; + bool version; + char *cpu_affinity; + char *custom_charset_1; + char *custom_charset_2; + char *custom_charset_3; + char *custom_charset_4; + char *debug_file; + char *induction_dir; + char *markov_hcstat; + char *opencl_devices; + char *opencl_device_types; + char *opencl_platforms; + char *outfile; + char *outfile_check_dir; + char *potfile_path; + char **rp_files; + char *rule_buf_l; + char *rule_buf_r; + char separator; + char *session; + char *truecrypt_keyfiles; + char *veracrypt_keyfiles; + u32 attack_mode; + u32 bitmap_max; + u32 bitmap_min; + u32 debug_mode; + u32 gpu_temp_abort; + u32 gpu_temp_retain; + u32 hash_mode; + u32 increment_max; + u32 increment_min; + u32 kernel_accel; + u32 kernel_loops; + u32 markov_threshold; + u32 nvidia_spin_damp; + u32 opencl_vector_width; + u32 outfile_check_timer; + u32 outfile_format; + u32 remove_timer; + u32 restore_timer; + u32 rp_files_cnt; + u32 rp_gen; + u32 rp_gen_func_max; + u32 rp_gen_func_min; + u32 rp_gen_seed; + u32 runtime; + u32 scrypt_tmto; + u32 segment_size; + u32 status_timer; + u32 veracrypt_pim; + u32 weak_hash_threshold; + u32 workload_profile; + u64 limit; + u64 skip; } user_options_t; diff --git a/include/user_options.h b/include/user_options.h index 81271cd48..ba5fd8719 100644 --- a/include/user_options.h +++ b/include/user_options.h @@ -10,45 +10,45 @@ typedef enum user_options_defaults { - ATTACK_MODE = 0, - BENCHMARK = 0, + ATTACK_MODE = ATTACK_MODE_STRAIGHT, + BENCHMARK = false, BITMAP_MAX = 24, BITMAP_MIN = 16, DEBUG_MODE = 0, - FORCE = 0, + FORCE = false, GPU_TEMP_ABORT = 90, - GPU_TEMP_DISABLE = 0, + GPU_TEMP_DISABLE = false, GPU_TEMP_RETAIN = 75, HASH_MODE = 0, - HEX_CHARSET = 0, - HEX_SALT = 0, - HEX_WORDLIST = 0, - INCREMENT = 0, + HEX_CHARSET = false, + HEX_SALT = false, + HEX_WORDLIST = false, + INCREMENT = false, INCREMENT_MAX = PW_MAX, INCREMENT_MIN = 1, KERNEL_ACCEL = 0, KERNEL_LOOPS = 0, - KEYSPACE = 0, - LEFT = 0, + KEYSPACE = false, + LEFT = false, LIMIT = 0, - LOGFILE_DISABLE = 0, - LOOPBACK = 0, - MACHINE_READABLE = 0, - MARKOV_CLASSIC = 0, - MARKOV_DISABLE = 0, + LOGFILE_DISABLE = false, + LOOPBACK = false, + MACHINE_READABLE = false, + MARKOV_CLASSIC = false, + MARKOV_DISABLE = false, MARKOV_THRESHOLD = 0, NVIDIA_SPIN_DAMP = 100, OPENCL_VECTOR_WIDTH = 0, - OUTFILE_AUTOHEX = 1, + OUTFILE_AUTOHEX = true, OUTFILE_CHECK_TIMER = 5, OUTFILE_FORMAT = 3, - POTFILE_DISABLE = 0, - POWERTUNE_ENABLE = 0, - QUIET = 0, - REMOVE = 0, + POTFILE_DISABLE = false, + POWERTUNE_ENABLE = false, + QUIET = false, + REMOVE = false, REMOVE_TIMER = 60, - RESTORE = 0, - RESTORE_DISABLE = 0, + RESTORE = false, + RESTORE_DISABLE = false, RESTORE_TIMER = 60, RP_GEN = 0, RP_GEN_FUNC_MAX = 4, @@ -58,14 +58,15 @@ typedef enum user_options_defaults SCRYPT_TMTO = 0, SEGMENT_SIZE = 33554432, SEPARATOR = ':', - SHOW = 0, + SHOW = false, SKIP = 0, - STATUS = 0, + STATUS = false, STATUS_TIMER = 10, - STDOUT_FLAG = 0, - USAGE = 0, - USERNAME = 0, - VERSION = 0, + STDOUT_FLAG = false, + SPEED_ONLY = false, + USAGE = false, + USERNAME = false, + VERSION = false, WEAK_HASH_THRESHOLD = 100, WORKLOAD_PROFILE = 2, @@ -145,13 +146,14 @@ typedef enum user_options_map IDX_STATUS = 0xff2d, IDX_STATUS_TIMER = 0xff2e, IDX_STDOUT_FLAG = 0xff2f, - IDX_TRUECRYPT_KEYFILES = 0xff30, - IDX_USERNAME = 0xff31, - IDX_VERACRYPT_KEYFILES = 0xff32, - IDX_VERACRYPT_PIM = 0xff33, + IDX_SPEED_ONLY = 0xff30, + IDX_TRUECRYPT_KEYFILES = 0xff31, + IDX_USERNAME = 0xff32, + IDX_VERACRYPT_KEYFILES = 0xff33, + IDX_VERACRYPT_PIM = 0xff34, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WEAK_HASH_THRESHOLD = 0xff34, + IDX_WEAK_HASH_THRESHOLD = 0xff35, IDX_WORKLOAD_PROFILE = 'w' } user_options_map_t; diff --git a/src/debugfile.c b/src/debugfile.c index 70614da0a..9e8c0941a 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -91,6 +91,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->opencl_info == 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; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->debug_mode == 0) return 0; diff --git a/src/dispatch.c b/src/dispatch.c index bb39cd8d0..e50a4a675 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -218,6 +218,10 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par } */ } + + if (status_ctx->run_thread_level1 == false) break; + + if (user_options->speed_only == true) break; } device_param->kernel_accel = 0; @@ -282,16 +286,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) run_cracker (hashcat_ctx, device_param, pws_cnt); device_param->pws_cnt = 0; - - /* - still required? - run_kernel_bzero (device_param, device_param->d_bfs_c, device_param->size_bfs); - */ } if (status_ctx->run_thread_level1 == false) break; - if (user_options->benchmark == true) break; + if (user_options->speed_only == true) break; device_param->words_done = words_fin; } @@ -524,6 +523,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) */ } + if (user_options->speed_only == true) break; + if (status_ctx->run_thread_level1 == false) break; if (words_fin == 0) break; diff --git a/src/hashcat.c b/src/hashcat.c index 94777ff1b..630bc5014 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -716,7 +716,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * Outfile remove */ - if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false) + if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->speed_only == false) { hc_thread_create (inner_threads[inner_threads_cnt], thread_monitor, hashcat_ctx); @@ -1030,21 +1030,22 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (status_ctx->run_main_level1 == false) break; } } + + user_options->quiet = false; } else { + if (user_options->speed_only == true) user_options->quiet = true; + rc_final = outer_loop (hashcat_ctx); if (rc_final == -1) myabort (hashcat_ctx); + + if (user_options->speed_only == true) user_options->quiet = false; } EVENT (EVENT_OUTERLOOP_FINISHED); - if (user_options->benchmark == true) - { - user_options->quiet = false; - } - // if exhausted or cracked, unlink the restore file unlink_restore (hashcat_ctx); diff --git a/src/induct.c b/src/induct.c index 441a71bf5..757157419 100644 --- a/src/induct.c +++ b/src/induct.c @@ -36,6 +36,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->opencl_info == 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; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/loopback.c b/src/loopback.c index f26d7ddbf..973bcf8ca 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -65,6 +65,7 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) if (user_options->opencl_info == 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; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; diff --git a/src/main.c b/src/main.c index 3488d3f51..71eb036db 100644 --- a/src/main.c +++ b/src/main.c @@ -135,7 +135,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA status_ctx->shutdown_outer = false; - if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->opencl_info == false) + if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->opencl_info == false && user_options->speed_only == false) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { @@ -178,7 +178,7 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false)) + if ((user_options->quiet == false) && (user_options->benchmark == false) && (user_options->speed_only == false)) { event_log_info_nn (hashcat_ctx, ""); @@ -199,7 +199,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB // print final status - if (user_options->benchmark == true) + if ((user_options->benchmark == true) || (user_options->speed_only == true)) { status_benchmark (hashcat_ctx); diff --git a/src/monitor.c b/src/monitor.c index e7c7b8a5c..c8c8ab3f7 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -307,12 +307,14 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) clear_prompt (); - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); + if (user_options->quiet == false) send_prompt (); + hc_thread_mutex_unlock (status_ctx->mux_display); status_left = user_options->status_timer; diff --git a/src/opencl.c b/src/opencl.c index fca84fe5e..9eb68c400 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1071,7 +1071,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, device_param->speed_ms[speed_pos] = speed_ms; - if (user_options->benchmark == true) + if (user_options->speed_only == true) { if (speed_ms > 4096) return -1; } @@ -1798,7 +1798,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co if (CL_err == -1) return -1; } - if (user_options->benchmark == true) + if (user_options->speed_only == true) { hc_timer_set (&device_param->timer_speed); } @@ -1811,7 +1811,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co * result */ - if (user_options->benchmark == false) + if (user_options->speed_only == false) { check_cracked (hashcat_ctx, device_param, salt_pos); } @@ -1857,7 +1857,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co * benchmark */ - if (user_options->benchmark == true) break; + if (user_options->speed_only == true) break; if (status_ctx->run_thread_level2 == false) break; } @@ -2177,7 +2177,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) fprintf (stdout, "\nPlatform ID #%u\n Vendor : %s\n Name : %s\n Version : %s\n\n", platform_id + 1, platform_vendor, platform_name, platform_version); } - if ((user_options->benchmark == true || user_options->quiet == false)) + if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) { if (user_options->machine_readable == false) { @@ -2648,7 +2648,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) hcfree (device_opencl_version); - if ((user_options->benchmark == true || user_options->quiet == false)) + if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) { if (user_options->machine_readable == false) { @@ -2763,7 +2763,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) devices_cnt++; } - if ((user_options->benchmark == true || user_options->quiet == false)) + if ((user_options->benchmark == true || user_options->speed_only == true || user_options->quiet == false)) { if (user_options->machine_readable == false) { diff --git a/src/outfile_check.c b/src/outfile_check.c index f86241979..c5d90c381 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -332,6 +332,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->keyspace == true) return 0; if (user_options->benchmark == true) return 0; + if (user_options->speed_only == true) return 0; if (user_options->opencl_info == true) return 0; if (user_options->outfile_check_timer == 0) return 0; diff --git a/src/potfile.c b/src/potfile.c index 9fd1b9923..9dd4a9352 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -156,6 +156,7 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->keyspace == true) return 0; if (user_options->opencl_info == true) return 0; if (user_options->stdout_flag == true) return 0; + if (user_options->speed_only == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->potfile_disable == true) return 0; diff --git a/src/restore.c b/src/restore.c index f5513cbc6..1ee55ee8a 100644 --- a/src/restore.c +++ b/src/restore.c @@ -420,6 +420,7 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->opencl_info == 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; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->restore_disable == true) return 0; diff --git a/src/status.c b/src/status.c index 1a63841e0..572c49a35 100644 --- a/src/status.c +++ b/src/status.c @@ -1175,9 +1175,9 @@ void status_display (hashcat_ctx_t *hashcat_ctx) void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; if (status_ctx->devices_status == STATUS_INIT) { @@ -1234,9 +1234,9 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) void status_benchmark (hashcat_ctx_t *hashcat_ctx) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; if (status_ctx->devices_status == STATUS_INIT) { diff --git a/src/terminal.c b/src/terminal.c index 09b084045..da1762842 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -29,7 +29,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const { if (user_options->machine_readable == false) { - event_log_info (hashcat_ctx, "%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, "%s (%s) starting in benchmark mode...", PROGNAME, version_tag); event_log_info (hashcat_ctx, ""); } else @@ -39,7 +39,12 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const } else if (user_options->restore == true) { - event_log_info (hashcat_ctx, "%s (%s) starting in restore-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, "%s (%s) starting in restore mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); + } + else if (user_options->speed_only == true) + { + event_log_info (hashcat_ctx, "%s (%s) starting in speed-only mode...", PROGNAME, version_tag); event_log_info (hashcat_ctx, ""); } else diff --git a/src/usage.c b/src/usage.c index a7b1d5ca9..5df411326 100644 --- a/src/usage.c +++ b/src/usage.c @@ -68,6 +68,7 @@ static const char *USAGE_BIG[] = " --veracrypt-keyfiles | File | Keyfiles used, separate with comma | --veracrypt-key=x.txt", " --veracrypt-pim | Num | VeraCrypt personal iterations multiplier | --veracrypt-pim=1000", " -b, --benchmark | | Run benchmark |", + " --speed-only | | Just return expected speed of the attack and quit |", " -c, --segment-size | Num | Sets size in MB to cache from the wordfile to X | -c 32", " --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24", " --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24", diff --git a/src/user_options.c b/src/user_options.c index 2e0c92e2d..104d84b3b 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -18,86 +18,87 @@ static const char short_options[] = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4: static const struct option long_options[] = { - {"help", no_argument, 0, IDX_HELP}, - {"version", no_argument, 0, IDX_VERSION}, - {"quiet", no_argument, 0, IDX_QUIET}, - {"show", no_argument, 0, IDX_SHOW}, - {"left", no_argument, 0, IDX_LEFT}, - {"username", no_argument, 0, IDX_USERNAME}, - {"remove", no_argument, 0, IDX_REMOVE}, - {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER}, - {"skip", required_argument, 0, IDX_SKIP}, - {"limit", required_argument, 0, IDX_LIMIT}, - {"keyspace", no_argument, 0, IDX_KEYSPACE}, - {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE}, - {"potfile-path", required_argument, 0, IDX_POTFILE_PATH}, - {"debug-mode", required_argument, 0, IDX_DEBUG_MODE}, - {"debug-file", required_argument, 0, IDX_DEBUG_FILE}, - {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR}, - {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR}, - {"force", no_argument, 0, IDX_FORCE}, - {"benchmark", no_argument, 0, IDX_BENCHMARK}, - {"stdout", no_argument, 0, IDX_STDOUT_FLAG}, - {"restore", no_argument, 0, IDX_RESTORE}, - {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE}, - {"status", no_argument, 0, IDX_STATUS}, - {"status-timer", required_argument, 0, IDX_STATUS_TIMER}, - {"machine-readable", no_argument, 0, IDX_MACHINE_READABLE}, - {"loopback", no_argument, 0, IDX_LOOPBACK}, - {"weak-hash-threshold", required_argument, 0, IDX_WEAK_HASH_THRESHOLD}, - {"session", required_argument, 0, IDX_SESSION}, - {"runtime", required_argument, 0, IDX_RUNTIME}, - {"generate-rules", required_argument, 0, IDX_RP_GEN}, - {"generate-rules-func-min", required_argument, 0, IDX_RP_GEN_FUNC_MIN}, - {"generate-rules-func-max", required_argument, 0, IDX_RP_GEN_FUNC_MAX}, - {"generate-rules-seed", required_argument, 0, IDX_RP_GEN_SEED}, - {"rule-left", required_argument, 0, IDX_RULE_BUF_L}, - {"rule-right", required_argument, 0, IDX_RULE_BUF_R}, - {"hash-type", required_argument, 0, IDX_HASH_MODE}, {"attack-mode", required_argument, 0, IDX_ATTACK_MODE}, - {"rules-file", required_argument, 0, IDX_RP_FILE}, - {"outfile", required_argument, 0, IDX_OUTFILE}, - {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT}, - {"outfile-autohex-disable", no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE}, - {"outfile-check-timer", required_argument, 0, IDX_OUTFILE_CHECK_TIMER}, - {"hex-charset", no_argument, 0, IDX_HEX_CHARSET}, - {"hex-salt", no_argument, 0, IDX_HEX_SALT}, - {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST}, - {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE}, - {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC}, - {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD}, - {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT}, - {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY}, - {"opencl-info", no_argument, 0, IDX_OPENCL_INFO}, - {"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES}, - {"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS}, - {"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES}, - {"opencl-vector-width", required_argument, 0, IDX_OPENCL_VECTOR_WIDTH}, - {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE}, - {"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL}, - {"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS}, - {"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP}, - {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE}, - {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT}, - {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN}, - {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE}, - {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE}, - {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES}, - {"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES}, - {"veracrypt-pim", required_argument, 0, IDX_VERACRYPT_PIM}, - {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE}, - {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO}, - {"seperator", required_argument, 0, IDX_SEPARATOR}, - {"separator", required_argument, 0, IDX_SEPARATOR}, - {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN}, + {"benchmark", no_argument, 0, IDX_BENCHMARK}, {"bitmap-max", required_argument, 0, IDX_BITMAP_MAX}, - {"increment", no_argument, 0, IDX_INCREMENT}, - {"increment-min", required_argument, 0, IDX_INCREMENT_MIN}, - {"increment-max", required_argument, 0, IDX_INCREMENT_MAX}, + {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN}, + {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY}, {"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1}, {"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2}, {"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3}, {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4}, + {"debug-file", required_argument, 0, IDX_DEBUG_FILE}, + {"debug-mode", required_argument, 0, IDX_DEBUG_MODE}, + {"force", no_argument, 0, IDX_FORCE}, + {"generate-rules-func-max", required_argument, 0, IDX_RP_GEN_FUNC_MAX}, + {"generate-rules-func-min", required_argument, 0, IDX_RP_GEN_FUNC_MIN}, + {"generate-rules", required_argument, 0, IDX_RP_GEN}, + {"generate-rules-seed", required_argument, 0, IDX_RP_GEN_SEED}, + {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT}, + {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE}, + {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN}, + {"hash-type", required_argument, 0, IDX_HASH_MODE}, + {"help", no_argument, 0, IDX_HELP}, + {"hex-charset", no_argument, 0, IDX_HEX_CHARSET}, + {"hex-salt", no_argument, 0, IDX_HEX_SALT}, + {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST}, + {"increment-max", required_argument, 0, IDX_INCREMENT_MAX}, + {"increment-min", required_argument, 0, IDX_INCREMENT_MIN}, + {"increment", no_argument, 0, IDX_INCREMENT}, + {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR}, + {"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL}, + {"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS}, + {"keyspace", no_argument, 0, IDX_KEYSPACE}, + {"left", no_argument, 0, IDX_LEFT}, + {"limit", required_argument, 0, IDX_LIMIT}, + {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE}, + {"loopback", no_argument, 0, IDX_LOOPBACK}, + {"machine-readable", no_argument, 0, IDX_MACHINE_READABLE}, + {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC}, + {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE}, + {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT}, + {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD}, + {"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP}, + {"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES}, + {"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES}, + {"opencl-info", no_argument, 0, IDX_OPENCL_INFO}, + {"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS}, + {"opencl-vector-width", required_argument, 0, IDX_OPENCL_VECTOR_WIDTH}, + {"outfile-autohex-disable", no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE}, + {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR}, + {"outfile-check-timer", required_argument, 0, IDX_OUTFILE_CHECK_TIMER}, + {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT}, + {"outfile", required_argument, 0, IDX_OUTFILE}, + {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE}, + {"potfile-path", required_argument, 0, IDX_POTFILE_PATH}, + {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE}, + {"quiet", no_argument, 0, IDX_QUIET}, + {"remove", no_argument, 0, IDX_REMOVE}, + {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER}, + {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE}, + {"restore", no_argument, 0, IDX_RESTORE}, + {"rule-left", required_argument, 0, IDX_RULE_BUF_L}, + {"rule-right", required_argument, 0, IDX_RULE_BUF_R}, + {"rules-file", required_argument, 0, IDX_RP_FILE}, + {"runtime", required_argument, 0, IDX_RUNTIME}, + {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO}, + {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE}, + {"separator", required_argument, 0, IDX_SEPARATOR}, + {"seperator", required_argument, 0, IDX_SEPARATOR}, + {"session", required_argument, 0, IDX_SESSION}, + {"show", no_argument, 0, IDX_SHOW}, + {"skip", required_argument, 0, IDX_SKIP}, + {"status", no_argument, 0, IDX_STATUS}, + {"status-timer", required_argument, 0, IDX_STATUS_TIMER}, + {"stdout", no_argument, 0, IDX_STDOUT_FLAG}, + {"speed-only", no_argument, 0, IDX_SPEED_ONLY}, + {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES}, + {"username", no_argument, 0, IDX_USERNAME}, + {"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES}, + {"veracrypt-pim", required_argument, 0, IDX_VERACRYPT_PIM}, + {"version", no_argument, 0, IDX_VERSION}, + {"weak-hash-threshold", required_argument, 0, IDX_WEAK_HASH_THRESHOLD}, + {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE}, {0, 0, 0, 0} }; @@ -183,6 +184,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->status = STATUS; user_options->status_timer = STATUS_TIMER; user_options->stdout_flag = STDOUT_FLAG; + user_options->speed_only = SPEED_ONLY; user_options->truecrypt_keyfiles = NULL; user_options->usage = USAGE; user_options->username = USERNAME; @@ -247,6 +249,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_KEYSPACE: user_options->keyspace = true; break; case IDX_BENCHMARK: user_options->benchmark = true; break; case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break; + case IDX_SPEED_ONLY: user_options->speed_only = true; break; case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; case IDX_STATUS: user_options->status = true; break; case IDX_STATUS_TIMER: user_options->status_timer = atoi (optarg); break; @@ -909,7 +912,8 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) if (user_options->opencl_info == true || user_options->keyspace == true || user_options->benchmark == true - || user_options->stdout_flag == true) + || user_options->stdout_flag == true + || user_options->speed_only == true) { user_options->show = false; user_options->left = false; @@ -932,6 +936,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->session = "benchmark"; user_options->attack_mode = ATTACK_MODE_BF; user_options->increment = false; + user_options->speed_only = true; if (user_options->workload_profile_chgd == false) { @@ -1198,66 +1203,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) user_options_t *user_options = hashcat_ctx->user_options; logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; - logfile_top_uint (user_options->benchmark); - logfile_top_uint (user_options->force); - logfile_top_uint (user_options->gpu_temp_disable); - logfile_top_uint (user_options->hex_charset); - logfile_top_uint (user_options->hex_salt); - logfile_top_uint (user_options->hex_wordlist); - logfile_top_uint (user_options->increment); - logfile_top_uint (user_options->keyspace); - logfile_top_uint (user_options->left); - logfile_top_uint (user_options->logfile_disable); - logfile_top_uint (user_options->loopback); - logfile_top_uint (user_options->machine_readable); - logfile_top_uint (user_options->markov_classic); - logfile_top_uint (user_options->markov_disable); - logfile_top_uint (user_options->opencl_info); - logfile_top_uint (user_options->outfile_autohex); - logfile_top_uint (user_options->potfile_disable); - logfile_top_uint (user_options->powertune_enable); - logfile_top_uint (user_options->quiet); - logfile_top_uint (user_options->remove); - logfile_top_uint (user_options->restore); - logfile_top_uint (user_options->restore_disable); - logfile_top_uint (user_options->show); - logfile_top_uint (user_options->status); - logfile_top_uint (user_options->stdout_flag); - logfile_top_uint (user_options->usage); - logfile_top_uint (user_options->username); - logfile_top_uint (user_options->version); - logfile_top_uint (user_options->attack_mode); - logfile_top_uint (user_options->bitmap_max); - logfile_top_uint (user_options->bitmap_min); - logfile_top_uint (user_options->debug_mode); - logfile_top_uint (user_options->gpu_temp_abort); - logfile_top_uint (user_options->gpu_temp_retain); - logfile_top_uint (user_options->hash_mode); - logfile_top_uint (user_options->increment_max); - logfile_top_uint (user_options->increment_min); - logfile_top_uint (user_options->kernel_accel); - logfile_top_uint (user_options->kernel_loops); - logfile_top_uint (user_options->markov_threshold); - logfile_top_uint (user_options->nvidia_spin_damp); - logfile_top_uint (user_options->opencl_vector_width); - logfile_top_uint (user_options->outfile_check_timer); - logfile_top_uint (user_options->outfile_format); - logfile_top_uint (user_options->remove_timer); - logfile_top_uint (user_options->restore_timer); - logfile_top_uint (user_options->rp_files_cnt); - logfile_top_uint (user_options->rp_gen); - logfile_top_uint (user_options->rp_gen_func_max); - logfile_top_uint (user_options->rp_gen_func_min); - logfile_top_uint (user_options->rp_gen_seed); - logfile_top_uint (user_options->runtime); - logfile_top_uint (user_options->scrypt_tmto); - logfile_top_uint (user_options->segment_size); - logfile_top_uint (user_options->status_timer); - logfile_top_uint (user_options->veracrypt_pim); - logfile_top_uint (user_options->weak_hash_threshold); - logfile_top_uint (user_options->workload_profile); - logfile_top_uint64 (user_options->limit); - logfile_top_uint64 (user_options->skip); + logfile_top_char (user_options->separator); logfile_top_string (user_options->cpu_affinity); logfile_top_string (user_options->custom_charset_1); logfile_top_string (user_options->custom_charset_2); @@ -1275,8 +1221,68 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_string (user_options->rp_files[0]); logfile_top_string (user_options->rule_buf_l); logfile_top_string (user_options->rule_buf_r); - logfile_top_char (user_options->separator); logfile_top_string (user_options->session); logfile_top_string (user_options->truecrypt_keyfiles); logfile_top_string (user_options->veracrypt_keyfiles); + logfile_top_uint64 (user_options->limit); + logfile_top_uint64 (user_options->skip); + logfile_top_uint (user_options->attack_mode); + logfile_top_uint (user_options->benchmark); + logfile_top_uint (user_options->bitmap_max); + logfile_top_uint (user_options->bitmap_min); + logfile_top_uint (user_options->debug_mode); + logfile_top_uint (user_options->force); + logfile_top_uint (user_options->gpu_temp_abort); + logfile_top_uint (user_options->gpu_temp_disable); + logfile_top_uint (user_options->gpu_temp_retain); + logfile_top_uint (user_options->hash_mode); + logfile_top_uint (user_options->hex_charset); + logfile_top_uint (user_options->hex_salt); + logfile_top_uint (user_options->hex_wordlist); + logfile_top_uint (user_options->increment); + logfile_top_uint (user_options->increment_max); + logfile_top_uint (user_options->increment_min); + logfile_top_uint (user_options->kernel_accel); + logfile_top_uint (user_options->kernel_loops); + logfile_top_uint (user_options->keyspace); + logfile_top_uint (user_options->left); + logfile_top_uint (user_options->logfile_disable); + logfile_top_uint (user_options->loopback); + logfile_top_uint (user_options->machine_readable); + logfile_top_uint (user_options->markov_classic); + logfile_top_uint (user_options->markov_disable); + logfile_top_uint (user_options->markov_threshold); + logfile_top_uint (user_options->nvidia_spin_damp); + logfile_top_uint (user_options->opencl_info); + logfile_top_uint (user_options->opencl_vector_width); + logfile_top_uint (user_options->outfile_autohex); + logfile_top_uint (user_options->outfile_check_timer); + logfile_top_uint (user_options->outfile_format); + logfile_top_uint (user_options->potfile_disable); + logfile_top_uint (user_options->powertune_enable); + logfile_top_uint (user_options->quiet); + logfile_top_uint (user_options->remove); + logfile_top_uint (user_options->remove_timer); + logfile_top_uint (user_options->restore); + logfile_top_uint (user_options->restore_disable); + logfile_top_uint (user_options->restore_timer); + logfile_top_uint (user_options->rp_files_cnt); + logfile_top_uint (user_options->rp_gen); + logfile_top_uint (user_options->rp_gen_func_max); + logfile_top_uint (user_options->rp_gen_func_min); + logfile_top_uint (user_options->rp_gen_seed); + logfile_top_uint (user_options->runtime); + logfile_top_uint (user_options->scrypt_tmto); + logfile_top_uint (user_options->segment_size); + logfile_top_uint (user_options->show); + logfile_top_uint (user_options->status); + logfile_top_uint (user_options->status_timer); + logfile_top_uint (user_options->stdout_flag); + logfile_top_uint (user_options->speed_only); + logfile_top_uint (user_options->usage); + logfile_top_uint (user_options->username); + logfile_top_uint (user_options->veracrypt_pim); + logfile_top_uint (user_options->version); + logfile_top_uint (user_options->weak_hash_threshold); + logfile_top_uint (user_options->workload_profile); } From 554c2f9e28887371ba7f593321d4935bcd2e5804 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 21:48:10 +0200 Subject: [PATCH 055/106] Add notes to changes --- docs/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes.txt b/docs/changes.txt index ee36109cb..e12d9c05f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -4,6 +4,7 @@ ## Improvements ## +- Added support for --speed-only: quickly shows expected speed per device based on the users hash(es) and option selected - Added the current first and last password candidate test queued for execution per device on status view - Use .gitmodules to handle OpenCL headers depency - Allow loading of bcrypt hashes with signature $2b$ (February 2014) From 7f6d027b35f889435da5a4eaa8241ab3155b315d Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 21:53:22 +0200 Subject: [PATCH 056/106] Add --speed-only to bash tab completion --- extra/tab_completion/hashcat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index 979a04856..3b027b72a 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -188,7 +188,7 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s' local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l" - local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles" + local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles" local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --benchmark-repeats --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --gpu-temp-retain -disable --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles" COMPREPLY=() From 4b8576ffb78562c6727af6484a36fb28f844324a Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 14 Oct 2016 21:56:23 +0200 Subject: [PATCH 057/106] Do not show goodbye_screen in --machine-readable mode --- src/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 71eb036db..efee4d72f 100644 --- a/src/main.c +++ b/src/main.c @@ -103,7 +103,10 @@ static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ // Inform user things getting started - const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + //const user_options_t *user_options = hashcat_ctx->user_options; + + //if (user_options->machine_readable == true) return; welcome_screen (hashcat_ctx, status_ctx->proc_start, VERSION_TAG); } @@ -112,7 +115,10 @@ static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ { // Inform user we're done - const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->machine_readable == true) return; goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop); } From 017555e257e51e15745f389833c4349db845af2c Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 14:28:46 +0200 Subject: [PATCH 058/106] Fix some log levels --- src/hashcat.c | 98 ++++++++++++++---------------------- src/main.c | 7 ++- src/opencl.c | 137 +++++++++++++++++++++++++++----------------------- 3 files changed, 117 insertions(+), 125 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 630bc5014..24eb394b9 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -354,7 +354,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) loopback_write_close (hashcat_ctx); } - // New induction folder check + // New induction folder check, which is a controlled recursion if (induct_ctx->induction_dictionaries_cnt == 0) { @@ -366,7 +366,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) { const int rc_inner2_loop = inner2_loop (hashcat_ctx); - if (rc_inner2_loop == -1) return -1; + if (rc_inner2_loop == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level3 == false) break; @@ -414,7 +414,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) const int rc_inner2_loop = inner2_loop (hashcat_ctx); - if (rc_inner2_loop == -1) return -1; + if (rc_inner2_loop == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level3 == false) break; } @@ -423,7 +423,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) { const int rc_inner2_loop = inner2_loop (hashcat_ctx); - if (rc_inner2_loop == -1) return -1; + if (rc_inner2_loop == -1) myabort (hashcat_ctx); } EVENT (EVENT_INNERLOOP2_FINISHED); @@ -436,14 +436,14 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) static int outer_loop (hashcat_ctx_t *hashcat_ctx) { - hashes_t *hashes = hashcat_ctx->hashes; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; - restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_t *user_options = hashcat_ctx->user_options; + hashes_t *hashes = hashcat_ctx->hashes; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; + restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_t *user_options = hashcat_ctx->user_options; status_ctx->devices_status = STATUS_INIT; @@ -757,7 +757,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) return -1; + if (rc_inner1_loop == -1) myabort (hashcat_ctx); if (status_ctx->run_main_level2 == false) break; } @@ -766,7 +766,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) { const int rc_inner1_loop = inner1_loop (hashcat_ctx); - if (rc_inner1_loop == -1) return -1; + if (rc_inner1_loop == -1) myabort (hashcat_ctx); } // wait for inner threads @@ -792,23 +792,15 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) // clean up + bitmap_ctx_destroy (hashcat_ctx); + combinator_ctx_destroy (hashcat_ctx); + cpt_ctx_destroy (hashcat_ctx); + hashconfig_destroy (hashcat_ctx); + hashes_destroy (hashcat_ctx); + mask_ctx_destroy (hashcat_ctx); status_progress_destroy (hashcat_ctx); - - bitmap_ctx_destroy (hashcat_ctx); - - mask_ctx_destroy (hashcat_ctx); - - combinator_ctx_destroy (hashcat_ctx); - - straight_ctx_destroy (hashcat_ctx); - - hashes_destroy (hashcat_ctx); - - hashconfig_destroy (hashcat_ctx); - - wl_data_destroy (hashcat_ctx); - - cpt_ctx_destroy (hashcat_ctx); + straight_ctx_destroy (hashcat_ctx); + wl_data_destroy (hashcat_ctx); return 0; } @@ -1067,38 +1059,23 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold EVENT (EVENT_GOODBYE_SCREEN); - logfile_destroy (hashcat_ctx); - - debugfile_destroy (hashcat_ctx); - - tuning_db_destroy (hashcat_ctx); - - loopback_destroy (hashcat_ctx); - - dictstat_destroy (hashcat_ctx); - - potfile_destroy (hashcat_ctx); - - induct_ctx_destroy (hashcat_ctx); - - outfile_destroy (hashcat_ctx); - - outcheck_ctx_destroy (hashcat_ctx); - - folder_config_destroy (hashcat_ctx); - - hwmon_ctx_destroy (hashcat_ctx); - + debugfile_destroy (hashcat_ctx); + dictstat_destroy (hashcat_ctx); + folder_config_destroy (hashcat_ctx); + hwmon_ctx_destroy (hashcat_ctx); + induct_ctx_destroy (hashcat_ctx); + logfile_destroy (hashcat_ctx); + loopback_destroy (hashcat_ctx); + opencl_ctx_destroy (hashcat_ctx); opencl_ctx_devices_destroy (hashcat_ctx); - - opencl_ctx_destroy (hashcat_ctx); - - restore_ctx_destroy (hashcat_ctx); - + outcheck_ctx_destroy (hashcat_ctx); + outfile_destroy (hashcat_ctx); + potfile_destroy (hashcat_ctx); + restore_ctx_destroy (hashcat_ctx); + tuning_db_destroy (hashcat_ctx); + user_options_destroy (hashcat_ctx); user_options_extra_destroy (hashcat_ctx); - user_options_destroy (hashcat_ctx); - if (rc_final == 0) { if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; @@ -1107,9 +1084,8 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0; } - event_ctx_destroy (hashcat_ctx); - status_ctx_destroy (hashcat_ctx); + event_ctx_destroy (hashcat_ctx); // done diff --git a/src/main.c b/src/main.c index efee4d72f..54aa22ea2 100644 --- a/src/main.c +++ b/src/main.c @@ -81,7 +81,7 @@ static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNU { static const char PREFIX_WARNING[] = "WARNING: "; - fwrite (PREFIX_WARNING, sizeof (PREFIX_WARNING), 1, stdout); + fwrite (PREFIX_WARNING, strlen (PREFIX_WARNING), 1, stdout); main_log (hashcat_ctx, stdout); } @@ -90,9 +90,12 @@ static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSE { static const char PREFIX_ERROR[] = "ERROR: "; - fwrite (PREFIX_ERROR, sizeof (PREFIX_ERROR), 1, stderr); + fwrite (EOL, strlen (EOL), 1, stderr); + fwrite (PREFIX_ERROR, strlen (PREFIX_ERROR), 1, stderr); main_log (hashcat_ctx, stderr); + + fwrite (EOL, strlen (EOL), 1, stderr); } static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) diff --git a/src/opencl.c b/src/opencl.c index 9eb68c400..d6563f7c1 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -303,7 +303,7 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) if (ocl->lib == NULL) { - event_log_warning (hashcat_ctx, + event_log_error (hashcat_ctx, "Can't find OpenCL ICD loader library" EOL "" EOL #if defined (__linux__) @@ -1073,7 +1073,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (user_options->speed_only == true) { - if (speed_ms > 4096) return -1; + if (speed_ms > 4096) return 0; } } @@ -1958,13 +1958,15 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (platforms_cnt == 0) { - event_log_info (hashcat_ctx, "ATTENTION! No OpenCL compatible platform found"); - event_log_info (hashcat_ctx, ""); - event_log_info (hashcat_ctx, "You're probably missing the OpenCL runtime installation"); - event_log_info (hashcat_ctx, " AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); - event_log_info (hashcat_ctx, " Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); - event_log_info (hashcat_ctx, " NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); - event_log_info (hashcat_ctx, ""); + event_log_error (hashcat_ctx, + "No OpenCL compatible platform found" EOL + "" EOL + "You're probably missing the OpenCL runtime installation" EOL + "* AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)" EOL + "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)" EOL + "* NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)" EOL + "" EOL + ); return -1; } @@ -2397,7 +2399,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_endian_little == CL_FALSE) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Not a little endian device", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Not a little endian device", device_id + 1); device_param->skipped = 1; } @@ -2412,7 +2414,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_available == CL_FALSE) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device not available", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Device not available", device_id + 1); device_param->skipped = 1; } @@ -2427,7 +2429,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_compiler_available == CL_FALSE) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: No compiler available for device", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: No compiler available for device", device_id + 1); device_param->skipped = 1; } @@ -2442,7 +2444,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if ((device_execution_capabilities & CL_EXEC_KERNEL) == 0) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support executing kernels", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Device does not support executing kernels", device_id + 1); device_param->skipped = 1; } @@ -2463,14 +2465,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (strstr (device_extensions, "base_atomics") == 0) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support base atomics", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Device does not support base atomics", device_id + 1); device_param->skipped = 1; } if (strstr (device_extensions, "byte_addressable_store") == 0) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device does not support byte addressable store", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Device does not support byte addressable store", device_id + 1); device_param->skipped = 1; } @@ -2487,7 +2489,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_local_mem_size < 32768) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Device local mem size is too small", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Device local mem size is too small", device_id + 1); device_param->skipped = 1; } @@ -2504,8 +2506,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); - event_log_info (hashcat_ctx, " You can use --force to override this but do not post error reports if you do so"); + event_log_warning (hashcat_ctx, + "Device #%u: Not a native Intel OpenCL runtime, expect massive speed loss" EOL + " You can use --force to override this but do not post error reports if you do so", device_id + 1); device_param->skipped = 1; } @@ -2654,7 +2657,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->skipped == 0) { - event_log_info (hashcat_ctx, "- Device #%u: %s, %lu/%lu MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "Device #%u: %s, %lu/%lu MB allocatable, %uMCU", device_id + 1, device_name, (unsigned int) (device_maxmem_alloc / 1024 / 1024), @@ -2663,7 +2666,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } else { - event_log_info (hashcat_ctx, "- Device #%u: %s, skipped", + event_log_info (hashcat_ctx, "Device #%u: %s, skipped", device_id + 1, device_name); } @@ -2699,25 +2702,29 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (catalyst_broken == 1) { - event_log_info (hashcat_ctx, "ATTENTION! The Catalyst driver installed on your system is known to be broken!"); - event_log_info (hashcat_ctx, "It passes over cracked hashes and will not report them as cracked"); - event_log_info (hashcat_ctx, "You are STRONGLY encouraged not to use it"); - event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); - event_log_info (hashcat_ctx, ""); + event_log_error (hashcat_ctx, + "The AMD driver installed on your system is known to be broken!" EOL + "It passes over cracked hashes and will not report them as cracked" EOL + "You are STRONGLY encouraged not to use it" EOL + "You can use --force to override this but do not post error reports if you do so" EOL + "" EOL + ); return -1; } if (catalyst_warn == 1) { - event_log_info (hashcat_ctx, "ATTENTION! Unsupported or incorrectly installed Catalyst driver detected!"); - event_log_info (hashcat_ctx, "You are STRONGLY encouraged to use the official supported catalyst driver"); - event_log_info (hashcat_ctx, "See hashcat's homepage for official supported catalyst drivers"); - #if defined (_WIN) - event_log_info (hashcat_ctx, "Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); - #endif - event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); - event_log_info (hashcat_ctx, ""); + event_log_error (hashcat_ctx, + "Unsupported or incorrectly installed Catalyst driver detected!" EOL + "You are STRONGLY encouraged to use the official supported catalyst driver" EOL + "See hashcat's homepage for official supported catalyst drivers" EOL + #if defined (_WIN) + "Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to" EOL + #endif + "You can use --force to override this but do not post error reports if you do so" EOL + "" + ); return -1; } @@ -2726,8 +2733,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->kernel_exec_timeout != 0) { - event_log_info (hashcat_ctx, "- Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); - event_log_info (hashcat_ctx, " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); + event_log_warning (hashcat_ctx, + "Device #%u: Kernel exec timeout is not disabled, it might cause you errors of code 702" EOL + " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch", device_id + 1); } } } @@ -2739,11 +2747,13 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - event_log_info (hashcat_ctx, "ATTENTION! OpenCL support for CPU of catalyst driver is not reliable."); - event_log_info (hashcat_ctx, "You are STRONGLY encouraged not to use it"); - event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); - event_log_info (hashcat_ctx, "A good alternative is the free pocl >= v0.13, but make sure to use a LLVM >= v3.8"); - event_log_info (hashcat_ctx, ""); + event_log_error (hashcat_ctx, + "OpenCL support for CPU of catalyst driver is not reliable." EOL + "You are STRONGLY encouraged not to use it" EOL + "You can use --force to override this but do not post error reports if you do so" EOL + "A good alternative is the free pocl >= v0.13, but make sure to use a LLVM >= v3.8" EOL + "" EOL + ); return -1; } @@ -2870,12 +2880,15 @@ void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) { clear_prompt (); - event_log_info (hashcat_ctx, "ATTENTION!"); - event_log_info (hashcat_ctx, " The wordlist or mask you are using is too small."); - event_log_info (hashcat_ctx, " Therefore, hashcat is unable to utilize the full parallelization power of your device(s)."); - event_log_info (hashcat_ctx, " The cracking speed will drop."); - event_log_info (hashcat_ctx, " Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed"); - event_log_info (hashcat_ctx, ""); + event_log_warning (hashcat_ctx, + " The wordlist or mask you are using is too small." EOL + " Therefore, hashcat is unable to utilize the full parallelization power of your device(s)." EOL + " The cracking speed will drop." EOL + " Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed" EOL + "" + ); + + send_prompt (); } } } @@ -3222,14 +3235,14 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if ((size_scrypt / 4) > device_param->device_maxmem_alloc) { - event_log_info (hashcat_ctx, "Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_warning (hashcat_ctx, "Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } if (size_scrypt > device_param->device_global_mem) { - event_log_info (hashcat_ctx, "Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); + event_log_warning (hashcat_ctx, "Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto); continue; } @@ -3346,7 +3359,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (kernel_accel_max < kernel_accel_min) { - event_log_error (hashcat_ctx, "- Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); + event_log_error (hashcat_ctx, "Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); return -1; } @@ -3357,7 +3370,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) /* if (kernel_accel_max < kernel_accel) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); device_param->kernel_accel = kernel_accel_max; } @@ -3453,7 +3466,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) strncpy (build_opts, build_opts_new, sizeof (build_opts)); #if defined (DEBUG) - event_log_info (hashcat_ctx, "- Device #%u: build_opts '%s'", device_id + 1, build_opts); + event_log_info (hashcat_ctx, "Device #%u: build_opts '%s'", device_id + 1, build_opts); #endif /** @@ -3507,7 +3520,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (cached == 0) { - if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3548,7 +3561,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3574,7 +3587,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) else { #if defined (DEBUG) - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + event_log_info (hashcat_ctx, "Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); @@ -3593,7 +3606,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) else { #if defined (DEBUG) - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size); + event_log_info (hashcat_ctx, "Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size); #endif const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3650,7 +3663,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); } } @@ -3709,7 +3722,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3750,7 +3763,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3774,7 +3787,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) else { #if defined (DEBUG) - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + event_log_info (hashcat_ctx, "Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); @@ -3849,7 +3862,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (cached == 0) { - if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, 1, kernel_lengths, kernel_sources); @@ -3890,7 +3903,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_info (hashcat_ctx, "- Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); + event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); continue; } @@ -3914,7 +3927,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) else { #if defined (DEBUG) - if (user_options->quiet == false) event_log_info (hashcat_ctx, "- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size); #endif const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, 1, kernel_lengths, kernel_sources); From 91979bff69be34ce9f3f63604d18a9e22122db89 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 14:34:07 +0200 Subject: [PATCH 059/106] Mark OpenCL devices as listing --- src/opencl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opencl.c b/src/opencl.c index d6563f7c1..0525d424c 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2657,7 +2657,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->skipped == 0) { - event_log_info (hashcat_ctx, "Device #%u: %s, %lu/%lu MB allocatable, %uMCU", + event_log_info (hashcat_ctx, "* Device #%u: %s, %lu/%lu MB allocatable, %uMCU", device_id + 1, device_name, (unsigned int) (device_maxmem_alloc / 1024 / 1024), @@ -2666,7 +2666,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } else { - event_log_info (hashcat_ctx, "Device #%u: %s, skipped", + event_log_info (hashcat_ctx, "* Device #%u: %s, skipped", device_id + 1, device_name); } From 694de366949b4843f1ce063091c220595b6850e8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 16:12:20 +0200 Subject: [PATCH 060/106] Print warnings in yellow and errors in red --- include/types.h | 8 +++ src/main.c | 145 +++++++++++++++++++++++++++++++----------------- src/monitor.c | 8 ++- src/opencl.c | 109 +++++++++++++----------------------- 4 files changed, 146 insertions(+), 124 deletions(-) diff --git a/include/types.h b/include/types.h index 24f4fdef4..91d8e0a75 100644 --- a/include/types.h +++ b/include/types.h @@ -75,6 +75,14 @@ typedef struct stat64 hc_stat; // enums +typedef enum loglevel +{ + LOGLEVEL_INFO = 0, + LOGLEVEL_WARNING = 1, + LOGLEVEL_ERROR = 2, + +} loglevel_t; + typedef enum event_identifier { EVENT_LOG_INFO = 0x00000001, diff --git a/src/main.c b/src/main.c index 54aa22ea2..f7c06e5b9 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,27 @@ #include "interface.h" #include "event.h" -static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) +static void main_log_clear_line (MAYBE_UNUSED const int prev_len, MAYBE_UNUSED FILE *fp) +{ + #if defined (_WIN) + + fputc ('\r', fp); + + for (int i = 0; i < prev_len; i++) + { + fputc (' ', fp); + } + + fputc ('\r', fp); + + #else + + printf ("\033[2K\r"); + + #endif +} + +static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel) { event_ctx_t *event_ctx = hashcat_ctx->event_ctx; @@ -33,22 +53,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) if (prev_len) { - #if defined (_WIN) - - fputc ('\r', fp); - - for (int i = 0; i < prev_len; i++) - { - fputc (' ', fp); - } - - fputc ('\r', fp); - - #else - - printf ("\033[2K\r"); - - #endif + main_log_clear_line (prev_len, fp); } if (msg_newline == true) @@ -60,13 +65,67 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) event_ctx->prev_len = msg_len; } + // color stuff pre + + #if defined (_WIN) + HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE); + + CONSOLE_SCREEN_BUFFER_INFO con_info; + + GetConsoleScreenBufferInfo (hConsole, &con_info); + + const int orig = con_info.wAttributes; + + switch (loglevel) + { + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: SetConsoleTextAttribute (hConsole, 6); break; + case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, FOREGROUND_RED); break; + } + + #else + switch (loglevel) + { + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: fwrite ("\033[33m", 5, 1, fp); break; + case LOGLEVEL_ERROR: fwrite ("\033[31m", 5, 1, fp); break; + } + #endif + // finally, print fwrite (msg_buf, msg_len, 1, fp); + // color stuff post + + #if defined (_WIN) + switch (loglevel) + { + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: SetConsoleTextAttribute (hConsole, orig); break; + case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, orig); break; + } + #else + switch (loglevel) + { + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: fwrite ("\033[0m", 4, 1, fp); break; + case LOGLEVEL_ERROR: fwrite ("\033[0m", 4, 1, fp); break; + } + #endif + + // eventual newline + if (msg_newline == true) { fwrite (EOL, strlen (EOL), 1, fp); + + // on error, add another newline + + if (loglevel == LOGLEVEL_ERROR) + { + fwrite (EOL, strlen (EOL), 1, fp); + } } fflush (fp); @@ -74,28 +133,17 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp) static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - main_log (hashcat_ctx, stdout); + main_log (hashcat_ctx, stdout, LOGLEVEL_INFO); } static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - static const char PREFIX_WARNING[] = "WARNING: "; - - fwrite (PREFIX_WARNING, strlen (PREFIX_WARNING), 1, stdout); - - main_log (hashcat_ctx, stdout); + main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING); } static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - static const char PREFIX_ERROR[] = "ERROR: "; - - fwrite (EOL, strlen (EOL), 1, stderr); - fwrite (PREFIX_ERROR, strlen (PREFIX_ERROR), 1, stderr); - - main_log (hashcat_ctx, stderr); - - fwrite (EOL, strlen (EOL), 1, stderr); + main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR); } static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -203,8 +251,19 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - const hashes_t *hashes = hashcat_ctx->hashes; - const user_options_t *user_options = hashcat_ctx->user_options; + const hashes_t *hashes = hashcat_ctx->hashes; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + // if we had a prompt, clear it + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if ((user_options->quiet == false) && (user_options->benchmark == false) && (user_options->speed_only == false)) + { + clear_prompt (); + } + } // print final status @@ -219,25 +278,11 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB } else { - if (user_options->quiet == false) - { - clear_prompt (); + if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); - if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); + status_display (hashcat_ctx); - status_display (hashcat_ctx); - - event_log_info (hashcat_ctx, ""); - } - else - { - if (user_options->status == true) - { - status_display (hashcat_ctx); - - event_log_info (hashcat_ctx, ""); - } - } + event_log_info (hashcat_ctx, ""); } } diff --git a/src/monitor.c b/src/monitor.c index c8c8ab3f7..e6ece1c56 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -157,7 +157,9 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (temperature > (int) user_options->gpu_temp_abort) { - event_log_error (hashcat_ctx, "Temperature limit on GPU %d reached, aborting...", device_id + 1); + if (user_options->quiet == false) clear_prompt (); + + event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", device_id + 1); myabort (hashcat_ctx); @@ -271,6 +273,8 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) { if (user_options->benchmark == false) { + if (user_options->quiet == false) clear_prompt (); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "NOTE: Runtime limit reached, aborting..."); } @@ -307,8 +311,6 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) clear_prompt (); - //if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - status_display (hashcat_ctx); if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); diff --git a/src/opencl.c b/src/opencl.c index 0525d424c..0d41e88d5 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -304,17 +304,17 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) if (ocl->lib == NULL) { event_log_error (hashcat_ctx, - "Can't find OpenCL ICD loader library" EOL - "" EOL + "Can't find an OpenCL ICD loader library" EOL + "" EOL #if defined (__linux__) "You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)" EOL "Run: sudo apt-get install ocl-icd-libopencl1" EOL "" EOL #elif defined (_WIN) "You're probably missing the OpenCL runtime installation" EOL - "* AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)" EOL - "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)" EOL - "* NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)" EOL + "* AMD users require AMD drivers 14.9 or later (recommended 15.12 exact)" EOL + "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 16.1 or later)" EOL + "* NVidia users require NVidia drivers 346.59 or later (recommended 367.27 or later)" EOL "" EOL #endif ); @@ -1958,15 +1958,13 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) if (platforms_cnt == 0) { - event_log_error (hashcat_ctx, - "No OpenCL compatible platform found" EOL - "" EOL - "You're probably missing the OpenCL runtime installation" EOL - "* AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)" EOL - "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)" EOL - "* NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)" EOL - "" EOL - ); + event_log_error (hashcat_ctx, "ATTENTION! No OpenCL compatible platform found"); + event_log_error (hashcat_ctx, ""); + event_log_error (hashcat_ctx, "You're probably missing the OpenCL runtime installation"); + event_log_error (hashcat_ctx, "* AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)"); + event_log_error (hashcat_ctx, "* Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)"); + event_log_error (hashcat_ctx, "* NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)"); + event_log_error (hashcat_ctx, ""); return -1; } @@ -2506,9 +2504,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - event_log_warning (hashcat_ctx, - "Device #%u: Not a native Intel OpenCL runtime, expect massive speed loss" EOL - " You can use --force to override this but do not post error reports if you do so", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); + event_log_warning (hashcat_ctx, " You can use --force to override this but do not post error reports if you do so"); device_param->skipped = 1; } @@ -2702,29 +2699,27 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (catalyst_broken == 1) { - event_log_error (hashcat_ctx, - "The AMD driver installed on your system is known to be broken!" EOL - "It passes over cracked hashes and will not report them as cracked" EOL - "You are STRONGLY encouraged not to use it" EOL - "You can use --force to override this but do not post error reports if you do so" EOL - "" EOL - ); + event_log_error (hashcat_ctx, "The Catalyst driver installed on your system is known to be broken!"); + event_log_error (hashcat_ctx, ""); + event_log_error (hashcat_ctx, "It passes over cracked hashes and will not report them as cracked"); + event_log_error (hashcat_ctx, "You are STRONGLY encouraged not to use it"); + event_log_error (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_error (hashcat_ctx, ""); return -1; } if (catalyst_warn == 1) { - event_log_error (hashcat_ctx, - "Unsupported or incorrectly installed Catalyst driver detected!" EOL - "You are STRONGLY encouraged to use the official supported catalyst driver" EOL - "See hashcat's homepage for official supported catalyst drivers" EOL - #if defined (_WIN) - "Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to" EOL - #endif - "You can use --force to override this but do not post error reports if you do so" EOL - "" - ); + event_log_error (hashcat_ctx, "Unsupported or incorrectly installed Catalyst driver detected!"); + event_log_error (hashcat_ctx, ""); + event_log_error (hashcat_ctx, "You are STRONGLY encouraged to use the official supported catalyst driver"); + event_log_error (hashcat_ctx, "See hashcat's homepage for official supported catalyst drivers"); + #if defined (_WIN) + event_log_error (hashcat_ctx, "Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to"); + #endif + event_log_error (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so"); + event_log_error (hashcat_ctx, ""); return -1; } @@ -2733,34 +2728,12 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->kernel_exec_timeout != 0) { - event_log_warning (hashcat_ctx, - "Device #%u: Kernel exec timeout is not disabled, it might cause you errors of code 702" EOL - " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch", device_id + 1); + event_log_warning (hashcat_ctx, "Device #%u: Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); + event_log_warning (hashcat_ctx, " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); } } } - /* turns out pocl still creates segfaults (because of llvm) - if (device_type & CL_DEVICE_TYPE_CPU) - { - if (platform_vendor_id == VENDOR_ID_AMD) - { - if (user_options->force == 0) - { - event_log_error (hashcat_ctx, - "OpenCL support for CPU of catalyst driver is not reliable." EOL - "You are STRONGLY encouraged not to use it" EOL - "You can use --force to override this but do not post error reports if you do so" EOL - "A good alternative is the free pocl >= v0.13, but make sure to use a LLVM >= v3.8" EOL - "" EOL - ); - - return -1; - } - } - } - */ - /** * activate device */ @@ -2878,17 +2851,11 @@ void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) { if (user_options->quiet == false) { - clear_prompt (); - - event_log_warning (hashcat_ctx, - " The wordlist or mask you are using is too small." EOL - " Therefore, hashcat is unable to utilize the full parallelization power of your device(s)." EOL - " The cracking speed will drop." EOL - " Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed" EOL - "" - ); - - send_prompt (); + event_log_warning (hashcat_ctx, "The wordlist or mask you are using is too small."); + event_log_warning (hashcat_ctx, "Therefore, hashcat is unable to utilize the full parallelization power of your device(s)."); + event_log_warning (hashcat_ctx, "The cracking speed will drop."); + event_log_warning (hashcat_ctx, "Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed"); + event_log_warning (hashcat_ctx, ""); } } } @@ -3434,7 +3401,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (fd == NULL) { - event_log_error (hashcat_ctx, "%s: fopen(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", files_names[i], strerror (errno)); return -1; } @@ -3445,7 +3412,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (n != 1) { - event_log_error (hashcat_ctx, "%s: fread(): %s", files_names[i], strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", files_names[i], strerror (errno)); return -1; } From e10c41c831e330d594c70f1507f476d2cabd4ab0 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 18:27:58 +0200 Subject: [PATCH 061/106] Do not show final status in case -I is used --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.c b/src/main.c index f7c06e5b9..74cac2222 100644 --- a/src/main.c +++ b/src/main.c @@ -255,6 +255,10 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + if (user_options->keyspace == true) return; + if (user_options->opencl_info == true) return; + if (user_options->stdout_flag == true) return; + // if we had a prompt, clear it if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) From 7383bb14f5dfc46ce7d8ccdd24701919bafbfcf2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 19:30:57 +0200 Subject: [PATCH 062/106] Add some more returncode checks --- include/outfile.h | 6 +- src/opencl.c | 1024 ++++++++++++++++++++++----------------------- src/outfile.c | 36 +- src/stdout.c | 16 +- 4 files changed, 542 insertions(+), 540 deletions(-) diff --git a/include/outfile.h b/include/outfile.h index 965c95da1..ef4b6b267 100644 --- a/include/outfile.h +++ b/include/outfile.h @@ -10,9 +10,9 @@ #include #include -void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len); -void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos); -void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len); +int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len); +int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos); +int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len); int outfile_init (hashcat_ctx_t *hashcat_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/src/opencl.c b/src/opencl.c index 0d41e88d5..eeaab57b3 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -965,9 +965,9 @@ int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event) int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw) { - cl_int CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL); + int CL_rc = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) return -1; + if (CL_rc == -1) return -1; return 0; } @@ -979,13 +979,13 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; - cl_int CL_err = CL_SUCCESS; - if (hashconfig->hash_mode == 2000) { return process_stdout (hashcat_ctx, device_param, pws_cnt); } + int CL_rc; + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { if (user_options->attack_mode == ATTACK_MODE_BF) @@ -994,48 +994,64 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { const u32 size_tm = 32 * sizeof (bs_word_t); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); - run_kernel_tm (hashcat_ctx, device_param); + if (CL_rc == -1) return -1; - CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); + CL_rc = run_kernel_tm (hashcat_ctx, device_param); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; + + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); + + if (CL_rc == -1) return -1; } } if (highest_pw_len < 16) { - run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_cnt, true, fast_iteration); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_cnt, true, fast_iteration); + + if (CL_rc == -1) return -1; } else if (highest_pw_len < 32) { - run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_cnt, true, fast_iteration); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_cnt, true, fast_iteration); + + if (CL_rc == -1) return -1; } else { - run_kernel (hashcat_ctx, device_param, KERN_RUN_3,pws_cnt, true, fast_iteration); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3,pws_cnt, true, fast_iteration); + + if (CL_rc == -1) return -1; } } else { - run_kernel_amp (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_kernel_amp (hashcat_ctx, device_param, pws_cnt); - run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_cnt, false, 0); + if (CL_rc == -1) return -1; + + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_cnt, false, 0); + + if (CL_rc == -1) return -1; if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { - run_kernel (hashcat_ctx, device_param, KERN_RUN_12, pws_cnt, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_12, pws_cnt, false, 0); - CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + if (CL_rc == -1) return -1; - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + + if (CL_rc == -1) return -1; // do something with data - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } u32 iter = hashes->salts_buf[salt_pos].salt_iter; @@ -1051,7 +1067,9 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, device_param->kernel_params_buf32[28] = loop_pos; device_param->kernel_params_buf32[29] = loop_left; - run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_cnt, true, slow_iteration); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_cnt, true, slow_iteration); + + if (CL_rc == -1) return -1; while (status_ctx->run_thread_level2 == false) break; @@ -1079,20 +1097,24 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { - run_kernel (hashcat_ctx, device_param, KERN_RUN_23, pws_cnt, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_23, pws_cnt, false, 0); - CL_err = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + if (CL_rc == -1) return -1; - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueReadBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + + if (CL_rc == -1) return -1; // do something with data - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } - run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_cnt, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_cnt, false, 0); + + if (CL_rc == -1) return -1; } return 0; @@ -1104,8 +1126,6 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; - cl_int CL_err = CL_SUCCESS; - u32 num_elements = num; device_param->kernel_params_buf32[34] = num; @@ -1125,19 +1145,19 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con case KERN_RUN_3: kernel = device_param->kernel3; break; } - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); + int CL_rc; - if (CL_err == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); if (CL_rc != -1) return -1; cl_event event; @@ -1146,9 +1166,9 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con const size_t global_work_size[3] = { num_elements, 32, 1 }; const size_t local_work_size[3] = { kernel_threads / 32, 32, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, &event); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, &event); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else { @@ -1165,14 +1185,14 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &event); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, &event); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } - CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (device_param->nvidia_spin_damp > 0) { @@ -1190,17 +1210,15 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con } } - CL_err = hc_clWaitForEvents (hashcat_ctx, 1, &event); + CL_rc = hc_clWaitForEvents (hashcat_ctx, 1, &event); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; cl_ulong time_start; cl_ulong time_end; - CL_err |= hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); - CL_err |= hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); - - if (CL_err == -1) return -1; + CL_rc = hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clGetEventProfilingInfo (hashcat_ctx, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); if (CL_rc == -1) return -1; const double exec_us = (double) (time_end - time_start) / 1000; @@ -1233,20 +1251,20 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con device_param->exec_pos = exec_pos; } - CL_err = hc_clReleaseEvent (hashcat_ctx, event); + CL_rc = hc_clReleaseEvent (hashcat_ctx, event); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFinish (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; return 0; } int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u32 num) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; u32 num_elements = num; @@ -1275,53 +1293,51 @@ int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, switch (kern_run) { - case KERN_RUN_MP: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]); + case KERN_RUN_MP: CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]); if (CL_rc == -1) return -1; break; - case KERN_RUN_MP_R: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]); + case KERN_RUN_MP_R: CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]); if (CL_rc == -1) return -1; break; - case KERN_RUN_MP_L: CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]); + case KERN_RUN_MP_L: CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]); if (CL_rc == -1) return -1; break; } - if (CL_err == -1) return -1; - const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFinish (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; return 0; } int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; const u32 num_elements = 1024; // fixed @@ -1332,24 +1348,24 @@ int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFinish (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; return 0; } int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 num) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; u32 num_elements = num; @@ -1364,31 +1380,31 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel = device_param->kernel_amp; - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFinish (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; return 0; } int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u32 value, const u32 num) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; const u32 num16d = num / 16; const u32 num16m = num % 16; @@ -1406,26 +1422,24 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par cl_kernel kernel = device_param->kernel_memset; - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 0, sizeof (cl_mem), (void *) &buf); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, kernel, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); - - if (CL_err == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 0, sizeof (cl_mem), (void *) &buf); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); if (CL_rc == -1) return -1; const size_t global_work_size[3] = { num_elements, 1, 1 }; const size_t local_work_size[3] = { kernel_threads, 1, 1 }; - CL_err = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); + CL_rc = hc_clEnqueueNDRangeKernel (hashcat_ctx, device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFlush (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFlush (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clFinish (hashcat_ctx, device_param->command_queue); + CL_rc = hc_clFinish (hashcat_ctx, device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (num16m) @@ -1437,9 +1451,9 @@ int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par tmp[2] = value; tmp[3] = value; - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, buf, CL_TRUE, num16d * 16, num16m, tmp, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, buf, CL_TRUE, num16d * 16, num16m, tmp, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } return 0; @@ -1457,13 +1471,13 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { @@ -1521,9 +1535,9 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const } } - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { @@ -1531,7 +1545,9 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const device_param->kernel_params_mp_l_buf64[3] = off; - run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt); + CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt); + + if (CL_rc == -1) return -1; } return 0; @@ -1746,7 +1762,9 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->kernel_params_mp_r_buf64[3] = off; - run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left); + int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left); + + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { @@ -1754,7 +1772,9 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->kernel_params_mp_buf64[3] = off; - run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { @@ -1762,40 +1782,42 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->kernel_params_mp_buf64[3] = off; - run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + + if (CL_rc == -1) return -1; } // copy amplifiers if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); + int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - cl_int CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (comb_t), device_param->combs_buf, 0, NULL, NULL); + int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (comb_t), device_param->combs_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_BF) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); + int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); + int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); + int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (user_options->speed_only == true) @@ -1952,9 +1974,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_uint platform_devices_cnt = 0; cl_device_id *platform_devices = (cl_device_id *) hccalloc (hashcat_ctx, DEVICES_MAX, sizeof (cl_device_id)); VERIFY_PTR (platform_devices); - cl_int CL_err = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); + int CL_rc = hc_clGetPlatformIDs (hashcat_ctx, CL_PLATFORMS_MAX, platforms, &platforms_cnt); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (platforms_cnt == 0) { @@ -1996,9 +2018,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_platform_id platform = platforms[platform_id]; - cl_int CL_err = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); + int CL_rc = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); - if (CL_err != CL_SUCCESS) continue; + if (CL_rc == -1) continue; for (u32 platform_devices_id = 0; platform_devices_id < platform_devices_cnt; platform_devices_id++) { @@ -2006,9 +2028,9 @@ int opencl_ctx_init (hashcat_ctx_t *hashcat_ctx) cl_device_type device_type; - cl_int CL_err = hc_clGetDeviceInfo (hashcat_ctx, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + int CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_types_all |= device_type; } @@ -2094,15 +2116,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) for (u32 platform_id = 0; platform_id < platforms_cnt; platform_id++) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; cl_platform_id platform = platforms[platform_id]; char platform_vendor[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; // find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl // this causes trouble with vendor id based macros @@ -2149,11 +2171,11 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) u32 platform_skipped = ((opencl_ctx->opencl_platforms_filter & (1u << platform_id)) == 0); - CL_err = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); + CL_rc = hc_clGetDeviceIDs (hashcat_ctx, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) { - //event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_err)); + //event_log_error (hashcat_ctx, "clGetDeviceIDs(): %s", val2cstr_cl (CL_rc)); //return -1; @@ -2164,15 +2186,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { char platform_name[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_NAME, HCBUFSIZ_TINY, platform_name, NULL); + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_NAME, HCBUFSIZ_TINY, platform_name, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char platform_version[HCBUFSIZ_TINY] = { 0 }; - CL_err = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VERSION, sizeof (platform_version), platform_version, NULL); + CL_rc = hc_clGetPlatformInfo (hashcat_ctx, platform, CL_PLATFORM_VERSION, sizeof (platform_version), platform_version, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; fprintf (stdout, "\nPlatform ID #%u\n Vendor : %s\n Name : %s\n Version : %s\n\n", platform_id + 1, platform_vendor, platform_name, platform_version); } @@ -2231,9 +2253,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_device_type device_type; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_TYPE, sizeof (device_type), &device_type, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_type &= ~CL_DEVICE_TYPE_DEFAULT; @@ -2241,29 +2263,29 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_name - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, 0, NULL, ¶m_value_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, 0, NULL, ¶m_value_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *device_name = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_name); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NAME, param_value_size, device_name, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_name = device_name; // device_vendor - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, 0, NULL, ¶m_value_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, 0, NULL, ¶m_value_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *device_vendor = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_vendor); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VENDOR, param_value_size, device_vendor, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_vendor = device_vendor; @@ -2310,29 +2332,29 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // device_version - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, 0, NULL, ¶m_value_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, 0, NULL, ¶m_value_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *device_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_version); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_VERSION, param_value_size, device_version, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_version = device_version; // device_opencl_version - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, 0, NULL, ¶m_value_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, 0, NULL, ¶m_value_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *device_opencl_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (device_opencl_version); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, device_opencl_version, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->opencl_v12 = device_opencl_version[9] > '1' || device_opencl_version[11] >= '2'; @@ -2340,9 +2362,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_uint device_processors; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (device_processors), &device_processors, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (device_processors), &device_processors, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_processors = device_processors; @@ -2351,9 +2373,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_maxmem_alloc; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (device_maxmem_alloc), &device_maxmem_alloc, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (device_maxmem_alloc), &device_maxmem_alloc, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_maxmem_alloc = MIN (device_maxmem_alloc, 0x7fffffff); @@ -2361,9 +2383,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_global_mem; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (device_global_mem), &device_global_mem, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (device_global_mem), &device_global_mem, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_global_mem = device_global_mem; @@ -2371,9 +2393,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) size_t device_maxworkgroup_size; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof (device_maxworkgroup_size), &device_maxworkgroup_size, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof (device_maxworkgroup_size), &device_maxworkgroup_size, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_maxworkgroup_size = device_maxworkgroup_size; @@ -2381,9 +2403,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_uint device_maxclock_frequency; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (device_maxclock_frequency), &device_maxclock_frequency, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (device_maxclock_frequency), &device_maxclock_frequency, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->device_maxclock_frequency = device_maxclock_frequency; @@ -2391,9 +2413,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_endian_little; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_ENDIAN_LITTLE, sizeof (device_endian_little), &device_endian_little, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_ENDIAN_LITTLE, sizeof (device_endian_little), &device_endian_little, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (device_endian_little == CL_FALSE) { @@ -2406,9 +2428,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_available; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_AVAILABLE, sizeof (device_available), &device_available, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_AVAILABLE, sizeof (device_available), &device_available, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (device_available == CL_FALSE) { @@ -2421,9 +2443,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_bool device_compiler_available; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPILER_AVAILABLE, sizeof (device_compiler_available), &device_compiler_available, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPILER_AVAILABLE, sizeof (device_compiler_available), &device_compiler_available, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (device_compiler_available == CL_FALSE) { @@ -2436,9 +2458,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_device_exec_capabilities device_execution_capabilities; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (device_execution_capabilities), &device_execution_capabilities, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof (device_execution_capabilities), &device_execution_capabilities, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if ((device_execution_capabilities & CL_EXEC_KERNEL) == 0) { @@ -2451,15 +2473,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) size_t device_extensions_size; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, 0, NULL, &device_extensions_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, 0, NULL, &device_extensions_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *device_extensions = hcmalloc (hashcat_ctx, device_extensions_size + 1); VERIFY_PTR (device_extensions); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_EXTENSIONS, device_extensions_size, device_extensions, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (strstr (device_extensions, "base_atomics") == 0) { @@ -2481,9 +2503,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) cl_ulong device_local_mem_size; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof (device_local_mem_size), &device_local_mem_size, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof (device_local_mem_size), &device_local_mem_size, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (device_local_mem_size < 32768) { @@ -2519,15 +2541,15 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // driver_version - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, 0, NULL, ¶m_value_size); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, 0, NULL, ¶m_value_size); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *driver_version = (char *) hcmalloc (hashcat_ctx, param_value_size); VERIFY_PTR (driver_version); - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DRIVER_VERSION, param_value_size, driver_version, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->driver_version = driver_version; @@ -2580,9 +2602,9 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->kernel_exec_timeout = kernel_exec_timeout; @@ -2592,13 +2614,13 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; device_param->sm_minor = sm_minor; device_param->sm_major = sm_major; @@ -2939,7 +2961,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; /** * host buffer @@ -2963,15 +2985,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64) { - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else { - CL_err = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL); + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof (vector_width), &vector_width, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } else @@ -3059,9 +3081,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) properties[1] = (cl_context_properties) device_param->platform; properties[2] = 0; - CL_err = hc_clCreateContext (hashcat_ctx, properties, 1, &device_param->device, NULL, NULL, &device_param->context); + CL_rc = hc_clCreateContext (hashcat_ctx, properties, 1, &device_param->device, NULL, NULL, &device_param->context); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; /** * create command-queue @@ -3070,9 +3092,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // not supported with NV // device_param->command_queue = hc_clCreateCommandQueueWithProperties (hashcat_ctx, device_param->device, NULL); - CL_err = hc_clCreateCommandQueue (hashcat_ctx, device_param->context, device_param->device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue); + CL_rc = hc_clCreateCommandQueue (hashcat_ctx, device_param->context, device_param->device, CL_QUEUE_PROFILING_ENABLE, &device_param->command_queue); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; /** * kernel threads: some algorithms need a fixed kernel-threads count @@ -3493,38 +3515,38 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; size_t build_log_size = 0; hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; #if defined (DEBUG) - if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) + if ((build_log_size != 0) || (CL_rc == -1)) #else - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) #endif { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; puts (build_log); hcfree (build_log); } - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) { device_param->skipped = true; @@ -3535,15 +3557,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; const int rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); @@ -3561,13 +3583,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } else @@ -3580,9 +3602,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char build_opts_update[1024] = { 0 }; @@ -3599,34 +3621,34 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) snprintf (build_opts_update, sizeof (build_opts_update) - 1, "%s", build_opts); } - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; size_t build_log_size = 0; hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; #if defined (DEBUG) - if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) + if ((build_log_size != 0) || (CL_rc == -1)) #else - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) #endif { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; puts (build_log); hcfree (build_log); } - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) { device_param->skipped = true; @@ -3695,38 +3717,38 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_mp); + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_mp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; size_t build_log_size = 0; hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; #if defined (DEBUG) - if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) + if ((build_log_size != 0) || (CL_rc == -1)) #else - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) #endif { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; puts (build_log); hcfree (build_log); } - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) { device_param->skipped = true; @@ -3737,15 +3759,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); @@ -3761,13 +3783,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_mp); + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_mp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } hcfree (kernel_lengths); @@ -3835,38 +3857,38 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_amp); + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program_amp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; size_t build_log_size = 0; hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - //if (CL_err == -1) return -1; + //if (CL_rc == -1) return -1; #if defined (DEBUG) - if ((build_log_size != 0) || (CL_err != CL_SUCCESS)) + if ((build_log_size != 0) || (CL_rc == -1)) #else - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) #endif { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_err = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; puts (build_log); hcfree (build_log); } - if (CL_err != CL_SUCCESS) + if (CL_rc == -1) { device_param->skipped = true; @@ -3877,15 +3899,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t binary_size; - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; char *binary = (char *) hcmalloc (hashcat_ctx, binary_size); VERIFY_PTR (binary); - CL_err = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); @@ -3901,13 +3923,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (rc_read_kernel == -1) return -1; - CL_err = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_amp); + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL, &device_param->program_amp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } hcfree (kernel_lengths); @@ -3938,43 +3960,39 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * global buffers */ - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_amp_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL, &device_param->d_tmps); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL, &device_param->d_hooks); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_plains, NULL, &device_param->d_plain_bufs); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_digests, NULL, &device_param->d_digests_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_salts, NULL, &device_param->d_salt_bufs); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_results, NULL, &device_param->d_result); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV0_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV1_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV2_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV3_buf); + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_pws, NULL, &device_param->d_pws_amp_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL, &device_param->d_tmps); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL, &device_param->d_hooks); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_a); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_b); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s1_d); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_a); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_b); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, bitmap_ctx->bitmap_size, NULL, &device_param->d_bitmap_s2_d); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_plains, NULL, &device_param->d_plain_bufs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_digests, NULL, &device_param->d_digests_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_shown, NULL, &device_param->d_digests_shown); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_salts, NULL, &device_param->d_salt_bufs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_results, NULL, &device_param->d_result); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV0_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV1_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV2_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_WRITE, size_scrypt4, NULL, &device_param->d_scryptV3_buf); if (CL_rc == -1) return -1; - if (CL_err == -1) return -1; - - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_a, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_b, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_c, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_d, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_a, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_b, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_c, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_d, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, hashes->digests_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, hashes->digests_shown, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, hashes->salts_buf, 0, NULL, NULL); - - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_a, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_b, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_c, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s1_d, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_a, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_b, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_c, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_s2_d, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, hashes->digests_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, hashes->digests_shown, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, hashes->salts_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; /** * special buffers @@ -3982,44 +4000,36 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); if (CL_rc == -1) return -1; - if (CL_err == -1) return -1; - - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); - - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); - - if (CL_err == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); - CL_err |= hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); - - if (CL_err == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; } if (size_esalts) { - CL_err = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL, &device_param->d_esalt_bufs); + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL, &device_param->d_esalt_bufs); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, hashes->esalts_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, hashes->esalts_buf, 0, NULL, NULL); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } /** @@ -4180,41 +4190,41 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 4); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 8); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", hashconfig->kern_type, 16); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 4); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 8); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", hashconfig->kern_type, 16); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (user_options->attack_mode == ATTACK_MODE_BF) @@ -4223,13 +4233,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_tm, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_tm, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } } @@ -4237,136 +4247,122 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel1); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel2); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel3); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel12); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel12, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel12, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", hashconfig->kern_type); - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel23); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel23, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel23, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } - CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel1, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel2, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel3, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err == -1) return -1; + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel1, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); if (CL_rc == -1) return -1; + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel2, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); if (CL_rc == -1) return -1; + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel3, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); if (CL_rc == -1) return -1; for (u32 i = 0; i <= 23; i++) { - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]); if (CL_rc == -1) return -1; - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]); - - if (CL_err == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]); if (CL_rc == -1) return -1; } + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]); if (CL_rc == -1) return -1; } } for (u32 i = 24; i <= 34; i++) { - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]); if (CL_rc == -1) return -1; - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]); - - if (CL_err == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]); if (CL_rc == -1) return -1; } + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]); if (CL_rc == -1) return -1; } } // GPU memset - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program, "gpu_memset", &device_param->kernel_memset); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, "gpu_memset", &device_param->kernel_memset); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_memset, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_memset, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); - - if (CL_err == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 2, sizeof (cl_uint), device_param->kernel_params_memset[2]); if (CL_rc == -1) return -1; // MP start if (user_options->attack_mode == ATTACK_MODE_BF) { - CL_err |= hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); - CL_err |= hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); if (CL_rc == -1) return -1; - if (CL_err == -1) return -1; - - CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_l, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - CL_err |= hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_r, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - - if (CL_err == -1) return -1; + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_l, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); if (CL_rc == -1) return -1; + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp_r, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); if (CL_rc == -1) return -1; if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) { - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); - - if (CL_err == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); if (CL_rc == -1) return -1; } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_mp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -4375,13 +4371,13 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - CL_err = hc_clCreateKernel (hashcat_ctx, device_param->program_amp, "amp", &device_param->kernel_amp); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_amp, "amp", &device_param->kernel_amp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; - CL_err = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_amp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, device_param->kernel_amp, device_param->device, CL_KERNEL_WORK_GROUP_SIZE, sizeof (size_t), &kernel_wgs_tmp, NULL); kernel_threads = MIN (kernel_threads, kernel_wgs_tmp); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -4392,16 +4388,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { for (u32 i = 0; i < 5; i++) { - CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } for (u32 i = 5; i < 7; i++) { - CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } @@ -4412,12 +4408,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // zero some data buffers - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_buf, size_pws); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_amp_buf, size_pws); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tmps, size_tmps); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_hooks, size_hooks); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_plain_bufs, size_plains); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_result, size_results); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_buf, size_pws); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_amp_buf, size_pws); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tmps, size_tmps); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_hooks, size_hooks); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_plain_bufs, size_plains); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_result, size_results); if (CL_rc == -1) return -1; /** * special buffers @@ -4425,22 +4421,22 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, size_rules_c); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, size_rules_c); } else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs, size_combs); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, size_combs); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs, size_combs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, size_combs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; } else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs, size_bfs); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, size_bfs); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); - run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs, size_bfs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, size_bfs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; } if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2)) @@ -4467,9 +4463,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params_mp_buf32[7] = 0; } - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]); - - if (CL_err == -1) return -1; + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -4486,10 +4480,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1; if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1; - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); - for (u32 i = 0; i < 3; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); - - if (CL_err == -1) return -1; + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } } } @@ -4510,65 +4502,61 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - cl_int CL_err = CL_SUCCESS; - hcfree (device_param->pws_buf); hcfree (device_param->combs_buf); hcfree (device_param->hooks_buf); - if (device_param->d_pws_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_buf); - if (device_param->d_pws_amp_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_amp_buf); - if (device_param->d_rules) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules); - if (device_param->d_rules_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules_c); - if (device_param->d_combs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs); - if (device_param->d_combs_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs_c); - if (device_param->d_bfs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs); - if (device_param->d_bfs_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs_c); - if (device_param->d_bitmap_s1_a) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_a); - if (device_param->d_bitmap_s1_b) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_b); - if (device_param->d_bitmap_s1_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_c); - if (device_param->d_bitmap_s1_d) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_d); - if (device_param->d_bitmap_s2_a) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_a); - if (device_param->d_bitmap_s2_b) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_b); - if (device_param->d_bitmap_s2_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_c); - if (device_param->d_bitmap_s2_d) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_d); - if (device_param->d_plain_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_plain_bufs); - if (device_param->d_digests_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_buf); - if (device_param->d_digests_shown) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_shown); - if (device_param->d_salt_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_salt_bufs); - if (device_param->d_esalt_bufs) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_esalt_bufs); - if (device_param->d_tmps) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_tmps); - if (device_param->d_hooks) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_hooks); - if (device_param->d_result) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_result); - if (device_param->d_scryptV0_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV0_buf); - if (device_param->d_scryptV1_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV1_buf); - if (device_param->d_scryptV2_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV2_buf); - if (device_param->d_scryptV3_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV3_buf); - if (device_param->d_root_css_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_root_css_buf); - if (device_param->d_markov_css_buf) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_markov_css_buf); - if (device_param->d_tm_c) CL_err |= hc_clReleaseMemObject (hashcat_ctx, device_param->d_tm_c); + if (device_param->d_pws_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_buf); + if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_pws_amp_buf); + if (device_param->d_rules) hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules); + if (device_param->d_rules_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_rules_c); + if (device_param->d_combs) hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs); + if (device_param->d_combs_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_combs_c); + if (device_param->d_bfs) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs); + if (device_param->d_bfs_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bfs_c); + if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_a); + if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_b); + if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_c); + if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s1_d); + if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_a); + if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_b); + if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_c); + if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (hashcat_ctx, device_param->d_bitmap_s2_d); + if (device_param->d_plain_bufs) hc_clReleaseMemObject (hashcat_ctx, device_param->d_plain_bufs); + if (device_param->d_digests_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_buf); + if (device_param->d_digests_shown) hc_clReleaseMemObject (hashcat_ctx, device_param->d_digests_shown); + if (device_param->d_salt_bufs) hc_clReleaseMemObject (hashcat_ctx, device_param->d_salt_bufs); + if (device_param->d_esalt_bufs) hc_clReleaseMemObject (hashcat_ctx, device_param->d_esalt_bufs); + if (device_param->d_tmps) hc_clReleaseMemObject (hashcat_ctx, device_param->d_tmps); + if (device_param->d_hooks) hc_clReleaseMemObject (hashcat_ctx, device_param->d_hooks); + if (device_param->d_result) hc_clReleaseMemObject (hashcat_ctx, device_param->d_result); + if (device_param->d_scryptV0_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV0_buf); + if (device_param->d_scryptV1_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV1_buf); + if (device_param->d_scryptV2_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV2_buf); + if (device_param->d_scryptV3_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_scryptV3_buf); + if (device_param->d_root_css_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_root_css_buf); + if (device_param->d_markov_css_buf) hc_clReleaseMemObject (hashcat_ctx, device_param->d_markov_css_buf); + if (device_param->d_tm_c) hc_clReleaseMemObject (hashcat_ctx, device_param->d_tm_c); - if (device_param->kernel1) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel1); - if (device_param->kernel12) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel12); - if (device_param->kernel2) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel2); - if (device_param->kernel23) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel23); - if (device_param->kernel3) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel3); - if (device_param->kernel_mp) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp); - if (device_param->kernel_mp_l) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_l); - if (device_param->kernel_mp_r) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_r); - if (device_param->kernel_tm) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_tm); - if (device_param->kernel_amp) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_amp); - if (device_param->kernel_memset) CL_err |= hc_clReleaseKernel (hashcat_ctx, device_param->kernel_memset); + if (device_param->kernel1) hc_clReleaseKernel (hashcat_ctx, device_param->kernel1); + if (device_param->kernel12) hc_clReleaseKernel (hashcat_ctx, device_param->kernel12); + if (device_param->kernel2) hc_clReleaseKernel (hashcat_ctx, device_param->kernel2); + if (device_param->kernel23) hc_clReleaseKernel (hashcat_ctx, device_param->kernel23); + if (device_param->kernel3) hc_clReleaseKernel (hashcat_ctx, device_param->kernel3); + if (device_param->kernel_mp) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp); + if (device_param->kernel_mp_l) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_l); + if (device_param->kernel_mp_r) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_mp_r); + if (device_param->kernel_tm) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_tm); + if (device_param->kernel_amp) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_amp); + if (device_param->kernel_memset) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_memset); - if (device_param->program) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program); - if (device_param->program_mp) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program_mp); - if (device_param->program_amp) CL_err |= hc_clReleaseProgram (hashcat_ctx, device_param->program_amp); + if (device_param->program) hc_clReleaseProgram (hashcat_ctx, device_param->program); + if (device_param->program_mp) hc_clReleaseProgram (hashcat_ctx, device_param->program_mp); + if (device_param->program_amp) hc_clReleaseProgram (hashcat_ctx, device_param->program_amp); - if (device_param->command_queue) CL_err |= hc_clReleaseCommandQueue (hashcat_ctx, device_param->command_queue); + if (device_param->command_queue) hc_clReleaseCommandQueue (hashcat_ctx, device_param->command_queue); - if (device_param->context) CL_err |= hc_clReleaseContext (hashcat_ctx, device_param->context); - - //if (CL_err == -1) return -1; + if (device_param->context) hc_clReleaseContext (hashcat_ctx, device_param->context); device_param->pws_buf = NULL; device_param->combs_buf = NULL; @@ -4682,16 +4670,14 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params_buf32[33] = combinator_ctx->combs_mode; - cl_int CL_err = CL_SUCCESS; + int CL_rc; - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, 33, sizeof (cl_uint), device_param->kernel_params[33]); - CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, 33, sizeof (cl_uint), device_param->kernel_params[33]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel1, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel2, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel3, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; - if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, 33, sizeof (cl_uint), device_param->kernel_params[33]); - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, 33, sizeof (cl_uint), device_param->kernel_params[33]); - - if (CL_err == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_HOOK12) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel12, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; } + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel23, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; } // kernel_params_amp @@ -4699,9 +4685,9 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) { - CL_err = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); - if (CL_err == -1) return -1; + if (CL_rc == -1) return -1; } } @@ -4724,17 +4710,13 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params_mp_buf64[3] = 0; device_param->kernel_params_mp_buf32[4] = mask_ctx->css_cnt; - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]); - for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]); + for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } + for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - if (CL_err == -1) return -1; - - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; } return 0; @@ -4760,20 +4742,16 @@ int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l device_param->kernel_params_mp_r_buf64[3] = 0; device_param->kernel_params_mp_r_buf32[4] = css_cnt_r; - cl_int CL_err = CL_SUCCESS; + int CL_rc = CL_SUCCESS; - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); - for (u32 i = 4; i < 9; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]); + for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } + for (u32 i = 4; i < 9; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - for (u32 i = 3; i < 4; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); - for (u32 i = 4; i < 8; i++) CL_err |= hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]); + for (u32 i = 3; i < 4; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } + for (u32 i = 4; i < 8; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } - if (CL_err == -1) return -1; - - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); - CL_err |= hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); - - if (CL_err == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, mask_ctx->root_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, mask_ctx->markov_css_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; } return 0; diff --git a/src/outfile.c b/src/outfile.c index afb568be1..7d7e711d7 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -16,7 +16,7 @@ #include "opencl.h" #include "outfile.h" -void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len) +int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -36,7 +36,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p { pw_t pw; - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (int i = 0; i < 16; i++) { @@ -55,7 +57,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p { pw_t pw; - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (int i = 0; i < 16; i++) { @@ -105,7 +109,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p { pw_t pw; - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (int i = 0; i < 16; i++) { @@ -132,7 +138,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p { pw_t pw; - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (int i = 0; i < 16; i++) { @@ -183,9 +191,11 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p } *out_len = plain_len; + + return 0; } -void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos) +int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; @@ -217,9 +227,11 @@ void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param } *out_pos = crackpos; + + return 0; } -void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len) +int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len) { debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; @@ -228,15 +240,17 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para const u32 gidvid = plain->gidvid; const u32 il_pos = plain->il_pos; - if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return; + if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return 0; const u32 debug_mode = debugfile_ctx->mode; - if (debug_mode == 0) return; + if (debug_mode == 0) return 0; pw_t pw; - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; int plain_len = (int) pw.pw_len; @@ -255,6 +269,8 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para *debug_plain_len = plain_len; } + + return 0; } int outfile_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/stdout.c b/src/stdout.c index a5f7a37ec..a7020f18b 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -84,7 +84,9 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++) { - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; const u32 pos = device_param->innerloop_pos; @@ -111,7 +113,9 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++) { - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) { @@ -177,7 +181,9 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++) { - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) { @@ -207,7 +213,9 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++) { - gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) { From bfbc4279f4f00acc32ff1774acee967c1a654ffc Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 19:44:31 +0200 Subject: [PATCH 063/106] Add some more returncode checks --- src/autotune.c | 36 ++++++++++++++++++------------------ src/dispatch.c | 46 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index 9ca5e8955..5602faee0 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -82,9 +82,13 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param const u32 kernel_power_max = device_param->device_processors * device_param->kernel_threads * kernel_accel_max; + int CL_rc; + if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; } else { @@ -95,33 +99,25 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->pws_buf[i].pw_len = 7 + (i & 7); } - cl_int CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "clEnqueueWriteBuffer(): %s", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { if (straight_ctx->kernel_rules_cnt > 1) { - cl_int CL_err = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); - if (CL_err != CL_SUCCESS) - { - event_log_error (hashcat_ctx, "clEnqueueCopyBuffer(): %s", val2cstr_cl (CL_err)); - - return -1; - } + if (CL_rc == -1) return -1; } } else { - run_kernel_amp (hashcat_ctx, device_param, kernel_power_max); + CL_rc = run_kernel_amp (hashcat_ctx, device_param, kernel_power_max); + + if (CL_rc == -1) return -1; } #define VERIFIER_CNT 1 @@ -252,11 +248,15 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); */ - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) { - run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t)); + CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t)); + + if (CL_rc == -1) return -1; } // reset timer diff --git a/src/dispatch.c b/src/dispatch.c index e50a4a675..d8894f444 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -200,9 +200,15 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; @@ -210,11 +216,15 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par still required? if (attack_kern == ATTACK_KERN_STRAIGHT) { - run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); + CL_rc = run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); + + if (CL_rc == -1) return -1; } else if (attack_kern == ATTACK_KERN_COMBI) { - run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs); + rCL_rc = un_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs); + + if (CL_rc == -1) return -1; } */ } @@ -281,9 +291,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; } @@ -504,9 +520,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (pws_cnt) { - run_copy (hashcat_ctx, device_param, pws_cnt); + int CL_rc; - run_cracker (hashcat_ctx, device_param, pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; device_param->pws_cnt = 0; @@ -514,11 +536,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) still required? if (attack_kern == ATTACK_KERN_STRAIGHT) { - run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + + if (CL_rc == -1) return -1; } else if (attack_kern == ATTACK_KERN_COMBI) { - run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + + if (CL_rc == -1) return -1; } */ } From 7bcbbbea7455b82da65280fc57ff60cd157a2810 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 19:47:53 +0200 Subject: [PATCH 064/106] Add some more returncode checks --- include/weak_hash.h | 2 +- src/hashcat.c | 4 +++- src/weak_hash.c | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/weak_hash.h b/include/weak_hash.h index aad4a9f3c..a2d0dfc44 100644 --- a/include/weak_hash.h +++ b/include/weak_hash.h @@ -6,6 +6,6 @@ #ifndef _WEAK_HASH_H #define _WEAK_HASH_H -void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos); +int weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos); #endif // _WEAK_HASH_H diff --git a/src/hashcat.c b/src/hashcat.c index 24eb394b9..634a36752 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -696,7 +696,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { - weak_hash_check (hashcat_ctx, device_param, salt_pos); + const int CL_rc = weak_hash_check (hashcat_ctx, device_param, salt_pos); + + if (CL_rc == -1) return -1; } EVENT (EVENT_WEAK_HASH_POST); diff --git a/src/weak_hash.c b/src/weak_hash.c index a40e82df9..96ebf14aa 100644 --- a/src/weak_hash.c +++ b/src/weak_hash.c @@ -10,7 +10,7 @@ #include "hashes.h" #include "weak_hash.h" -void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos) +int weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; @@ -33,13 +33,19 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para * run the kernel */ + int CL_rc; + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0); + + if (CL_rc == -1) return -1; } else { - run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0); + + if (CL_rc == -1) return -1; u32 loop_step = 16; @@ -54,10 +60,14 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para device_param->kernel_params_buf32[28] = loop_pos; device_param->kernel_params_buf32[29] = loop_left; - run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0); + + if (CL_rc == -1) return -1; } - run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0); + CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0); + + if (CL_rc == -1) return -1; } /** @@ -80,4 +90,6 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para device_param->kernel_params_buf32[34] = 0; straight_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old; + + return 0; } From d2bcb19740c7c2faa81664acee95b722a0eb391a Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 19:58:39 +0200 Subject: [PATCH 065/106] Fix some rc check --- src/opencl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/opencl.c b/src/opencl.c index eeaab57b3..445318d69 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1147,17 +1147,17 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con int CL_rc; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc != -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); if (CL_rc != -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 32, sizeof (cl_uint), device_param->kernel_params[32]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 33, sizeof (cl_uint), device_param->kernel_params[33]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, kernel, 34, sizeof (cl_uint), device_param->kernel_params[34]); if (CL_rc == -1) return -1; cl_event event; From f8a6d156ebe1806e51cbf02dd236e242778eed5a Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Oct 2016 21:34:38 +0200 Subject: [PATCH 066/106] Add some more returncode checks --- src/autotune.c | 2 +- src/hashcat.c | 4 +++- src/opencl.c | 40 ++++++++++++++++++++++------------------ src/restore.c | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index 5602faee0..0d8ec12ed 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -314,7 +314,7 @@ void *thread_autotune (void *p) hc_device_param_t *device_param = opencl_ctx->devices_param + thread_param->tid; - if (device_param->skipped) return NULL; + if (device_param->skipped == true) return NULL; const int rc_autotune = autotune (hashcat_ctx, device_param); diff --git a/src/hashcat.c b/src/hashcat.c index 634a36752..9f96a1827 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -663,7 +663,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_OPENCL_SESSION_PRE); - opencl_session_begin (hashcat_ctx); + const int rc_session_begin = opencl_session_begin (hashcat_ctx); + + if (rc_session_begin == -1) return -1; EVENT (EVENT_OPENCL_SESSION_POST); diff --git a/src/opencl.c b/src/opencl.c index 445318d69..ec886d8b2 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3108,8 +3108,6 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->hardware_power = device_processors * kernel_threads; - hardware_power_all += device_param->hardware_power; - /** * create input buffers on device : calculate size of fixed memory buffers */ @@ -3537,9 +3535,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_rc == -1) return -1; + if (CL_rc_build == -1) return -1; puts (build_log); @@ -3550,7 +3548,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_error (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3639,9 +3637,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_rc == -1) return -1; + if (CL_rc_build == -1) return -1; puts (build_log); @@ -3652,7 +3650,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_error (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + + continue; } } @@ -3739,9 +3739,9 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { char *build_log = (char *) hcmalloc (hashcat_ctx, build_log_size + 1); VERIFY_PTR (build_log); - CL_rc = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_rc == -1) return -1; + if (CL_rc_build == -1) return -1; puts (build_log); @@ -3752,7 +3752,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); + event_log_error (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceeding without this device.", device_id + 1, source_file); continue; } @@ -3892,7 +3892,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { device_param->skipped = true; - event_log_warning (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); + event_log_error (hashcat_ctx, "Device #%u: Kernel %s build failure. Proceed without this device.", device_id + 1, source_file); continue; } @@ -4408,12 +4408,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // zero some data buffers - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_buf, size_pws); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_amp_buf, size_pws); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tmps, size_tmps); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_hooks, size_hooks); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_plain_bufs, size_plains); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_result, size_results); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_buf, size_pws); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_pws_amp_buf, size_pws); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tmps, size_tmps); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_hooks, size_hooks); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_plain_bufs, size_plains); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_result, size_results); if (CL_rc == -1) return -1; /** * special buffers @@ -4483,8 +4483,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } } + + hardware_power_all += device_param->hardware_power; } + if (hardware_power_all == 0) return -1; + opencl_ctx->hardware_power_all = hardware_power_all; return 0; diff --git a/src/restore.c b/src/restore.c index 1ee55ee8a..cf1c5a0c3 100644 --- a/src/restore.c +++ b/src/restore.c @@ -28,7 +28,7 @@ u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx) restore_data_t *rd = restore_ctx->rd; - u64 words_cur = -1llu; + u64 words_cur = 0xffffffffffffffff; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { From 2545ec6bf9665ad15fcff74d0daa6e7311d69b92 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 16 Oct 2016 19:32:43 +0200 Subject: [PATCH 067/106] Prepare hashcat_get_status() --- include/hashcat.h | 14 +- include/restore.h | 2 - include/status.h | 25 +- include/terminal.h | 5 + include/thread.h | 14 +- include/types.h | 43 ++ src/hashcat.c | 207 ++++--- src/main.c | 6 +- src/main_shared.c | 24 +- src/restore.c | 38 -- src/status.c | 1447 ++++++++------------------------------------ src/terminal.c | 1128 +++++++++++++++++++++++++++++++++- src/thread.c | 76 ++- 13 files changed, 1687 insertions(+), 1342 deletions(-) diff --git a/include/hashcat.h b/include/hashcat.h index ed47ab4a4..51302b567 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -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 diff --git a/include/restore.h b/include/restore.h index f42760638..7a238e700 100644 --- a/include/restore.h +++ b/include/restore.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); diff --git a/include/status.h b/include/status.h index 2799f5def..eccea7bf7 100644 --- a/include/status.h +++ b/include/status.h @@ -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 diff --git a/include/terminal.h b/include/terminal.h index 7312ba675..284411387 100644 --- a/include/terminal.h +++ b/include/terminal.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); diff --git a/include/thread.h b/include/thread.h index 907af8aaa..713fe9064 100644 --- a/include/thread.h +++ b/include/thread.h @@ -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 diff --git a/include/types.h b/include/types.h index 91d8e0a75..38472b3cf 100644 --- a/include/types.h +++ b/include/types.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; diff --git a/src/hashcat.c b/src/hashcat.c index 9f96a1827..f4c6688da 100644 --- a/src/hashcat.c +++ b/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; +} diff --git a/src/main.c b/src/main.c index 74cac2222..6c9c8a3d7 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/main_shared.c b/src/main_shared.c index 328165e8b..7312b94d4 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -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); diff --git a/src/restore.c b/src/restore.c index cf1c5a0c3..db9a7df3d 100644 --- a/src/restore.c +++ b/src/restore.c @@ -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; diff --git a/src/status.c b/src/status.c index 572c49a35..4167aa7d2 100644 --- a/src/status.c +++ b/src/status.c @@ -25,98 +25,31 @@ static const char ST_0005[] = "Cracked"; static const char ST_0006[] = "Aborted"; static const char ST_0007[] = "Quit"; static const char ST_0008[] = "Bypass"; +static const char ST_9999[] = "Unknown! Bug!"; -static void format_timer_display (struct tm *tm, char *buf, size_t len) +static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx) { - const char *time_entities_s[] = { "year", "day", "hour", "min", "sec" }; - const char *time_entities_m[] = { "years", "days", "hours", "mins", "secs" }; + const user_options_t *user_options = hashcat_ctx->user_options; - if (tm->tm_year - 70) + if (user_options->rp_files_cnt > 0) { - char *time_entity1 = ((tm->tm_year - 70) == 1) ? (char *) time_entities_s[0] : (char *) time_entities_m[0]; - char *time_entity2 = ( tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; + char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); - } - else if (tm->tm_yday) - { - char *time_entity1 = (tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; - char *time_entity2 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; + int tmp_len = 0; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); - } - else if (tm->tm_hour) - { - char *time_entity1 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; - char *time_entity2 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; + u32 i; - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); - } - else if (tm->tm_min) - { - char *time_entity1 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; - char *time_entity2 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + for (i = 0; i < user_options->rp_files_cnt - 1; i++) + { + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s, ", user_options->rp_files[i]); + } - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); - } - else - { - char *time_entity1 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + tmp_len += snprintf (tmp_buf + tmp_len, HCBUFSIZ_TINY - tmp_len - 1, "%s", user_options->rp_files[i]); - snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); - } -} - -static void format_speed_display (double val, char *buf, size_t len) -{ - if (val <= 0) - { - buf[0] = '0'; - buf[1] = ' '; - buf[2] = 0; - - return; + return tmp_buf; // yes, user need to free() } - char units[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; - - u32 level = 0; - - while (val > 99999) - { - val /= 1000; - - level++; - } - - /* generate output */ - - if (level == 0) - { - snprintf (buf, len - 1, "%.0f ", val); - } - else - { - snprintf (buf, len - 1, "%.1f %c", val, units[level]); - } -} - -static char *strstatus (const u32 devices_status) -{ - switch (devices_status) - { - case STATUS_INIT: return ((char *) ST_0000); - case STATUS_AUTOTUNE: return ((char *) ST_0001); - case STATUS_RUNNING: return ((char *) ST_0002); - case STATUS_PAUSED: return ((char *) ST_0003); - case STATUS_EXHAUSTED: return ((char *) ST_0004); - case STATUS_CRACKED: return ((char *) ST_0005); - case STATUS_ABORTED: return ((char *) ST_0006); - case STATUS_QUIT: return ((char *) ST_0007); - case STATUS_BYPASS: return ((char *) ST_0008); - } - - return ((char *) "Uninitialized! Bug!"); + return NULL; } double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries) @@ -146,1202 +79,340 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en return exec_ms_sum / exec_ms_cnt; } -void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) +char *status_get_session (const hashcat_ctx_t *hashcat_ctx) { - combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - hashes_t *hashes = hashcat_ctx->hashes; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + const user_options_t *user_options = hashcat_ctx->user_options; - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - FILE *out = stdout; - - fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); - - /** - * speed new - */ - - fprintf (out, "SPEED\t"); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - u64 speed_cnt = 0; - double speed_ms = 0; - - for (int i = 0; i < SPEED_CACHE; i++) - { - speed_cnt += device_param->speed_cnt[i]; - speed_ms += device_param->speed_ms[i]; - } - - speed_cnt /= SPEED_CACHE; - speed_ms /= SPEED_CACHE; - - fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); - } - - /** - * exec time - */ - - fprintf (out, "EXEC_RUNTIME\t"); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - fprintf (out, "%f\t", exec_ms_avg); - } - - /** - * words_cur - */ - - u64 words_cur = get_lowest_words_done (hashcat_ctx); - - fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); - - /** - * counter - */ - - u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; - - u64 all_done = 0; - u64 all_rejected = 0; - u64 all_restored = 0; - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - all_done += status_ctx->words_progress_done[salt_pos]; - all_rejected += status_ctx->words_progress_rejected[salt_pos]; - all_restored += status_ctx->words_progress_restored[salt_pos]; - } - - u64 progress_cur = all_restored + all_done + all_rejected; - u64 progress_end = progress_total; - - u64 progress_skip = 0; - - if (user_options->skip) - { - progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; - } - - if (user_options->limit) - { - progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; - } - - u64 progress_cur_relative_skip = progress_cur - progress_skip; - u64 progress_end_relative_skip = progress_end - progress_skip; - - fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); - - /** - * cracks - */ - - fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); - fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); - - /** - * temperature - */ - - if (user_options->gpu_temp_disable == false) - { - fprintf (out, "TEMP\t"); - - hc_thread_mutex_lock (status_ctx->mux_hwmon); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - - fprintf (out, "%d\t", temp); - } - - hc_thread_mutex_unlock (status_ctx->mux_hwmon); - } - - /** - * flush - */ - - fputs (EOL, out); - fflush (out); + return user_options->session; } -void status_display (hashcat_ctx_t *hashcat_ctx) +char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) { - combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - hashes_t *hashes = hashcat_ctx->hashes; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status == STATUS_INIT) + const int devices_status = status_ctx->devices_status; + + switch (devices_status) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; + case STATUS_INIT: return ((char *) ST_0000); + case STATUS_AUTOTUNE: return ((char *) ST_0001); + case STATUS_RUNNING: return ((char *) ST_0002); + case STATUS_PAUSED: return ((char *) ST_0003); + case STATUS_EXHAUSTED: return ((char *) ST_0004); + case STATUS_CRACKED: return ((char *) ST_0005); + case STATUS_ABORTED: return ((char *) ST_0006); + case STATUS_QUIT: return ((char *) ST_0007); + case STATUS_BYPASS: return ((char *) ST_0008); } - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + return ((char *) ST_9999); +} - return; - } +char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx) +{ + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - // in this case some required buffers are free'd, ascii_digest() would run into segfault - if (status_ctx->shutdown_inner == 1) return; + return strhashtype (hashconfig->hash_mode); +} - if (user_options->machine_readable == true) - { - status_display_machine_readable (hashcat_ctx); - - return; - } - - char tmp_buf[1000] = { 0 }; - - u32 tmp_len = 0; - - event_log_info (hashcat_ctx, "Session.Name...: %s", user_options->session); - - char *status_type = strstatus (status_ctx->devices_status); - - u32 hash_mode = hashconfig->hash_mode; - - char *hash_type = strhashtype (hash_mode); // not a bug - - event_log_info (hashcat_ctx, "Status.........: %s", status_type); - - /** - * show rules - */ - - if (user_options->rp_files_cnt) - { - u32 i; - - for (i = 0, tmp_len = 0; i < user_options->rp_files_cnt - 1 && tmp_len < sizeof (tmp_buf); i++) - { - tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s), ", user_options->rp_files[i]); - } - - snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - - event_log_info (hashcat_ctx, "Rules.Type.....: %s", tmp_buf); - - tmp_len = 0; - } - - if (user_options->rp_gen) - { - event_log_info (hashcat_ctx, "Rules.Type.....: Generated (%u)", user_options->rp_gen); - - if (user_options->rp_gen_seed) - { - event_log_info (hashcat_ctx, "Rules.Seed.....: %u", user_options->rp_gen_seed); - } - } - - /** - * show input - */ - - char *custom_charset_1 = user_options->custom_charset_1; - char *custom_charset_2 = user_options->custom_charset_2; - char *custom_charset_3 = user_options->custom_charset_3; - char *custom_charset_4 = user_options->custom_charset_4; - - if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) - { - if (user_options_extra->wordlist_mode == WL_MODE_FILE) - { - event_log_info (hashcat_ctx, "Input.Mode.....: File (%s)", straight_ctx->dict); - } - else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) - { - event_log_info (hashcat_ctx, "Input.Mode.....: Pipe"); - } - } - else if (user_options->attack_mode == ATTACK_MODE_COMBI) - { - event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", combinator_ctx->dict1); - event_log_info (hashcat_ctx, "Input.Right....: File (%s)", combinator_ctx->dict2); - } - else if (user_options->attack_mode == ATTACK_MODE_BF) - { - char *mask = mask_ctx->mask; - - if (mask != NULL) - { - u32 mask_len = mask_ctx->css_cnt; - - tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "Mask (%s)", mask); - - if (mask_len > 0) - { - if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH) - { - if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) - { - mask_len -= hashes->salts_buf[0].salt_len; - } - } - - if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) mask_len /= 2; - - tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " [%i]", mask_len); - } - - if (mask_ctx->masks_cnt > 1) - { - const int maks_pos_done = ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_main_level1 == true)) ? 1 : 0; - - double mask_percentage = (double) (mask_ctx->masks_pos + maks_pos_done) / (double) mask_ctx->masks_cnt; - - tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); - } - - event_log_info (hashcat_ctx, "Input.Mode.....: %s", tmp_buf); - - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) - { - if (custom_charset_1 == NULL) custom_charset_1 = "Undefined"; - if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; - if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; - if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); - } - } - - tmp_len = 0; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", straight_ctx->dict); - event_log_info (hashcat_ctx, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) - { - if (custom_charset_1 == NULL) custom_charset_1 = "Undefined"; - if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; - if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; - if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); - } - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - event_log_info (hashcat_ctx, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - event_log_info (hashcat_ctx, "Input.Right....: File (%s)", straight_ctx->dict); - - if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) - { - if (custom_charset_1 == NULL) custom_charset_1 = "Undefined"; - if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; - if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; - if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - - event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); - } - } +char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx) +{ + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; if (hashes->digests_cnt == 1) { if (hashconfig->hash_mode == 2500) { + char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); + wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - event_log_info (hashcat_ctx, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", - (char *) hashes->salts_buf[0].salt_buf, - wpa->orig_mac1[0], - wpa->orig_mac1[1], - wpa->orig_mac1[2], - wpa->orig_mac1[3], - wpa->orig_mac1[4], - wpa->orig_mac1[5], - wpa->orig_mac2[0], - wpa->orig_mac2[1], - wpa->orig_mac2[2], - wpa->orig_mac2[3], - wpa->orig_mac2[4], - wpa->orig_mac2[5]); + snprintf (tmp_buf, HCBUFSIZ_TINY - 1, "%s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + (char *) hashes->salts_buf[0].salt_buf, + wpa->orig_mac1[0], + wpa->orig_mac1[1], + wpa->orig_mac1[2], + wpa->orig_mac1[3], + wpa->orig_mac1[4], + wpa->orig_mac1[5], + wpa->orig_mac2[0], + wpa->orig_mac2[1], + wpa->orig_mac2[2], + wpa->orig_mac2[3], + wpa->orig_mac2[4], + wpa->orig_mac2[5]); + + return tmp_buf; } else if (hashconfig->hash_mode == 5200) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + return hashes->hashfile; } else if (hashconfig->hash_mode == 9000) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + return hashes->hashfile; } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + return hashes->hashfile; } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + return hashes->hashfile; } else { - char out_buf[HCBUFSIZ_LARGE] = { 0 }; + char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); - ascii_digest (hashcat_ctx, out_buf, 0, 0); + ascii_digest ((hashcat_ctx_t *) hashcat_ctx, tmp_buf, 0, 0); - // limit length - if (strlen (out_buf) > 40) - { - out_buf[41] = '.'; - out_buf[42] = '.'; - out_buf[43] = '.'; - out_buf[44] = 0; - } - - event_log_info (hashcat_ctx, "Hash.Target....: %s", out_buf); + return tmp_buf; } } else { if (hashconfig->hash_mode == 3000) { + char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); + char out_buf1[32] = { 0 }; char out_buf2[32] = { 0 }; - ascii_digest (hashcat_ctx, out_buf1, 0, 0); - ascii_digest (hashcat_ctx, out_buf2, 0, 1); + ascii_digest ((hashcat_ctx_t *) hashcat_ctx, out_buf1, 0, 0); + ascii_digest ((hashcat_ctx_t *) hashcat_ctx, out_buf2, 0, 1); - event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); + snprintf (tmp_buf, HCBUFSIZ_TINY - 1, "%s, %s", out_buf1, out_buf2); + + return tmp_buf; } else { - event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); + return hashes->hashfile; } } - event_log_info (hashcat_ctx, "Hash.Type......: %s", hash_type); + return NULL; +} - /** - * speed new - */ +int status_get_input_mode (const hashcat_ctx_t *hashcat_ctx) +{ + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; + bool has_wordlist = false; + bool has_rule_file = false; + bool has_rule_gen = false; + bool has_base_left = false; + bool has_mask_cs = false; - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + if (user_options_extra->wordlist_mode == WL_MODE_FILE) has_wordlist = true; + + if (user_options->rp_files_cnt > 0) has_rule_file = true; + if (user_options->rp_gen > 0) has_rule_gen = true; + + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) has_base_left = true; + + if (user_options->custom_charset_1) has_mask_cs = true; + if (user_options->custom_charset_2) has_mask_cs = true; + if (user_options->custom_charset_3) has_mask_cs = true; + if (user_options->custom_charset_4) has_mask_cs = true; + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - speed_cnt[device_id] = 0; - speed_ms[device_id] = 0; - - for (int i = 0; i < SPEED_CACHE; i++) + if (has_wordlist == true) { - speed_cnt[device_id] += device_param->speed_cnt[i]; - speed_ms[device_id] += device_param->speed_ms[i]; - } - - speed_cnt[device_id] /= SPEED_CACHE; - speed_ms[device_id] /= SPEED_CACHE; - } - - double hashes_all_ms = 0; - - double hashes_dev_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_ms[device_id] = 0; - - if (speed_ms[device_id] > 0) - { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; - - hashes_all_ms += hashes_dev_ms[device_id]; - } - } - - /** - * exec time - */ - - double exec_all_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - exec_all_ms[device_id] = exec_ms_avg; - } - - /** - * timers - */ - - double ms_running = hc_timer_get (status_ctx->timer_running); - - double ms_paused = status_ctx->ms_paused; - - if (status_ctx->devices_status == STATUS_PAUSED) - { - double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused); - - ms_paused += ms_paused_tmp; - } - - #if defined (_WIN) - - __time64_t sec_run = (__time64_t) ms_running / 1000; - - #else - - time_t sec_run = (time_t) ms_running / 1000; - - #endif - - if (sec_run) - { - char display_run[32] = { 0 }; - - struct tm tm_run; - - struct tm *tmp = NULL; - - #if defined (_WIN) - - tmp = _gmtime64 (&sec_run); - - #else - - tmp = gmtime (&sec_run); - - #endif - - if (tmp != NULL) - { - memset (&tm_run, 0, sizeof (tm_run)); - - memcpy (&tm_run, tmp, sizeof (tm_run)); - - format_timer_display (&tm_run, display_run, sizeof (tm_run)); - - char *start = ctime (&status_ctx->proc_start); - - size_t start_len = strlen (start); - - if (start[start_len - 1] == '\n') start[start_len - 1] = 0; - if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - - event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); - } - } - else - { - event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); - } - - /** - * counters - */ - - u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; - - u64 all_done = 0; - u64 all_rejected = 0; - u64 all_restored = 0; - - u64 progress_noneed = 0; - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - all_done += status_ctx->words_progress_done[salt_pos]; - all_rejected += status_ctx->words_progress_rejected[salt_pos]; - all_restored += status_ctx->words_progress_restored[salt_pos]; - - // Important for ETA only - - if (hashes->salts_shown[salt_pos] == 1) - { - const u64 all = status_ctx->words_progress_done[salt_pos] - + status_ctx->words_progress_rejected[salt_pos] - + status_ctx->words_progress_restored[salt_pos]; - - const u64 left = status_ctx->words_cnt - all; - - progress_noneed += left; - } - } - - u64 progress_cur = all_restored + all_done + all_rejected; - u64 progress_end = progress_total; - - u64 progress_skip = 0; - - if (user_options->skip) - { - progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; - } - - if (user_options->limit) - { - progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; - } - - u64 progress_cur_relative_skip = progress_cur - progress_skip; - u64 progress_end_relative_skip = progress_end - progress_skip; - - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - if (status_ctx->devices_status != STATUS_CRACKED) - { - #if defined (_WIN) - __time64_t sec_etc = 0; - #else - time_t sec_etc = 0; - #endif - - if (hashes_all_ms > 0) + if (has_rule_file == true) { - u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; - - u64 ms_left = (u64) ((progress_left_relative_skip - progress_noneed) / hashes_all_ms); - - sec_etc = ms_left / 1000; + return INPUT_MODE_STRAIGHT_FILE_RULES_FILE; } - - #define SEC10YEARS (60 * 60 * 24 * 365 * 10) - - if (sec_etc == 0) + else if (has_rule_gen == true) { - //log_info ("Time.Estimated.: 0 secs"); - } - else if ((u64) sec_etc > SEC10YEARS) - { - event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); + return INPUT_MODE_STRAIGHT_FILE_RULES_GEN; } else { - char display_etc[32] = { 0 }; - char display_runtime[32] = { 0 }; - - struct tm tm_etc; - struct tm tm_runtime; - - struct tm *tmp = NULL; - - #if defined (_WIN) - tmp = _gmtime64 (&sec_etc); - #else - tmp = gmtime (&sec_etc); - #endif - - if (tmp != NULL) - { - memcpy (&tm_etc, tmp, sizeof (tm_etc)); - - format_timer_display (&tm_etc, display_etc, sizeof (display_etc)); - - time_t now; - - time (&now); - - now += sec_etc; - - char *etc = ctime (&now); - - size_t etc_len = strlen (etc); - - if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0; - if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0; - - if (user_options->runtime) - { - time_t runtime_cur; - - time (&runtime_cur); - - #if defined (_WIN) - - __time64_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; - - tmp = _gmtime64 (&runtime_left); - - #else - - time_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; - - tmp = gmtime (&runtime_left); - - #endif - - if ((tmp != NULL) && (runtime_left > 0) && (runtime_left < sec_etc)) - { - memcpy (&tm_runtime, tmp, sizeof (tm_runtime)); - - format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); - } - else - { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); - } - } - else - { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); - } - } - } - } - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - char display_dev_cur[16] = { 0 }; - - strncpy (display_dev_cur, "0.00", 4); - - format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - - event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); - } - - char display_all_cur[16] = { 0 }; - - strncpy (display_all_cur, "0.00", 4); - - format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); - - const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; - const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - - event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); - - // crack-per-time - - if (hashes->digests_cnt > 100) - { - time_t now = time (NULL); - - int cpt_cur_min = 0; - int cpt_cur_hour = 0; - int cpt_cur_day = 0; - - for (int i = 0; i < CPT_BUF; i++) - { - const u32 cracked = cpt_ctx->cpt_buf[i].cracked; - const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; - - if ((timestamp + 60) > now) - { - cpt_cur_min += cracked; - } - - if ((timestamp + 3600) > now) - { - cpt_cur_hour += cracked; - } - - if ((timestamp + 86400) > now) - { - cpt_cur_day += cracked; - } - } - - double ms_real = ms_running - ms_paused; - - double cpt_avg_min = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 60); - double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 3600); - double cpt_avg_day = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 86400); - - if ((cpt_ctx->cpt_start + 86400) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_cur_hour, - cpt_cur_day, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else if ((cpt_ctx->cpt_start + 3600) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_cur_hour, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else if ((cpt_ctx->cpt_start + 60) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - } - - // Restore point - - u64 restore_point = get_lowest_words_done (hashcat_ctx); - - u64 restore_total = status_ctx->words_base; - - double percent_restore = 0; - - if (restore_total != 0) percent_restore = (double) restore_point / (double) restore_total; - - if (progress_end_relative_skip) - { - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - double percent_finished = (double) progress_cur_relative_skip / (double) progress_end_relative_skip; - double percent_rejected = 0.0; - - if (progress_cur) - { - percent_rejected = (double) (all_rejected) / (double) progress_cur; - } - - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); - - if (user_options->restore_disable == false) - { - if (percent_finished != 1) - { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); - } - } - } - } - else - { - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - - if (user_options->restore_disable == false) - { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + return INPUT_MODE_STRAIGHT_FILE; } } else { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); - - // --restore not allowed if stdin is used -- really? why? - - //if (user_options->restore_disable == false) - //{ - // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); - //} - } - } - - if (status_ctx->run_main_level1 == false) return; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) - { - if (user_options_extra->attack_kern == ATTACK_KERN_BF) + if (has_rule_file == true) { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); + return INPUT_MODE_STRAIGHT_STDIN_RULES_FILE; + } + else if (has_rule_gen == true) + { + return INPUT_MODE_STRAIGHT_STDIN_RULES_GEN; } else { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); + return INPUT_MODE_STRAIGHT_STDIN; } - - continue; } - - const u32 outerloop_first = 0; - const u32 outerloop_last = device_param->outerloop_left - 1; - - const u32 innerloop_first = 0; - const u32 innerloop_last = device_param->innerloop_left - 1; - - plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; - plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; - - u32 plain_buf1[16] = { 0 }; - u32 plain_buf2[16] = { 0 }; - - u8 *plain_ptr1 = (u8 *) plain_buf1; - u8 *plain_ptr2 = (u8 *) plain_buf2; - - int plain_len1 = 0; - int plain_len2 = 0; - - build_plain (hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); - build_plain (hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); - - bool need_hex1 = need_hexify (plain_ptr1, plain_len1); - bool need_hex2 = need_hexify (plain_ptr2, plain_len2); - - if ((need_hex1 == true) || (need_hex2 == true)) + } + else if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + if (has_base_left == true) { - exec_hexify (plain_ptr1, plain_len1, plain_ptr1); - exec_hexify (plain_ptr2, plain_len2, plain_ptr2); - - plain_ptr1[plain_len1 * 2] = 0; - plain_ptr2[plain_len2 * 2] = 0; - - event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + return INPUT_MODE_COMBINATOR_BASE_LEFT; } else { - event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + return INPUT_MODE_COMBINATOR_BASE_RIGHT; } } - - if (user_options->gpu_temp_disable == false) + else if (user_options->attack_mode == ATTACK_MODE_BF) { - hc_thread_mutex_lock (status_ctx->mux_hwmon); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + if (has_mask_cs == true) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - const int num_temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - const int num_fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id); - const int num_utilization = hm_get_utilization_with_device_id (hashcat_ctx, device_id); - const int num_corespeed = hm_get_corespeed_with_device_id (hashcat_ctx, device_id); - const int num_memoryspeed = hm_get_memoryspeed_with_device_id (hashcat_ctx, device_id); - const int num_buslanes = hm_get_buslanes_with_device_id (hashcat_ctx, device_id); - const int num_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id); - - char output_buf[256] = { 0 }; - - int output_len = 0; - - if (num_temperature >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Temp:%3uc", num_temperature); - - output_len = strlen (output_buf); - } - - if (num_fanspeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Fan:%3u%%", num_fanspeed); - - output_len = strlen (output_buf); - } - - if (num_utilization >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Util:%3u%%", num_utilization); - - output_len = strlen (output_buf); - } - - if (num_corespeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Core:%4uMhz", num_corespeed); - - output_len = strlen (output_buf); - } - - if (num_memoryspeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Mem:%4uMhz", num_memoryspeed); - - output_len = strlen (output_buf); - } - - if (num_buslanes >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Lanes:%u", num_buslanes); - - output_len = strlen (output_buf); - } - - if (num_throttle >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " *Throttled*"); - - output_len = strlen (output_buf); - } - - if (output_len == 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " N/A"); - - output_len = strlen (output_buf); - } - - event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); - } - - hc_thread_mutex_unlock (status_ctx->mux_hwmon); - } -} - -void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_ms[device_id] = device_param->speed_ms[0]; - } - - u64 hashes_dev_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_ms[device_id] = 0; - - if (speed_ms[device_id] > 0) - { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; - } - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); - } -} - -void status_benchmark (hashcat_ctx_t *hashcat_ctx) -{ - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; - - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - if (status_ctx->shutdown_inner == 1) return; - - if (user_options->machine_readable == true) - { - status_benchmark_automate (hashcat_ctx); - - return; - } - - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_ms[device_id] = device_param->speed_ms[0]; - } - - double hashes_all_ms = 0; - - double hashes_dev_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_ms[device_id] = 0; - - if (speed_ms[device_id] > 0) - { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; - - hashes_all_ms += hashes_dev_ms[device_id]; - } - } - - /** - * exec time - */ - - double exec_all_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - exec_all_ms[device_id] = exec_ms_avg; - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - char display_dev_cur[16] = { 0 }; - - strncpy (display_dev_cur, "0.00", 4); - - format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - - if (opencl_ctx->devices_active >= 10) - { - event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + return INPUT_MODE_MASK_CS; } else { - event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + return INPUT_MODE_MASK; + } + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + if (has_mask_cs == true) + { + return INPUT_MODE_HYBRID1_CS; + } + else + { + return INPUT_MODE_HYBRID1; + } + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + if (has_mask_cs == true) + { + return INPUT_MODE_HYBRID2_CS; + } + else + { + return INPUT_MODE_HYBRID2; } } - char display_all_cur[16] = { 0 }; - - strncpy (display_all_cur, "0.00", 4); - - format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); + return INPUT_MODE_NONE; } +char *status_get_input_base (const hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + + return straight_ctx->dict; + } + else if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + + if (combinator_ctx->combs_mode == INPUT_MODE_COMBINATOR_BASE_LEFT) + { + return combinator_ctx->dict1; + } + else + { + return combinator_ctx->dict2; + } + } + else if (user_options->attack_mode == ATTACK_MODE_BF) + { + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + + return mask_ctx->mask; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + + return straight_ctx->dict; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + + return straight_ctx->dict; + } + + return NULL; +} + +char *status_get_input_mod (const hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + return status_get_rules_file (hashcat_ctx); + } + else if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + + if (combinator_ctx->combs_mode == INPUT_MODE_COMBINATOR_BASE_LEFT) + { + return combinator_ctx->dict2; + } + else + { + return combinator_ctx->dict1; + } + } + else if (user_options->attack_mode == ATTACK_MODE_BF) + { + + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + + return mask_ctx->mask; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + + return mask_ctx->mask; + } + + return NULL; +} + +char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + const char *custom_charset_1 = user_options->custom_charset_1; + const char *custom_charset_2 = user_options->custom_charset_2; + const char *custom_charset_3 = user_options->custom_charset_3; + const char *custom_charset_4 = user_options->custom_charset_4; + + if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) + { + char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); + + if (custom_charset_1 == NULL) custom_charset_1 = "Undefined"; + if (custom_charset_2 == NULL) custom_charset_2 = "Undefined"; + if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; + if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; + + snprintf (tmp_buf, HCBUFSIZ_TINY - 1, "-1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + + return tmp_buf; + } + + return NULL; +} + + int status_progress_init (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; diff --git a/src/terminal.c b/src/terminal.c index da1762842..2dc2094ad 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -6,11 +6,15 @@ #include "common.h" #include "types.h" #include "event.h" +#include "convert.h" #include "thread.h" #include "timer.h" #include "status.h" #include "restore.h" #include "shared.h" +#include "hwmon.h" +#include "interface.h" +#include "outfile.h" #include "terminal.h" const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => "; @@ -228,7 +232,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, ""); - myabort (hashcat_ctx); + myquit (hashcat_ctx); break; } @@ -439,3 +443,1125 @@ int tty_fix() return 0; } #endif + +static void format_timer_display (struct tm *tm, char *buf, size_t len) +{ + const char *time_entities_s[] = { "year", "day", "hour", "min", "sec" }; + const char *time_entities_m[] = { "years", "days", "hours", "mins", "secs" }; + + if (tm->tm_year - 70) + { + char *time_entity1 = ((tm->tm_year - 70) == 1) ? (char *) time_entities_s[0] : (char *) time_entities_m[0]; + char *time_entity2 = ( tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); + } + else if (tm->tm_yday) + { + char *time_entity1 = (tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; + char *time_entity2 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); + } + else if (tm->tm_hour) + { + char *time_entity1 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; + char *time_entity2 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); + } + else if (tm->tm_min) + { + char *time_entity1 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; + char *time_entity2 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); + } + else + { + char *time_entity1 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + + snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); + } +} + +static void format_speed_display (double val, char *buf, size_t len) +{ + if (val <= 0) + { + buf[0] = '0'; + buf[1] = ' '; + buf[2] = 0; + + return; + } + + char units[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; + + u32 level = 0; + + while (val > 99999) + { + val /= 1000; + + level++; + } + + /* generate output */ + + if (level == 0) + { + snprintf (buf, len - 1, "%.0f ", val); + } + else + { + snprintf (buf, len - 1, "%.1f %c", val, units[level]); + } +} + +void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) +{ + combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + hashes_t *hashes = hashcat_ctx->hashes; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + user_options_t *user_options = hashcat_ctx->user_options; + + if (status_ctx->devices_status == STATUS_INIT) + { + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + + return; + } + + if (status_ctx->devices_status == STATUS_AUTOTUNE) + { + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + + return; + } + + FILE *out = stdout; + + fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); + + /** + * speed new + */ + + fprintf (out, "SPEED\t"); + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + u64 speed_cnt = 0; + double speed_ms = 0; + + for (int i = 0; i < SPEED_CACHE; i++) + { + speed_cnt += device_param->speed_cnt[i]; + speed_ms += device_param->speed_ms[i]; + } + + speed_cnt /= SPEED_CACHE; + speed_ms /= SPEED_CACHE; + + fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); + } + + /** + * exec time + */ + + fprintf (out, "EXEC_RUNTIME\t"); + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + + fprintf (out, "%f\t", exec_ms_avg); + } + + /** + * words_cur + */ + + u64 words_cur = get_lowest_words_done (hashcat_ctx); + + fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); + + /** + * counter + */ + + u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; + + u64 all_done = 0; + u64 all_rejected = 0; + u64 all_restored = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + all_done += status_ctx->words_progress_done[salt_pos]; + all_rejected += status_ctx->words_progress_rejected[salt_pos]; + all_restored += status_ctx->words_progress_restored[salt_pos]; + } + + u64 progress_cur = all_restored + all_done + all_rejected; + u64 progress_end = progress_total; + + u64 progress_skip = 0; + + if (user_options->skip) + { + progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; + } + + if (user_options->limit) + { + progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; + } + + u64 progress_cur_relative_skip = progress_cur - progress_skip; + u64 progress_end_relative_skip = progress_end - progress_skip; + + fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); + + /** + * cracks + */ + + fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); + fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); + + /** + * temperature + */ + + if (user_options->gpu_temp_disable == false) + { + fprintf (out, "TEMP\t"); + + hc_thread_mutex_lock (status_ctx->mux_hwmon); + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); + + fprintf (out, "%d\t", temp); + } + + hc_thread_mutex_unlock (status_ctx->mux_hwmon); + } + + /** + * flush + */ + + fputs (EOL, out); + fflush (out); +} + +void status_display (hashcat_ctx_t *hashcat_ctx) +{ + combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + hashes_t *hashes = hashcat_ctx->hashes; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + user_options_t *user_options = hashcat_ctx->user_options; + + if (status_ctx->devices_status == STATUS_INIT) + { + event_log_error (hashcat_ctx, "Status view is not available during initialization phase"); + + return; + } + + if (status_ctx->devices_status == STATUS_AUTOTUNE) + { + event_log_error (hashcat_ctx, "Status view is not available during autotune phase"); + + return; + } + + if (status_ctx->shutdown_inner == true) + { + // in this case some required buffers are free'd, ascii_digest() would run into segfault + + event_log_error (hashcat_ctx, "Status view is not available during shutdown phase"); + + return; + } + + if (user_options->machine_readable == true) + { + status_display_machine_readable (hashcat_ctx); + + return; + } + + /** + * show something + */ + + event_log_info (hashcat_ctx, "Session........: %s", status_get_session (hashcat_ctx)); + event_log_info (hashcat_ctx, "Status.........: %s", status_get_status_string (hashcat_ctx)); + event_log_info (hashcat_ctx, "Hash.Type......: %s", status_get_hash_type (hashcat_ctx)); + event_log_info (hashcat_ctx, "Hash.Target....: %s", status_get_hash_target (hashcat_ctx)); + + const int input_mode = status_get_input_mode (hashcat_ctx); + + switch (input_mode) + { + case INPUT_MODE_STRAIGHT_FILE: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); + break; + case INPUT_MODE_STRAIGHT_FILE_RULES_FILE: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Rules (%s)", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_STRAIGHT_FILE_RULES_GEN: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Rules (Generated)"); + break; + case INPUT_MODE_STRAIGHT_STDIN: + event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); + break; + case INPUT_MODE_STRAIGHT_STDIN_RULES_FILE: + event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); + event_log_info (hashcat_ctx, "Input.Mod......: Rules (%s)", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_STRAIGHT_STDIN_RULES_GEN: + event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); + event_log_info (hashcat_ctx, "Input.Mod......: Rules (Generated)"); + break; + case INPUT_MODE_COMBINATOR_BASE_LEFT: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: File (%s), Right Side", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_COMBINATOR_BASE_RIGHT: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: File (%s), Left Side", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_MASK: + event_log_info (hashcat_ctx, "Input.Mask.....: %s", status_get_input_base (hashcat_ctx)); + break; + case INPUT_MODE_MASK_CS: + event_log_info (hashcat_ctx, "Input.Mask.....: %s", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + break; + case INPUT_MODE_HYBRID1: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Right Side", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_HYBRID1_CS: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Right Side", status_get_input_mod (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + break; + case INPUT_MODE_HYBRID2: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Left Side", status_get_input_mod (hashcat_ctx)); + break; + case INPUT_MODE_HYBRID2_CS: + event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Left Side", status_get_input_mod (hashcat_ctx)); + event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + break; + } + + /** + * speed new + */ + + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + speed_cnt[device_id] = 0; + speed_ms[device_id] = 0; + + for (int i = 0; i < SPEED_CACHE; i++) + { + speed_cnt[device_id] += device_param->speed_cnt[i]; + speed_ms[device_id] += device_param->speed_ms[i]; + } + + speed_cnt[device_id] /= SPEED_CACHE; + speed_ms[device_id] /= SPEED_CACHE; + } + + double hashes_all_ms = 0; + + double hashes_dev_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + hashes_dev_ms[device_id] = 0; + + if (speed_ms[device_id] > 0) + { + hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; + + hashes_all_ms += hashes_dev_ms[device_id]; + } + } + + /** + * exec time + */ + + double exec_all_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + + exec_all_ms[device_id] = exec_ms_avg; + } + + /** + * timers + */ + + double ms_running = hc_timer_get (status_ctx->timer_running); + + double ms_paused = status_ctx->ms_paused; + + if (status_ctx->devices_status == STATUS_PAUSED) + { + double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused); + + ms_paused += ms_paused_tmp; + } + + #if defined (_WIN) + + __time64_t sec_run = (__time64_t) ms_running / 1000; + + #else + + time_t sec_run = (time_t) ms_running / 1000; + + #endif + + if (sec_run) + { + char display_run[32] = { 0 }; + + struct tm tm_run; + + struct tm *tmp = NULL; + + #if defined (_WIN) + + tmp = _gmtime64 (&sec_run); + + #else + + tmp = gmtime (&sec_run); + + #endif + + if (tmp != NULL) + { + memset (&tm_run, 0, sizeof (tm_run)); + + memcpy (&tm_run, tmp, sizeof (tm_run)); + + format_timer_display (&tm_run, display_run, sizeof (tm_run)); + + char *start = ctime (&status_ctx->proc_start); + + size_t start_len = strlen (start); + + if (start[start_len - 1] == '\n') start[start_len - 1] = 0; + if (start[start_len - 2] == '\r') start[start_len - 2] = 0; + + event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); + } + } + else + { + event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); + } + + /** + * counters + */ + + u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; + + u64 all_done = 0; + u64 all_rejected = 0; + u64 all_restored = 0; + + u64 progress_noneed = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + all_done += status_ctx->words_progress_done[salt_pos]; + all_rejected += status_ctx->words_progress_rejected[salt_pos]; + all_restored += status_ctx->words_progress_restored[salt_pos]; + + // Important for ETA only + + if (hashes->salts_shown[salt_pos] == 1) + { + const u64 all = status_ctx->words_progress_done[salt_pos] + + status_ctx->words_progress_rejected[salt_pos] + + status_ctx->words_progress_restored[salt_pos]; + + const u64 left = status_ctx->words_cnt - all; + + progress_noneed += left; + } + } + + u64 progress_cur = all_restored + all_done + all_rejected; + u64 progress_end = progress_total; + + u64 progress_skip = 0; + + if (user_options->skip) + { + progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; + } + + if (user_options->limit) + { + progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; + } + + u64 progress_cur_relative_skip = progress_cur - progress_skip; + u64 progress_end_relative_skip = progress_end - progress_skip; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (status_ctx->devices_status != STATUS_CRACKED) + { + #if defined (_WIN) + __time64_t sec_etc = 0; + #else + time_t sec_etc = 0; + #endif + + if (hashes_all_ms > 0) + { + u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; + + u64 ms_left = (u64) ((progress_left_relative_skip - progress_noneed) / hashes_all_ms); + + sec_etc = ms_left / 1000; + } + + #define SEC10YEARS (60 * 60 * 24 * 365 * 10) + + if (sec_etc == 0) + { + //log_info ("Time.Estimated.: 0 secs"); + } + else if ((u64) sec_etc > SEC10YEARS) + { + event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); + } + else + { + char display_etc[32] = { 0 }; + char display_runtime[32] = { 0 }; + + struct tm tm_etc; + struct tm tm_runtime; + + struct tm *tmp = NULL; + + #if defined (_WIN) + tmp = _gmtime64 (&sec_etc); + #else + tmp = gmtime (&sec_etc); + #endif + + if (tmp != NULL) + { + memcpy (&tm_etc, tmp, sizeof (tm_etc)); + + format_timer_display (&tm_etc, display_etc, sizeof (display_etc)); + + time_t now; + + time (&now); + + now += sec_etc; + + char *etc = ctime (&now); + + size_t etc_len = strlen (etc); + + if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0; + if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0; + + if (user_options->runtime) + { + time_t runtime_cur; + + time (&runtime_cur); + + #if defined (_WIN) + + __time64_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; + + tmp = _gmtime64 (&runtime_left); + + #else + + time_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; + + tmp = gmtime (&runtime_left); + + #endif + + if ((tmp != NULL) && (runtime_left > 0) && (runtime_left < sec_etc)) + { + memcpy (&tm_runtime, tmp, sizeof (tm_runtime)); + + format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); + + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + } + else + { + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + } + } + else + { + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); + } + } + } + } + } + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + char display_dev_cur[16] = { 0 }; + + strncpy (display_dev_cur, "0.00", 4); + + format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); + + event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + } + + char display_all_cur[16] = { 0 }; + + strncpy (display_all_cur, "0.00", 4); + + format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); + + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); + + const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; + const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; + + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + + // crack-per-time + + if (hashes->digests_cnt > 100) + { + time_t now = time (NULL); + + int cpt_cur_min = 0; + int cpt_cur_hour = 0; + int cpt_cur_day = 0; + + for (int i = 0; i < CPT_BUF; i++) + { + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; + + if ((timestamp + 60) > now) + { + cpt_cur_min += cracked; + } + + if ((timestamp + 3600) > now) + { + cpt_cur_hour += cracked; + } + + if ((timestamp + 86400) > now) + { + cpt_cur_day += cracked; + } + } + + double ms_real = ms_running - ms_paused; + + double cpt_avg_min = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 60); + double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 3600); + double cpt_avg_day = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 86400); + + if ((cpt_ctx->cpt_start + 86400) < now) + { + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_cur_hour, + cpt_cur_day, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else if ((cpt_ctx->cpt_start + 3600) < now) + { + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_cur_hour, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else if ((cpt_ctx->cpt_start + 60) < now) + { + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else + { + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + } + + // Restore point + + u64 restore_point = get_lowest_words_done (hashcat_ctx); + + u64 restore_total = status_ctx->words_base; + + double percent_restore = 0; + + if (restore_total != 0) percent_restore = (double) restore_point / (double) restore_total; + + if (progress_end_relative_skip) + { + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + double percent_finished = (double) progress_cur_relative_skip / (double) progress_end_relative_skip; + double percent_rejected = 0.0; + + if (progress_cur) + { + percent_rejected = (double) (all_rejected) / (double) progress_cur; + } + + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + + if (user_options->restore_disable == false) + { + if (percent_finished != 1) + { + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + } + } + } + } + else + { + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + + if (user_options->restore_disable == false) + { + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + } + } + else + { + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); + + // --restore not allowed if stdin is used -- really? why? + + //if (user_options->restore_disable == false) + //{ + // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); + //} + } + } + + if (status_ctx->run_main_level1 == false) return; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) + { + if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); + } + else + { + event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); + } + + continue; + } + + const u32 outerloop_first = 0; + const u32 outerloop_last = device_param->outerloop_left - 1; + + const u32 innerloop_first = 0; + const u32 innerloop_last = device_param->innerloop_left - 1; + + plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; + plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; + + u32 plain_buf1[16] = { 0 }; + u32 plain_buf2[16] = { 0 }; + + u8 *plain_ptr1 = (u8 *) plain_buf1; + u8 *plain_ptr2 = (u8 *) plain_buf2; + + int plain_len1 = 0; + int plain_len2 = 0; + + build_plain (hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); + build_plain (hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); + + bool need_hex1 = need_hexify (plain_ptr1, plain_len1); + bool need_hex2 = need_hexify (plain_ptr2, plain_len2); + + if ((need_hex1 == true) || (need_hex2 == true)) + { + exec_hexify (plain_ptr1, plain_len1, plain_ptr1); + exec_hexify (plain_ptr2, plain_len2, plain_ptr2); + + plain_ptr1[plain_len1 * 2] = 0; + plain_ptr2[plain_len2 * 2] = 0; + + event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + } + else + { + event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + } + } + + if (user_options->gpu_temp_disable == false) + { + hc_thread_mutex_lock (status_ctx->mux_hwmon); + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + const int num_temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id); + const int num_fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id); + const int num_utilization = hm_get_utilization_with_device_id (hashcat_ctx, device_id); + const int num_corespeed = hm_get_corespeed_with_device_id (hashcat_ctx, device_id); + const int num_memoryspeed = hm_get_memoryspeed_with_device_id (hashcat_ctx, device_id); + const int num_buslanes = hm_get_buslanes_with_device_id (hashcat_ctx, device_id); + const int num_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id); + + char output_buf[256] = { 0 }; + + int output_len = 0; + + if (num_temperature >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Temp:%3uc", num_temperature); + + output_len = strlen (output_buf); + } + + if (num_fanspeed >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Fan:%3u%%", num_fanspeed); + + output_len = strlen (output_buf); + } + + if (num_utilization >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Util:%3u%%", num_utilization); + + output_len = strlen (output_buf); + } + + if (num_corespeed >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Core:%4uMhz", num_corespeed); + + output_len = strlen (output_buf); + } + + if (num_memoryspeed >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Mem:%4uMhz", num_memoryspeed); + + output_len = strlen (output_buf); + } + + if (num_buslanes >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Lanes:%u", num_buslanes); + + output_len = strlen (output_buf); + } + + if (num_throttle >= 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " *Throttled*"); + + output_len = strlen (output_buf); + } + + if (output_len == 0) + { + snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " N/A"); + + output_len = strlen (output_buf); + } + + event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + } + + hc_thread_mutex_unlock (status_ctx->mux_hwmon); + } +} + +void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) +{ + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + if (status_ctx->devices_status == STATUS_INIT) + { + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + + return; + } + + if (status_ctx->devices_status == STATUS_AUTOTUNE) + { + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + + return; + } + + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + speed_cnt[device_id] = device_param->speed_cnt[0]; + speed_ms[device_id] = device_param->speed_ms[0]; + } + + u64 hashes_dev_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + hashes_dev_ms[device_id] = 0; + + if (speed_ms[device_id] > 0) + { + hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; + } + } + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + } +} + +void status_benchmark (hashcat_ctx_t *hashcat_ctx) +{ + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + + if (status_ctx->devices_status == STATUS_INIT) + { + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + + return; + } + + if (status_ctx->devices_status == STATUS_AUTOTUNE) + { + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + + return; + } + + if (status_ctx->shutdown_inner == 1) return; + + if (user_options->machine_readable == true) + { + status_benchmark_automate (hashcat_ctx); + + return; + } + + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + speed_cnt[device_id] = device_param->speed_cnt[0]; + speed_ms[device_id] = device_param->speed_ms[0]; + } + + double hashes_all_ms = 0; + + double hashes_dev_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + hashes_dev_ms[device_id] = 0; + + if (speed_ms[device_id] > 0) + { + hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; + + hashes_all_ms += hashes_dev_ms[device_id]; + } + } + + /** + * exec time + */ + + double exec_all_ms[DEVICES_MAX] = { 0 }; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + + exec_all_ms[device_id] = exec_ms_avg; + } + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + char display_dev_cur[16] = { 0 }; + + strncpy (display_dev_cur, "0.00", 4); + + format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); + + if (opencl_ctx->devices_active >= 10) + { + event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + } + else + { + event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + } + } + + char display_all_cur[16] = { 0 }; + + strncpy (display_all_cur, "0.00", 4); + + format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); + + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); +} diff --git a/src/thread.c b/src/thread.c index bedba5f78..b97c8b2b8 100644 --- a/src/thread.c +++ b/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; } From bb98a8c8e167f36fc5c09708959745d26addc535 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sun, 16 Oct 2016 23:32:30 +0200 Subject: [PATCH 068/106] Update changes.txt --- docs/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes.txt b/docs/changes.txt index e12d9c05f..6902cf610 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -14,6 +14,7 @@ - Added docs/team.txt - Allow words of length > 32 in wordlists for -a 0 for slow hashes if no rules are in use or a : rule is in the rulefile - Reduce max. number of allowed function calls per rule from 256 to 32 to save GPU memory +- Status display shows what's the base and modifier keyspace currently in use ## ## Algorithms From b044271b01290cd9780444d2564e936e84f39f6a Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 13:44:07 +0200 Subject: [PATCH 069/106] Move more status display calculate logic into separate functions --- include/monitor.h | 2 + include/shared.h | 4 +- include/status.h | 63 +++-- include/types.h | 18 +- src/autotune.c | 46 ++-- src/hashcat.c | 22 +- src/monitor.c | 50 ++-- src/opencl.c | 22 +- src/shared.c | 2 +- src/status.c | 598 +++++++++++++++++++++++++++++++++++++++++++++- src/terminal.c | 479 +++++-------------------------------- src/thread.c | 4 +- 12 files changed, 797 insertions(+), 513 deletions(-) diff --git a/include/monitor.h b/include/monitor.h index ac0d67acb..2f6da11ab 100644 --- a/include/monitor.h +++ b/include/monitor.h @@ -6,6 +6,8 @@ #ifndef _MONITOR_H #define _MONITOR_H +int get_runtime_left (const hashcat_ctx_t *hashcat_ctx); + void *thread_monitor (void *p); #endif // _MONITOR_H diff --git a/include/shared.h b/include/shared.h index 9971466f1..1fa73fcf3 100644 --- a/include/shared.h +++ b/include/shared.h @@ -24,8 +24,8 @@ char *filename_from_filepath (char *filepath); void naive_replace (char *s, const char key_char, const char replace_char); void naive_escape (char *s, size_t s_max, const char key_char, const char escape_char); -void hc_sleep_ms (const u32 msec); -void hc_sleep (const u32 sec); +void hc_sleep_msec (const u32 msec); +void hc_sleep (const u32 sec); void setup_environment_variables (); void setup_umask (); diff --git a/include/status.h b/include/status.h index eccea7bf7..7b310c9ef 100644 --- a/include/status.h +++ b/include/status.h @@ -12,23 +12,56 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries); -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); +// should be static after refactoring +void format_timer_display (struct tm *tm, char *buf, size_t len); +void format_speed_display (double val, char *buf, size_t len); -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); +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_get_digests_done (const hashcat_ctx_t *hashcat_ctx); +int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx); +double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx); +int status_get_salts_done (const hashcat_ctx_t *hashcat_ctx); +int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx); +double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_estimated_relative (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); +u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); -int status_ctx_init (hashcat_ctx_t *hashcat_ctx); -void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx); +double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); +double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); + +double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); +double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); + +char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); +char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); + +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_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 diff --git a/include/types.h b/include/types.h index 38472b3cf..b542f9db3 100644 --- a/include/types.h +++ b/include/types.h @@ -679,7 +679,7 @@ typedef struct hc_device_param u32 innerloop_left; u32 exec_pos; - double exec_ms[EXEC_CACHE]; + double exec_msec[EXEC_CACHE]; // workaround cpu spinning @@ -691,7 +691,7 @@ typedef struct hc_device_param u32 speed_pos; u64 speed_cnt[SPEED_CACHE]; - double speed_ms[SPEED_CACHE]; + double speed_msec[SPEED_CACHE]; hc_timer_t timer_speed; @@ -818,7 +818,7 @@ typedef struct opencl_ctx u32 devices_filter; cl_device_type device_types_filter; - double target_ms; + double target_msec; bool need_adl; bool need_nvml; @@ -1394,7 +1394,7 @@ typedef struct status_ctx hc_timer_t timer_running; // timer on current dict hc_timer_t timer_paused; // timer on current dict - double ms_paused; // timer on current dict + double msec_paused; // timer on current dict } status_ctx_t; @@ -1483,12 +1483,18 @@ typedef struct { char *status; char *session; + char *time_started_absolute; + char *time_started_relative; + char *time_estimated_absolute; + char *time_estimated_relative; + char *hash_type; + char *hash_target; 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; diff --git a/src/autotune.c b/src/autotune.c index 0d8ec12ed..cf68c14e5 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -30,9 +30,9 @@ static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par run_kernel (hashcat_ctx, device_param, KERN_RUN_2, kernel_power_try, true, 0); } - const double exec_ms_prev = get_avg_exec_time (device_param, 1); + const double exec_msec_prev = get_avg_exec_time (device_param, 1); - return exec_ms_prev; + return exec_msec_prev; } static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) @@ -42,7 +42,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - const double target_ms = opencl_ctx->target_ms; + const double target_msec = opencl_ctx->target_msec; const u32 kernel_accel_min = device_param->kernel_accel_min; const u32 kernel_accel_max = device_param->kernel_accel_max; @@ -122,22 +122,22 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param #define VERIFIER_CNT 1 - // first find out highest kernel-loops that stays below target_ms + // first find out highest kernel-loops that stays below target_msec if (kernel_loops_min < kernel_loops_max) { for (kernel_loops = kernel_loops_max; kernel_loops > kernel_loops_min; kernel_loops >>= 1) { - double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops); + double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops); for (int i = 0; i < VERIFIER_CNT; i++) { - double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops); + double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops); - exec_ms = MIN (exec_ms, exec_ms_v); + exec_msec = MIN (exec_msec, exec_msec_v); } - if (exec_ms < target_ms) break; + if (exec_msec < target_msec) break; } } @@ -154,16 +154,16 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (kernel_accel_try < kernel_accel_min) continue; if (kernel_accel_try > kernel_accel_max) break; - double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops); + double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops); for (int i = 0; i < VERIFIER_CNT; i++) { - double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops); + double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops); - exec_ms = MIN (exec_ms, exec_ms_v); + exec_msec = MIN (exec_msec, exec_msec_v); } - if (exec_ms > target_ms) break; + if (exec_msec > target_msec) break; kernel_accel = kernel_accel_try; } @@ -173,17 +173,17 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param // we need a reference for the balancing loop following up, and this // the balancing loop can have an effect that the creates a new opportunity, for example: // if the target is 95 ms and the current runtime is 48ms the above loop - // stopped the execution because the previous exec_ms was > 95ms + // stopped the execution because the previous exec_msec was > 95ms // due to the rebalance it's possible that the runtime reduces from 48ms to 47ms // and this creates the possibility to double the workload -> 47 * 2 = 95ms, which is < 96ms - double exec_ms_pre_final = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops); + double exec_msec_pre_final = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops); for (int i = 0; i < VERIFIER_CNT; i++) { - double exec_ms_pre_final_v = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops); + double exec_msec_pre_final_v = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops); - exec_ms_pre_final = MIN (exec_ms_pre_final, exec_ms_pre_final_v); + exec_msec_pre_final = MIN (exec_msec_pre_final, exec_msec_pre_final_v); } u32 diff = kernel_loops - kernel_accel; @@ -207,18 +207,18 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param diff_new = diff; - double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try); + double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try); for (int i = 0; i < VERIFIER_CNT; i++) { - double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try); + double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try); - exec_ms = MIN (exec_ms, exec_ms_v); + exec_msec = MIN (exec_msec, exec_msec_v); } - if (exec_ms < exec_ms_pre_final) + if (exec_msec < exec_msec_pre_final) { - exec_ms_pre_final = exec_ms; + exec_msec_pre_final = exec_msec; kernel_accel = kernel_accel_try; kernel_loops = kernel_loops_try; @@ -226,7 +226,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param } } - const double exec_left = target_ms / exec_ms_pre_final; + const double exec_left = target_msec / exec_msec_pre_final; const double accel_left = kernel_accel_max / kernel_accel; @@ -263,7 +263,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param device_param->exec_pos = 0; - memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); + memset (device_param->exec_msec, 0, EXEC_CACHE * sizeof (double)); memset (device_param->exec_us_prev1, 0, EXPECTED_ITERATIONS * sizeof (double)); memset (device_param->exec_us_prev2, 0, EXPECTED_ITERATIONS * sizeof (double)); diff --git a/src/hashcat.c b/src/hashcat.c index f4c6688da..db5794f78 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -100,7 +100,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) user_options->skip = 0; } - status_ctx->ms_paused = 0; + status_ctx->msec_paused = 0; opencl_session_reset (hashcat_ctx); @@ -1133,14 +1133,18 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st { 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); + hashcat_status->session = status_get_session (hashcat_ctx); + hashcat_status->status = status_get_status_string (hashcat_ctx); + hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx); + hashcat_status->time_started_relative = status_get_time_started_relative (hashcat_ctx); + hashcat_status->time_estimated_absolute = status_get_time_estimated_absolute (hashcat_ctx); + hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx); + hashcat_status->hash_type = status_get_hash_type (hashcat_ctx); + hashcat_status->hash_target = status_get_hash_target (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); status_ctx_t *status_ctx = hashcat_ctx->status_ctx; diff --git a/src/monitor.c b/src/monitor.c index e6ece1c56..f52ded01b 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -17,14 +17,37 @@ #include "shared.h" #include "monitor.h" +int get_runtime_left (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + + double msec_paused = status_ctx->msec_paused; + + if (status_ctx->devices_status == STATUS_PAUSED) + { + double msec_paused_tmp = hc_timer_get (status_ctx->timer_paused); + + msec_paused += msec_paused_tmp; + } + + time_t runtime_cur; + + time (&runtime_cur); + + const int runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (msec_paused / 1000) - runtime_cur; + + return runtime_left; +} + static int monitor (hashcat_ctx_t *hashcat_ctx) { - hashes_t *hashes = hashcat_ctx->hashes; - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; + hashes_t *hashes = hashcat_ctx->hashes; + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; bool runtime_check = false; bool remove_check = false; @@ -254,20 +277,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if ((runtime_check == true) && (status_ctx->runtime_start > 0)) { - double ms_paused = status_ctx->ms_paused; - - if (status_ctx->devices_status == STATUS_PAUSED) - { - double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused); - - ms_paused += ms_paused_tmp; - } - - time_t runtime_cur; - - time (&runtime_cur); - - int runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; + const int runtime_left = get_runtime_left (hashcat_ctx); if (runtime_left <= 0) { diff --git a/src/opencl.c b/src/opencl.c index ec886d8b2..8cdc3aba3 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -30,7 +30,7 @@ static const u32 full01 = 0x01010101; static const u32 full80 = 0x80808080; -static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 }; +static double TARGET_MSEC_PROFILE[4] = { 2, 12, 96, 480 }; static void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, char *shared_dir, char *source_file) { @@ -1081,17 +1081,17 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 perf_sum_all = (u64) (pws_cnt * iter_part); - double speed_ms = hc_timer_get (device_param->timer_speed); + double speed_msec = hc_timer_get (device_param->timer_speed); const u32 speed_pos = device_param->speed_pos; device_param->speed_cnt[speed_pos] = perf_sum_all; - device_param->speed_ms[speed_pos] = speed_ms; + device_param->speed_msec[speed_pos] = speed_msec; if (user_options->speed_only == true) { - if (speed_ms > 4096) return 0; + if (speed_msec > 4096) return 0; } } @@ -1239,7 +1239,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con { u32 exec_pos = device_param->exec_pos; - device_param->exec_ms[exec_pos] = exec_us / 1000; + device_param->exec_msec[exec_pos] = exec_us / 1000; exec_pos++; @@ -1854,7 +1854,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co * speed */ - double speed_ms = hc_timer_get (device_param->timer_speed); + double speed_msec = hc_timer_get (device_param->timer_speed); hc_timer_set (&device_param->timer_speed); @@ -1864,7 +1864,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->speed_cnt[speed_pos] = perf_sum_all; - device_param->speed_ms[speed_pos] = speed_ms; + device_param->speed_msec[speed_pos] = speed_msec; //hc_thread_mutex_unlock (status_ctx->mux_display); @@ -2803,7 +2803,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } } - opencl_ctx->target_ms = TARGET_MS_PROFILE[user_options->workload_profile - 1]; + opencl_ctx->target_msec = TARGET_MSEC_PROFILE[user_options->workload_profile - 1]; opencl_ctx->devices_cnt = devices_cnt; opencl_ctx->devices_active = devices_active; @@ -4630,12 +4630,12 @@ void opencl_session_reset (hashcat_ctx_t *hashcat_ctx) device_param->speed_pos = 0; - memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); - memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (double)); + memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); + memset (device_param->speed_msec, 0, SPEED_CACHE * sizeof (double)); device_param->exec_pos = 0; - memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); + memset (device_param->exec_msec, 0, EXEC_CACHE * sizeof (double)); device_param->outerloop_pos = 0; device_param->outerloop_left = 0; diff --git a/src/shared.c b/src/shared.c index c7c157b77..fb89e7ac6 100644 --- a/src/shared.c +++ b/src/shared.c @@ -99,7 +99,7 @@ void naive_escape (char *s, size_t s_max, const char key_char, const char escape strncpy (s, s_escaped, s_max - 1); } -void hc_sleep_ms (const u32 msec) +void hc_sleep_msec (const u32 msec) { #if defined (_WIN) Sleep (msec); diff --git a/src/status.c b/src/status.c index 4167aa7d2..4523c8536 100644 --- a/src/status.c +++ b/src/status.c @@ -14,6 +14,7 @@ #include "interface.h" #include "hwmon.h" #include "outfile.h" +#include "monitor.h" #include "status.h" static const char ST_0000[] = "Initializing"; @@ -52,31 +53,106 @@ static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx) return NULL; } +void format_timer_display (struct tm *tm, char *buf, size_t len) +{ + const char *time_entities_s[] = { "year", "day", "hour", "min", "sec" }; + const char *time_entities_m[] = { "years", "days", "hours", "mins", "secs" }; + + if (tm->tm_year - 70) + { + char *time_entity1 = ((tm->tm_year - 70) == 1) ? (char *) time_entities_s[0] : (char *) time_entities_m[0]; + char *time_entity2 = ( tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); + } + else if (tm->tm_yday) + { + char *time_entity1 = (tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; + char *time_entity2 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); + } + else if (tm->tm_hour) + { + char *time_entity1 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; + char *time_entity2 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); + } + else if (tm->tm_min) + { + char *time_entity1 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; + char *time_entity2 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + + snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); + } + else + { + char *time_entity1 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; + + snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); + } +} + +void format_speed_display (double val, char *buf, size_t len) +{ + if (val <= 0) + { + buf[0] = '0'; + buf[1] = ' '; + buf[2] = 0; + + return; + } + + char units[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; + + u32 level = 0; + + while (val > 99999) + { + val /= 1000; + + level++; + } + + /* generate output */ + + if (level == 0) + { + snprintf (buf, len - 1, "%.0f ", val); + } + else + { + snprintf (buf, len - 1, "%.1f %c", val, units[level]); + } +} + double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries) { int exec_pos = (int) device_param->exec_pos - last_num_entries; if (exec_pos < 0) exec_pos += EXEC_CACHE; - double exec_ms_sum = 0; + double exec_msec_sum = 0; - int exec_ms_cnt = 0; + int exec_msec_cnt = 0; for (int i = 0; i < last_num_entries; i++) { - double exec_ms = device_param->exec_ms[(exec_pos + i) % EXEC_CACHE]; + double exec_msec = device_param->exec_msec[(exec_pos + i) % EXEC_CACHE]; - if (exec_ms > 0) + if (exec_msec > 0) { - exec_ms_sum += exec_ms; + exec_msec_sum += exec_msec; - exec_ms_cnt++; + exec_msec_cnt++; } } - if (exec_ms_cnt == 0) return 0; + if (exec_msec_cnt == 0) return 0; - return exec_ms_sum / exec_ms_cnt; + return exec_msec_sum / exec_msec_cnt; } char *status_get_session (const hashcat_ctx_t *hashcat_ctx) @@ -412,6 +488,415 @@ char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx) return NULL; } +int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return hashes->digests_done; +} + +int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return hashes->digests_cnt; +} + +double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return ((double) hashes->digests_done / (double) hashes->digests_cnt) * 100; +} + +int status_get_salts_done (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return hashes->salts_done; +} + +int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return hashes->salts_cnt; +} + +double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + + return ((double) hashes->salts_done / (double) hashes->salts_cnt) * 100; +} + +double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + double msec_running = hc_timer_get (status_ctx->timer_running); + + return msec_running; +} + +double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + double msec_paused = status_ctx->msec_paused; + + if (status_ctx->devices_status == STATUS_PAUSED) + { + double msec_paused_tmp = hc_timer_get (status_ctx->timer_paused); + + msec_paused += msec_paused_tmp; + } + + return msec_paused; +} + +char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + const time_t time_start = status_ctx->runtime_start; + + char *start = ctime (&time_start); + + const size_t start_len = strlen (start); + + if (start[start_len - 1] == '\n') start[start_len - 1] = 0; + if (start[start_len - 2] == '\r') start[start_len - 2] = 0; + + return start; +} + +char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + time_t time_now; + + time (&time_now); + + const time_t time_start = status_ctx->runtime_start; + + #if defined (_WIN) + + __time64_t sec_run = time_now - time_start; + + #else + + time_t sec_run = time_now - time_start; + + #endif + + struct tm *tmp; + + #if defined (_WIN) + + tmp = _gmtime64 (&sec_run); + + #else + + tmp = gmtime (&sec_run); + + #endif + + char *display_run = (char *) malloc (HCBUFSIZ_TINY); + + format_timer_display (tmp, display_run, HCBUFSIZ_TINY); + + return display_run; +} + +char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + #if defined (_WIN) + __time64_t sec_etc = 0; + #else + time_t sec_etc = 0; + #endif + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (status_ctx->devices_status != STATUS_CRACKED) + { + const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); + const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); + + const u64 progress_ignore = status_get_progress_ignore (hashcat_ctx); + + const double hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); + + if (hashes_msec_all > 0) + { + const u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; + + u64 msec_left = (u64) ((progress_left_relative_skip - progress_ignore) / hashes_msec_all); + + sec_etc = msec_left / 1000; + } + } + } + + time_t now; + + time (&now); + + now += sec_etc; + + char *etc = ctime (&now); + + const size_t etc_len = strlen (etc); + + if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0; + if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0; + + return etc; +} + +char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + #if defined (_WIN) + __time64_t sec_etc = 0; + #else + time_t sec_etc = 0; + #endif + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (status_ctx->devices_status != STATUS_CRACKED) + { + const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); + const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); + + const u64 progress_ignore = status_get_progress_ignore (hashcat_ctx); + + const double hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); + + if (hashes_msec_all > 0) + { + const u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; + + u64 msec_left = (u64) ((progress_left_relative_skip - progress_ignore) / hashes_msec_all); + + sec_etc = msec_left / 1000; + } + } + } + + struct tm *tmp; + + #if defined (_WIN) + tmp = _gmtime64 (&sec_etc); + #else + tmp = gmtime (&sec_etc); + #endif + + char *display = (char *) malloc (HCBUFSIZ_TINY); + + format_timer_display (tmp, display, HCBUFSIZ_TINY); + + if (user_options->runtime > 0) + { + const int runtime_left = get_runtime_left (hashcat_ctx); + + char *tmp = strdup (display); + + if (runtime_left > 0) + { + #if defined (_WIN) + __time64_t sec_left = runtime_left; + #else + time_t sec_left = runtime_left; + #endif + + struct tm *tmp_left; + + #if defined (_WIN) + tmp_left = _gmtime64 (&sec_left); + #else + tmp_left = gmtime (&sec_left); + #endif + + char *display_left = (char *) malloc (HCBUFSIZ_TINY); + + format_timer_display (tmp_left, display_left, HCBUFSIZ_TINY); + + snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limited: %s", tmp, display_left); + + free (display_left); + } + else + { + snprintf (display, HCBUFSIZ_TINY - 1, "%s; Runtime limit exceeded", tmp); + } + + free (tmp); + } + + return display; +} + +u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + u64 progress_done = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + progress_done += status_ctx->words_progress_done[salt_pos]; + } + + return progress_done; +} + +u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + u64 progress_rejected = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + progress_rejected += status_ctx->words_progress_rejected[salt_pos]; + } + + return progress_rejected; +} + +u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + u64 progress_restored = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + progress_restored += status_ctx->words_progress_restored[salt_pos]; + } + + return progress_restored; +} + +u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_done = status_get_progress_done (hashcat_ctx); + const u64 progress_rejected = status_get_progress_rejected (hashcat_ctx); + const u64 progress_restored = status_get_progress_restored (hashcat_ctx); + + const u64 progress_cur = progress_done + progress_rejected + progress_restored; + + return progress_cur; +} + +u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + // Important for ETA only + + u64 progress_ignore = 0; + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + if (hashes->salts_shown[salt_pos] == 1) + { + const u64 all = status_ctx->words_progress_done[salt_pos] + + status_ctx->words_progress_rejected[salt_pos] + + status_ctx->words_progress_restored[salt_pos]; + + const u64 left = status_ctx->words_cnt - all; + + progress_ignore += left; + } + } + + return progress_ignore; +} + +u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + u64 progress_end = status_ctx->words_cnt * hashes->salts_cnt; + + if (user_options->limit) + { + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + + progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; + } + + return progress_end; +} + +u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx) +{ + const hashes_t *hashes = hashcat_ctx->hashes; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + u64 progress_skip = 0; + + if (user_options->skip) + { + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + + progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; + } + + return progress_skip; +} + +u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_cur = status_get_progress_cur (hashcat_ctx); + const u64 progress_skip = status_get_progress_skip (hashcat_ctx); + + const u64 progress_cur_relative_skip = progress_cur - progress_skip; + + return progress_cur_relative_skip; +} + +u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_skip = status_get_progress_skip (hashcat_ctx); + const u64 progress_end = status_get_progress_end (hashcat_ctx); + + const u64 progress_end_relative_skip = progress_end - progress_skip; + + return progress_end_relative_skip; +} int status_progress_init (hashcat_ctx_t *hashcat_ctx) { @@ -448,6 +933,103 @@ void status_progress_reset (hashcat_ctx_t *hashcat_ctx) memset (status_ctx->words_progress_restored, 0, hashes->salts_cnt * sizeof (u64)); } +double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + double hashes_all_msec = 0; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hashes_all_msec += status_get_hashes_msec_dev (hashcat_ctx, device_id); + } + + return hashes_all_msec; +} + +double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + u64 speed_cnt = 0; + double speed_msec = 0; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped == false) + { + for (int i = 0; i < SPEED_CACHE; i++) + { + speed_cnt += device_param->speed_cnt[i]; + speed_msec += device_param->speed_msec[i]; + } + } + + speed_cnt /= SPEED_CACHE; + speed_msec /= SPEED_CACHE; + + double hashes_dev_msec = 0; + + if (speed_msec > 0) + { + hashes_dev_msec = (double) speed_cnt / speed_msec; + } + + return hashes_dev_msec; +} + +double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + double exec_all_msec = 0; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + exec_all_msec += status_get_exec_msec_dev (hashcat_ctx, device_id); + } + + return exec_all_msec; +} + +double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + double exec_dev_msec = 0; + + if (device_param->skipped == false) + { + exec_dev_msec = get_avg_exec_time (device_param, EXEC_CACHE); + } + + return exec_dev_msec; +} + +char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx) +{ + const double hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); + + char *display = (char *) malloc (HCBUFSIZ_TINY); + + format_speed_display (hashes_msec_all * 1000, display, HCBUFSIZ_TINY); + + return display; +} + +char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +{ + const double hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); + + char *display = (char *) malloc (HCBUFSIZ_TINY); + + format_speed_display (hashes_msec_dev * 1000, display, HCBUFSIZ_TINY); + + return display; +} + int status_ctx_init (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; diff --git a/src/terminal.c b/src/terminal.c index 2dc2094ad..223ddb48a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -129,7 +129,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) user_options_t *user_options = hashcat_ctx->user_options; // this is required, because some of the variables down there are not initialized at that point - while (status_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100); + while (status_ctx->devices_status == STATUS_INIT) hc_sleep_msec (100); const bool quiet = user_options->quiet; @@ -444,81 +444,6 @@ int tty_fix() } #endif -static void format_timer_display (struct tm *tm, char *buf, size_t len) -{ - const char *time_entities_s[] = { "year", "day", "hour", "min", "sec" }; - const char *time_entities_m[] = { "years", "days", "hours", "mins", "secs" }; - - if (tm->tm_year - 70) - { - char *time_entity1 = ((tm->tm_year - 70) == 1) ? (char *) time_entities_s[0] : (char *) time_entities_m[0]; - char *time_entity2 = ( tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; - - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_year - 70, time_entity1, tm->tm_yday, time_entity2); - } - else if (tm->tm_yday) - { - char *time_entity1 = (tm->tm_yday == 1) ? (char *) time_entities_s[1] : (char *) time_entities_m[1]; - char *time_entity2 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; - - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_yday, time_entity1, tm->tm_hour, time_entity2); - } - else if (tm->tm_hour) - { - char *time_entity1 = (tm->tm_hour == 1) ? (char *) time_entities_s[2] : (char *) time_entities_m[2]; - char *time_entity2 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; - - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_hour, time_entity1, tm->tm_min, time_entity2); - } - else if (tm->tm_min) - { - char *time_entity1 = (tm->tm_min == 1) ? (char *) time_entities_s[3] : (char *) time_entities_m[3]; - char *time_entity2 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; - - snprintf (buf, len - 1, "%d %s, %d %s", tm->tm_min, time_entity1, tm->tm_sec, time_entity2); - } - else - { - char *time_entity1 = (tm->tm_sec == 1) ? (char *) time_entities_s[4] : (char *) time_entities_m[4]; - - snprintf (buf, len - 1, "%d %s", tm->tm_sec, time_entity1); - } -} - -static void format_speed_display (double val, char *buf, size_t len) -{ - if (val <= 0) - { - buf[0] = '0'; - buf[1] = ' '; - buf[2] = 0; - - return; - } - - char units[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; - - u32 level = 0; - - while (val > 99999) - { - val /= 1000; - - level++; - } - - /* generate output */ - - if (level == 0) - { - snprintf (buf, len - 1, "%.0f ", val); - } - else - { - snprintf (buf, len - 1, "%.1f %c", val, units[level]); - } -} - void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; @@ -561,18 +486,18 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; u64 speed_cnt = 0; - double speed_ms = 0; + double speed_msec = 0; for (int i = 0; i < SPEED_CACHE; i++) { speed_cnt += device_param->speed_cnt[i]; - speed_ms += device_param->speed_ms[i]; + speed_msec += device_param->speed_msec[i]; } speed_cnt /= SPEED_CACHE; - speed_ms /= SPEED_CACHE; + speed_msec /= SPEED_CACHE; - fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); + fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_msec); } /** @@ -587,9 +512,9 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + const double exec_msec_avg = get_avg_exec_time (device_param, EXEC_CACHE); - fprintf (out, "%f\t", exec_ms_avg); + fprintf (out, "%f\t", exec_msec_avg); } /** @@ -686,13 +611,10 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) void status_display (hashcat_ctx_t *hashcat_ctx) { - combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; hashes_t *hashes = hashcat_ctx->hashes; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_t *user_options = hashcat_ctx->user_options; @@ -732,8 +654,21 @@ void status_display (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, "Session........: %s", status_get_session (hashcat_ctx)); event_log_info (hashcat_ctx, "Status.........: %s", status_get_status_string (hashcat_ctx)); + event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", + status_get_time_started_absolute (hashcat_ctx), + status_get_time_started_relative (hashcat_ctx)); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", + status_get_time_estimated_absolute (hashcat_ctx), + status_get_time_estimated_relative (hashcat_ctx)); event_log_info (hashcat_ctx, "Hash.Type......: %s", status_get_hash_type (hashcat_ctx)); event_log_info (hashcat_ctx, "Hash.Target....: %s", status_get_hash_target (hashcat_ctx)); + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", + status_get_digests_done (hashcat_ctx), + status_get_digests_cnt (hashcat_ctx), + status_get_digests_percent (hashcat_ctx), + status_get_salts_done (hashcat_ctx), + status_get_salts_cnt (hashcat_ctx), + status_get_salts_percent (hashcat_ctx)); const int input_mode = status_get_input_mode (hashcat_ctx); @@ -796,326 +731,38 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } - /** - * speed new - */ - - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; if (device_param->skipped) continue; - speed_cnt[device_id] = 0; - speed_ms[device_id] = 0; - - for (int i = 0; i < SPEED_CACHE; i++) - { - speed_cnt[device_id] += device_param->speed_cnt[i]; - speed_ms[device_id] += device_param->speed_ms[i]; - } - - speed_cnt[device_id] /= SPEED_CACHE; - speed_ms[device_id] /= SPEED_CACHE; + event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, + status_get_speed_sec_dev (hashcat_ctx, device_id), + status_get_exec_msec_dev (hashcat_ctx, device_id)); } - double hashes_all_ms = 0; + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); - double hashes_dev_ms[DEVICES_MAX] = { 0 }; - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_ms[device_id] = 0; - - if (speed_ms[device_id] > 0) - { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; - - hashes_all_ms += hashes_dev_ms[device_id]; - } - } - - /** - * exec time - */ - - double exec_all_ms[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - exec_all_ms[device_id] = exec_ms_avg; - } /** * timers */ - double ms_running = hc_timer_get (status_ctx->timer_running); + const double msec_running = status_get_msec_running (hashcat_ctx); + const double msec_paused = status_get_msec_paused (hashcat_ctx); - double ms_paused = status_ctx->ms_paused; - - if (status_ctx->devices_status == STATUS_PAUSED) - { - double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused); - - ms_paused += ms_paused_tmp; - } - - #if defined (_WIN) - - __time64_t sec_run = (__time64_t) ms_running / 1000; - - #else - - time_t sec_run = (time_t) ms_running / 1000; - - #endif - - if (sec_run) - { - char display_run[32] = { 0 }; - - struct tm tm_run; - - struct tm *tmp = NULL; - - #if defined (_WIN) - - tmp = _gmtime64 (&sec_run); - - #else - - tmp = gmtime (&sec_run); - - #endif - - if (tmp != NULL) - { - memset (&tm_run, 0, sizeof (tm_run)); - - memcpy (&tm_run, tmp, sizeof (tm_run)); - - format_timer_display (&tm_run, display_run, sizeof (tm_run)); - - char *start = ctime (&status_ctx->proc_start); - - size_t start_len = strlen (start); - - if (start[start_len - 1] == '\n') start[start_len - 1] = 0; - if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - - event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); - } - } - else - { - event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); - } /** * counters */ - u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; + const u64 progress_cur = status_get_progress_cur (hashcat_ctx); + const u64 progress_rejected = status_get_progress_rejected (hashcat_ctx); + const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); + const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); - u64 all_done = 0; - u64 all_rejected = 0; - u64 all_restored = 0; - - u64 progress_noneed = 0; - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - all_done += status_ctx->words_progress_done[salt_pos]; - all_rejected += status_ctx->words_progress_rejected[salt_pos]; - all_restored += status_ctx->words_progress_restored[salt_pos]; - - // Important for ETA only - - if (hashes->salts_shown[salt_pos] == 1) - { - const u64 all = status_ctx->words_progress_done[salt_pos] - + status_ctx->words_progress_rejected[salt_pos] - + status_ctx->words_progress_restored[salt_pos]; - - const u64 left = status_ctx->words_cnt - all; - - progress_noneed += left; - } - } - - u64 progress_cur = all_restored + all_done + all_rejected; - u64 progress_end = progress_total; - - u64 progress_skip = 0; - - if (user_options->skip) - { - progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; - } - - if (user_options->limit) - { - progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; - } - - u64 progress_cur_relative_skip = progress_cur - progress_skip; - u64 progress_end_relative_skip = progress_end - progress_skip; - - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - if (status_ctx->devices_status != STATUS_CRACKED) - { - #if defined (_WIN) - __time64_t sec_etc = 0; - #else - time_t sec_etc = 0; - #endif - - if (hashes_all_ms > 0) - { - u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip; - - u64 ms_left = (u64) ((progress_left_relative_skip - progress_noneed) / hashes_all_ms); - - sec_etc = ms_left / 1000; - } - - #define SEC10YEARS (60 * 60 * 24 * 365 * 10) - - if (sec_etc == 0) - { - //log_info ("Time.Estimated.: 0 secs"); - } - else if ((u64) sec_etc > SEC10YEARS) - { - event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); - } - else - { - char display_etc[32] = { 0 }; - char display_runtime[32] = { 0 }; - - struct tm tm_etc; - struct tm tm_runtime; - - struct tm *tmp = NULL; - - #if defined (_WIN) - tmp = _gmtime64 (&sec_etc); - #else - tmp = gmtime (&sec_etc); - #endif - - if (tmp != NULL) - { - memcpy (&tm_etc, tmp, sizeof (tm_etc)); - - format_timer_display (&tm_etc, display_etc, sizeof (display_etc)); - - time_t now; - - time (&now); - - now += sec_etc; - - char *etc = ctime (&now); - - size_t etc_len = strlen (etc); - - if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0; - if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0; - - if (user_options->runtime) - { - time_t runtime_cur; - - time (&runtime_cur); - - #if defined (_WIN) - - __time64_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; - - tmp = _gmtime64 (&runtime_left); - - #else - - time_t runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur; - - tmp = gmtime (&runtime_left); - - #endif - - if ((tmp != NULL) && (runtime_left > 0) && (runtime_left < sec_etc)) - { - memcpy (&tm_runtime, tmp, sizeof (tm_runtime)); - - format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); - } - else - { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); - } - } - else - { - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); - } - } - } - } - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - char display_dev_cur[16] = { 0 }; - - strncpy (display_dev_cur, "0.00", 4); - - format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - - event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); - } - - char display_all_cur[16] = { 0 }; - - strncpy (display_all_cur, "0.00", 4); - - format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); - - const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; - const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - - event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -1148,11 +795,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } } - double ms_real = ms_running - ms_paused; + const double msec_real = msec_running - msec_paused; - double cpt_avg_min = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 60); - double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 3600); - double cpt_avg_day = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 86400); + double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60); + double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600); + double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400); if ((cpt_ctx->cpt_start + 86400) < now) { @@ -1209,11 +856,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (progress_cur) { - percent_rejected = (double) (all_rejected) / (double) progress_cur; + percent_rejected = (double) (progress_rejected) / (double) progress_cur; } event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { @@ -1239,7 +886,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) else { event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", progress_rejected); // --restore not allowed if stdin is used -- really? why? @@ -1417,8 +1064,8 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) return; } - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_msec[DEVICES_MAX] = { 0 }; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1426,11 +1073,11 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_ms[device_id] = device_param->speed_ms[0]; + speed_cnt[device_id] = device_param->speed_cnt[0]; + speed_msec[device_id] = device_param->speed_msec[0]; } - u64 hashes_dev_ms[DEVICES_MAX] = { 0 }; + u64 hashes_dev_msec[DEVICES_MAX] = { 0 }; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1438,11 +1085,11 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - hashes_dev_ms[device_id] = 0; + hashes_dev_msec[device_id] = 0; - if (speed_ms[device_id] > 0) + if (speed_msec[device_id] > 0) { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; + hashes_dev_msec[device_id] = (double) speed_cnt[device_id] / speed_msec[device_id]; } } @@ -1452,7 +1099,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_msec[device_id] * 1000)); } } @@ -1485,8 +1132,8 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) return; } - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_ms[DEVICES_MAX] = { 0 }; + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_msec[DEVICES_MAX] = { 0 }; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1494,13 +1141,13 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_ms[device_id] = device_param->speed_ms[0]; + speed_cnt[device_id] = device_param->speed_cnt[0]; + speed_msec[device_id] = device_param->speed_msec[0]; } - double hashes_all_ms = 0; + double hashes_all_msec = 0; - double hashes_dev_ms[DEVICES_MAX] = { 0 }; + double hashes_dev_msec[DEVICES_MAX] = { 0 }; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1508,13 +1155,13 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - hashes_dev_ms[device_id] = 0; + hashes_dev_msec[device_id] = 0; - if (speed_ms[device_id] > 0) + if (speed_msec[device_id] > 0) { - hashes_dev_ms[device_id] = (double) speed_cnt[device_id] / speed_ms[device_id]; + hashes_dev_msec[device_id] = (double) speed_cnt[device_id] / speed_msec[device_id]; - hashes_all_ms += hashes_dev_ms[device_id]; + hashes_all_msec += hashes_dev_msec[device_id]; } } @@ -1522,7 +1169,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) * exec time */ - double exec_all_ms[DEVICES_MAX] = { 0 }; + double exec_all_msec[DEVICES_MAX] = { 0 }; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -1530,9 +1177,9 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + double exec_msec_avg = get_avg_exec_time (device_param, EXEC_CACHE); - exec_all_ms[device_id] = exec_ms_avg; + exec_all_msec[device_id] = exec_msec_avg; } for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) @@ -1545,15 +1192,15 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) strncpy (display_dev_cur, "0.00", 4); - format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); + format_speed_display ((double) hashes_dev_msec[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); if (opencl_ctx->devices_active >= 10) { - event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_msec[device_id]); } else { - event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_msec[device_id]); } } @@ -1561,7 +1208,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) strncpy (display_all_cur, "0.00", 4); - format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); + format_speed_display ((double) hashes_all_msec * 1000, display_all_cur, sizeof (display_all_cur)); if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); } diff --git a/src/thread.c b/src/thread.c index b97c8b2b8..e3cd7e6bc 100644 --- a/src/thread.c +++ b/src/thread.c @@ -205,9 +205,9 @@ int ResumeThreads (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status != STATUS_PAUSED) return -1; - double ms_paused = hc_timer_get (status_ctx->timer_paused); + const double msec_paused = hc_timer_get (status_ctx->timer_paused); - status_ctx->ms_paused += ms_paused; + status_ctx->msec_paused += msec_paused; status_ctx->devices_status = STATUS_RUNNING; From 615d977b7c9cef0bf58cd60c4133d7d3cf3d29f2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 13:55:55 +0200 Subject: [PATCH 070/106] Add new functions to hashcat_get_status() --- include/status.h | 13 +++------ include/types.h | 42 ++++++++++++++++++++--------- src/hashcat.c | 49 +++++++++++++++++++-------------- src/status.c | 70 ++++++++++++++++++++++++------------------------ 4 files changed, 97 insertions(+), 77 deletions(-) diff --git a/include/status.h b/include/status.h index 7b310c9ef..effd6b6f6 100644 --- a/include/status.h +++ b/include/status.h @@ -18,6 +18,10 @@ void format_speed_display (double val, char *buf, size_t len); char *status_get_session (const hashcat_ctx_t *hashcat_ctx); char *status_get_status_string (const 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); char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx); @@ -32,7 +36,6 @@ char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx) char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx); - u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); @@ -42,21 +45,13 @@ u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx) u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); - double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); - double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); - char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); -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_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); diff --git a/include/types.h b/include/types.h index b542f9db3..8c7af9288 100644 --- a/include/types.h +++ b/include/types.h @@ -1481,19 +1481,35 @@ typedef enum input_mode typedef struct { - char *status; - char *session; - char *time_started_absolute; - char *time_started_relative; - char *time_estimated_absolute; - char *time_estimated_relative; - char *hash_type; - char *hash_target; - int input_mode; - char *input_base; - char *input_mod; - char *input_charset; - + char *hash_target; + char *hash_type; + char *input_base; + char *input_charset; + char *input_mod; + char *session; + char *status; + char *time_estimated_absolute; + char *time_estimated_relative; + char *time_started_absolute; + char *time_started_relative; + double msec_paused; + double msec_running; + int digests_cnt; + int digests_done; + int digests_percent; + int input_mode; + int salts_cnt; + int salts_done; + int salts_percent; + u64 progress_cur; + u64 progress_cur_relative_skip; + u64 progress_done; + u64 progress_end; + u64 progress_end_relative_skip; + u64 progress_ignore; + u64 progress_rejected; + u64 progress_restored; + u64 progress_skip; device_info_t device_info_buf[DEVICES_MAX]; diff --git a/src/hashcat.c b/src/hashcat.c index db5794f78..3375db75b 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1133,26 +1133,35 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st { 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->time_started_absolute = status_get_time_started_absolute (hashcat_ctx); - hashcat_status->time_started_relative = status_get_time_started_relative (hashcat_ctx); - hashcat_status->time_estimated_absolute = status_get_time_estimated_absolute (hashcat_ctx); - hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx); - hashcat_status->hash_type = status_get_hash_type (hashcat_ctx); - hashcat_status->hash_target = status_get_hash_target (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); - - 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; - + hashcat_status->digests_cnt = status_get_digests_cnt (hashcat_ctx); + hashcat_status->digests_done = status_get_digests_done (hashcat_ctx); + hashcat_status->digests_percent = status_get_digests_percent (hashcat_ctx); + hashcat_status->hash_target = status_get_hash_target (hashcat_ctx); + hashcat_status->hash_type = status_get_hash_type (hashcat_ctx); + hashcat_status->input_base = status_get_input_base (hashcat_ctx); + hashcat_status->input_charset = status_get_input_charset (hashcat_ctx); + hashcat_status->input_mode = status_get_input_mode (hashcat_ctx); + hashcat_status->input_mod = status_get_input_mod (hashcat_ctx); + hashcat_status->msec_paused = status_get_msec_paused (hashcat_ctx); + hashcat_status->msec_running = status_get_msec_running (hashcat_ctx); + hashcat_status->progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); + hashcat_status->progress_cur = status_get_progress_cur (hashcat_ctx); + hashcat_status->progress_done = status_get_progress_done (hashcat_ctx); + hashcat_status->progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); + hashcat_status->progress_end = status_get_progress_end (hashcat_ctx); + hashcat_status->progress_ignore = status_get_progress_ignore (hashcat_ctx); + hashcat_status->progress_rejected = status_get_progress_rejected (hashcat_ctx); + hashcat_status->progress_restored = status_get_progress_restored (hashcat_ctx); + hashcat_status->progress_skip = status_get_progress_skip (hashcat_ctx); + hashcat_status->salts_cnt = status_get_salts_cnt (hashcat_ctx); + hashcat_status->salts_done = status_get_salts_done (hashcat_ctx); + hashcat_status->salts_percent = status_get_salts_percent (hashcat_ctx); + hashcat_status->session = status_get_session (hashcat_ctx); + hashcat_status->status = status_get_status_string (hashcat_ctx); + hashcat_status->time_estimated_absolute = status_get_time_estimated_absolute (hashcat_ctx); + hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx); + hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx); + hashcat_status->time_started_relative = status_get_time_started_relative (hashcat_ctx); return 0; } diff --git a/src/status.c b/src/status.c index 4523c8536..b0872b0b1 100644 --- a/src/status.c +++ b/src/status.c @@ -898,41 +898,6 @@ u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx) return progress_end_relative_skip; } -int status_progress_init (hashcat_ctx_t *hashcat_ctx) -{ - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - hashes_t *hashes = hashcat_ctx->hashes; - - status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_done); - status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_rejected); - status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_restored); - - return 0; -} - -void status_progress_destroy (hashcat_ctx_t *hashcat_ctx) -{ - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - - hcfree (status_ctx->words_progress_done); - hcfree (status_ctx->words_progress_rejected); - hcfree (status_ctx->words_progress_restored); - - status_ctx->words_progress_done = NULL; - status_ctx->words_progress_rejected = NULL; - status_ctx->words_progress_restored = NULL; -} - -void status_progress_reset (hashcat_ctx_t *hashcat_ctx) -{ - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - hashes_t *hashes = hashcat_ctx->hashes; - - memset (status_ctx->words_progress_done, 0, hashes->salts_cnt * sizeof (u64)); - memset (status_ctx->words_progress_rejected, 0, hashes->salts_cnt * sizeof (u64)); - memset (status_ctx->words_progress_restored, 0, hashes->salts_cnt * sizeof (u64)); -} - double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; @@ -1030,6 +995,41 @@ char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 devi return display; } +int status_progress_init (hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + hashes_t *hashes = hashcat_ctx->hashes; + + status_ctx->words_progress_done = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_done); + status_ctx->words_progress_rejected = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_rejected); + status_ctx->words_progress_restored = (u64 *) hccalloc (hashcat_ctx, hashes->salts_cnt, sizeof (u64)); VERIFY_PTR (status_ctx->words_progress_restored); + + return 0; +} + +void status_progress_destroy (hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + hcfree (status_ctx->words_progress_done); + hcfree (status_ctx->words_progress_rejected); + hcfree (status_ctx->words_progress_restored); + + status_ctx->words_progress_done = NULL; + status_ctx->words_progress_rejected = NULL; + status_ctx->words_progress_restored = NULL; +} + +void status_progress_reset (hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + hashes_t *hashes = hashcat_ctx->hashes; + + memset (status_ctx->words_progress_done, 0, hashes->salts_cnt * sizeof (u64)); + memset (status_ctx->words_progress_rejected, 0, hashes->salts_cnt * sizeof (u64)); + memset (status_ctx->words_progress_restored, 0, hashes->salts_cnt * sizeof (u64)); +} + int status_ctx_init (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; From df521d664b4a973574a011813d93ce4bc96ee731 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 14:25:16 +0200 Subject: [PATCH 071/106] Move restore_* variables into separate functions for later use in status.c --- include/restore.h | 2 +- include/status.h | 3 +++ include/types.h | 8 +++++--- src/hashcat.c | 3 +++ src/opencl.c | 32 ++++++++++++++++---------------- src/restore.c | 2 +- src/status.c | 31 +++++++++++++++++++++++++++++++ src/terminal.c | 11 ++++------- 8 files changed, 64 insertions(+), 28 deletions(-) diff --git a/include/restore.h b/include/restore.h index 7a238e700..9a851b910 100644 --- a/include/restore.h +++ b/include/restore.h @@ -23,7 +23,7 @@ #define RESTORE_VERSION_MIN 320 #define RESTORE_VERSION_CUR 320 -u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx); +u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx); int cycle_restore (hashcat_ctx_t *hashcat_ctx); diff --git a/include/status.h b/include/status.h index effd6b6f6..67cf986ea 100644 --- a/include/status.h +++ b/include/status.h @@ -36,6 +36,9 @@ char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx) char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx); +double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 8c7af9288..9bd982bdd 100644 --- a/include/types.h +++ b/include/types.h @@ -1496,11 +1496,11 @@ typedef struct double msec_running; int digests_cnt; int digests_done; - int digests_percent; + double digests_percent; int input_mode; int salts_cnt; int salts_done; - int salts_percent; + double salts_percent; u64 progress_cur; u64 progress_cur_relative_skip; u64 progress_done; @@ -1510,7 +1510,9 @@ typedef struct u64 progress_rejected; u64 progress_restored; u64 progress_skip; - + u64 restore_point; + u64 restore_total; + double restore_percent; device_info_t device_info_buf[DEVICES_MAX]; int device_info_cnt; diff --git a/src/hashcat.c b/src/hashcat.c index 3375db75b..436fd220b 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1153,6 +1153,9 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->progress_rejected = status_get_progress_rejected (hashcat_ctx); hashcat_status->progress_restored = status_get_progress_restored (hashcat_ctx); hashcat_status->progress_skip = status_get_progress_skip (hashcat_ctx); + hashcat_status->restore_point = status_get_restore_point (hashcat_ctx); + hashcat_status->restore_total = status_get_restore_total (hashcat_ctx); + hashcat_status->restore_percent = status_get_restore_percent (hashcat_ctx); hashcat_status->salts_cnt = status_get_salts_cnt (hashcat_ctx); hashcat_status->salts_done = status_get_salts_done (hashcat_ctx); hashcat_status->salts_percent = status_get_salts_percent (hashcat_ctx); diff --git a/src/opencl.c b/src/opencl.c index 8cdc3aba3..3e9a27643 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2419,7 +2419,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_endian_little == CL_FALSE) { - event_log_warning (hashcat_ctx, "Device #%u: Not a little endian device", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Not a little endian device", device_id + 1); device_param->skipped = 1; } @@ -2434,7 +2434,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_available == CL_FALSE) { - event_log_warning (hashcat_ctx, "Device #%u: Device not available", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Device not available", device_id + 1); device_param->skipped = 1; } @@ -2449,7 +2449,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_compiler_available == CL_FALSE) { - event_log_warning (hashcat_ctx, "Device #%u: No compiler available for device", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: No compiler available for device", device_id + 1); device_param->skipped = 1; } @@ -2464,7 +2464,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if ((device_execution_capabilities & CL_EXEC_KERNEL) == 0) { - event_log_warning (hashcat_ctx, "Device #%u: Device does not support executing kernels", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Device does not support executing kernels", device_id + 1); device_param->skipped = 1; } @@ -2485,14 +2485,14 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (strstr (device_extensions, "base_atomics") == 0) { - event_log_warning (hashcat_ctx, "Device #%u: Device does not support base atomics", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Device does not support base atomics", device_id + 1); device_param->skipped = 1; } if (strstr (device_extensions, "byte_addressable_store") == 0) { - event_log_warning (hashcat_ctx, "Device #%u: Device does not support byte addressable store", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Device does not support byte addressable store", device_id + 1); device_param->skipped = 1; } @@ -2509,7 +2509,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_local_mem_size < 32768) { - event_log_warning (hashcat_ctx, "Device #%u: Device local mem size is too small", device_id + 1); + event_log_warning (hashcat_ctx, "* Device #%u: Device local mem size is too small", device_id + 1); device_param->skipped = 1; } @@ -2526,8 +2526,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (user_options->force == 0) { - event_log_warning (hashcat_ctx, "Device #%u: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); - event_log_warning (hashcat_ctx, " You can use --force to override this but do not post error reports if you do so"); + event_log_warning (hashcat_ctx, "* Device #%u: Not a native Intel OpenCL runtime, expect massive speed loss", device_id + 1); + event_log_warning (hashcat_ctx, " You can use --force to override this but do not post error reports if you do so"); device_param->skipped = 1; } @@ -2721,7 +2721,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (catalyst_broken == 1) { - event_log_error (hashcat_ctx, "The Catalyst driver installed on your system is known to be broken!"); + event_log_error (hashcat_ctx, "* Device #%u: The Catalyst driver installed on your system is known to be broken!", device_id + 1); event_log_error (hashcat_ctx, ""); event_log_error (hashcat_ctx, "It passes over cracked hashes and will not report them as cracked"); event_log_error (hashcat_ctx, "You are STRONGLY encouraged not to use it"); @@ -2733,7 +2733,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (catalyst_warn == 1) { - event_log_error (hashcat_ctx, "Unsupported or incorrectly installed Catalyst driver detected!"); + event_log_error (hashcat_ctx, "* Device #%u: Unsupported or incorrectly installed Catalyst driver detected!", device_id + 1); event_log_error (hashcat_ctx, ""); event_log_error (hashcat_ctx, "You are STRONGLY encouraged to use the official supported catalyst driver"); event_log_error (hashcat_ctx, "See hashcat's homepage for official supported catalyst drivers"); @@ -2750,8 +2750,8 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) { if (device_param->kernel_exec_timeout != 0) { - event_log_warning (hashcat_ctx, "Device #%u: Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); - event_log_warning (hashcat_ctx, " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); + event_log_warning (hashcat_ctx, "* Device #%u: Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); + event_log_warning (hashcat_ctx, " See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); } } } @@ -3346,7 +3346,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (kernel_accel_max < kernel_accel_min) { - event_log_error (hashcat_ctx, "Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); + event_log_error (hashcat_ctx, "* Device #%u: Device does not provide enough allocatable device-memory to handle this attack", device_id + 1); return -1; } @@ -3357,7 +3357,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) /* if (kernel_accel_max < kernel_accel) { - if (user_options->quiet == false) event_log_info (hashcat_ctx, "Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); + if (user_options->quiet == false) event_log_info (hashcat_ctx, "* Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max); device_param->kernel_accel = kernel_accel_max; } @@ -3453,7 +3453,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) strncpy (build_opts, build_opts_new, sizeof (build_opts)); #if defined (DEBUG) - event_log_info (hashcat_ctx, "Device #%u: build_opts '%s'", device_id + 1, build_opts); + event_log_info (hashcat_ctx, "* Device #%u: build_opts '%s'", device_id + 1, build_opts); #endif /** diff --git a/src/restore.c b/src/restore.c index db9a7df3d..0391b93fe 100644 --- a/src/restore.c +++ b/src/restore.c @@ -19,7 +19,7 @@ static void fsync (int fd) } #endif -u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx) +u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; diff --git a/src/status.c b/src/status.c index b0872b0b1..f515ad0d3 100644 --- a/src/status.c +++ b/src/status.c @@ -746,6 +746,37 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx) return display; } +u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 restore_point = get_lowest_words_done (hashcat_ctx); + + return restore_point; +} + +u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + const u64 restore_total = status_ctx->words_base; + + return restore_total; +} + +double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx) +{ + double restore_percent = 0; + + const u64 restore_point = status_get_restore_point (hashcat_ctx); + const u64 restore_total = status_get_restore_total (hashcat_ctx); + + if (restore_total > 0) + { + restore_percent = (double) restore_point / (double) restore_total; + } + + return restore_percent; +} + u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx) { const hashes_t *hashes = hashcat_ctx->hashes; diff --git a/src/terminal.c b/src/terminal.c index 223ddb48a..21c9f1674 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -839,13 +839,10 @@ void status_display (hashcat_ctx_t *hashcat_ctx) // Restore point - u64 restore_point = get_lowest_words_done (hashcat_ctx); + const u64 restore_point = status_get_restore_point (hashcat_ctx); + const u64 restore_total = status_get_restore_total (hashcat_ctx); + const double restore_percent = status_get_restore_percent (hashcat_ctx); - u64 restore_total = status_ctx->words_base; - - double percent_restore = 0; - - if (restore_total != 0) percent_restore = (double) restore_point / (double) restore_total; if (progress_end_relative_skip) { @@ -866,7 +863,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (percent_finished != 1) { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, restore_percent * 100); } } } From 86c1c7ef10ae8a028c0aa35aa449f67f62c20b92 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 15:19:25 +0200 Subject: [PATCH 072/106] Added CPT functions for later use in status.c --- include/status.h | 17 ++++- include/types.h | 29 +++++-- src/hashcat.c | 27 +++++++ src/status.c | 192 ++++++++++++++++++++++++++++++++++++++++++++++- src/terminal.c | 97 ++---------------------- 5 files changed, 259 insertions(+), 103 deletions(-) diff --git a/include/status.h b/include/status.h index 67cf986ea..268fd69c3 100644 --- a/include/status.h +++ b/include/status.h @@ -16,6 +16,9 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en void format_timer_display (struct tm *tm, char *buf, size_t len); void format_speed_display (double val, char *buf, size_t len); +int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx); +int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx); +bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_session (const hashcat_ctx_t *hashcat_ctx); char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx); int status_get_input_mode (const hashcat_ctx_t *hashcat_ctx); @@ -32,6 +35,7 @@ int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx) double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx); double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx); double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); @@ -49,11 +53,18 @@ u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx) u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); -double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); +double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); -double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); +double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); -char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id); +char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); +char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx); int status_progress_init (hashcat_ctx_t *hashcat_ctx); void status_progress_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 9bd982bdd..71cd070fb 100644 --- a/include/types.h +++ b/include/types.h @@ -1452,13 +1452,6 @@ typedef struct hashcat_ctx } hashcat_ctx_t; -typedef struct -{ - bool skipped; - - -} device_info_t; - typedef enum input_mode { INPUT_MODE_NONE = 0, @@ -1479,6 +1472,15 @@ typedef enum input_mode } input_mode_t; +typedef struct +{ + bool skipped_dev; + double hashes_msec_dev; + double exec_msec_dev; + char *speed_sec_dev; + +} device_info_t; + typedef struct { char *hash_target; @@ -1494,6 +1496,7 @@ typedef struct char *time_started_relative; double msec_paused; double msec_running; + double msec_real; int digests_cnt; int digests_done; double digests_percent; @@ -1513,9 +1516,21 @@ typedef struct u64 restore_point; u64 restore_total; double restore_percent; + int cpt_cur_min; + int cpt_cur_hour; + int cpt_cur_day; + double cpt_avg_min; + double cpt_avg_hour; + double cpt_avg_day; + char *cpt; device_info_t device_info_buf[DEVICES_MAX]; int device_info_cnt; + int device_info_active; + + double hashes_msec_all; + double exec_msec_all; + char *speed_sec_all; } hashcat_status_t; diff --git a/src/hashcat.c b/src/hashcat.c index 436fd220b..0e4ef8710 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1144,6 +1144,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->input_mod = status_get_input_mod (hashcat_ctx); hashcat_status->msec_paused = status_get_msec_paused (hashcat_ctx); hashcat_status->msec_running = status_get_msec_running (hashcat_ctx); + hashcat_status->msec_real = status_get_msec_real (hashcat_ctx); hashcat_status->progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); hashcat_status->progress_cur = status_get_progress_cur (hashcat_ctx); hashcat_status->progress_done = status_get_progress_done (hashcat_ctx); @@ -1165,6 +1166,32 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx); hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx); hashcat_status->time_started_relative = status_get_time_started_relative (hashcat_ctx); + hashcat_status->cpt_cur_min = status_get_cpt_cur_min (hashcat_ctx); + hashcat_status->cpt_cur_hour = status_get_cpt_cur_hour (hashcat_ctx); + hashcat_status->cpt_cur_day = status_get_cpt_cur_day (hashcat_ctx); + hashcat_status->cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx); + hashcat_status->cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx); + hashcat_status->cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx); + hashcat_status->cpt = status_get_cpt (hashcat_ctx); + + // multiple devices + + hashcat_status->device_info_cnt = status_get_device_info_cnt (hashcat_ctx); + hashcat_status->device_info_active = status_get_device_info_active (hashcat_ctx); + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + device_info_t *device_info = hashcat_status->device_info_buf + device_id; + + device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); + device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); + device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); + } + + hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); + hashcat_status->exec_msec_all = status_get_exec_msec_all (hashcat_ctx); + hashcat_status->speed_sec_all = status_get_speed_sec_all (hashcat_ctx); return 0; } diff --git a/src/status.c b/src/status.c index f515ad0d3..db5eb7490 100644 --- a/src/status.c +++ b/src/status.c @@ -155,6 +155,29 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en return exec_msec_sum / exec_msec_cnt; } +int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + return opencl_ctx->devices_cnt; +} + +int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + return opencl_ctx->devices_active; +} + +bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + return device_param->skipped; +} + char *status_get_session (const hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -555,6 +578,16 @@ double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx) return msec_paused; } +double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx) +{ + const double msec_running = status_get_msec_running (hashcat_ctx); + const double msec_paused = status_get_msec_paused (hashcat_ctx); + + const double msec_real = msec_running - msec_paused; + + return msec_real; +} + char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -943,7 +976,7 @@ double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx) return hashes_all_msec; } -double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; @@ -988,7 +1021,7 @@ double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx) return exec_all_msec; } -double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; @@ -1015,7 +1048,7 @@ char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx) return display; } -char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id) +char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) { const double hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); @@ -1026,6 +1059,159 @@ char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 devi return display; } +int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const time_t now = time (NULL); + + int cpt_cur_min = 0; + + for (int i = 0; i < CPT_BUF; i++) + { + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; + + if ((timestamp + 60) > now) + { + cpt_cur_min += cracked; + } + } + + return cpt_cur_min; +} + +int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const time_t now = time (NULL); + + int cpt_cur_hour = 0; + + for (int i = 0; i < CPT_BUF; i++) + { + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; + + if ((timestamp + 3600) > now) + { + cpt_cur_hour += cracked; + } + } + + return cpt_cur_hour; +} + +int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const time_t now = time (NULL); + + int cpt_cur_day = 0; + + for (int i = 0; i < CPT_BUF; i++) + { + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; + + if ((timestamp + 86400) > now) + { + cpt_cur_day += cracked; + } + } + + return cpt_cur_day; +} + +double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const double msec_real = status_get_msec_real (hashcat_ctx); + + const double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60); + + return cpt_avg_min; +} + +double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const double msec_real = status_get_msec_real (hashcat_ctx); + + const double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600); + + return cpt_avg_hour; +} + +double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const double msec_real = status_get_msec_real (hashcat_ctx); + + const double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400); + + return cpt_avg_day; +} + +char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) +{ + const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; + + const time_t now = time (NULL); + + char *cpt = (char *) malloc (HCBUFSIZ_TINY); + + const int cpt_cur_min = status_get_cpt_cur_min (hashcat_ctx); + const int cpt_cur_hour = status_get_cpt_cur_hour (hashcat_ctx); + const int cpt_cur_day = status_get_cpt_cur_day (hashcat_ctx); + + const double cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx); + const double cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx); + const double cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx); + + if ((cpt_ctx->cpt_start + 86400) < now) + { + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_cur_hour, + cpt_cur_day, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else if ((cpt_ctx->cpt_start + 3600) < now) + { + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_cur_hour, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else if ((cpt_ctx->cpt_start + 60) < now) + { + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_cur_min, + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + else + { + snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + cpt_avg_min, + cpt_avg_hour, + cpt_avg_day); + } + + return cpt; +} + int status_progress_init (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; diff --git a/src/terminal.c b/src/terminal.c index 21c9f1674..0c1c671e3 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -611,8 +611,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) void status_display (hashcat_ctx_t *hashcat_ctx) { - cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; - hashes_t *hashes = hashcat_ctx->hashes; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -669,6 +667,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) status_get_salts_done (hashcat_ctx), status_get_salts_cnt (hashcat_ctx), status_get_salts_percent (hashcat_ctx)); + event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx)); const int input_mode = status_get_input_mode (hashcat_ctx); @@ -731,27 +730,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + const int device_info_cnt = status_get_device_info_cnt (hashcat_ctx); + const int device_info_active = status_get_device_info_active (hashcat_ctx); - if (device_param->skipped) continue; + for (int device_id = 0; device_id < device_info_cnt; device_id++) + { + if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, status_get_speed_sec_dev (hashcat_ctx, device_id), status_get_exec_msec_dev (hashcat_ctx, device_id)); } - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); - - - - /** - * timers - */ - - const double msec_running = status_get_msec_running (hashcat_ctx); - const double msec_paused = status_get_msec_paused (hashcat_ctx); + if (device_info_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); /** @@ -763,80 +754,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); - - // crack-per-time - - if (hashes->digests_cnt > 100) - { - time_t now = time (NULL); - - int cpt_cur_min = 0; - int cpt_cur_hour = 0; - int cpt_cur_day = 0; - - for (int i = 0; i < CPT_BUF; i++) - { - const u32 cracked = cpt_ctx->cpt_buf[i].cracked; - const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; - - if ((timestamp + 60) > now) - { - cpt_cur_min += cracked; - } - - if ((timestamp + 3600) > now) - { - cpt_cur_hour += cracked; - } - - if ((timestamp + 86400) > now) - { - cpt_cur_day += cracked; - } - } - - const double msec_real = msec_running - msec_paused; - - double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60); - double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600); - double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400); - - if ((cpt_ctx->cpt_start + 86400) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_cur_hour, - cpt_cur_day, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else if ((cpt_ctx->cpt_start + 3600) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_cur_hour, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else if ((cpt_ctx->cpt_start + 60) < now) - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_cur_min, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - else - { - event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); - } - } - // Restore point const u64 restore_point = status_get_restore_point (hashcat_ctx); From 8d81d3bd55302522aeb4e8df60afbf120218c3c3 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 16:22:32 +0200 Subject: [PATCH 073/106] Added progress_mode to status.c --- include/status.h | 3 ++ include/types.h | 11 ++++++ src/hashcat.c | 3 ++ src/status.c | 64 ++++++++++++++++++++++++++++++--- src/terminal.c | 94 +++++++++++++----------------------------------- 5 files changed, 101 insertions(+), 74 deletions(-) diff --git a/include/status.h b/include/status.h index 268fd69c3..bff65c767 100644 --- a/include/status.h +++ b/include/status.h @@ -43,8 +43,11 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx) u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx); u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx); double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx); +int status_get_progress_mode (const hashcat_ctx_t *hashcat_ctx); +double status_get_progress_finished_percent (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); +double status_get_progress_rejected_percent (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx); u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 71cd070fb..25a697673 100644 --- a/include/types.h +++ b/include/types.h @@ -1472,6 +1472,14 @@ typedef enum input_mode } input_mode_t; +typedef enum progress_mode +{ + PROGRESS_MODE_NONE = 0, + PROGRESS_MODE_KEYSPACE_KNOWN = 1, + PROGRESS_MODE_KEYSPACE_UNKNOWN = 2, + +} progress_mode_t; + typedef struct { bool skipped_dev; @@ -1504,6 +1512,8 @@ typedef struct int salts_cnt; int salts_done; double salts_percent; + int progress_mode; + double progress_finished_percent; u64 progress_cur; u64 progress_cur_relative_skip; u64 progress_done; @@ -1511,6 +1521,7 @@ typedef struct u64 progress_end_relative_skip; u64 progress_ignore; u64 progress_rejected; + double progress_rejected_percent; u64 progress_restored; u64 progress_skip; u64 restore_point; diff --git a/src/hashcat.c b/src/hashcat.c index 0e4ef8710..7c8cc2e33 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1145,6 +1145,8 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->msec_paused = status_get_msec_paused (hashcat_ctx); hashcat_status->msec_running = status_get_msec_running (hashcat_ctx); hashcat_status->msec_real = status_get_msec_real (hashcat_ctx); + hashcat_status->progress_mode = status_get_progress_mode (hashcat_ctx); + hashcat_status->progress_finished_percent = status_get_progress_finished_percent (hashcat_ctx); hashcat_status->progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); hashcat_status->progress_cur = status_get_progress_cur (hashcat_ctx); hashcat_status->progress_done = status_get_progress_done (hashcat_ctx); @@ -1152,6 +1154,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->progress_end = status_get_progress_end (hashcat_ctx); hashcat_status->progress_ignore = status_get_progress_ignore (hashcat_ctx); hashcat_status->progress_rejected = status_get_progress_rejected (hashcat_ctx); + hashcat_status->progress_rejected_percent = status_get_progress_rejected_percent (hashcat_ctx); hashcat_status->progress_restored = status_get_progress_restored (hashcat_ctx); hashcat_status->progress_skip = status_get_progress_skip (hashcat_ctx); hashcat_status->restore_point = status_get_restore_point (hashcat_ctx); diff --git a/src/status.c b/src/status.c index db5eb7490..d31f0e9ee 100644 --- a/src/status.c +++ b/src/status.c @@ -804,12 +804,43 @@ double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx) if (restore_total > 0) { - restore_percent = (double) restore_point / (double) restore_total; + restore_percent = ((double) restore_point / (double) restore_total) * 100; } return restore_percent; } +int status_get_progress_mode (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); + + if (progress_end_relative_skip > 0) + { + return PROGRESS_MODE_KEYSPACE_KNOWN; + } + else + { + return PROGRESS_MODE_KEYSPACE_UNKNOWN; + } + + return PROGRESS_MODE_NONE; +} + +double status_get_progress_finished_percent (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); + const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); + + double progress_finished_percent = 0; + + if (progress_end_relative_skip > 0) + { + progress_finished_percent = ((double) progress_cur_relative_skip / (double) progress_end_relative_skip) * 100; + } + + return progress_finished_percent; +} + u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx) { const hashes_t *hashes = hashcat_ctx->hashes; @@ -840,6 +871,21 @@ u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx) return progress_rejected; } +double status_get_progress_rejected_percent (const hashcat_ctx_t *hashcat_ctx) +{ + const u64 progress_cur = status_get_progress_cur (hashcat_ctx); + const u64 progress_rejected = status_get_progress_rejected (hashcat_ctx); + + double percent_rejected = 0; + + if (progress_cur) + { + percent_rejected = ((double) (progress_rejected) / (double) progress_cur) * 100; + } + + return percent_rejected; +} + u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx) { const hashes_t *hashes = hashcat_ctx->hashes; @@ -944,10 +990,15 @@ u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx) u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx) { - const u64 progress_cur = status_get_progress_cur (hashcat_ctx); const u64 progress_skip = status_get_progress_skip (hashcat_ctx); + const u64 progress_cur = status_get_progress_cur (hashcat_ctx); - const u64 progress_cur_relative_skip = progress_cur - progress_skip; + u64 progress_cur_relative_skip = 0; + + if (progress_cur > 0) + { + progress_cur_relative_skip = progress_cur - progress_skip; + } return progress_cur_relative_skip; } @@ -957,7 +1008,12 @@ u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx) const u64 progress_skip = status_get_progress_skip (hashcat_ctx); const u64 progress_end = status_get_progress_end (hashcat_ctx); - const u64 progress_end_relative_skip = progress_end - progress_skip; + u64 progress_end_relative_skip = 0; + + if (progress_end > 0) + { + progress_end_relative_skip = progress_end - progress_skip; + } return progress_end_relative_skip; } diff --git a/src/terminal.c b/src/terminal.c index 0c1c671e3..c8cdfa3a1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -669,9 +669,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) status_get_salts_percent (hashcat_ctx)); event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx)); - const int input_mode = status_get_input_mode (hashcat_ctx); - - switch (input_mode) + switch (status_get_input_mode (hashcat_ctx)) { case INPUT_MODE_STRAIGHT_FILE: event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); @@ -730,6 +728,29 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } + switch (status_get_progress_mode (hashcat_ctx)) + { + case PROGRESS_MODE_KEYSPACE_KNOWN: + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + status_get_progress_cur_relative_skip (hashcat_ctx), + status_get_progress_end_relative_skip (hashcat_ctx), + status_get_progress_finished_percent (hashcat_ctx)); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + status_get_progress_rejected (hashcat_ctx), + status_get_progress_cur_relative_skip (hashcat_ctx), + status_get_progress_rejected_percent (hashcat_ctx)); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + status_get_restore_point (hashcat_ctx), + status_get_restore_total (hashcat_ctx), + status_get_restore_percent (hashcat_ctx)); + break; + case PROGRESS_MODE_KEYSPACE_UNKNOWN: + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64, status_get_progress_cur_relative_skip (hashcat_ctx)); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64, status_get_progress_rejected (hashcat_ctx)); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64, status_get_restore_point (hashcat_ctx)); + break; + } + const int device_info_cnt = status_get_device_info_cnt (hashcat_ctx); const int device_info_active = status_get_device_info_active (hashcat_ctx); @@ -744,73 +765,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); - - /** - * counters - */ - - const u64 progress_cur = status_get_progress_cur (hashcat_ctx); - const u64 progress_rejected = status_get_progress_rejected (hashcat_ctx); - const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx); - const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx); - - // Restore point - - const u64 restore_point = status_get_restore_point (hashcat_ctx); - const u64 restore_total = status_get_restore_total (hashcat_ctx); - const double restore_percent = status_get_restore_percent (hashcat_ctx); - - - if (progress_end_relative_skip) - { - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - double percent_finished = (double) progress_cur_relative_skip / (double) progress_end_relative_skip; - double percent_rejected = 0.0; - - if (progress_cur) - { - percent_rejected = (double) (progress_rejected) / (double) progress_cur; - } - - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_rejected, progress_cur_relative_skip, percent_rejected * 100); - - if (user_options->restore_disable == false) - { - if (percent_finished != 1) - { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, restore_percent * 100); - } - } - } - } - else - { - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - - if (user_options->restore_disable == false) - { - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); - } - } - else - { - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", progress_rejected); - - // --restore not allowed if stdin is used -- really? why? - - //if (user_options->restore_disable == false) - //{ - // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); - //} - } - } - if (status_ctx->run_main_level1 == false) return; for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) From 2b28010aae439bca691f25540709eaa4b93f4bf4 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 16:46:16 +0200 Subject: [PATCH 074/106] Added status_get_input_candidates_dev() to status.c --- include/status.h | 1 + include/types.h | 1 + src/hashcat.c | 9 +++-- src/status.c | 64 +++++++++++++++++++++++++++++++ src/terminal.c | 98 ++++++++++-------------------------------------- 5 files changed, 91 insertions(+), 82 deletions(-) diff --git a/include/status.h b/include/status.h index bff65c767..0e22c9f3b 100644 --- a/include/status.h +++ b/include/status.h @@ -25,6 +25,7 @@ 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); +char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 25a697673..3f24a9477 100644 --- a/include/types.h +++ b/include/types.h @@ -1486,6 +1486,7 @@ typedef struct double hashes_msec_dev; double exec_msec_dev; char *speed_sec_dev; + char *input_candidates_dev; } device_info_t; diff --git a/src/hashcat.c b/src/hashcat.c index 7c8cc2e33..0e0e06923 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1186,10 +1186,11 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st { device_info_t *device_info = hashcat_status->device_info_buf + device_id; - device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); - device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); - device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); - device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); + device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); + device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); + device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); + device_info->input_candidates_dev = status_get_input_candidates_dev (hashcat_ctx, device_id); } hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); diff --git a/src/status.c b/src/status.c index d31f0e9ee..b140e4afd 100644 --- a/src/status.c +++ b/src/status.c @@ -511,6 +511,70 @@ char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx) return NULL; } +char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + char *display = (char *) malloc (HCBUFSIZ_TINY); + + if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + snprintf (display, HCBUFSIZ_TINY - 1, "[Generating]"); + } + else + { + snprintf (display, HCBUFSIZ_TINY - 1, "[Copying]"); + } + + if (device_param->skipped == true) return display; + + if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) return display; + + const u32 outerloop_first = 0; + const u32 outerloop_last = device_param->outerloop_left - 1; + + const u32 innerloop_first = 0; + const u32 innerloop_last = device_param->innerloop_left - 1; + + plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; + plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; + + u32 plain_buf1[16] = { 0 }; + u32 plain_buf2[16] = { 0 }; + + u8 *plain_ptr1 = (u8 *) plain_buf1; + u8 *plain_ptr2 = (u8 *) plain_buf2; + + int plain_len1 = 0; + int plain_len2 = 0; + + build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); + build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); + + const bool need_hex1 = need_hexify (plain_ptr1, plain_len1); + const bool need_hex2 = need_hexify (plain_ptr2, plain_len2); + + if ((need_hex1 == true) || (need_hex2 == true)) + { + exec_hexify (plain_ptr1, plain_len1, plain_ptr1); + exec_hexify (plain_ptr2, plain_len2, plain_ptr2); + + plain_ptr1[plain_len1 * 2] = 0; + plain_ptr2[plain_len2 * 2] = 0; + + snprintf (display, HCBUFSIZ_TINY - 1, "$HEX[%s] -> $HEX[%s]", plain_ptr1, plain_ptr2); + } + else + { + snprintf (display, HCBUFSIZ_TINY - 1, "%s -> %s", plain_ptr1, plain_ptr2); + } + + return display; +} + int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx) { const hashes_t *hashes = hashcat_ctx->hashes; diff --git a/src/terminal.c b/src/terminal.c index c8cdfa3a1..87f8e9782 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -611,10 +611,9 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) void status_display (hashcat_ctx_t *hashcat_ctx) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; if (status_ctx->devices_status == STATUS_INIT) { @@ -660,14 +659,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) status_get_time_estimated_relative (hashcat_ctx)); event_log_info (hashcat_ctx, "Hash.Type......: %s", status_get_hash_type (hashcat_ctx)); event_log_info (hashcat_ctx, "Hash.Target....: %s", status_get_hash_target (hashcat_ctx)); - event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", - status_get_digests_done (hashcat_ctx), - status_get_digests_cnt (hashcat_ctx), - status_get_digests_percent (hashcat_ctx), - status_get_salts_done (hashcat_ctx), - status_get_salts_cnt (hashcat_ctx), - status_get_salts_percent (hashcat_ctx)); - event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx)); switch (status_get_input_mode (hashcat_ctx)) { @@ -728,6 +719,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } + for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) + { + if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; + + event_log_info (hashcat_ctx, "Candidates.#%d..: %s", device_id + 1, status_get_input_candidates_dev (hashcat_ctx, device_id)); + } + switch (status_get_progress_mode (hashcat_ctx)) { case PROGRESS_MODE_KEYSPACE_KNOWN: @@ -751,10 +749,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } - const int device_info_cnt = status_get_device_info_cnt (hashcat_ctx); - const int device_info_active = status_get_device_info_active (hashcat_ctx); + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", + status_get_digests_done (hashcat_ctx), + status_get_digests_cnt (hashcat_ctx), + status_get_digests_percent (hashcat_ctx), + status_get_salts_done (hashcat_ctx), + status_get_salts_cnt (hashcat_ctx), + status_get_salts_percent (hashcat_ctx)); + event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx)); - for (int device_id = 0; device_id < device_info_cnt; device_id++) + for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) { if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; @@ -763,69 +767,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) status_get_exec_msec_dev (hashcat_ctx, device_id)); } - if (device_info_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); - - if (status_ctx->run_main_level1 == false) return; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - if ((device_param->outerloop_left == 0) || (device_param->innerloop_left == 0)) - { - if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); - } - else - { - event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); - } - - continue; - } - - const u32 outerloop_first = 0; - const u32 outerloop_last = device_param->outerloop_left - 1; - - const u32 innerloop_first = 0; - const u32 innerloop_last = device_param->innerloop_left - 1; - - plain_t plain1 = { 0, 0, 0, outerloop_first, innerloop_first }; - plain_t plain2 = { 0, 0, 0, outerloop_last, innerloop_last }; - - u32 plain_buf1[16] = { 0 }; - u32 plain_buf2[16] = { 0 }; - - u8 *plain_ptr1 = (u8 *) plain_buf1; - u8 *plain_ptr2 = (u8 *) plain_buf2; - - int plain_len1 = 0; - int plain_len2 = 0; - - build_plain (hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); - build_plain (hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); - - bool need_hex1 = need_hexify (plain_ptr1, plain_len1); - bool need_hex2 = need_hexify (plain_ptr2, plain_len2); - - if ((need_hex1 == true) || (need_hex2 == true)) - { - exec_hexify (plain_ptr1, plain_len1, plain_ptr1); - exec_hexify (plain_ptr2, plain_len2, plain_ptr2); - - plain_ptr1[plain_len1 * 2] = 0; - plain_ptr2[plain_len2 * 2] = 0; - - event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); - } - else - { - event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); - } - } + if (status_get_device_info_active (hashcat_ctx) > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); if (user_options->gpu_temp_disable == false) { From 1d0810a7594ae9f761d8a556fb0b99ea18b93ed6 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 17:02:56 +0200 Subject: [PATCH 075/106] Added status_get_hwmon_dev() to status.c --- include/status.h | 1 + include/types.h | 1 + src/hashcat.c | 1 + src/status.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ src/terminal.c | 86 ++++-------------------------------------------- 5 files changed, 95 insertions(+), 79 deletions(-) diff --git a/include/status.h b/include/status.h index 0e22c9f3b..29b8ce72f 100644 --- a/include/status.h +++ b/include/status.h @@ -69,6 +69,7 @@ double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx) double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx); +char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); int status_progress_init (hashcat_ctx_t *hashcat_ctx); void status_progress_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 3f24a9477..2620b0841 100644 --- a/include/types.h +++ b/include/types.h @@ -1487,6 +1487,7 @@ typedef struct double exec_msec_dev; char *speed_sec_dev; char *input_candidates_dev; + char *hwmon_dev; } device_info_t; diff --git a/src/hashcat.c b/src/hashcat.c index 0e0e06923..0b2104240 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1191,6 +1191,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); device_info->input_candidates_dev = status_get_input_candidates_dev (hashcat_ctx, device_id); + device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); } hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); diff --git a/src/status.c b/src/status.c index b140e4afd..bfb521971 100644 --- a/src/status.c +++ b/src/status.c @@ -1332,6 +1332,91 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) return cpt; } +char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + char *output_buf = (char *) malloc (HCBUFSIZ_TINY); + + snprintf (output_buf, HCBUFSIZ_TINY - 1, "N/A"); + + if (device_param->skipped == true) return output_buf; + + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + hc_thread_mutex_lock (status_ctx->mux_hwmon); + + const int num_temperature = hm_get_temperature_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_fanspeed = hm_get_fanspeed_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_utilization = hm_get_utilization_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_corespeed = hm_get_corespeed_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_memoryspeed = hm_get_memoryspeed_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_buslanes = hm_get_buslanes_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + const int num_throttle = hm_get_throttle_with_device_id ((hashcat_ctx_t *) hashcat_ctx, device_id); + + int output_len = 0; + + if (num_temperature >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Temp:%3uc ", num_temperature); + + output_len = strlen (output_buf); + } + + if (num_fanspeed >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Fan:%3u%% ", num_fanspeed); + + output_len = strlen (output_buf); + } + + if (num_utilization >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Util:%3u%% ", num_utilization); + + output_len = strlen (output_buf); + } + + if (num_corespeed >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Core:%4uMhz ", num_corespeed); + + output_len = strlen (output_buf); + } + + if (num_memoryspeed >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Mem:%4uMhz ", num_memoryspeed); + + output_len = strlen (output_buf); + } + + if (num_buslanes >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "Lanes:%u ", num_buslanes); + + output_len = strlen (output_buf); + } + + if (num_throttle >= 0) + { + snprintf (output_buf + output_len, HCBUFSIZ_TINY - output_len, "*Throttled* "); + + output_len = strlen (output_buf); + } + + if (output_len > 0) + { + output_buf[output_len - 1] = 0; + } + + hc_thread_mutex_unlock (status_ctx->mux_hwmon); + + return output_buf; +} + int status_progress_init (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; diff --git a/src/terminal.c b/src/terminal.c index 87f8e9782..67f351ad6 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -611,7 +611,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) void status_display (hashcat_ctx_t *hashcat_ctx) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -767,90 +766,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) status_get_exec_msec_dev (hashcat_ctx, device_id)); } - if (status_get_device_info_active (hashcat_ctx) > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); + if (status_get_device_info_active (hashcat_ctx) > 1) + { + event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); + } if (user_options->gpu_temp_disable == false) { - hc_thread_mutex_lock (status_ctx->mux_hwmon); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; - if (device_param->skipped) continue; - - const int num_temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - const int num_fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id); - const int num_utilization = hm_get_utilization_with_device_id (hashcat_ctx, device_id); - const int num_corespeed = hm_get_corespeed_with_device_id (hashcat_ctx, device_id); - const int num_memoryspeed = hm_get_memoryspeed_with_device_id (hashcat_ctx, device_id); - const int num_buslanes = hm_get_buslanes_with_device_id (hashcat_ctx, device_id); - const int num_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id); - - char output_buf[256] = { 0 }; - - int output_len = 0; - - if (num_temperature >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Temp:%3uc", num_temperature); - - output_len = strlen (output_buf); - } - - if (num_fanspeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Fan:%3u%%", num_fanspeed); - - output_len = strlen (output_buf); - } - - if (num_utilization >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Util:%3u%%", num_utilization); - - output_len = strlen (output_buf); - } - - if (num_corespeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Core:%4uMhz", num_corespeed); - - output_len = strlen (output_buf); - } - - if (num_memoryspeed >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Mem:%4uMhz", num_memoryspeed); - - output_len = strlen (output_buf); - } - - if (num_buslanes >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " Lanes:%u", num_buslanes); - - output_len = strlen (output_buf); - } - - if (num_throttle >= 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " *Throttled*"); - - output_len = strlen (output_buf); - } - - if (output_len == 0) - { - snprintf (output_buf + output_len, sizeof (output_buf) - output_len, " N/A"); - - output_len = strlen (output_buf); - } - - event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + event_log_info (hashcat_ctx, "HWMon.Dev.#%d...: %s", device_id + 1, status_get_hwmon_dev (hashcat_ctx, device_id)); } - - hc_thread_mutex_unlock (status_ctx->mux_hwmon); } } From 65b3910dc0b4a389058820788725c76d3812148d Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 17:20:19 +0200 Subject: [PATCH 076/106] Converted status_benchmark_automate() --- include/status.h | 1 + src/status.c | 27 ++++++++++++++++++++++++ src/terminal.c | 55 +++++------------------------------------------- 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/include/status.h b/include/status.h index 29b8ce72f..c4fb57b66 100644 --- a/include/status.h +++ b/include/status.h @@ -58,6 +58,7 @@ u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx) u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id); double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); diff --git a/src/status.c b/src/status.c index bfb521971..9680362e6 100644 --- a/src/status.c +++ b/src/status.c @@ -1127,6 +1127,33 @@ double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int d return hashes_dev_msec; } +double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id) +{ + // this function increases accuracy for benchmark modes + + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + u64 speed_cnt = 0; + double speed_msec = 0; + + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped == false) + { + speed_cnt += device_param->speed_cnt[0]; + speed_msec += device_param->speed_msec[0]; + } + + double hashes_dev_msec = 0; + + if (speed_msec > 0) + { + hashes_dev_msec = (double) speed_cnt / speed_msec; + } + + return hashes_dev_msec; +} + double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; diff --git a/src/terminal.c b/src/terminal.c index 67f351ad6..b8692967f 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -785,59 +785,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - if (status_ctx->devices_status == STATUS_INIT) + const u32 hash_mode = hashconfig->hash_mode; + + for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_msec[device_id] = device_param->speed_msec[0]; - } - - u64 hashes_dev_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - hashes_dev_msec[device_id] = 0; - - if (speed_msec[device_id] > 0) - { - hashes_dev_msec[device_id] = (double) speed_cnt[device_id] / speed_msec[device_id]; - } - } - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_msec[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id) * 1000)); } } From 89e31682800c4fd1f7d912d785fccbea4ce5e1b8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 17 Oct 2016 23:49:44 +0200 Subject: [PATCH 077/106] Make status_display(), status_benchmark_automate() and status_benchmark() use of hashcat_status_t --- include/types.h | 1 + src/hashcat.c | 38 +++- src/terminal.c | 471 +++++++++++++++++++++++++++++------------------- 3 files changed, 315 insertions(+), 195 deletions(-) diff --git a/include/types.h b/include/types.h index 2620b0841..922c65f12 100644 --- a/include/types.h +++ b/include/types.h @@ -1484,6 +1484,7 @@ typedef struct { bool skipped_dev; double hashes_msec_dev; + double hashes_msec_dev_benchmark; double exec_msec_dev; char *speed_sec_dev; char *input_candidates_dev; diff --git a/src/hashcat.c b/src/hashcat.c index 0b2104240..3a695229e 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1131,6 +1131,31 @@ char *hashcat_get_log (hashcat_ctx_t *hashcat_ctx) int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_status) { + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + if (status_ctx->devices_status == STATUS_INIT) + { + event_log_error (hashcat_ctx, "Status view is not available during initialization phase"); + + return -1; + } + + if (status_ctx->devices_status == STATUS_AUTOTUNE) + { + event_log_error (hashcat_ctx, "Status view is not available during autotune phase"); + + return -1; + } + + if (status_ctx->shutdown_inner == true) + { + // in this case some required buffers are free'd, ascii_digest() would run into segfault + + event_log_error (hashcat_ctx, "Status view is not available during shutdown phase"); + + return -1; + } + memset (hashcat_status, 0, sizeof (hashcat_status_t)); hashcat_status->digests_cnt = status_get_digests_cnt (hashcat_ctx); @@ -1186,12 +1211,13 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st { device_info_t *device_info = hashcat_status->device_info_buf + device_id; - device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); - device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); - device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); - device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); - device_info->input_candidates_dev = status_get_input_candidates_dev (hashcat_ctx, device_id); - device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); + device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev_benchmark = status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id); + device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); + device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); + device_info->input_candidates_dev = status_get_input_candidates_dev (hashcat_ctx, device_id); + device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); } hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); diff --git a/src/terminal.c b/src/terminal.c index b8692967f..0d916cc08 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5,6 +5,7 @@ #include "common.h" #include "types.h" +#include "memory.h" #include "event.h" #include "convert.h" #include "thread.h" @@ -16,6 +17,7 @@ #include "interface.h" #include "outfile.h" #include "terminal.h" +#include "hashcat.h" const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => "; @@ -611,31 +613,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) void status_display (hashcat_ctx_t *hashcat_ctx) { - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; - - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "Status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "Status view is not available during autotune phase"); - - return; - } - - if (status_ctx->shutdown_inner == true) - { - // in this case some required buffers are free'd, ascii_digest() would run into segfault - - event_log_error (hashcat_ctx, "Status view is not available during shutdown phase"); - - return; - } + const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->machine_readable == true) { @@ -644,142 +622,308 @@ void status_display (hashcat_ctx_t *hashcat_ctx) return; } + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) + { + hcfree (hashcat_status); + + return; + } + /** * show something */ - event_log_info (hashcat_ctx, "Session........: %s", status_get_session (hashcat_ctx)); - event_log_info (hashcat_ctx, "Status.........: %s", status_get_status_string (hashcat_ctx)); - event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", - status_get_time_started_absolute (hashcat_ctx), - status_get_time_started_relative (hashcat_ctx)); - event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", - status_get_time_estimated_absolute (hashcat_ctx), - status_get_time_estimated_relative (hashcat_ctx)); - event_log_info (hashcat_ctx, "Hash.Type......: %s", status_get_hash_type (hashcat_ctx)); - event_log_info (hashcat_ctx, "Hash.Target....: %s", status_get_hash_target (hashcat_ctx)); + event_log_info (hashcat_ctx, + "Session........: %s", + hashcat_status->session); - switch (status_get_input_mode (hashcat_ctx)) + event_log_info (hashcat_ctx, + "Status.........: %s", + hashcat_status->status); + + event_log_info (hashcat_ctx, + "Time.Started...: %s (%s)", + hashcat_status->time_started_absolute, + hashcat_status->time_started_relative); + + event_log_info (hashcat_ctx, + "Time.Estimated.: %s (%s)", + hashcat_status->time_estimated_absolute, + hashcat_status->time_estimated_relative); + + event_log_info (hashcat_ctx, + "Hash.Type......: %s", + hashcat_status->hash_type); + + event_log_info (hashcat_ctx, + "Hash.Target....: %s", + hashcat_status->hash_target); + + switch (hashcat_status->input_mode) { case INPUT_MODE_STRAIGHT_FILE: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s)", + hashcat_status->input_base); + break; + case INPUT_MODE_STRAIGHT_FILE_RULES_FILE: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Rules (%s)", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s)", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Rules (%s)", + hashcat_status->input_mod); + break; + case INPUT_MODE_STRAIGHT_FILE_RULES_GEN: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s)", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Rules (Generated)"); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s)", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Rules (Generated)"); + break; + case INPUT_MODE_STRAIGHT_STDIN: - event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); + + event_log_info (hashcat_ctx, + "Input.Base.....: Pipe"); + break; + case INPUT_MODE_STRAIGHT_STDIN_RULES_FILE: - event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); - event_log_info (hashcat_ctx, "Input.Mod......: Rules (%s)", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: Pipe"); + + event_log_info (hashcat_ctx, + "Input.Mod......: Rules (%s)", + hashcat_status->input_mod); + break; + case INPUT_MODE_STRAIGHT_STDIN_RULES_GEN: - event_log_info (hashcat_ctx, "Input.Base.....: Pipe"); - event_log_info (hashcat_ctx, "Input.Mod......: Rules (Generated)"); + + event_log_info (hashcat_ctx, + "Input.Base.....: Pipe"); + + event_log_info (hashcat_ctx, + "Input.Mod......: Rules (Generated)"); + break; + case INPUT_MODE_COMBINATOR_BASE_LEFT: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: File (%s), Right Side", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Left Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: File (%s), Right Side", + hashcat_status->input_mod); + break; + case INPUT_MODE_COMBINATOR_BASE_RIGHT: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: File (%s), Left Side", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Right Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: File (%s), Left Side", + hashcat_status->input_mod); + break; + case INPUT_MODE_MASK: - event_log_info (hashcat_ctx, "Input.Mask.....: %s", status_get_input_base (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Mask.....: %s", + hashcat_status->input_base); + break; + case INPUT_MODE_MASK_CS: - event_log_info (hashcat_ctx, "Input.Mask.....: %s", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Mask.....: %s", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Charset..: %s", + hashcat_status->input_charset); + break; + case INPUT_MODE_HYBRID1: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Right Side", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Left Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Mask (%s), Right Side", + hashcat_status->input_mod); + break; + case INPUT_MODE_HYBRID1_CS: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Left Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Right Side", status_get_input_mod (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Left Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Mask (%s), Right Side", + hashcat_status->input_mod); + + event_log_info (hashcat_ctx, + "Input.Charset..: %s", + hashcat_status->input_charset); + break; + case INPUT_MODE_HYBRID2: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Left Side", status_get_input_mod (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Right Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Mask (%s), Left Side", + hashcat_status->input_mod); + break; + case INPUT_MODE_HYBRID2_CS: - event_log_info (hashcat_ctx, "Input.Base.....: File (%s), Right Side", status_get_input_base (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Mod......: Mask (%s), Left Side", status_get_input_mod (hashcat_ctx)); - event_log_info (hashcat_ctx, "Input.Charset..: %s", status_get_input_charset (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Input.Base.....: File (%s), Right Side", + hashcat_status->input_base); + + event_log_info (hashcat_ctx, + "Input.Mod......: Mask (%s), Left Side", + hashcat_status->input_mod); + + event_log_info (hashcat_ctx, + "Input.Charset..: %s", + hashcat_status->input_charset); + break; } - for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - event_log_info (hashcat_ctx, "Candidates.#%d..: %s", device_id + 1, status_get_input_candidates_dev (hashcat_ctx, device_id)); + if (device_info->skipped_dev == true) continue; + + event_log_info (hashcat_ctx, + "Candidates.#%d..: %s", device_id + 1, + device_info->input_candidates_dev); } - switch (status_get_progress_mode (hashcat_ctx)) + switch (hashcat_status->progress_mode) { case PROGRESS_MODE_KEYSPACE_KNOWN: - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", - status_get_progress_cur_relative_skip (hashcat_ctx), - status_get_progress_end_relative_skip (hashcat_ctx), - status_get_progress_finished_percent (hashcat_ctx)); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", - status_get_progress_rejected (hashcat_ctx), - status_get_progress_cur_relative_skip (hashcat_ctx), - status_get_progress_rejected_percent (hashcat_ctx)); - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", - status_get_restore_point (hashcat_ctx), - status_get_restore_total (hashcat_ctx), - status_get_restore_percent (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + hashcat_status->progress_cur_relative_skip, + hashcat_status->progress_end_relative_skip, + hashcat_status->progress_finished_percent); + + event_log_info (hashcat_ctx, + "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + hashcat_status->progress_rejected, + hashcat_status->progress_cur_relative_skip, + hashcat_status->progress_rejected_percent); + + event_log_info (hashcat_ctx, + "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + hashcat_status->restore_point, + hashcat_status->restore_total, + hashcat_status->restore_percent); + break; + case PROGRESS_MODE_KEYSPACE_UNKNOWN: - event_log_info (hashcat_ctx, "Progress.......: %" PRIu64, status_get_progress_cur_relative_skip (hashcat_ctx)); - event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64, status_get_progress_rejected (hashcat_ctx)); - event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64, status_get_restore_point (hashcat_ctx)); + + event_log_info (hashcat_ctx, + "Progress.......: %" PRIu64, + hashcat_status->progress_cur_relative_skip); + + event_log_info (hashcat_ctx, + "Rejected.......: %" PRIu64, + hashcat_status->progress_rejected); + + event_log_info (hashcat_ctx, + "Restore.Point..: %" PRIu64, + hashcat_status->restore_point); + break; } - event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", - status_get_digests_done (hashcat_ctx), - status_get_digests_cnt (hashcat_ctx), - status_get_digests_percent (hashcat_ctx), - status_get_salts_done (hashcat_ctx), - status_get_salts_cnt (hashcat_ctx), - status_get_salts_percent (hashcat_ctx)); - event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx)); + event_log_info (hashcat_ctx, + "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", + hashcat_status->digests_done, + hashcat_status->digests_cnt, + hashcat_status->digests_percent, + hashcat_status->salts_done, + hashcat_status->salts_cnt, + hashcat_status->salts_percent); - for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) + event_log_info (hashcat_ctx, + "Recovered/Time.: %s", + hashcat_status->cpt); + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, - status_get_speed_sec_dev (hashcat_ctx, device_id), - status_get_exec_msec_dev (hashcat_ctx, device_id)); + if (device_info->skipped_dev == true) continue; + + event_log_info (hashcat_ctx, + "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, + device_info->speed_sec_dev, + device_info->exec_msec_dev); } - if (status_get_device_info_active (hashcat_ctx) > 1) + if (hashcat_status->device_info_active > 1) { - event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx)); + event_log_info (hashcat_ctx, + "Speed.Dev.#*...: %9sH/s", + hashcat_status->speed_sec_all); } if (user_options->gpu_temp_disable == false) { - for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - event_log_info (hashcat_ctx, "HWMon.Dev.#%d...: %s", device_id + 1, status_get_hwmon_dev (hashcat_ctx, device_id)); + if (device_info->skipped_dev == true) continue; + + event_log_info (hashcat_ctx, + "HWMon.Dev.#%d...: %s", device_id + 1, + device_info->hwmon_dev); } } + + hcfree (hashcat_status); } void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) @@ -788,35 +932,32 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) const u32 hash_mode = hashconfig->hash_mode; - for (int device_id = 0; device_id < status_get_device_info_cnt (hashcat_ctx); device_id++) - { - if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue; + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); - event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id) * 1000)); + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) + { + hcfree (hashcat_status); + + return; } + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; + + if (device_info->skipped_dev == true) continue; + + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (device_info->hashes_msec_dev_benchmark * 1000)); + } + + hcfree (hashcat_status); } void status_benchmark (hashcat_ctx_t *hashcat_ctx) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; - - if (status_ctx->devices_status == STATUS_INIT) - { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); - - return; - } - - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); - - return; - } - - if (status_ctx->shutdown_inner == 1) return; + const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->machine_readable == true) { @@ -825,83 +966,35 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) return; } - u64 speed_cnt[DEVICES_MAX] = { 0 }; - double speed_msec[DEVICES_MAX] = { 0 }; + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + hcfree (hashcat_status); - if (device_param->skipped) continue; - - speed_cnt[device_id] = device_param->speed_cnt[0]; - speed_msec[device_id] = device_param->speed_msec[0]; + return; } - double hashes_all_msec = 0; - - double hashes_dev_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - if (device_param->skipped) continue; + if (device_info->skipped_dev == true) continue; - hashes_dev_msec[device_id] = 0; - - if (speed_msec[device_id] > 0) - { - hashes_dev_msec[device_id] = (double) speed_cnt[device_id] / speed_msec[device_id]; - - hashes_all_msec += hashes_dev_msec[device_id]; - } + event_log_info (hashcat_ctx, + "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, + device_info->speed_sec_dev, + device_info->exec_msec_dev); } - /** - * exec time - */ - - double exec_all_msec[DEVICES_MAX] = { 0 }; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + if (hashcat_status->device_info_active > 1) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - double exec_msec_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - exec_all_msec[device_id] = exec_msec_avg; + event_log_info (hashcat_ctx, + "Speed.Dev.#*...: %9sH/s", + hashcat_status->speed_sec_all); } - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - char display_dev_cur[16] = { 0 }; - - strncpy (display_dev_cur, "0.00", 4); - - format_speed_display ((double) hashes_dev_msec[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - - if (opencl_ctx->devices_active >= 10) - { - event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_msec[device_id]); - } - else - { - event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_msec[device_id]); - } - } - - char display_all_cur[16] = { 0 }; - - strncpy (display_all_cur, "0.00", 4); - - format_speed_display ((double) hashes_all_msec * 1000, display_all_cur, sizeof (display_all_cur)); - - if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); + hcfree (hashcat_status); } From c3266e363a90e9320ee9611a79d769e996e69a1a Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 00:13:40 +0200 Subject: [PATCH 078/106] Make status_display_machine_readable() use of hashcat_status_t --- include/status.h | 1 + include/types.h | 3 +- src/hashcat.c | 3 +- src/status.c | 7 ++ src/terminal.c | 175 ++++++++++++----------------------------------- 5 files changed, 54 insertions(+), 135 deletions(-) diff --git a/include/status.h b/include/status.h index c4fb57b66..60f8dc16e 100644 --- a/include/status.h +++ b/include/status.h @@ -21,6 +21,7 @@ int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx) bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_session (const hashcat_ctx_t *hashcat_ctx); char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx); +int status_get_status_number (const 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); diff --git a/include/types.h b/include/types.h index 922c65f12..6d17babca 100644 --- a/include/types.h +++ b/include/types.h @@ -1500,7 +1500,8 @@ typedef struct char *input_charset; char *input_mod; char *session; - char *status; + char *status_string; + int status_number; char *time_estimated_absolute; char *time_estimated_relative; char *time_started_absolute; diff --git a/src/hashcat.c b/src/hashcat.c index 3a695229e..72cbeff64 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1189,7 +1189,8 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->salts_done = status_get_salts_done (hashcat_ctx); hashcat_status->salts_percent = status_get_salts_percent (hashcat_ctx); hashcat_status->session = status_get_session (hashcat_ctx); - hashcat_status->status = status_get_status_string (hashcat_ctx); + hashcat_status->status_string = status_get_status_string (hashcat_ctx); + hashcat_status->status_number = status_get_status_number (hashcat_ctx); hashcat_status->time_estimated_absolute = status_get_time_estimated_absolute (hashcat_ctx); hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx); hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx); diff --git a/src/status.c b/src/status.c index 9680362e6..febd2f8cd 100644 --- a/src/status.c +++ b/src/status.c @@ -207,6 +207,13 @@ char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) return ((char *) ST_9999); } +int status_get_status_number (const hashcat_ctx_t *hashcat_ctx) +{ + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + return status_ctx->devices_status; +} + char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; diff --git a/src/terminal.c b/src/terminal.c index 0d916cc08..c0e4c060d 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -448,167 +448,75 @@ int tty_fix() void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) { - combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - hashes_t *hashes = hashcat_ctx->hashes; - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + const user_options_t *user_options = hashcat_ctx->user_options; - if (status_ctx->devices_status == STATUS_INIT) + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t)); + + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) { - event_log_error (hashcat_ctx, "status view is not available during initialization phase"); + hcfree (hashcat_status); return; } - if (status_ctx->devices_status == STATUS_AUTOTUNE) - { - event_log_error (hashcat_ctx, "status view is not available during autotune phase"); + printf ("STATUS\t%u\t", hashcat_status->status_number); - return; + printf ("SPEED\t"); + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; + + if (device_info->skipped_dev == true) continue; + + // the 1\t is for backward compatibility + printf ("%" PRIu64 "\t1\t", (u64) device_info->hashes_msec_dev); } - FILE *out = stdout; + printf ("EXEC_RUNTIME\t"); - fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); - - /** - * speed new - */ - - fprintf (out, "SPEED\t"); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - if (device_param->skipped) continue; + if (device_info->skipped_dev == true) continue; - u64 speed_cnt = 0; - double speed_msec = 0; - - for (int i = 0; i < SPEED_CACHE; i++) - { - speed_cnt += device_param->speed_cnt[i]; - speed_msec += device_param->speed_msec[i]; - } - - speed_cnt /= SPEED_CACHE; - speed_msec /= SPEED_CACHE; - - fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_msec); + printf ("%f\t", device_info->exec_msec_dev); } - /** - * exec time - */ + printf ("CURKU\t%" PRIu64 "\t", hashcat_status->restore_point); - fprintf (out, "EXEC_RUNTIME\t"); + printf ("PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + printf ("RECHASH\t%u\t%u\t", hashcat_status->digests_done, hashcat_status->digests_cnt); - if (device_param->skipped) continue; - - const double exec_msec_avg = get_avg_exec_time (device_param, EXEC_CACHE); - - fprintf (out, "%f\t", exec_msec_avg); - } - - /** - * words_cur - */ - - u64 words_cur = get_lowest_words_done (hashcat_ctx); - - fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); - - /** - * counter - */ - - u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt; - - u64 all_done = 0; - u64 all_rejected = 0; - u64 all_restored = 0; - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - all_done += status_ctx->words_progress_done[salt_pos]; - all_rejected += status_ctx->words_progress_rejected[salt_pos]; - all_restored += status_ctx->words_progress_restored[salt_pos]; - } - - u64 progress_cur = all_restored + all_done + all_rejected; - u64 progress_end = progress_total; - - u64 progress_skip = 0; - - if (user_options->skip) - { - progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt; - } - - if (user_options->limit) - { - progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt; - } - - u64 progress_cur_relative_skip = progress_cur - progress_skip; - u64 progress_end_relative_skip = progress_end - progress_skip; - - fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); - - /** - * cracks - */ - - fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); - fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt); - - /** - * temperature - */ + printf ("RECSALT\t%u\t%u\t", hashcat_status->salts_done, hashcat_status->salts_cnt); if (user_options->gpu_temp_disable == false) { - fprintf (out, "TEMP\t"); + printf ("TEMP\t"); - hc_thread_mutex_lock (status_ctx->mux_hwmon); - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; - if (device_param->skipped) continue; + if (device_info->skipped_dev == true) continue; - int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); + // ok, little cheat here... - fprintf (out, "%d\t", temp); + const int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); + + printf ("%d\t", temp); } - - hc_thread_mutex_unlock (status_ctx->mux_hwmon); } - /** - * flush - */ + printf (EOL); - fputs (EOL, out); - fflush (out); + fflush (stdout); + + hcfree (hashcat_status); } void status_display (hashcat_ctx_t *hashcat_ctx) @@ -642,8 +550,9 @@ void status_display (hashcat_ctx_t *hashcat_ctx) hashcat_status->session); event_log_info (hashcat_ctx, - "Status.........: %s", - hashcat_status->status); + "Status.........: %s (%u)", + hashcat_status->status_string, + hashcat_status->status_number); event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", From 54e5e6c2d0945ab6c466ec757bef97fd7b622011 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 00:15:25 +0200 Subject: [PATCH 079/106] Make some backward compatibility code more visible --- src/terminal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index c0e4c060d..13a771605 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -471,8 +471,10 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; - // the 1\t is for backward compatibility - printf ("%" PRIu64 "\t1\t", (u64) device_info->hashes_msec_dev); + printf ("%" PRIu64 "\t", (u64) device_info->hashes_msec_dev); + + // that 1\t is for backward compatibility + printf ("1\t"); } printf ("EXEC_RUNTIME\t"); From 08d52cc1d3b9bfad27b37940f8291edcdfe4f028 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 00:27:15 +0200 Subject: [PATCH 080/106] Go back to original status view attribute ordering --- src/main_shared.c | 2 +- src/terminal.c | 71 +++++++++++++++++++++++------------------------ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/main_shared.c b/src/main_shared.c index 7312b94d4..986aee4ec 100644 --- a/src/main_shared.c +++ b/src/main_shared.c @@ -78,7 +78,7 @@ int main () const int rc = hashcat_get_status (hashcat_ctx, &hashcat_status); printf ("Session: %s\n", hashcat_status.session); - printf ("Status: %s\n", hashcat_status.status); + printf ("Status: %s\n", hashcat_status.status_string); if (rc == 0) { diff --git a/src/terminal.c b/src/terminal.c index 13a771605..c09f953e5 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -552,9 +552,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) hashcat_status->session); event_log_info (hashcat_ctx, - "Status.........: %s (%u)", - hashcat_status->status_string, - hashcat_status->status_number); + "Status.........: %s", + hashcat_status->status_string); + + event_log_info (hashcat_ctx, + "Hash.Type......: %s", + hashcat_status->hash_type); + + event_log_info (hashcat_ctx, + "Hash.Target....: %s", + hashcat_status->hash_target); event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", @@ -566,14 +573,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) hashcat_status->time_estimated_absolute, hashcat_status->time_estimated_relative); - event_log_info (hashcat_ctx, - "Hash.Type......: %s", - hashcat_status->hash_type); - - event_log_info (hashcat_ctx, - "Hash.Target....: %s", - hashcat_status->hash_target); - switch (hashcat_status->input_mode) { case INPUT_MODE_STRAIGHT_FILE: @@ -743,10 +742,31 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Candidates.#%d..: %s", device_id + 1, - device_info->input_candidates_dev); + "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, + device_info->speed_sec_dev, + device_info->exec_msec_dev); } + if (hashcat_status->device_info_active > 1) + { + event_log_info (hashcat_ctx, + "Speed.Dev.#*...: %9sH/s", + hashcat_status->speed_sec_all); + } + + event_log_info (hashcat_ctx, + "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", + hashcat_status->digests_done, + hashcat_status->digests_cnt, + hashcat_status->digests_percent, + hashcat_status->salts_done, + hashcat_status->salts_cnt, + hashcat_status->salts_percent); + + event_log_info (hashcat_ctx, + "Recovered/Time.: %s", + hashcat_status->cpt); + switch (hashcat_status->progress_mode) { case PROGRESS_MODE_KEYSPACE_KNOWN: @@ -788,19 +808,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) break; } - event_log_info (hashcat_ctx, - "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", - hashcat_status->digests_done, - hashcat_status->digests_cnt, - hashcat_status->digests_percent, - hashcat_status->salts_done, - hashcat_status->salts_cnt, - hashcat_status->salts_percent); - - event_log_info (hashcat_ctx, - "Recovered/Time.: %s", - hashcat_status->cpt); - for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -808,16 +815,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, - device_info->speed_sec_dev, - device_info->exec_msec_dev); - } - - if (hashcat_status->device_info_active > 1) - { - event_log_info (hashcat_ctx, - "Speed.Dev.#*...: %9sH/s", - hashcat_status->speed_sec_all); + "Candidates.#%d..: %s", device_id + 1, + device_info->input_candidates_dev); } if (user_options->gpu_temp_disable == false) From 2005f5d193159d167270171002a0f95220bc30bd Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 00:41:24 +0200 Subject: [PATCH 081/106] Remove terminal.h where's it's not needed --- src/autotune.c | 1 - src/dispatch.c | 1 - src/opencl.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index cf68c14e5..4219617ff 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -8,7 +8,6 @@ #include "event.h" #include "opencl.h" #include "status.h" -#include "terminal.h" #include "autotune.h" static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kernel_accel, const u32 kernel_loops) diff --git a/src/dispatch.c b/src/dispatch.c index d8894f444..5f5b92c79 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -21,7 +21,6 @@ #include "restore.h" #include "hashes.h" #include "rp_cpu.h" -#include "terminal.h" #include "mpsp.h" #include "outfile.h" #include "potfile.h" diff --git a/src/opencl.c b/src/opencl.c index 3e9a27643..c77e3d9b2 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -11,7 +11,6 @@ #include "timer.h" #include "tuningdb.h" #include "rp_cpu.h" -#include "terminal.h" #include "mpsp.h" #include "straight.h" #include "combinator.h" From 1f72aa95e60a13b6a48f285102ca388cb4c146d8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 00:50:54 +0200 Subject: [PATCH 082/106] Destinguish between EVENT_POTFILE_HASH_CRACKED and EVENT_CRACKER_HASH_CRACKED for prompt handling --- include/types.h | 5 +++-- src/hashes.c | 20 ++------------------ src/main.c | 29 ++++++++++++++++++++++++++++- src/potfile.c | 8 ++++---- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/include/types.h b/include/types.h index 6d17babca..59b6080ff 100644 --- a/include/types.h +++ b/include/types.h @@ -105,8 +105,9 @@ typedef enum event_identifier EVENT_CRACKER_HASH_CRACKED = 0x00000058, EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061, EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062, - EVENT_POTFILE_NUM_CRACKED = 0x00000063, - EVENT_POTFILE_ALL_CRACKED = 0x00000064, + EVENT_POTFILE_HASH_CRACKED = 0x00000063, + EVENT_POTFILE_NUM_CRACKED = 0x00000064, + EVENT_POTFILE_ALL_CRACKED = 0x00000065, EVENT_OPENCL_SESSION_PRE = 0x00000071, EVENT_OPENCL_SESSION_POST = 0x00000072, EVENT_BITMAP_INIT_PRE = 0x00000081, diff --git a/src/hashes.c b/src/hashes.c index 832a979fc..1e4c1c092 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -21,7 +21,6 @@ #include "potfile.h" #include "rp.h" #include "rp_kernel_on_cpu.h" -#include "terminal.h" #include "thread.h" #include "timer.h" @@ -219,12 +218,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain) { - debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; - loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; - outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_t *user_options = hashcat_ctx->user_options; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; + loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; const u32 salt_pos = plain->salt_pos; const u32 digest_pos = plain->digest_pos; // relative @@ -270,8 +265,6 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl outfile_write_open (hashcat_ctx); - if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (); - char tmp_buf[HCBUFSIZ_LARGE]; const int tmp_len = outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, tmp_buf); @@ -280,17 +273,8 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); - if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) - { - if ((status_ctx->devices_status != STATUS_CRACKED) && (user_options->status != true)) - { - if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt (); - } - } - // if enabled, update also the loopback file - if (loopback_ctx->fp != NULL) { loopback_write_append (hashcat_ctx, plain_ptr, plain_len); diff --git a/src/main.c b/src/main.c index 6c9c8a3d7..97e8e3120 100644 --- a/src/main.c +++ b/src/main.c @@ -292,12 +292,28 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { - outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (); + } + fwrite (buf, len, 1, stdout); fwrite (EOL, strlen (EOL), 1, stdout); + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (status_ctx->devices_status != STATUS_CRACKED) + { + if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt (); + } + } } static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -328,6 +344,16 @@ static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); } +static void main_potfile_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + + if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile + + fwrite (buf, len, 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); +} + static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -532,6 +558,7 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break; case EVENT_POTFILE_REMOVE_PARSE_PRE: main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; case EVENT_POTFILE_REMOVE_PARSE_POST: main_potfile_remove_parse_post (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_HASH_CRACKED: main_potfile_hash_cracked (hashcat_ctx, buf, len); break; case EVENT_POTFILE_NUM_CRACKED: main_potfile_num_cracked (hashcat_ctx, buf, len); break; case EVENT_POTFILE_ALL_CRACKED: main_potfile_all_cracked (hashcat_ctx, buf, len); break; case EVENT_OPENCL_SESSION_PRE: main_opencl_session_pre (hashcat_ctx, buf, len); break; diff --git a/src/potfile.c b/src/potfile.c index 9dd4a9352..a7a2ad8fb 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -529,7 +529,7 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu const int tmp_len = outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, tmp_buf); - EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); } } @@ -556,7 +556,7 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu const int tmp_len = outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0, tmp_buf); - EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); } } @@ -685,7 +685,7 @@ int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in const int tmp_len = outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, tmp_buf); - EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); if (weak_hash_found == 1) hcfree (pot_right_ptr); @@ -777,7 +777,7 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in const int tmp_len = outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0, tmp_buf); - EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); hcfree (hash_output); From 0fd48b228fc49004c79e996221a50c510ed6c03a Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 01:24:03 +0200 Subject: [PATCH 083/106] Get rid of all event_log_* calls in monitor.c and replace them with real events --- include/types.h | 6 +++ src/main.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++ src/monitor.c | 41 +++------------ 3 files changed, 147 insertions(+), 34 deletions(-) diff --git a/include/types.h b/include/types.h index 59b6080ff..fd28d04b9 100644 --- a/include/types.h +++ b/include/types.h @@ -115,6 +115,12 @@ typedef enum event_identifier EVENT_WEAK_HASH_PRE = 0x00000091, EVENT_WEAK_HASH_POST = 0x00000092, EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1, + EVENT_MONITOR_THROTTLE1 = 0x000000b1, + EVENT_MONITOR_THROTTLE2 = 0x000000b2, + EVENT_MONITOR_THROTTLE3 = 0x000000b3, + EVENT_MONITOR_TEMP_ABORT = 0x000000c1, + EVENT_MONITOR_RUNTIME_LIMIT = 0x000000d1, + EVENT_MONITOR_STATUS_REFRESH = 0x000000e1, // there will be much more event types soon diff --git a/src/main.c b/src/main.c index 97e8e3120..0ba8ad4a4 100644 --- a/src/main.c +++ b/src/main.c @@ -540,6 +540,134 @@ static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx send_prompt (); } +static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + clear_prompt (); + } + + u32 *device_id = (u32 *) buf; + + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1); + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + send_prompt (); + } +} + +static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + clear_prompt (); + } + + u32 *device_id = (u32 *) buf; + + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1); + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + send_prompt (); + } +} + +static void main_monitor_throttle3 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + clear_prompt (); + } + + u32 *device_id = (u32 *) buf; + + event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1); + event_log_warning (hashcat_ctx, ""); + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + send_prompt (); + } +} + +static void main_monitor_temp_abort (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + clear_prompt (); + } + + u32 *device_id = (u32 *) buf; + + event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", *device_id + 1); +} + +static void main_monitor_runtime_limit (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options->quiet == true) return; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + clear_prompt (); + } + + event_log_warning (hashcat_ctx, "Runtime limit reached, aborting..."); +} + +static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (user_options->quiet == false) + { + //clear_prompt (); + + event_log_info (hashcat_ctx, ""); + event_log_info (hashcat_ctx, ""); + } + } + + status_display (hashcat_ctx); + + if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) + { + if (user_options->quiet == false) + { + event_log_info (hashcat_ctx, ""); + + send_prompt (); + } + } +} + void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len) { switch (id) @@ -568,6 +696,12 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break; case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break; case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_THROTTLE1: main_monitor_throttle1 (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_THROTTLE2: main_monitor_throttle2 (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_THROTTLE3: main_monitor_throttle3 (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_TEMP_ABORT: main_monitor_temp_abort (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_RUNTIME_LIMIT: main_monitor_runtime_limit (hashcat_ctx, buf, len); break; + case EVENT_MONITOR_STATUS_REFRESH: main_monitor_status_refresh (hashcat_ctx, buf, len); break; } } diff --git a/src/monitor.c b/src/monitor.c index f52ded01b..1fe99ca73 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -12,8 +12,6 @@ #include "hashes.h" #include "thread.h" #include "restore.h" -#include "terminal.h" -#include "status.h" #include "shared.h" #include "monitor.h" @@ -131,21 +129,11 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (rc_throttle > 0) { - if (slowdown_warnings < 3) - { - if (user_options->quiet == false) clear_prompt (); + slowdown_warnings++; - event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1); - - if (slowdown_warnings == 2) - { - event_log_info (hashcat_ctx, ""); - } - - if (user_options->quiet == false) send_prompt (); - - slowdown_warnings++; - } + if (slowdown_warnings == 1) EVENT_DATA (EVENT_MONITOR_THROTTLE1, &device_id, sizeof (u32)); + if (slowdown_warnings == 2) EVENT_DATA (EVENT_MONITOR_THROTTLE2, &device_id, sizeof (u32)); + if (slowdown_warnings == 3) EVENT_DATA (EVENT_MONITOR_THROTTLE3, &device_id, sizeof (u32)); } else { @@ -180,13 +168,9 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (temperature > (int) user_options->gpu_temp_abort) { - if (user_options->quiet == false) clear_prompt (); - - event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", device_id + 1); + EVENT_DATA (EVENT_MONITOR_TEMP_ABORT, &device_id, sizeof (u32)); myabort (hashcat_ctx); - - break; } const u32 gpu_temp_retain = user_options->gpu_temp_retain; @@ -281,12 +265,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) if (runtime_left <= 0) { - if (user_options->benchmark == false) - { - if (user_options->quiet == false) clear_prompt (); - - if (user_options->quiet == false) event_log_info (hashcat_ctx, "NOTE: Runtime limit reached, aborting..."); - } + EVENT_DATA (EVENT_MONITOR_RUNTIME_LIMIT, NULL, 0); myabort (hashcat_ctx); } @@ -319,13 +298,7 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) { hc_thread_mutex_lock (status_ctx->mux_display); - if (user_options->quiet == false) clear_prompt (); - - status_display (hashcat_ctx); - - if (user_options->quiet == false) event_log_info (hashcat_ctx, ""); - - if (user_options->quiet == false) send_prompt (); + EVENT_DATA (EVENT_MONITOR_STATUS_REFRESH, NULL, 0); hc_thread_mutex_unlock (status_ctx->mux_display); From f6334b5f90b24bf30773587917cd118360ec0c9d Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 20:42:34 +0200 Subject: [PATCH 084/106] Handling --show and --left need to be refactored, do not use those flags atm --- include/hashes.h | 1 + include/potfile.h | 14 +-- include/types.h | 6 -- src/hashcat.c | 111 +++++++++++----------- src/hashes.c | 235 ++++++++++++++++++++-------------------------- src/potfile.c | 135 ++++++++++---------------- 6 files changed, 214 insertions(+), 288 deletions(-) diff --git a/include/hashes.h b/include/hashes.h index 79219b38c..2c0564aa2 100644 --- a/include/hashes.h +++ b/include/hashes.h @@ -20,6 +20,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx); int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx); int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx); +int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx); void hashes_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/potfile.h b/include/potfile.h index 85ba9ca1f..d2f5260e5 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -22,18 +22,18 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size int potfile_init (hashcat_ctx_t *hashcat_ctx); int potfile_read_open (hashcat_ctx_t *hashcat_ctx); -int potfile_read_parse (hashcat_ctx_t *hashcat_ctx); +//int potfile_read_parse (hashcat_ctx_t *hashcat_ctx); void potfile_read_close (hashcat_ctx_t *hashcat_ctx); int potfile_write_open (hashcat_ctx_t *hashcat_ctx); void potfile_write_close (hashcat_ctx_t *hashcat_ctx); void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len); -int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num); -void potfile_hash_free (hashcat_ctx_t *hashcat_ctx); -void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); -void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); -int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); -int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); +//void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); +//void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); +//int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); +//int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); void potfile_destroy (hashcat_ctx_t *hashcat_ctx); +int potfile_handle_show (hashcat_ctx_t *hashcat_ctx); +int potfile_handle_left (hashcat_ctx_t *hashcat_ctx); #endif // _POTFILE_H diff --git a/include/types.h b/include/types.h index fd28d04b9..0b57d336f 100644 --- a/include/types.h +++ b/include/types.h @@ -989,12 +989,6 @@ typedef struct potfile_ctx FILE *fp; char *filename; - pot_t *pot; - - u32 pot_cnt; - u32 pot_avail; - u32 pot_hashes_avail; - } potfile_ctx_t; typedef struct restore_data diff --git a/src/hashcat.c b/src/hashcat.c index 72cbeff64..849b3a951 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -395,23 +395,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (rc_hashconfig == -1) return -1; - /** - * potfile show/left depends on hash_mode, so it's called here first time - */ - - if (user_options->show == true || user_options->left == true) - { - outfile_write_open (hashcat_ctx); - - potfile_read_open (hashcat_ctx); - - const int rc = potfile_read_parse (hashcat_ctx); - - if (rc == -1) return -1; - - potfile_read_close (hashcat_ctx); - } - /** * load hashes, stage 1 */ @@ -430,32 +413,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) } } - /** - * potfile show/left final - */ - - if (user_options->show == true || user_options->left == true) - { - outfile_write_close (hashcat_ctx); - - potfile_hash_free (hashcat_ctx); - - return 0; - } - - /** - * potfile removes - */ - - if (user_options->potfile_disable == 0) - { - EVENT (EVENT_POTFILE_REMOVE_PARSE_PRE); - - potfile_remove_parse (hashcat_ctx); - - EVENT (EVENT_POTFILE_REMOVE_PARSE_POST); - } - /** * load hashes, stage 2, remove duplicates, build base structure */ @@ -467,29 +424,77 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (rc_hashes_init_stage2 == -1) return -1; /** - * load hashes, stage 2: at this point we can check for all hashes cracked (by potfile) + * potfile removes + */ + + if (user_options->potfile_disable == false) + { + EVENT (EVENT_POTFILE_REMOVE_PARSE_PRE); + + potfile_remove_parse (hashcat_ctx); + + EVENT (EVENT_POTFILE_REMOVE_PARSE_POST); + } + + /** + * load hashes, stage 3, update cracked results from potfile + */ + + const int rc_hashes_init_stage3 = hashes_init_stage3 (hashcat_ctx); + + if (rc_hashes_init_stage3 == -1) return -1; + + /** + * potfile show/left handling + */ + + if (user_options->show == true) + { + outfile_write_open (hashcat_ctx); + + const int rc = potfile_handle_show (hashcat_ctx); + + if (rc == -1) return -1; + + outfile_write_close (hashcat_ctx); + + return 0; + } + else if (user_options->left == true) + { + outfile_write_open (hashcat_ctx); + + const int rc = potfile_handle_left (hashcat_ctx); + + if (rc == -1) return -1; + + outfile_write_close (hashcat_ctx); + + return 0; + } + + /** + * maybe all hashes were cracked, we can exit here */ if (status_ctx->devices_status == STATUS_CRACKED) { EVENT (EVENT_POTFILE_ALL_CRACKED); - hashes_destroy (hashcat_ctx); - - hashconfig_destroy (hashcat_ctx); - - potfile_destroy (hashcat_ctx); - return 0; } /** - * load hashes, stage 3, automatic Optimizers + * load hashes, stage 4, automatic Optimizers */ - const int rc_hashes_init_stage3 = hashes_init_stage3 (hashcat_ctx); + const int rc_hashes_init_stage4 = hashes_init_stage4 (hashcat_ctx); - if (rc_hashes_init_stage3 == -1) return -1; + if (rc_hashes_init_stage4 == -1) return -1; + + /** + * Done loading hashes, log results + */ hashes_logger (hashcat_ctx); diff --git a/src/hashes.c b/src/hashes.c index 1e4c1c092..cc481c373 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -726,50 +726,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) continue; } - // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2) - - if ((user_options->show == true) || (user_options->left == true)) - { - salt_t *tmp_salt = hashes_buf[hashes_cnt].salt; - - char *salt_ptr = (char *) tmp_salt->salt_buf; - - int cur_pos = tmp_salt->salt_len; - int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos; - - wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt; - - // do the appending task - - snprintf (salt_ptr + cur_pos, - rem_len, - ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x", - wpa->orig_mac1[0], - wpa->orig_mac1[1], - wpa->orig_mac1[2], - wpa->orig_mac1[3], - wpa->orig_mac1[4], - wpa->orig_mac1[5], - wpa->orig_mac2[0], - wpa->orig_mac2[1], - wpa->orig_mac2[2], - wpa->orig_mac2[3], - wpa->orig_mac2[4], - wpa->orig_mac2[5]); - - // memset () the remaining part of the salt - - cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12; - rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos; - - if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len); - - tmp_salt->salt_len += 1 + 12 + 1 + 12; - } - - if (user_options->show == true) potfile_show_request (hashcat_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf); - if (user_options->left == true) potfile_left_request (hashcat_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf); - hashes_cnt++; } @@ -783,12 +739,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { parser_status = hashconfig->parse_func (hash_buf, 16, &hashes_buf[hashes_cnt], hashconfig); - hash_t *lm_hash_left = NULL; - if (parser_status == PARSER_OK) { - lm_hash_left = &hashes_buf[hashes_cnt]; - hashes_cnt++; } else @@ -798,37 +750,19 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) parser_status = hashconfig->parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig); - hash_t *lm_hash_right = NULL; - if (parser_status == PARSER_OK) { - lm_hash_right = &hashes_buf[hashes_cnt]; - hashes_cnt++; } else { event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } - - // show / left - - if ((lm_hash_left != NULL) && (lm_hash_right != NULL)) - { - if (user_options->show == true) potfile_show_request_lm (hashcat_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot); - if (user_options->left == true) potfile_left_request_lm (hashcat_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot); - } } else { parser_status = hashconfig->parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt], hashconfig); - if (parser_status == PARSER_OK) - { - if (user_options->show == true) potfile_show_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); - if (user_options->left == true) potfile_left_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); - } - if (parser_status == PARSER_OK) { hashes_cnt++; @@ -843,12 +777,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { parser_status = hashconfig->parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt], hashconfig); - if (parser_status == PARSER_OK) - { - if (user_options->show == true) potfile_show_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); - if (user_options->left == true) potfile_left_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); - } - if (parser_status == PARSER_OK) { hashes_cnt++; @@ -955,8 +883,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) continue; } - hash_t *lm_hash_left = &hashes_buf[hashes_cnt]; - hashes_cnt++; parser_status = hashconfig->parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig); @@ -968,16 +894,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) continue; } - hash_t *lm_hash_right = &hashes_buf[hashes_cnt]; - if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); hashes_cnt++; - - // show / left - - if (user_options->show == true) potfile_show_request_lm (hashcat_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot); - if (user_options->left == true) potfile_left_request_lm (hashcat_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot); } else { @@ -992,9 +911,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); - if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); - if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); - hashes_cnt++; } } @@ -1011,9 +927,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); - if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); - if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); - hashes_cnt++; } } @@ -1062,9 +975,9 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Removing duplicate hashes..."); - hashes_cnt = 1; + u32 hashes_cnt_new = 1; - for (u32 hashes_pos = 1; hashes_pos < hashes->hashes_cnt; hashes_pos++) + for (u32 hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++) { if (hashconfig->is_salted) { @@ -1078,14 +991,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest, (void *) hashconfig) == 0) continue; } - if (hashes_pos > hashes_cnt) - { - memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t)); - } + hash_t tmp; - hashes_cnt++; + memcpy (&tmp, &hashes_buf[hashes_pos], sizeof (hash_t)); + + memcpy (&hashes_buf[hashes_cnt_new], &tmp, sizeof (hash_t)); + + hashes_cnt_new++; } + for (u32 i = hashes_cnt_new; i < hashes->hashes_cnt; i++) + { + memset (&hashes_buf[i], 0, sizeof (hash_t)); + } + + hashes_cnt = hashes_cnt_new; + hashes->hashes_cnt = hashes_cnt; /** @@ -1133,7 +1054,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) for (user_pos = 0; user_pos < hashes_cnt; user_pos++) { - hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]); + hash_info[user_pos] = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]); hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info[user_pos]->user); } @@ -1151,9 +1072,15 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t)); + hashes_buf[0].salt = salt_buf; + if (hashconfig->esalt_size) { - memcpy (((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size), hashes_buf[0].esalt, hashconfig->esalt_size); + char *esalts_buf_new_ptr = ((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size); + + memcpy (esalts_buf_new_ptr, hashes_buf[0].esalt, hashconfig->esalt_size); + + hashes_buf[0].esalt = esalts_buf_new_ptr; } salt_buf->digests_cnt = 0; @@ -1163,18 +1090,13 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) salts_cnt++; } - if (hashes_buf[0].cracked == 1) - { - digests_shown[0] = 1; - - digests_done++; - - salt_buf->digests_done++; - } - salt_buf->digests_cnt++; - memcpy (((char *) digests_buf_new) + (0 * hashconfig->dgst_size), hashes_buf[0].digest, hashconfig->dgst_size); + char *digests_buf_new_ptr = ((char *) digests_buf_new) + (0 * hashconfig->dgst_size); + + memcpy (digests_buf_new_ptr, hashes_buf[0].digest, hashconfig->dgst_size); + + hashes_buf[0].digest = digests_buf_new_ptr; if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -1193,9 +1115,15 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t)); + hashes_buf[hashes_pos].salt = salt_buf; + if (hashconfig->esalt_size) { - memcpy (((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size), hashes_buf[hashes_pos].esalt, hashconfig->esalt_size); + char *esalts_buf_new_ptr = ((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size); + + memcpy (esalts_buf_new_ptr, hashes_buf[hashes_pos].esalt, hashconfig->esalt_size); + + hashes_buf[hashes_pos].esalt = esalts_buf_new_ptr; } salt_buf->digests_cnt = 0; @@ -1206,18 +1134,13 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) } } - if (hashes_buf[hashes_pos].cracked == 1) - { - digests_shown[hashes_pos] = 1; - - digests_done++; - - salt_buf->digests_done++; - } - salt_buf->digests_cnt++; - memcpy (((char *) digests_buf_new) + (hashes_pos * hashconfig->dgst_size), hashes_buf[hashes_pos].digest, hashconfig->dgst_size); + digests_buf_new_ptr = ((char *) digests_buf_new) + (hashes_pos * hashconfig->dgst_size); + + memcpy (digests_buf_new_ptr, hashes_buf[hashes_pos].digest, hashconfig->dgst_size); + + hashes_buf[hashes_pos].digest = digests_buf_new_ptr; if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { @@ -1225,24 +1148,9 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) } } - for (u32 salt_pos = 0; salt_pos < salts_cnt; salt_pos++) - { - salt_t *salt_buf = &salts_buf_new[salt_pos]; - - if (salt_buf->digests_done == salt_buf->digests_cnt) - { - salts_shown[salt_pos] = 1; - - salts_done++; - } - - if (salts_done == salts_cnt) mycracked (hashcat_ctx); - } - hcfree (hashes->digests_buf); hcfree (hashes->salts_buf); hcfree (hashes->esalts_buf); - hcfree (hashes->hashes_buf); hashes->digests_cnt = digests_cnt; hashes->digests_done = digests_done; @@ -1257,15 +1165,72 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) hashes->esalts_buf = esalts_buf_new; - hashes->hashes_cnt = 0; - hashes->hashes_buf = NULL; - hashes->hash_info = hash_info; return 0; } int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx) +{ + hashes_t *hashes = hashcat_ctx->hashes; + + u32 digests_done = hashes->digests_done; + u32 *digests_shown = hashes->digests_shown; + + u32 salts_cnt = hashes->salts_cnt; + u32 salts_done = hashes->salts_done; + u32 *salts_shown = hashes->salts_shown; + + hash_t *hashes_buf = hashes->hashes_buf; + + salt_t *salts_buf = hashes->salts_buf; + + for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++) + { + salt_t *salt_buf = salts_buf + salt_idx; + + u32 digests_cnt = salt_buf->digests_cnt; + + for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++) + { + const u32 hashes_idx = salt_buf->digests_offset + digest_idx; + + if (hashes_buf[hashes_idx].cracked == 1) + { + digests_shown[hashes_idx] = 1; + + digests_done++; + + salt_buf->digests_done++; + } + } + + if (salt_buf->digests_done == salt_buf->digests_cnt) + { + salts_shown[salt_idx] = 1; + + salts_done++; + } + + if (salts_done == salts_cnt) mycracked (hashcat_ctx); + } + + hashes->digests_done = digests_done; + + hashes->salts_cnt = salts_cnt; + hashes->salts_done = salts_done; + + // at this point we no longer need hash_t* structure + + hcfree (hashes_buf); + + hashes->hashes_cnt = 0; + hashes->hashes_buf = NULL; + + return 0; +} + +int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; diff --git a/src/potfile.c b/src/potfile.c index a7a2ad8fb..870509de8 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -182,11 +182,6 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) potfile_write_close (hashcat_ctx); - potfile_ctx->pot = NULL; - potfile_ctx->pot_cnt = 0; - potfile_ctx->pot_avail = 0; - potfile_ctx->pot_hashes_avail = 0; - return 0; } @@ -209,7 +204,7 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->fp == NULL) { - //log_error ("%s: %s", potfile_ctx->filename, strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno)); return -1; } @@ -217,6 +212,18 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) return 0; } +void potfile_read_close (hashcat_ctx_t *hashcat_ctx) +{ + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + + if (potfile_ctx->enabled == false) return; + + if (potfile_ctx->fp == NULL) return; + + fclose (potfile_ctx->fp); +} + +/* int potfile_read_parse (hashcat_ctx_t *hashcat_ctx) { potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; @@ -330,17 +337,7 @@ int potfile_read_parse (hashcat_ctx_t *hashcat_ctx) return 0; } - -void potfile_read_close (hashcat_ctx_t *hashcat_ctx) -{ - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return; - - if (potfile_ctx->fp == NULL) return; - - fclose (potfile_ctx->fp); -} +*/ int potfile_write_open (hashcat_ctx_t *hashcat_ctx) { @@ -423,70 +420,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * fflush (potfile_ctx->fp); } -int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num) -{ - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - if (potfile_ctx->enabled == false) return 0; - - u32 pos = 0; - - for (pos = 0; pos < num; pos++) - { - if ((potfile_ctx->pot_cnt + pos) >= potfile_ctx->pot_avail) break; - - pot_t *tmp_pot = &potfile_ctx->pot[potfile_ctx->pot_cnt + pos]; - - hash_t *tmp_hash = &tmp_pot->hash; - - tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (tmp_hash->digest); - - if (hashconfig->is_salted) - { - tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (tmp_hash->salt); - } - - if (hashconfig->esalt_size) - { - tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (tmp_hash->esalt); - } - - potfile_ctx->pot_hashes_avail++; - } - - return 0; -} - -void potfile_hash_free (hashcat_ctx_t *hashcat_ctx) -{ - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - if (potfile_ctx->enabled == false) return; - - for (u32 i = 0; i < potfile_ctx->pot_cnt; i++) - { - pot_t *pot_ptr = &potfile_ctx->pot[i]; - - hash_t *hashes_buf = &pot_ptr->hash; - - hcfree (hashes_buf->digest); - - if (hashconfig->is_salted) - { - hcfree (hashes_buf->salt); - } - - if (hashconfig->esalt_size) - { - hcfree (hashes_buf->esalt); - } - } - - hcfree (potfile_ctx->pot); -} - +/* void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -499,7 +433,9 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu pot_key.hash.salt = hashes_buf->salt; pot_key.hash.digest = hashes_buf->digest; - pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_ptr = NULL; if (pot_ptr) { @@ -544,7 +480,9 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t)); - pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_ptr = NULL; if (pot_ptr == NULL) { @@ -574,7 +512,9 @@ int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in pot_left_key.hash.salt = hash_left->salt; pot_left_key.hash.digest = hash_left->digest; - pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_left_ptr = NULL; // right @@ -585,7 +525,9 @@ int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in pot_right_key.hash.salt = hash_right->salt; pot_right_key.hash.digest = hash_right->digest; - pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_right_ptr = NULL; if (pot_right_ptr == NULL) { @@ -708,7 +650,9 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in memcpy (&pot_left_key.hash, hash_left, sizeof (hash_t)); - pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_left_ptr = NULL; // right @@ -716,7 +660,9 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in memcpy (&pot_right_key.hash, hash_right, sizeof (hash_t)); - pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + //pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); + + pot_t *pot_right_ptr = NULL; u32 weak_hash_found = 0; @@ -785,6 +731,7 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in return 0; } +*/ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) { @@ -991,3 +938,17 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) return 0; } + + +int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) +{ + + return 0; +} + +int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) +{ + + + return 0; +} From edefcdbaaa9c6b2bff6a63ddb646a279b7d68dbe Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 21:03:16 +0200 Subject: [PATCH 085/106] Rudimentary --left support is back --- src/potfile.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/potfile.c b/src/potfile.c index 870509de8..97ec8ab91 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -948,7 +948,38 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) { + hashes_t *hashes = hashcat_ctx->hashes; + u32 salts_cnt = hashes->salts_cnt; + salt_t *salts_buf = hashes->salts_buf; + + for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++) + { + salt_t *salt_buf = salts_buf + salt_idx; + + u32 digests_cnt = salt_buf->digests_cnt; + + for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++) + { + const u32 hashes_idx = salt_buf->digests_offset + digest_idx; + + u32 *digests_shown = hashes->digests_shown; + + if (digests_shown[hashes_idx] == 1) continue; + + char out_buf[HCBUFSIZ_LARGE]; // scratch buffer + + out_buf[0] = 0; + + ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx); + + char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer + + const int tmp_len = outfile_write (hashcat_ctx, out_buf, NULL, 0, 0, NULL, 0, tmp_buf); + + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); + } + } return 0; } From 9b2c69a00d81e8263489277a841eb7d369090097 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 18 Oct 2016 21:04:40 +0200 Subject: [PATCH 086/106] Bring error in case someone uses --show --- src/potfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/potfile.c b/src/potfile.c index 97ec8ab91..daedbb285 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -942,6 +942,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) { + event_log_error (hashcat_ctx, "The --show feature is currently not available"); return 0; } From f5a92900c6a0b032e73472017a909d4ee4bc18dd Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Oct 2016 11:55:43 +0200 Subject: [PATCH 087/106] Rudimentary --show support is back --- include/types.h | 2 ++ src/hashes.c | 16 ++++++++------ src/outfile_check.c | 2 +- src/potfile.c | 54 +++++++++++++++++++++++++++++++++++++++------ 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/include/types.h b/include/types.h index 0b57d336f..89aa1cf44 100644 --- a/include/types.h +++ b/include/types.h @@ -476,6 +476,8 @@ typedef struct hash void *esalt; int cracked; hashinfo_t *hash_info; + char *pw_buf; + int pw_len; } hash_t; diff --git a/src/hashes.c b/src/hashes.c index cc481c373..04c9f6801 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1220,13 +1220,6 @@ int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx) hashes->salts_cnt = salts_cnt; hashes->salts_done = salts_done; - // at this point we no longer need hash_t* structure - - hcfree (hashes_buf); - - hashes->hashes_cnt = 0; - hashes->hashes_buf = NULL; - return 0; } @@ -1279,6 +1272,15 @@ int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx) } } + // at this point we no longer need hash_t* structure + + hash_t *hashes_buf = hashes->hashes_buf; + + hcfree (hashes_buf); + + hashes->hashes_cnt = 0; + hashes->hashes_buf = NULL; + return 0; } diff --git a/src/outfile_check.c b/src/outfile_check.c index c5d90c381..cd8f1a37c 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -36,7 +36,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) u32 outfile_check_timer = user_options->outfile_check_timer; // buffers - hash_t hash_buf = { 0, 0, 0, 0, 0 }; + hash_t hash_buf = { 0, 0, 0, 0, 0, NULL, 0 }; hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest); diff --git a/src/potfile.c b/src/potfile.c index daedbb285..da4a066e8 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -785,14 +785,12 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) while (!feof (potfile_ctx->fp)) { - char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, potfile_ctx->fp); - - if (ptr == NULL) break; - - int line_len = strlen (line_buf); + int line_len = fgetl (potfile_ctx->fp, line_buf); if (line_len == 0) continue; + const int line_len_orig = line_len; + int iter = MAX_CUT_TRIES; for (int i = line_len - 1; i && iter; i--, line_len--) @@ -910,6 +908,16 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (found == NULL) continue; + char *pw_buf = line_buf + line_len; + int pw_len = line_len_orig - line_len; + + found->pw_buf = (char *) hcmalloc (hashcat_ctx, pw_len + 1); VERIFY_PTR (found->pw_buf); + found->pw_len = pw_len; + + memcpy (found->pw_buf, pw_buf, pw_len); + + found->pw_buf[found->pw_len] = 0; + found->cracked = 1; if (found) break; @@ -939,10 +947,42 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) return 0; } - int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) { - event_log_error (hashcat_ctx, "The --show feature is currently not available"); + hashes_t *hashes = hashcat_ctx->hashes; + + hash_t *hashes_buf = hashes->hashes_buf; + + u32 salts_cnt = hashes->salts_cnt; + salt_t *salts_buf = hashes->salts_buf; + + for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++) + { + salt_t *salt_buf = salts_buf + salt_idx; + + u32 digests_cnt = salt_buf->digests_cnt; + + for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++) + { + const u32 hashes_idx = salt_buf->digests_offset + digest_idx; + + u32 *digests_shown = hashes->digests_shown; + + if (digests_shown[hashes_idx] == 0) continue; + + char out_buf[HCBUFSIZ_LARGE]; // scratch buffer + + out_buf[0] = 0; + + ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx); + + char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer + + const int tmp_len = outfile_write (hashcat_ctx, out_buf, (unsigned char *) hashes_buf[hashes_idx].pw_buf, hashes->hashes_buf[hashes_idx].pw_len, 0, NULL, 0, tmp_buf); + + EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); + } + } return 0; } From a460ab01b684eeb1d26c503df60d8654a57bf699 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Oct 2016 12:42:41 +0200 Subject: [PATCH 088/106] Bring back --username handling to --show and --left --- include/potfile.h | 5 - include/types.h | 7 +- src/hashes.c | 49 +++-- src/main.c | 15 +- src/outfile.c | 33 ++-- src/potfile.c | 481 +++++----------------------------------------- 6 files changed, 105 insertions(+), 485 deletions(-) diff --git a/include/potfile.h b/include/potfile.h index d2f5260e5..72c54d805 100644 --- a/include/potfile.h +++ b/include/potfile.h @@ -22,15 +22,10 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size int potfile_init (hashcat_ctx_t *hashcat_ctx); int potfile_read_open (hashcat_ctx_t *hashcat_ctx); -//int potfile_read_parse (hashcat_ctx_t *hashcat_ctx); void potfile_read_close (hashcat_ctx_t *hashcat_ctx); int potfile_write_open (hashcat_ctx_t *hashcat_ctx); void potfile_write_close (hashcat_ctx_t *hashcat_ctx); void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len); -//void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); -//void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); -//int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); -//int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)); int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx); void potfile_destroy (hashcat_ctx_t *hashcat_ctx); int potfile_handle_show (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 89aa1cf44..09e85b074 100644 --- a/include/types.h +++ b/include/types.h @@ -105,9 +105,10 @@ typedef enum event_identifier EVENT_CRACKER_HASH_CRACKED = 0x00000058, EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061, EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062, - EVENT_POTFILE_HASH_CRACKED = 0x00000063, - EVENT_POTFILE_NUM_CRACKED = 0x00000064, - EVENT_POTFILE_ALL_CRACKED = 0x00000065, + EVENT_POTFILE_NUM_CRACKED = 0x00000063, + EVENT_POTFILE_ALL_CRACKED = 0x00000064, + EVENT_POTFILE_HASH_SHOW = 0x00000065, + EVENT_POTFILE_HASH_LEFT = 0x00000066, EVENT_OPENCL_SESSION_PRE = 0x00000071, EVENT_OPENCL_SESSION_POST = 0x00000072, EVENT_BITMAP_INIT_PRE = 0x00000081, diff --git a/src/hashes.c b/src/hashes.c index 04c9f6801..681c1fc3c 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -157,7 +157,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) if (hashconfig->hash_mode != 2500) { - if (user_options->username == 1) + if (user_options->username == true) { user_t *user = hashes->hash_info[idx]->user; @@ -546,7 +546,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) digests_buf = (void *) hccalloc (hashcat_ctx, hashes_avail, hashconfig->dgst_size); VERIFY_PTR (digests_buf); - if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) + if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { u32 hash_pos; @@ -556,12 +556,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hashes_buf[hash_pos].hash_info = hash_info; - if (user_options->username && (user_options->remove || user_options->show || user_options->left)) + if (user_options->username == true) { hash_info->user = (user_t*) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info->user); } - if (user_options->benchmark) + if (user_options->benchmark == true) { hash_info->orighash = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (hash_info->orighash); } @@ -830,32 +830,29 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) continue; } - if (user_options->username) + if (user_options->username == true) { char *user_buf = NULL; int user_len = 0; hlfmt_user (hashcat_ctx, hashlist_format, line_buf, line_len, &user_buf, &user_len); - if (user_options->remove || user_options->show) + user_t **user = &hashes_buf[hashes_cnt].hash_info->user; + + *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (*user); + + user_t *user_ptr = *user; + + if (user_buf != NULL) { - user_t **user = &hashes_buf[hashes_cnt].hash_info->user; - - *user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (*user); - - user_t *user_ptr = *user; - - if (user_buf != NULL) - { - user_ptr->user_name = hcstrdup (hashcat_ctx, user_buf); - } - else - { - user_ptr->user_name = hcstrdup (hashcat_ctx, ""); - } - - user_ptr->user_len = user_len; + user_ptr->user_name = hcstrdup (hashcat_ctx, user_buf); } + else + { + user_ptr->user_name = hcstrdup (hashcat_ctx, ""); + } + + user_ptr->user_len = user_len; } if (hashconfig->opts_type & OPTS_TYPE_HASH_COPY) @@ -1044,11 +1041,11 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) hashinfo_t **hash_info = NULL; - if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) + if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { hash_info = (hashinfo_t **) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t *)); VERIFY_PTR (hash_info); - if (user_options->username && (user_options->remove || user_options->show)) + if (user_options->username == true) { u32 user_pos; @@ -1098,7 +1095,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) hashes_buf[0].digest = digests_buf_new_ptr; - if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) + if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { hash_info[0] = hashes_buf[0].hash_info; } @@ -1142,7 +1139,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx) hashes_buf[hashes_pos].digest = digests_buf_new_ptr; - if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) + if ((user_options->username == true) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY)) { hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info; } diff --git a/src/main.c b/src/main.c index 0ba8ad4a4..92717a46f 100644 --- a/src/main.c +++ b/src/main.c @@ -344,7 +344,17 @@ static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries..."); } -static void main_potfile_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +static void main_potfile_hash_show (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; + + if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile + + fwrite (buf, len, 1, stdout); + fwrite (EOL, strlen (EOL), 1, stdout); +} + +static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; @@ -686,7 +696,8 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break; case EVENT_POTFILE_REMOVE_PARSE_PRE: main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break; case EVENT_POTFILE_REMOVE_PARSE_POST: main_potfile_remove_parse_post (hashcat_ctx, buf, len); break; - case EVENT_POTFILE_HASH_CRACKED: main_potfile_hash_cracked (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_HASH_SHOW: main_potfile_hash_show (hashcat_ctx, buf, len); break; + case EVENT_POTFILE_HASH_LEFT: main_potfile_hash_left (hashcat_ctx, buf, len); break; case EVENT_POTFILE_NUM_CRACKED: main_potfile_num_cracked (hashcat_ctx, buf, len); break; case EVENT_POTFILE_ALL_CRACKED: main_potfile_all_cracked (hashcat_ctx, buf, len); break; case EVENT_OPENCL_SESSION_PRE: main_opencl_session_pre (hashcat_ctx, buf, len); break; diff --git a/src/outfile.c b/src/outfile.c index 7d7e711d7..4a8549bed 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -331,6 +331,23 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign int tmp_len = 0; + if (user_len > 0) + { + if (username != NULL) + { + memcpy (tmp_buf + tmp_len, username, user_len); + + tmp_len += user_len; + + if (outfile_ctx->outfile_format & (OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) + { + tmp_buf[tmp_len] = hashconfig->separator; + + tmp_len += 1; + } + } + } + if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH) { const size_t out_len = strlen (out_buf); @@ -346,22 +363,6 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign tmp_len += 1; } } - else if (user_len) - { - if (username != NULL) - { - memcpy (tmp_buf + tmp_len, username, user_len); - - tmp_len += user_len; - - if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) - { - tmp_buf[tmp_len] = hashconfig->separator; - - tmp_len += 1; - } - } - } if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN) { diff --git a/src/potfile.c b/src/potfile.c index da4a066e8..b8dc4a150 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -223,122 +223,6 @@ void potfile_read_close (hashcat_ctx_t *hashcat_ctx) fclose (potfile_ctx->fp); } -/* -int potfile_read_parse (hashcat_ctx_t *hashcat_ctx) -{ - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - if (potfile_ctx->enabled == false) return 0; - - if (potfile_ctx->fp == NULL) return 0; - - potfile_ctx->pot_avail = count_lines (hashcat_ctx, potfile_ctx->fp); - - potfile_ctx->pot = (pot_t *) hccalloc (hashcat_ctx, potfile_ctx->pot_avail, sizeof (pot_t)); VERIFY_PTR (potfile_ctx->pot); - - rewind (potfile_ctx->fp); - - char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf); - - for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++) - { - int line_len = fgetl (potfile_ctx->fp, line_buf); - - if (line_len == 0) continue; - - pot_t *pot_ptr = &potfile_ctx->pot[potfile_ctx->pot_cnt]; - - // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be - // valid lines of this specific hash type (otherwise it would be more waste of memory than gain) - - if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail) - { - const int rc = potfile_hash_alloc (hashcat_ctx, INCR_POT); - - if (rc == -1) return -1; - } - - int parser_status; - - int iter = MAX_CUT_TRIES; - - hash_t *hashes_buf = &pot_ptr->hash; - - char *plain_buf = line_buf + line_len; - - int plain_len = 0; - - do - { - for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--) - { - if (line_buf[i] == ':') - { - line_len--; - - break; - } - } - - if (hashconfig->hash_mode != 2500) - { - parser_status = hashconfig->parse_func (line_buf, line_len, hashes_buf, hashconfig); - } - else - { - int max_salt_size = sizeof (hashes_buf->salt->salt_buf); - - if (line_len > max_salt_size) - { - parser_status = PARSER_GLOBAL_LENGTH; - } - else - { - memset (&hashes_buf->salt->salt_buf, 0, max_salt_size); - - memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len); - - hashes_buf->salt->salt_len = line_len; - - parser_status = PARSER_OK; - } - } - - // if NOT parsed without error, we add the ":" to the plain - - if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) - { - plain_len++; - plain_buf--; - } - - } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter); - - if (parser_status < PARSER_GLOBAL_ZERO) - { - // event_log_warning (hashcat_ctx, "Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status)); - - continue; - } - - if (plain_len >= HCBUFSIZ_TINY) continue; - - memcpy (pot_ptr->plain_buf, plain_buf, plain_len); - - pot_ptr->plain_len = plain_len; - - potfile_ctx->pot_cnt++; - } - - hcfree (line_buf); - - hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - return 0; -} -*/ - int potfile_write_open (hashcat_ctx_t *hashcat_ctx) { potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; @@ -420,319 +304,6 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * fflush (potfile_ctx->fp); } -/* -void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return; - - pot_t pot_key; - - pot_key.hash.salt = hashes_buf->salt; - pot_key.hash.digest = hashes_buf->digest; - - //pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_ptr = NULL; - - if (pot_ptr) - { - event_log_info_nn (hashcat_ctx, ""); - - input_buf[input_len] = 0; - - // user - unsigned char *username = NULL; - u32 user_len = 0; - - if (hashes_buf->hash_info) - { - user_t *user = hashes_buf->hash_info->user; - - if (user) - { - username = (unsigned char *) (user->user_name); - - user_len = user->user_len; - } - } - - // do output the line - - char tmp_buf[HCBUFSIZ_LARGE]; - - const int tmp_len = outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, tmp_buf); - - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); - } -} - -void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return; - - pot_t pot_key; - - memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t)); - - //pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_ptr = NULL; - - if (pot_ptr == NULL) - { - event_log_info_nn (hashcat_ctx, ""); - - input_buf[input_len] = 0; - - char tmp_buf[HCBUFSIZ_LARGE]; - - const int tmp_len = outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0, tmp_buf); - - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); - } -} - -int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return 0; - - // left - - pot_t pot_left_key; - - pot_left_key.hash.salt = hash_left->salt; - pot_left_key.hash.digest = hash_left->digest; - - //pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_left_ptr = NULL; - - // right - - u32 weak_hash_found = 0; - - pot_t pot_right_key; - - pot_right_key.hash.salt = hash_right->salt; - pot_right_key.hash.digest = hash_right->digest; - - //pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_right_ptr = NULL; - - if (pot_right_ptr == NULL) - { - // special case, if "weak hash" - - if (memcmp (hash_right->digest, LM_WEAK_HASH, 8) == 0) - { - weak_hash_found = 1; - - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); - - // in theory this is not needed, but we are paranoia: - - memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); - - pot_right_ptr->plain_len = 0; - } - } - - if ((pot_left_ptr == NULL) && (pot_right_ptr == NULL)) - { - if (weak_hash_found == 1) hcfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure - - return 0; - } - - // at least one half was found: - - event_log_info_nn (hashcat_ctx, ""); - - input_buf[input_len] = 0; - - // user - - unsigned char *username = NULL; - - u32 user_len = 0; - - if (hash_left->hash_info) - { - user_t *user = hash_left->hash_info->user; - - if (user) - { - username = (unsigned char *) (user->user_name); - - user_len = user->user_len; - } - } - - // mask the part which was not found - - u32 left_part_masked = 0; - u32 right_part_masked = 0; - - u32 mask_plain_len = strlen (LM_MASKED_PLAIN); - - if (pot_left_ptr == NULL) - { - left_part_masked = 1; - - pot_left_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_left_ptr); - - memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf)); - - memcpy (pot_left_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len); - - pot_left_ptr->plain_len = mask_plain_len; - } - - if (pot_right_ptr == NULL) - { - right_part_masked = 1; - - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); - - memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf)); - - memcpy (pot_right_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len); - - pot_right_ptr->plain_len = mask_plain_len; - } - - // create the pot_ptr out of pot_left_ptr and pot_right_ptr - - pot_t pot_ptr; - - pot_ptr.plain_len = pot_left_ptr->plain_len + pot_right_ptr->plain_len; - - memcpy (pot_ptr.plain_buf, pot_left_ptr->plain_buf, pot_left_ptr->plain_len); - - memcpy (pot_ptr.plain_buf + pot_left_ptr->plain_len, pot_right_ptr->plain_buf, pot_right_ptr->plain_len); - - // do output the line - - char tmp_buf[HCBUFSIZ_LARGE]; - - const int tmp_len = outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, tmp_buf); - - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); - - if (weak_hash_found == 1) hcfree (pot_right_ptr); - - if (left_part_masked == 1) hcfree (pot_left_ptr); - if (right_part_masked == 1) hcfree (pot_right_ptr); - - return 0; -} - -int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *)) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - - if (potfile_ctx->enabled == false) return 0; - - // left - - pot_t pot_left_key; - - memcpy (&pot_left_key.hash, hash_left, sizeof (hash_t)); - - //pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_left_ptr = NULL; - - // right - - pot_t pot_right_key; - - memcpy (&pot_right_key.hash, hash_right, sizeof (hash_t)); - - //pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); - - pot_t *pot_right_ptr = NULL; - - u32 weak_hash_found = 0; - - if (pot_right_ptr == NULL) - { - // special case, if "weak hash" - - if (memcmp (hash_right->digest, LM_WEAK_HASH, 8) == 0) - { - weak_hash_found = 1; - - // we just need that pot_right_ptr is not a NULL pointer - - pot_right_ptr = (pot_t *) hccalloc (hashcat_ctx, 1, sizeof (pot_t)); VERIFY_PTR (pot_right_ptr); - } - } - - if ((pot_left_ptr != NULL) && (pot_right_ptr != NULL)) - { - if (weak_hash_found == 1) hcfree (pot_right_ptr); - - return 0; - } - - // ... at least one part was not cracked - - event_log_info_nn (hashcat_ctx, ""); - - input_buf[input_len] = 0; - - // only show the hash part which is still not cracked - - u32 user_len = (u32)input_len - 32u; - - char *hash_output = (char *) hcmalloc (hashcat_ctx, 33); VERIFY_PTR (hash_output); - - memcpy (hash_output, input_buf, input_len); - - if (pot_left_ptr != NULL) - { - // only show right part (because left part was already found) - - memcpy (hash_output + user_len, input_buf + user_len + 16, 16); - - hash_output[user_len + 16] = 0; - } - - if (pot_right_ptr != NULL) - { - // only show left part (because right part was already found) - - memcpy (hash_output + user_len, input_buf + user_len, 16); - - hash_output[user_len + 16] = 0; - } - - char tmp_buf[HCBUFSIZ_LARGE]; - - const int tmp_len = outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0, tmp_buf); - - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); - - hcfree (hash_output); - - if (weak_hash_found == 1) hcfree (pot_right_ptr); - - return 0; -} -*/ - int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -978,9 +549,30 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer - const int tmp_len = outfile_write (hashcat_ctx, out_buf, (unsigned char *) hashes_buf[hashes_idx].pw_buf, hashes->hashes_buf[hashes_idx].pw_len, 0, NULL, 0, tmp_buf); + hash_t *hash = &hashes_buf[hashes_idx]; - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); + // user + unsigned char *username = NULL; + + u32 user_len = 0; + + if (hash->hash_info != NULL) + { + user_t *user = hash->hash_info->user; + + if (user) + { + username = (unsigned char *) (user->user_name); + + user_len = user->user_len; + + username[user_len] = 0; + } + } + + const int tmp_len = outfile_write (hashcat_ctx, out_buf, (unsigned char *) hash->pw_buf, hash->pw_len, 0, username, user_len, tmp_buf); + + EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); } } @@ -991,6 +583,8 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) { hashes_t *hashes = hashcat_ctx->hashes; + hash_t *hashes_buf = hashes->hashes_buf; + u32 salts_cnt = hashes->salts_cnt; salt_t *salts_buf = hashes->salts_buf; @@ -1014,11 +608,32 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx); + hash_t *hash = &hashes_buf[hashes_idx]; + + // user + unsigned char *username = NULL; + + u32 user_len = 0; + + if (hash->hash_info != NULL) + { + user_t *user = hash->hash_info->user; + + if (user) + { + username = (unsigned char *) (user->user_name); + + user_len = user->user_len; + + username[user_len] = 0; + } + } + char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer - const int tmp_len = outfile_write (hashcat_ctx, out_buf, NULL, 0, 0, NULL, 0, tmp_buf); + const int tmp_len = outfile_write (hashcat_ctx, out_buf, NULL, 0, 0, username, user_len, tmp_buf); - EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len); + EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); } } From 0a26b09684b44eddd62d4f298c59fd7378496a4f Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Oct 2016 13:51:06 +0200 Subject: [PATCH 089/106] Fix buffer overflow in status_get_hash_target() --- src/hashes.c | 4 +++- src/status.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hashes.c b/src/hashes.c index 681c1fc3c..3ff91e0de 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -226,7 +226,9 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl // hash - char out_buf[HCBUFSIZ_LARGE] = { 0 }; + char out_buf[HCBUFSIZ_LARGE]; + + out_buf[0] = 0; ascii_digest (hashcat_ctx, out_buf, salt_pos, digest_pos); diff --git a/src/status.c b/src/status.c index febd2f8cd..d79cd3505 100644 --- a/src/status.c +++ b/src/status.c @@ -269,11 +269,17 @@ char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx) } else { - char *tmp_buf = (char *) malloc (HCBUFSIZ_TINY); + char *tmp_buf = (char *) malloc (HCBUFSIZ_LARGE); + + tmp_buf[0] = 0; ascii_digest ((hashcat_ctx_t *) hashcat_ctx, tmp_buf, 0, 0); - return tmp_buf; + char *tmp_buf2 = strdup (tmp_buf); + + free (tmp_buf); + + return tmp_buf2; } } else From eeefe8051aab3d28ea9d58ca160bb37af79282a8 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Oct 2016 14:44:30 +0200 Subject: [PATCH 090/106] Enable ASLR or/and DEP for Windows builds Suggested here: https://github.com/hashcat/hashcat/issues/530 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index aae87603f..356a74b7a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -170,7 +170,7 @@ LFLAGS_CROSS_LINUX += -lpthread -ldl LFLAGS_CROSS_WIN := LFLAGS_CROSS_WIN += $(LDFLAGS) -LFLAGS_CROSS_WIN += -lpsapi +LFLAGS_CROSS_WIN += -lpsapi -Wl,--dynamicbase -Wl,--nxcompat ## ## Objects From e4b3ea937faa48a8a8c7bc91d422ed44ed7e64b1 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Oct 2016 16:52:41 +0200 Subject: [PATCH 091/106] Fix salt length for -m 22 in benchmark mode --- src/interface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/interface.c b/src/interface.c index 4638139d5..4f5782968 100644 --- a/src/interface.c +++ b/src/interface.c @@ -20046,6 +20046,8 @@ void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, vo switch (hashconfig->hash_mode) { + case 22: salt->salt_len = 30; + break; case 1500: salt->salt_len = 2; salt->salt_buf[0] = 388; // pure magic break; From 98cdfac52d423fea884015627b37eabec182a08e Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 10:01:19 +0200 Subject: [PATCH 092/106] Fix --quiet mode in main_cracker_finished() --- src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 92717a46f..2c49b4805 100644 --- a/src/main.c +++ b/src/main.c @@ -258,12 +258,13 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->keyspace == true) return; if (user_options->opencl_info == true) return; if (user_options->stdout_flag == true) return; + if (user_options->quiet == true) return; // if we had a prompt, clear it if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - if ((user_options->quiet == false) && (user_options->benchmark == false) && (user_options->speed_only == false)) + if ((user_options->benchmark == false) && (user_options->speed_only == false)) { clear_prompt (); } From fa293bb409e0cda75d728631caa6351872ab998d Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 10:21:25 +0200 Subject: [PATCH 093/106] Fix --quiet mode in main_cracker_finished() --- src/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 2c49b4805..efc470753 100644 --- a/src/main.c +++ b/src/main.c @@ -258,7 +258,6 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB if (user_options->keyspace == true) return; if (user_options->opencl_info == true) return; if (user_options->stdout_flag == true) return; - if (user_options->quiet == true) return; // if we had a prompt, clear it @@ -283,11 +282,14 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB } else { - if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); + if (user_options->quiet == false) + { + if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, ""); - status_display (hashcat_ctx); + status_display (hashcat_ctx); - event_log_info (hashcat_ctx, ""); + event_log_info (hashcat_ctx, ""); + } } } From 5b26567cb6f835f3c52d5ac7c3613d33102979ac Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 11:02:45 +0200 Subject: [PATCH 094/106] Do not unroll -m 10900 based algorithms, it takes ages to compile with latest NV drivers --- OpenCL/inc_vendor.cl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenCL/inc_vendor.cl b/OpenCL/inc_vendor.cl index 8469c0661..646eb2893 100644 --- a/OpenCL/inc_vendor.cl +++ b/OpenCL/inc_vendor.cl @@ -113,6 +113,9 @@ #if KERN_TYPE == 10700 #undef _unroll #endif +#if KERN_TYPE == 10900 +#undef _unroll +#endif #if KERN_TYPE == 12300 #undef _unroll #endif From 761e3f0d96f4a0f1b7fc3fbe4740b442d542843f Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 21:27:42 +0200 Subject: [PATCH 095/106] Move out words_cur from restore_ctx to status_ctx and let the dispatcher update it --- include/restore.h | 2 -- include/types.h | 8 ++++-- src/dispatch.c | 67 +++++++++++++++++++++++++++++++++------------ src/hashcat.c | 29 ++++++++------------ src/restore.c | 70 ++++++++++++----------------------------------- src/status.c | 4 ++- 6 files changed, 87 insertions(+), 93 deletions(-) diff --git a/include/restore.h b/include/restore.h index 9a851b910..28623f8fb 100644 --- a/include/restore.h +++ b/include/restore.h @@ -23,8 +23,6 @@ #define RESTORE_VERSION_MIN 320 #define RESTORE_VERSION_CUR 320 -u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx); - int cycle_restore (hashcat_ctx_t *hashcat_ctx); void unlink_restore (hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 09e85b074..600377b34 100644 --- a/include/types.h +++ b/include/types.h @@ -1370,9 +1370,11 @@ typedef struct status_ctx * workload */ - u64 words_cnt; - u64 words_cur; - u64 words_base; + u64 words_off; // used by dispatcher; get_work () as offset; attention: needs to be redone on in restore case! + u64 words_cur; // used by dispatcher; the different to words_cur_next is that this counter guarantees that the work from zero to this counter has been actually computed + // has been finished actually, can be used for restore point therefore + u64 words_base; // the unamplified max keyspace + u64 words_cnt; // the amplified max keyspace /** * progress diff --git a/src/dispatch.c b/src/dispatch.c index 5f5b92c79..eee6448b3 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -34,6 +34,33 @@ #include "event.h" #include "dispatch.h" +static u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx) +{ + const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + + u64 words_cur = 0xffffffffffffffff; + + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + const u64 words_done = device_param->words_done; + + if (words_done < words_cur) words_cur = words_done; + } + + // It's possible that a device's workload isn't finished right after a restore-case. + // In that case, this function would return 0 and overwrite the real restore point + + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + if (words_cur < status_ctx->words_cur) words_cur = status_ctx->words_cur; + + return words_cur; +} + static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final) { EVENT (EVENT_SET_KERNEL_POWER_FINAL); @@ -65,7 +92,7 @@ static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param) return device_param->kernel_power; } -static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 max) +static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 max) { opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -73,14 +100,14 @@ static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param hc_thread_mutex_lock (status_ctx->mux_dispatcher); - const u64 words_cur = status_ctx->words_cur; + const u64 words_off = status_ctx->words_off; const u64 words_base = (user_options->limit == 0) ? status_ctx->words_base : MIN (user_options->limit, status_ctx->words_base); - device_param->words_off = words_cur; + device_param->words_off = words_off; const u64 kernel_power_all = opencl_ctx->kernel_power_all; - const u64 words_left = words_base - words_cur; + const u64 words_left = words_base - words_off; if (words_left < kernel_power_all) { @@ -96,7 +123,7 @@ static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param work = MIN (work, max); - status_ctx->words_cur += work; + status_ctx->words_off += work; hc_thread_mutex_unlock (status_ctx->mux_dispatcher); @@ -127,9 +154,9 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par break; } - u32 words_cur = 0; + u32 words_buffered = 0; - while (words_cur < device_param->kernel_power) + while (words_buffered < device_param->kernel_power) { char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin); @@ -184,7 +211,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par pw_add (device_param, (u8 *) line_buf, (int) line_len); - words_cur++; + words_buffered++; while (status_ctx->run_thread_level1 == false) break; } @@ -303,11 +330,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) device_param->pws_cnt = 0; } - if (status_ctx->run_thread_level1 == false) break; - if (user_options->speed_only == true) break; device_param->words_done = words_fin; + + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + + if (status_ctx->run_thread_level1 == false) break; } } else @@ -418,15 +447,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) u64 words_off = 0; u64 words_fin = 0; - u64 max = -1llu; + u32 words_extra = -1u; - while (max) + while (words_extra) { - const u32 work = get_work (hashcat_ctx, device_param, max); + const u32 work = get_work (hashcat_ctx, device_param, words_extra); if (work == 0) break; - max = 0; + words_extra = 0; words_off = device_param->words_off; words_fin = words_off + work; @@ -465,7 +494,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) { - max++; + words_extra++; hc_thread_mutex_lock (status_ctx->mux_counter); @@ -486,7 +515,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (line_len > hashconfig->pw_max) { - max++; + words_extra++; hc_thread_mutex_lock (status_ctx->mux_counter); @@ -550,11 +579,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (user_options->speed_only == true) break; + device_param->words_done = words_fin; + + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + if (status_ctx->run_thread_level1 == false) break; if (words_fin == 0) break; - - device_param->words_done = words_fin; } if (attack_mode == ATTACK_MODE_COMBI) diff --git a/src/hashcat.c b/src/hashcat.c index 849b3a951..c52813a85 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -82,20 +82,25 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_progress_reset (hashcat_ctx); + status_ctx->words_off = 0; status_ctx->words_cur = 0; restore_data_t *rd = restore_ctx->rd; if (rd->words_cur) { - status_ctx->words_cur = rd->words_cur; + status_ctx->words_off = rd->words_cur; + status_ctx->words_cur = status_ctx->words_off; + + rd->words_cur = 0; user_options->skip = 0; } if (user_options->skip) { - status_ctx->words_cur = user_options->skip; + status_ctx->words_off = user_options->skip; + status_ctx->words_cur = status_ctx->words_off; user_options->skip = 0; } @@ -128,21 +133,18 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) // restore stuff - if (status_ctx->words_cur > status_ctx->words_base) + if (status_ctx->words_off > status_ctx->words_base) { event_log_error (hashcat_ctx, "Restore value greater keyspace"); return -1; } - if (status_ctx->words_cur) - { - const u64 progress_restored = status_ctx->words_cur * user_options_extra_amplifier (hashcat_ctx); + const u64 progress_restored = status_ctx->words_off * user_options_extra_amplifier (hashcat_ctx); - for (u32 i = 0; i < hashes->salts_cnt; i++) - { - status_ctx->words_progress_restored[i] = progress_restored; - } + for (u32 i = 0; i < hashes->salts_cnt; i++) + { + status_ctx->words_progress_restored[i] = progress_restored; } /** @@ -262,13 +264,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_CRACKER_FINISHED); - // no more skip and restore from here - - if (status_ctx->devices_status == STATUS_EXHAUSTED) - { - rd->words_cur = 0; - } - // mark sub logfile logfile_sub_var_uint ("status-after-work", status_ctx->devices_status); diff --git a/src/restore.c b/src/restore.c index 0391b93fe..412b5fe03 100644 --- a/src/restore.c +++ b/src/restore.c @@ -19,39 +19,6 @@ static void fsync (int fd) } #endif -u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx) -{ - restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - - if (restore_ctx->enabled == false) return 0; - - restore_data_t *rd = restore_ctx->rd; - - u64 words_cur = 0xffffffffffffffff; - - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - const u64 words_done = device_param->words_done; - - if (words_done < words_cur) words_cur = words_done; - } - - // It's possible that a device's workload isn't finished right after a restore-case. - // In that case, this function would return 0 and overwrite the real restore point - // There's also status_ctx->words_cur which is set to rd->words_cur but it changes while - // 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. - - if (words_cur < rd->words_cur) words_cur = rd->words_cur; - - return words_cur; -} - static int check_running_process (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; @@ -255,14 +222,13 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) static int write_restore (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; if (restore_ctx->enabled == false) return 0; - const u64 words_cur = get_lowest_words_done (hashcat_ctx); - restore_data_t *rd = restore_ctx->rd; - rd->words_cur = words_cur; + rd->words_cur = status_ctx->words_cur; char *new_restore_file = restore_ctx->new_restore_file; @@ -357,6 +323,20 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; + if (user_options->benchmark == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->opencl_info == 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; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->restore_disable == true) return 0; + + if (argc == 0) return 0; + if (argv == NULL) return 0; + char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (eff_restore_file); char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (new_restore_file); @@ -373,20 +353,6 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (rc_init_restore == -1) return -1; - if (argc == 0) return 0; - if (argv == NULL) return 0; - - if (user_options->benchmark == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->opencl_info == 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; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; - if (user_options->restore_disable == true) return 0; - restore_ctx->enabled = true; if (user_options->restore == true) @@ -424,12 +390,12 @@ void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; + if (restore_ctx->enabled == false) return; + hcfree (restore_ctx->eff_restore_file); hcfree (restore_ctx->new_restore_file); hcfree (restore_ctx->rd); - if (restore_ctx->enabled == false) return; - memset (restore_ctx, 0, sizeof (restore_ctx_t)); } diff --git a/src/status.c b/src/status.c index d79cd3505..74aa248d9 100644 --- a/src/status.c +++ b/src/status.c @@ -858,7 +858,9 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx) u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx) { - const u64 restore_point = get_lowest_words_done (hashcat_ctx); + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + const u64 restore_point = status_ctx->words_cur; return restore_point; } From 574acfab6ab9656d752c94c7195a5741646dad0a Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 22:14:54 +0200 Subject: [PATCH 096/106] Move masks_pos from rd* to masks_ctx and dicts_pot from rd* to straight_ctx --- src/dispatch.c | 14 ++++++++---- src/hashcat.c | 62 ++++++++++++++++++++++++++++++++------------------ src/restore.c | 8 +++++-- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/dispatch.c b/src/dispatch.c index eee6448b3..206ae6481 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -332,9 +332,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (user_options->speed_only == true) break; - device_param->words_done = words_fin; + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } if (status_ctx->run_thread_level1 == false) break; } @@ -579,9 +582,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (user_options->speed_only == true) break; - device_param->words_done = words_fin; + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } if (status_ctx->run_thread_level1 == false) break; diff --git a/src/hashcat.c b/src/hashcat.c index c52813a85..3b0fc6e93 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -85,19 +85,22 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->words_off = 0; status_ctx->words_cur = 0; - restore_data_t *rd = restore_ctx->rd; - - if (rd->words_cur) + if (restore_ctx->rd) { - status_ctx->words_off = rd->words_cur; - status_ctx->words_cur = status_ctx->words_off; + restore_data_t *rd = restore_ctx->rd; - rd->words_cur = 0; + if (rd->words_cur > 0) + { + status_ctx->words_off = rd->words_cur; + status_ctx->words_cur = status_ctx->words_off; - user_options->skip = 0; + rd->words_cur = 0; + + user_options->skip = 0; + } } - if (user_options->skip) + if (user_options->skip > 0) { status_ctx->words_off = user_options->skip; status_ctx->words_cur = status_ctx->words_off; @@ -325,14 +328,22 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_INNERLOOP2_STARTING); - restore_data_t *rd = restore_ctx->rd; + if (restore_ctx->rd) + { + restore_data_t *rd = restore_ctx->rd; + + if (rd->dicts_pos > 0) + { + straight_ctx->dicts_pos = rd->dicts_pos; + + rd->dicts_pos = 0; + } + } if (straight_ctx->dicts_cnt) { - for (u32 dicts_pos = rd->dicts_pos; dicts_pos < straight_ctx->dicts_cnt; dicts_pos++) + for (u32 dicts_pos = straight_ctx->dicts_pos; dicts_pos < straight_ctx->dicts_cnt; dicts_pos++) { - rd->dicts_pos = dicts_pos; - straight_ctx->dicts_pos = dicts_pos; const int rc_inner2_loop = inner2_loop (hashcat_ctx); @@ -341,6 +352,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->run_main_level3 == false) break; } + + if (straight_ctx->dicts_pos == straight_ctx->dicts_cnt) straight_ctx->dicts_pos = 0; } else { @@ -670,21 +683,24 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) // main call + if (restore_ctx->rd) + { + restore_data_t *rd = restore_ctx->rd; + + if (rd->masks_pos > 0) + { + mask_ctx->masks_pos = rd->masks_pos; + + rd->masks_pos = 0; + } + } + EVENT (EVENT_INNERLOOP1_STARTING); if (mask_ctx->masks_cnt) { - restore_data_t *rd = restore_ctx->rd; - - for (u32 masks_pos = rd->masks_pos; masks_pos < mask_ctx->masks_cnt; masks_pos++) + for (u32 masks_pos = mask_ctx->masks_pos; masks_pos < mask_ctx->masks_cnt; masks_pos++) { - if (masks_pos > rd->masks_pos) - { - rd->dicts_pos = 0; - } - - rd->masks_pos = masks_pos; - mask_ctx->masks_pos = masks_pos; const int rc_inner1_loop = inner1_loop (hashcat_ctx); @@ -693,6 +709,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->run_main_level2 == false) break; } + + if (mask_ctx->masks_pos == mask_ctx->masks_cnt) mask_ctx->masks_pos = 0; } else { diff --git a/src/restore.c b/src/restore.c index 412b5fe03..9ab30baed 100644 --- a/src/restore.c +++ b/src/restore.c @@ -221,13 +221,17 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) static int write_restore (hashcat_ctx_t *hashcat_ctx) { - restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + 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; if (restore_ctx->enabled == false) return 0; restore_data_t *rd = restore_ctx->rd; + rd->masks_pos = mask_ctx->masks_pos; + rd->dicts_pos = straight_ctx->dicts_pos; rd->words_cur = status_ctx->words_cur; char *new_restore_file = restore_ctx->new_restore_file; From 8ecabcb9ac0722f5a70d55c28eee6f57971692c9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 22:30:00 +0200 Subject: [PATCH 097/106] Fix --stdout and --keyspace --- src/hashcat.c | 6 ++++-- src/user_options.c | 34 +++++++++++++++++----------------- src/wordlist.c | 1 - 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 3b0fc6e93..a1f184ab1 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -128,7 +128,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) // words base - status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx); + const u64 amplifier_cnt = user_options_extra_amplifier (hashcat_ctx); + + status_ctx->words_base = status_ctx->words_cnt / amplifier_cnt; EVENT (EVENT_CALCULATED_WORDS_BASE); @@ -143,7 +145,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) return -1; } - const u64 progress_restored = status_ctx->words_off * user_options_extra_amplifier (hashcat_ctx); + const u64 progress_restored = status_ctx->words_off * amplifier_cnt; for (u32 i = 0; i < hashes->salts_cnt; i++) { diff --git a/src/user_options.c b/src/user_options.c index 104d84b3b..ba9c64cd4 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1110,23 +1110,6 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx) 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); - // wordlist_mode - - user_options_extra->wordlist_mode = WL_MODE_NONE; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - user_options_extra->wordlist_mode = (user_options->hc_argc >= 2) ? WL_MODE_FILE : WL_MODE_STDIN; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - user_options_extra->wordlist_mode = WL_MODE_FILE; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - user_options_extra->wordlist_mode = WL_MODE_MASK; - } - // hc_hash and hc_work* user_options_extra->hc_hash = NULL; @@ -1157,6 +1140,23 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx) user_options_extra->hc_workc = user_options->hc_argc - 1; user_options_extra->hc_workv = user_options->hc_argv + 1; } + + // wordlist_mode + + user_options_extra->wordlist_mode = WL_MODE_NONE; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + user_options_extra->wordlist_mode = (user_options_extra->hc_workc >= 1) ? WL_MODE_FILE : WL_MODE_STDIN; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + user_options_extra->wordlist_mode = WL_MODE_FILE; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + user_options_extra->wordlist_mode = WL_MODE_MASK; + } } void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx) diff --git a/src/wordlist.c b/src/wordlist.c index afdc4dce7..5aff5fa02 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -423,7 +423,6 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = false; if (user_options->benchmark == true) return 0; - if (user_options->keyspace == true) return 0; if (user_options->left == true) return 0; if (user_options->opencl_info == true) return 0; if (user_options->usage == true) return 0; From e9b11c2951cd1c29388d174f1a45314b352f34f9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 22:53:47 +0200 Subject: [PATCH 098/106] Do not unroll scrypt based algorithm on NV, latest windows driver can't compile them otherwise --- OpenCL/inc_vendor.cl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenCL/inc_vendor.cl b/OpenCL/inc_vendor.cl index 646eb2893..18d152c5d 100644 --- a/OpenCL/inc_vendor.cl +++ b/OpenCL/inc_vendor.cl @@ -104,6 +104,9 @@ #if KERN_TYPE == 8200 #undef _unroll #endif +#if KERN_TYPE == 8900 +#undef _unroll +#endif #if KERN_TYPE == 10400 #undef _unroll #endif From 27e92540e4ce6238644232554f9c5af1ad208ddf Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 22:58:40 +0200 Subject: [PATCH 099/106] Do not unlink restore file of restore is disabled --- src/restore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/restore.c b/src/restore.c index 9ab30baed..5bf889df6 100644 --- a/src/restore.c +++ b/src/restore.c @@ -306,6 +306,8 @@ void unlink_restore (hashcat_ctx_t *hashcat_ctx) restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + if (restore_ctx->enabled == false) return; + if ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_thread_level1 == true)) // this is to check for [c]heckpoint { unlink (restore_ctx->eff_restore_file); From 655c3881f38a6427b837ee97eea64537371d58e9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 23:27:10 +0200 Subject: [PATCH 100/106] Add compilation on MINGW64 to Makefile --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 356a74b7a..5cd2810b4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,8 +13,9 @@ UNAME := $(shell uname -s) # we need to strip the windows version number to be able to build hashcat on cygwin hosts UNAME := $(patsubst CYGWIN_NT-%,CYGWIN_NT-,$(UNAME)) +UNAME := $(patsubst MINGW64_NT-%,MINGW64_NT-,$(UNAME)) -ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN_NT- FreeBSD)) +ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN_NT- MINGW64_NT- FreeBSD)) $(error "! Your Operating System ($(UNAME)) is not supported by $(PROG_NAME) Makefile") endif From 6b96146e0f7bb1fd484f4ed908863cecd79c3240 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 00:28:14 +0200 Subject: [PATCH 101/106] Fix integer overflow in status.c --- src/status.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/status.c b/src/status.c index 74aa248d9..0f539a67f 100644 --- a/src/status.c +++ b/src/status.c @@ -753,6 +753,14 @@ char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx) } } + // we need this check to avoid integer overflow + #if defined (_WIN) + if (sec_etc > 100000000) + { + sec_etc = 100000000; + } + #endif + time_t now; time (&now); @@ -803,6 +811,14 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx) } } + // we need this check to avoid integer overflow + #if defined (_WIN) + if (sec_etc > 100000000) + { + sec_etc = 100000000; + } + #endif + struct tm *tmp; #if defined (_WIN) From c6c31a86d8cb41f0a5ca3246a2d03565b03bb91b Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 09:07:39 +0200 Subject: [PATCH 102/106] Add some changes to improve compiling on MSYS2 --- src/Makefile | 8 +++++--- src/folder.c | 6 +++--- src/win_file_globbing.mk | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5cd2810b4..8c9f2d698 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,10 +12,12 @@ PROG_NAME := hashcat UNAME := $(shell uname -s) # we need to strip the windows version number to be able to build hashcat on cygwin hosts -UNAME := $(patsubst CYGWIN_NT-%,CYGWIN_NT-,$(UNAME)) -UNAME := $(patsubst MINGW64_NT-%,MINGW64_NT-,$(UNAME)) +UNAME := $(patsubst CYGWIN_NT-%,CYGWIN,$(UNAME)) +UNAME := $(patsubst MSYS_NT-%,MSYS2,$(UNAME)) +UNAME := $(patsubst MINGW32_NT-%,MSYS2,$(UNAME)) +UNAME := $(patsubst MINGW64_NT-%,MSYS2,$(UNAME)) -ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN_NT- MINGW64_NT- FreeBSD)) +ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN MSYS2 FreeBSD)) $(error "! Your Operating System ($(UNAME)) is not supported by $(PROG_NAME) Makefile") endif diff --git a/src/folder.c b/src/folder.c index a3d41a34a..4fe097936 100644 --- a/src/folder.c +++ b/src/folder.c @@ -74,7 +74,7 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) return 0; } -static void get_install_dir (char *install_dir, const char *exec_path) +void get_install_dir (char *install_dir, const char *exec_path) { strncpy (install_dir, exec_path, HCBUFSIZ_TINY - 1); @@ -95,12 +95,12 @@ static void get_install_dir (char *install_dir, const char *exec_path) } } -static void get_profile_dir (char *profile_dir, const char *home_dir) +void get_profile_dir (char *profile_dir, const char *home_dir) { snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT); } -static void get_session_dir (char *session_dir, const char *profile_dir) +void get_session_dir (char *session_dir, const char *profile_dir) { snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER); } diff --git a/src/win_file_globbing.mk b/src/win_file_globbing.mk index b136eef4d..cd6cb97f7 100644 --- a/src/win_file_globbing.mk +++ b/src/win_file_globbing.mk @@ -18,8 +18,13 @@ ifneq (,$(IS_WIN_BUILD)) # entering this code path means: we need to check for CRT_glob.o since we try to build binaries for windows operating systems +ifeq ($(UNAME),MSYS2) +CRT_GLOB_LIB_PATH_32 ?= /mingw32/i686-w64-mingw32/lib/ +CRT_GLOB_LIB_PATH_64 ?= /mingw64/x86_64-w64-mingw32/lib/ +else CRT_GLOB_LIB_PATH_32 ?= /usr/i686-w64-mingw32/lib/ CRT_GLOB_LIB_PATH_64 ?= /usr/x86_64-w64-mingw32/lib/ +endif CRT_GLOB_LIB_SYSROOT_32 := $(shell $(CC_WIN_32) --verbose 2>&1 | $(EGREP) -m 1 -o '(with-sysroot="[^"]"|with-sysroot=[^ ]*)' | $(SED) 's/^with-sysroot="\?\([^"]*\)"\?$$/\1/') CRT_GLOB_LIB_SYSROOT_64 := $(shell $(CC_WIN_64) --verbose 2>&1 | $(EGREP) -m 1 -o '(with-sysroot="[^"]"|with-sysroot=[^ ]*)' | $(SED) 's/^with-sysroot="\?\([^"]*\)"\?$$/\1/') From a43902b96bd7ffc6f0b4e2b5081bbb439544cfed Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 09:51:41 +0200 Subject: [PATCH 103/106] Do not unroll -m 6400 based algorithm on NV, latest windows driver can't compile them otherwise --- OpenCL/inc_vendor.cl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenCL/inc_vendor.cl b/OpenCL/inc_vendor.cl index 18d152c5d..9ce7327b2 100644 --- a/OpenCL/inc_vendor.cl +++ b/OpenCL/inc_vendor.cl @@ -89,6 +89,9 @@ #if KERN_TYPE == 6223 #undef _unroll #endif +#if KERN_TYPE == 6400 +#undef _unroll +#endif #if KERN_TYPE == 6500 #undef _unroll #endif From f58c9baade79011c41eaf18eff2fd580b7829c89 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 10:14:15 +0200 Subject: [PATCH 104/106] Do not unroll -m 6800 based algorithm on NV, latest windows driver can't compile them otherwise --- OpenCL/inc_vendor.cl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OpenCL/inc_vendor.cl b/OpenCL/inc_vendor.cl index 9ce7327b2..14bcbebed 100644 --- a/OpenCL/inc_vendor.cl +++ b/OpenCL/inc_vendor.cl @@ -95,6 +95,9 @@ #if KERN_TYPE == 6500 #undef _unroll #endif +#if KERN_TYPE == 6800 +#undef _unroll +#endif #if KERN_TYPE == 7100 #undef _unroll #endif @@ -128,6 +131,9 @@ #if KERN_TYPE == 12400 #undef _unroll #endif +#if KERN_TYPE == 12900 +#undef _unroll +#endif #if KERN_TYPE == 13721 #undef _unroll #endif @@ -137,6 +143,15 @@ #if KERN_TYPE == 13723 #undef _unroll #endif +#if KERN_TYPE == 13751 +#undef _unroll +#endif +#if KERN_TYPE == 13752 +#undef _unroll +#endif +#if KERN_TYPE == 13753 +#undef _unroll +#endif #if KERN_TYPE == 14000 #undef _unroll #endif From 8cfb1f03abcd649a377b8b888ed0461b5e3bb206 Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 16:02:13 +0200 Subject: [PATCH 105/106] Workaround to enable use of amd-gpu-pro --- OpenCL/m01800.cl | 2 +- OpenCL/m10700.cl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenCL/m01800.cl b/OpenCL/m01800.cl index e295e70be..985844971 100644 --- a/OpenCL/m01800.cl +++ b/OpenCL/m01800.cl @@ -58,7 +58,7 @@ __constant u64 k_sha512[80] = SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f, }; -void sha512_transform (const u64 w[16], u64 digest[8]) +void sha512_transform (const u64 *w, u64 *digest) { u64 w0_t = w[ 0]; u64 w1_t = w[ 1]; diff --git a/OpenCL/m10700.cl b/OpenCL/m10700.cl index 5eaa72f8f..2219ed466 100644 --- a/OpenCL/m10700.cl +++ b/OpenCL/m10700.cl @@ -54,7 +54,7 @@ __constant u32 k_sha256[64] = SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f, }; -void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[8]) +void sha256_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u32 a = digest[0]; u32 b = digest[1]; @@ -166,7 +166,7 @@ __constant u64 k_sha384[80] = SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f, }; -void sha384_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) +void sha384_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u64 a = digest[0]; u64 b = digest[1]; @@ -278,7 +278,7 @@ __constant u64 k_sha512[80] = SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f, }; -void sha512_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8]) +void sha512_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest) { u64 a = digest[0]; u64 b = digest[1]; From 313bdd5e5ba2d19e6d1b78f59ae54023e5d02b3f Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 21 Oct 2016 16:24:08 +0200 Subject: [PATCH 106/106] Added a note --- docs/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changes.txt b/docs/changes.txt index 6902cf610..2e0ee1824 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -15,6 +15,7 @@ - Allow words of length > 32 in wordlists for -a 0 for slow hashes if no rules are in use or a : rule is in the rulefile - Reduce max. number of allowed function calls per rule from 256 to 32 to save GPU memory - Status display shows what's the base and modifier keyspace currently in use +- Added a workaround for some OpenCL kernel to compile with amd-gpu-pro ## ## Algorithms