From 9aabc2024895b44d565457a1ae8afe7befa1055f Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 8 Feb 2017 20:25:04 +0100 Subject: [PATCH] Add a warning message if old hccap file is detected and abort --- include/interface.h | 1 + src/hashes.c | 14 ++++++++++++++ src/interface.c | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/include/interface.h b/include/interface.h index 338ee68f3..500db4bfa 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1733,6 +1733,7 @@ char *stroptitype (const u32 opti_type); char *strhashtype (const u32 hash_mode); char *strparser (const u32 parser_status); +int check_old_hccap (const char *hashfile); void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos); void wpa_essid_reuse (hashcat_ctx_t *hashcat_ctx); diff --git a/src/hashes.c b/src/hashes.c index a5ae513a9..3d8835922 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -477,6 +477,20 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) return -1; } + // 392 = old hccap_t size + + if ((st.st_size % 392) == 0) + { + const int rc = check_old_hccap (hashes->hashfile); + + if (rc == 1) + { + event_log_error (hashcat_ctx, "%s: Old hccap file format detected! You need to update: https://hashcat.net/forum/thread-6273.html", hashes->hashfile); + + return -1; + } + } + hashes_avail = st.st_size / sizeof (hccapx_t); } else if (hashconfig->hash_mode == 14600) diff --git a/src/interface.c b/src/interface.c index 9322d9f92..69c1f6eba 100644 --- a/src/interface.c +++ b/src/interface.c @@ -14720,6 +14720,25 @@ char *strparser (const u32 parser_status) return ((char *) PA_255); } +int check_old_hccap (const char *hashfile) +{ + FILE *fp = fopen (hashfile, "rb"); + + if (fp == NULL) return -1; + + u32 signature; + + const int nread = fread (&signature, sizeof (u32), 1, fp); + + if (nread != 1) return -1; + + fclose (fp); + + if (signature == HCCAPX_SIGNATURE) return 0; + + return 1; +} + void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;