mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-22 14:48:12 +00:00
Print warnings in yellow and errors in red
This commit is contained in:
parent
91979bff69
commit
694de36694
@ -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,
|
||||
|
145
src/main.c
145
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, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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, "");
|
||||
|
109
src/opencl.c
109
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user