From 430b8b17c15e8cf1df31f2a9a75143f87e8b8bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?= Date: Sun, 4 Apr 2021 15:11:07 +0200 Subject: [PATCH] Machine readable mode for show hash feature --- src/hashes.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/src/hashes.c b/src/hashes.c index 9f76e58de..e3935aae4 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1187,7 +1187,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) 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)); + if (user_options->machine_readable == true) { + event_log_warning(hashcat_ctx, "%s:%u:%s:%s", hashes->hashfile, + line_num, tmp_line_buf, + strparser(parser_status)); + + } else { + 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); @@ -1211,7 +1221,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) 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)); + if (user_options->machine_readable == true) { + event_log_warning(hashcat_ctx, "%s:%u:%s:%s", hashes->hashfile, + line_num, tmp_line_buf, + strparser(parser_status)); + + } else { + 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); @@ -1237,7 +1257,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) 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)); + if (user_options->machine_readable == true) { + event_log_warning(hashcat_ctx, "%s:%u:%s:%s", hashes->hashfile, + line_num, tmp_line_buf, + strparser(parser_status)); + + } else { + 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); @@ -1264,7 +1294,17 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) 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)); + if (user_options->machine_readable == true) { + event_log_warning(hashcat_ctx, "%s:%u:%s:%s", hashes->hashfile, + line_num, tmp_line_buf, + strparser(parser_status)); + + } else { + 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);