Add function to distinguish between warning and advice messages

pull/1208/head
jsteube 7 years ago
parent 99fbaa8bcc
commit 368f8b39bc

@ -14,19 +14,15 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons
#define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0)
#define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len))
__attribute__ ((format (printf, 2, 3)))
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3)))
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3)))
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3)))
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3)))
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3)))
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_advice_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_advice (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
__attribute__ ((format (printf, 2, 3))) 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);

@ -74,6 +74,7 @@ typedef enum loglevel
LOGLEVEL_INFO = 0,
LOGLEVEL_WARNING = 1,
LOGLEVEL_ERROR = 2,
LOGLEVEL_ADVICE = 3,
} loglevel_t;
@ -103,6 +104,7 @@ typedef enum event_identifier
EVENT_LOG_ERROR = 0x00000070,
EVENT_LOG_INFO = 0x00000071,
EVENT_LOG_WARNING = 0x00000072,
EVENT_LOG_ADVICE = 0x00000073,
EVENT_MONITOR_RUNTIME_LIMIT = 0x00000080,
EVENT_MONITOR_STATUS_REFRESH = 0x00000081,
EVENT_MONITOR_TEMP_ABORT = 0x00000082,
@ -490,6 +492,7 @@ typedef enum progress_mode
typedef enum user_options_defaults
{
ADVICE_DISABLE = false,
ATTACK_MODE = ATTACK_MODE_STRAIGHT,
BENCHMARK = false,
BITMAP_MAX = 24,
@ -558,91 +561,92 @@ typedef enum user_options_defaults
typedef enum user_options_map
{
IDX_ADVICE_DISABLE = 0xff00,
IDX_ATTACK_MODE = 'a',
IDX_BENCHMARK = 'b',
IDX_BITMAP_MAX = 0xff00,
IDX_BITMAP_MIN = 0xff01,
IDX_CPU_AFFINITY = 0xff02,
IDX_BITMAP_MAX = 0xff01,
IDX_BITMAP_MIN = 0xff02,
IDX_CPU_AFFINITY = 0xff03,
IDX_CUSTOM_CHARSET_1 = '1',
IDX_CUSTOM_CHARSET_2 = '2',
IDX_CUSTOM_CHARSET_3 = '3',
IDX_CUSTOM_CHARSET_4 = '4',
IDX_DEBUG_FILE = 0xff03,
IDX_DEBUG_MODE = 0xff04,
IDX_FORCE = 0xff05,
IDX_GPU_TEMP_ABORT = 0xff06,
IDX_GPU_TEMP_DISABLE = 0xff07,
IDX_GPU_TEMP_RETAIN = 0xff08,
IDX_DEBUG_FILE = 0xff04,
IDX_DEBUG_MODE = 0xff05,
IDX_FORCE = 0xff06,
IDX_GPU_TEMP_ABORT = 0xff07,
IDX_GPU_TEMP_DISABLE = 0xff08,
IDX_GPU_TEMP_RETAIN = 0xff09,
IDX_HASH_MODE = 'm',
IDX_HCCAPX_MESSAGE_PAIR = 0xff09,
IDX_HCCAPX_MESSAGE_PAIR = 0xff0a,
IDX_HELP = 'h',
IDX_HEX_CHARSET = 0xff0a,
IDX_HEX_SALT = 0xff0b,
IDX_HEX_WORDLIST = 0xff0c,
IDX_HEX_CHARSET = 0xff0b,
IDX_HEX_SALT = 0xff0c,
IDX_HEX_WORDLIST = 0xff0d,
IDX_INCREMENT = 'i',
IDX_INCREMENT_MAX = 0xff0d,
IDX_INCREMENT_MIN = 0xff0e,
IDX_INDUCTION_DIR = 0xff0f,
IDX_KEEP_GUESSING = 0xff10,
IDX_INCREMENT_MAX = 0xff0e,
IDX_INCREMENT_MIN = 0xff0f,
IDX_INDUCTION_DIR = 0xff10,
IDX_KEEP_GUESSING = 0xff11,
IDX_KERNEL_ACCEL = 'n',
IDX_KERNEL_LOOPS = 'u',
IDX_KEYSPACE = 0xff11,
IDX_LEFT = 0xff12,
IDX_KEYSPACE = 0xff12,
IDX_LEFT = 0xff13,
IDX_LIMIT = 'l',
IDX_LOGFILE_DISABLE = 0xff13,
IDX_LOOPBACK = 0xff14,
IDX_MACHINE_READABLE = 0xff15,
IDX_MARKOV_CLASSIC = 0xff16,
IDX_MARKOV_DISABLE = 0xff17,
IDX_MARKOV_HCSTAT = 0xff18,
IDX_LOGFILE_DISABLE = 0xff14,
IDX_LOOPBACK = 0xff15,
IDX_MACHINE_READABLE = 0xff16,
IDX_MARKOV_CLASSIC = 0xff17,
IDX_MARKOV_DISABLE = 0xff18,
IDX_MARKOV_HCSTAT = 0xff19,
IDX_MARKOV_THRESHOLD = 't',
IDX_NONCE_ERROR_CORRECTIONS = 0xff19,
IDX_NVIDIA_SPIN_DAMP = 0xff1a,
IDX_NONCE_ERROR_CORRECTIONS = 0xff1a,
IDX_NVIDIA_SPIN_DAMP = 0xff1b,
IDX_OPENCL_DEVICES = 'd',
IDX_OPENCL_DEVICE_TYPES = 'D',
IDX_OPENCL_INFO = 'I',
IDX_OPENCL_PLATFORMS = 0xff1b,
IDX_OPENCL_VECTOR_WIDTH = 0xff1c,
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff1d,
IDX_OUTFILE_CHECK_DIR = 0xff1e,
IDX_OUTFILE_CHECK_TIMER = 0xff1f,
IDX_OUTFILE_FORMAT = 0xff20,
IDX_OPENCL_PLATFORMS = 0xff1c,
IDX_OPENCL_VECTOR_WIDTH = 0xff1d,
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff1e,
IDX_OUTFILE_CHECK_DIR = 0xff1f,
IDX_OUTFILE_CHECK_TIMER = 0xff20,
IDX_OUTFILE_FORMAT = 0xff21,
IDX_OUTFILE = 'o',
IDX_POTFILE_DISABLE = 0xff21,
IDX_POTFILE_PATH = 0xff22,
IDX_POWERTUNE_ENABLE = 0xff23,
IDX_QUIET = 0xff24,
IDX_REMOVE = 0xff25,
IDX_REMOVE_TIMER = 0xff26,
IDX_RESTORE = 0xff27,
IDX_RESTORE_DISABLE = 0xff28,
IDX_RESTORE_FILE_PATH = 0xff29,
IDX_POTFILE_DISABLE = 0xff22,
IDX_POTFILE_PATH = 0xff23,
IDX_POWERTUNE_ENABLE = 0xff24,
IDX_QUIET = 0xff25,
IDX_REMOVE = 0xff26,
IDX_REMOVE_TIMER = 0xff27,
IDX_RESTORE = 0xff28,
IDX_RESTORE_DISABLE = 0xff29,
IDX_RESTORE_FILE_PATH = 0xff2a,
IDX_RP_FILE = 'r',
IDX_RP_GEN_FUNC_MAX = 0xff2a,
IDX_RP_GEN_FUNC_MIN = 0xff2b,
IDX_RP_GEN_FUNC_MAX = 0xff2b,
IDX_RP_GEN_FUNC_MIN = 0xff2c,
IDX_RP_GEN = 'g',
IDX_RP_GEN_SEED = 0xff2c,
IDX_RP_GEN_SEED = 0xff2d,
IDX_RULE_BUF_L = 'j',
IDX_RULE_BUF_R = 'k',
IDX_RUNTIME = 0xff2d,
IDX_SCRYPT_TMTO = 0xff2e,
IDX_RUNTIME = 0xff2e,
IDX_SCRYPT_TMTO = 0xff2f,
IDX_SEGMENT_SIZE = 'c',
IDX_SEPARATOR = 'p',
IDX_SESSION = 0xff2f,
IDX_SHOW = 0xff30,
IDX_SESSION = 0xff30,
IDX_SHOW = 0xff31,
IDX_SKIP = 's',
IDX_STATUS = 0xff31,
IDX_STATUS_TIMER = 0xff32,
IDX_STDOUT_FLAG = 0xff33,
IDX_SPEED_ONLY = 0xff34,
IDX_PROGRESS_ONLY = 0xff35,
IDX_TRUECRYPT_KEYFILES = 0xff36,
IDX_USERNAME = 0xff37,
IDX_VERACRYPT_KEYFILES = 0xff38,
IDX_VERACRYPT_PIM = 0xff39,
IDX_STATUS = 0xff32,
IDX_STATUS_TIMER = 0xff33,
IDX_STDOUT_FLAG = 0xff34,
IDX_SPEED_ONLY = 0xff35,
IDX_PROGRESS_ONLY = 0xff36,
IDX_TRUECRYPT_KEYFILES = 0xff37,
IDX_USERNAME = 0xff38,
IDX_VERACRYPT_KEYFILES = 0xff39,
IDX_VERACRYPT_PIM = 0xff3a,
IDX_VERSION_LOWER = 'v',
IDX_VERSION = 'V',
IDX_WEAK_HASH_THRESHOLD = 0xff3a,
IDX_WEAK_HASH_THRESHOLD = 0xff3b,
IDX_WORKLOAD_PROFILE = 'w'
} user_options_map_t;
@ -1411,6 +1415,7 @@ typedef struct user_options
bool segment_size_chgd;
bool hccapx_message_pair_chgd;
bool advice_disable;
bool benchmark;
bool force;
bool gpu_temp_disable;

@ -19,6 +19,7 @@ void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, cons
case EVENT_LOG_INFO: is_log = true; break;
case EVENT_LOG_WARNING: is_log = true; break;
case EVENT_LOG_ERROR: is_log = true; break;
case EVENT_LOG_ADVICE: is_log = true; break;
}
if (is_log == false)
@ -66,6 +67,34 @@ static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)
return (int) length;
}
size_t event_log_advice_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = false;
event_call (EVENT_LOG_ADVICE, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
@ -150,6 +179,34 @@ size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
return event_ctx->msg_len;
}
size_t event_log_advice (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
if (fmt == NULL)
{
event_ctx->msg_buf[0] = 0;
event_ctx->msg_len = 0;
}
else
{
va_list ap;
va_start (ap, fmt);
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
va_end (ap);
}
event_ctx->msg_newline = true;
event_call (EVENT_LOG_ADVICE, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;

@ -89,6 +89,8 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
break;
case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
break;
case LOGLEVEL_ADVICE: SetConsoleTextAttribute (hConsole, 6);
break;
}
#else
@ -97,6 +99,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int 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;
case LOGLEVEL_ADVICE: fwrite ("\033[33m", 5, 1, fp); break;
}
#endif
@ -112,6 +115,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: SetConsoleTextAttribute (hConsole, orig); break;
case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, orig); break;
case LOGLEVEL_ADVICE: SetConsoleTextAttribute (hConsole, orig); break;
}
#else
switch (loglevel)
@ -119,6 +123,7 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int 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;
case LOGLEVEL_ADVICE: fwrite ("\033[0m", 4, 1, fp); break;
}
#endif
@ -139,6 +144,15 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
fflush (fp);
}
static void main_log_advice (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->advice_disable == true) return;
main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
}
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, LOGLEVEL_INFO);
@ -559,8 +573,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, NULL);
event_log_advice (hashcat_ctx, "Approaching final keyspace, workload adjusted");
event_log_advice (hashcat_ctx, NULL);
send_prompt ();
}
@ -646,19 +660,19 @@ static void main_monitor_performance_hint (MAYBE_UNUSED hashcat_ctx_t *hashcat_c
if (user_options->workload_profile < 3)
{
event_log_warning (hashcat_ctx, "Cracking performance lower than expected? Append -w 3 to the commandline!");
event_log_warning (hashcat_ctx, NULL);
event_log_advice (hashcat_ctx, "Cracking performance lower than expected? Append -w 3 to the commandline!");
event_log_advice (hashcat_ctx, NULL);
}
else
{
event_log_warning (hashcat_ctx, "Cracking performance lower than expected?");
event_log_warning (hashcat_ctx, NULL);
event_log_warning (hashcat_ctx, "* Update your OpenCL runtime / Driver but the right way:");
event_log_warning (hashcat_ctx, " https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#i_may_have_the_wrong_driver_installed_what_should_i_do");
event_log_warning (hashcat_ctx, NULL);
event_log_warning (hashcat_ctx, "* Create more work items to make use of your parallelization power:");
event_log_warning (hashcat_ctx, " https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
event_log_warning (hashcat_ctx, NULL);
event_log_advice (hashcat_ctx, "Cracking performance lower than expected?");
event_log_advice (hashcat_ctx, NULL);
event_log_advice (hashcat_ctx, "* Update your OpenCL runtime / Driver but the right way:");
event_log_advice (hashcat_ctx, " https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#i_may_have_the_wrong_driver_installed_what_should_i_do");
event_log_advice (hashcat_ctx, NULL);
event_log_advice (hashcat_ctx, "* Create more work items to make use of your parallelization power:");
event_log_advice (hashcat_ctx, " https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
event_log_advice (hashcat_ctx, NULL);
}
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
@ -894,6 +908,7 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co
case EVENT_LOG_ERROR: main_log_error (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_ADVICE: main_log_advice (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;
case EVENT_MONITOR_TEMP_ABORT: main_monitor_temp_abort (hashcat_ctx, buf, len); break;

@ -3274,11 +3274,11 @@ void opencl_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->quiet == false)
{
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, NULL);
event_log_advice (hashcat_ctx, "The wordlist or mask you are using is too small.");
event_log_advice (hashcat_ctx, "Therefore, hashcat is unable to utilize the full parallelization power of your device(s).");
event_log_advice (hashcat_ctx, "The cracking speed will drop.");
event_log_advice (hashcat_ctx, "Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
event_log_advice (hashcat_ctx, NULL);
}
}
}

@ -18,6 +18,7 @@ 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[] =
{
{"advice-disable", no_argument, 0, IDX_ADVICE_DISABLE},
{"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
{"benchmark", no_argument, 0, IDX_BENCHMARK},
{"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
@ -118,6 +119,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options->advice_disable = ADVICE_DISABLE;
user_options->attack_mode = ATTACK_MODE;
user_options->benchmark = BENCHMARK;
user_options->bitmap_max = BITMAP_MAX;
@ -303,6 +305,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_QUIET: user_options->quiet = true; break;
case IDX_SHOW: user_options->show = true; break;
case IDX_LEFT: user_options->left = true; break;
case IDX_ADVICE_DISABLE: user_options->advice_disable = true; break;
case IDX_USERNAME: user_options->username = true; break;
case IDX_REMOVE: user_options->remove = true; break;
case IDX_REMOVE_TIMER: user_options->remove_timer = atoi (optarg);

Loading…
Cancel
Save