Add function to distinguish between warning and advice messages

This commit is contained in:
jsteube
2017-03-25 20:50:37 +01:00
parent 99fbaa8bcc
commit 368f8b39bc
6 changed files with 164 additions and 88 deletions
+57
View File
@@ -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;
+27 -12
View File
@@ -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;
+5 -5
View File
@@ -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);
}
}
}
+3
View File
@@ -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);