From 2670791916cd78c9e547bc24d37edcaf9a9e4c5f Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 2 Oct 2017 15:44:03 +0200 Subject: [PATCH] Improved dictstat header check --- src/dictstat.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/dictstat.c b/src/dictstat.c index a02e92870..67953ada9 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -103,22 +103,37 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename); + fclose (fp); + return; } v = byte_swap_64 (v); z = byte_swap_64 (z); - if (v != DICTSTAT_VERSION) + if ((v & 0xffffffffffffff00) != (DICTSTAT_VERSION & 0xffffffffffffff00)) { - event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename); + + fclose (fp); return; } if (z != 0) { - event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename); + event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename); + + fclose (fp); + + return; + } + + if ((v & 0xff) < (DICTSTAT_VERSION & 0xff)) + { + event_log_warning (hashcat_ctx, "%s: Outdated header version, ignoring content", dictstat_ctx->filename); + + fclose (fp); return; }