From 612a50408cbdb9dda668f52f4c575e4cef83da9b Mon Sep 17 00:00:00 2001 From: philsmd Date: Thu, 16 Nov 2017 12:37:31 +0100 Subject: [PATCH] in case of a parser error we always should include the actual error message even if hash is long --- docs/changes.txt | 6 ++++++ src/hashes.c | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 956ffe74f..569c71c31 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -14,6 +14,12 @@ * changes v4.0.0 -> v4.0.1: +## +## Improvements +## + +- Changed the maximum length of the substring of a hash shown whenever the parser found a problem while parsing the hash + ## ## Bugs ## diff --git a/src/hashes.c b/src/hashes.c index 61fc7b85a..9891e2770 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -14,6 +14,7 @@ #include "filehandling.h" #include "hlfmt.h" #include "interface.h" +#include "terminal.h" #include "logfile.h" #include "loopback.h" #include "mpsp.h" @@ -1035,7 +1036,15 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + char *tmp_line_buf = (char *) malloc (HCBUFSIZ_LARGE); + + snprintf (tmp_line_buf, HCBUFSIZ_LARGE, "%s", line_buf); + + compress_terminal_line_length (tmp_line_buf, 38, 32); + + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, tmp_line_buf, strparser (parser_status)); + + hcfree (tmp_line_buf); continue; } @@ -1049,7 +1058,15 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + char *tmp_line_buf = (char *) malloc (HCBUFSIZ_LARGE); + + snprintf (tmp_line_buf, HCBUFSIZ_LARGE, "%s", line_buf); + + compress_terminal_line_length (tmp_line_buf, 38, 32); + + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, tmp_line_buf, strparser (parser_status)); + + hcfree (tmp_line_buf); continue; } @@ -1065,7 +1082,15 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + char *tmp_line_buf = (char *) malloc (HCBUFSIZ_LARGE); + + snprintf (tmp_line_buf, HCBUFSIZ_LARGE, "%s", line_buf); + + compress_terminal_line_length (tmp_line_buf, 38, 32); + + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, tmp_line_buf, strparser (parser_status)); + + hcfree (tmp_line_buf); continue; } @@ -1082,7 +1107,15 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (parser_status < PARSER_GLOBAL_ZERO) { - event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, line_buf, strparser (parser_status)); + char *tmp_line_buf = (char *) malloc (HCBUFSIZ_LARGE); + + snprintf (tmp_line_buf, HCBUFSIZ_LARGE, "%s", line_buf); + + compress_terminal_line_length (tmp_line_buf, 38, 32); + + event_log_warning (hashcat_ctx, "Hashfile '%s' on line %u (%s): %s", hashes->hashfile, line_num, tmp_line_buf, strparser (parser_status)); + + hcfree (tmp_line_buf); continue; }