From 2ff7d0bb4d035b2ef92531eff030d29f70440ef7 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 15 May 2022 18:04:29 +0200 Subject: [PATCH] Added support to include source wordlist in debugging format --- src/debugfile.c | 26 +++++++++++++++++++++++--- src/outfile.c | 8 ++++---- src/user_options.c | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/debugfile.c b/src/debugfile.c index e28179dba..3b6c361d1 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -61,13 +61,15 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, const u32 rule_len, const u8 *mod_plain_ptr, const u32 mod_plain_len, const u8 *orig_plain_ptr, const u32 orig_plain_len) { - debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; + debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx; + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; if (debugfile_ctx->enabled == false) return; const u32 debug_mode = debugfile_ctx->mode; - if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) + if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) { debugfile_format_plain (hashcat_ctx, orig_plain_ptr, orig_plain_len); @@ -76,13 +78,31 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con hc_fwrite ((void *) rule_buf, rule_len, 1, &debugfile_ctx->fp); - if (debug_mode == 4) + if ((debug_mode == 4) || (debug_mode == 5)) { hc_fputc (':', &debugfile_ctx->fp); debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len); } + if (debug_mode == 5) + { + hc_fputc (':', &debugfile_ctx->fp); + + if (user_options_extra->wordlist_mode == WL_MODE_FILE) + { + hc_fprintf (&debugfile_ctx->fp, "%s", straight_ctx->dict); + } + else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) + { + hc_fprintf (&debugfile_ctx->fp, ""); + } + else + { + hc_fprintf (&debugfile_ctx->fp, ""); + } + } + hc_fwrite (EOL, strlen (EOL), 1, &debugfile_ctx->fp); } diff --git a/src/outfile.c b/src/outfile.c index 26c135657..c1125bbba 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -439,7 +439,7 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param pw_pre_t *pw_base = device_param->pws_base_buf + gidvid; // save rule - if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) + if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) { const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[pw_base->rule_idx]); @@ -449,7 +449,7 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param } // save plain - if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) + if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) { memcpy (debug_plain_ptr, pw_base->base_buf, pw_base->base_len); @@ -471,7 +471,7 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param const u64 off = device_param->innerloop_pos + il_pos; // save rule - if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) + if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) { const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]); @@ -481,7 +481,7 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param } // save plain - if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) + if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4) || (debug_mode == 5)) { memcpy (debug_plain_ptr, (char *) pw.i, (size_t) plain_len); diff --git a/src/user_options.c b/src/user_options.c index 56e545c69..4dd2dce39 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1107,7 +1107,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) } } - if (user_options->debug_mode > 4) + if (user_options->debug_mode > 5) { event_log_error (hashcat_ctx, "Invalid --debug-mode value specified.");