1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-08 23:01:14 +00:00

HCdict File: Renamed file from hashcat.hcdict to hashcat.hcdict2 and add header because versions are incompatible

This commit is contained in:
jsteube 2017-09-20 10:22:18 +02:00
parent acca562e9f
commit f55446b6f3
3 changed files with 55 additions and 2 deletions

View File

@ -69,6 +69,8 @@
- General: Update C standard from c99 to gnu99
- Hash Parser: Improved salt-length checks for generic hash modes
- HCdict File: Renamed file from hashcat.hcdict to hashcat.hcdict2 and add header because versions are incompatible
- HCstat File: Renamed file from hashcat.hcstat to hashcat.hcstat2 and add header because versions are incompatible
- HCstat File: Add code to read LZMA compressed hashcat.hcstat2
- HCstat File: Add hcstat2 support to enable masks of length up to 256, also adds a filetype header
- OpenCL Kernels: Added code generator for most of the switch_* functions and replaced existing code

View File

@ -15,7 +15,10 @@
#include <errno.h>
#include <search.h>
#define MAX_DICTSTAT 10000
#define MAX_DICTSTAT 100000
#define DICTSTAT_FILENAME "hashcat.dictstat2"
#define DICTSTAT_VERSION (0x6863646963740000 | 0x0002)
int sort_by_dictstat (const void *s1, const void *s2);

View File

@ -6,6 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "bitops.h"
#include "event.h"
#include "dictstat.h"
#include "locking.h"
@ -54,7 +55,7 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx)
dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t));
dictstat_ctx->cnt = 0;
hc_asprintf (&dictstat_ctx->filename, "%s/hashcat.dictstat", folder_config->profile_dir);
hc_asprintf (&dictstat_ctx->filename, "%s/%s", folder_config->profile_dir, DICTSTAT_FILENAME);
return 0;
}
@ -86,6 +87,40 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
return;
}
// parse header
u64 v;
u64 z;
const size_t nread1 = hc_fread (&v, sizeof (u64), 1, fp);
const size_t nread2 = hc_fread (&z, sizeof (u64), 1, fp);
if ((nread1 != 1) || (nread2 != 1))
{
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
return;
}
v = byte_swap_64 (v);
z = byte_swap_64 (z);
if (v != DICTSTAT_VERSION)
{
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
return;
}
if (z != 0)
{
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
return;
}
// parse data
while (!feof (fp))
{
dictstat_t d;
@ -131,6 +166,19 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
return -1;
}
// header
u64 v = DICTSTAT_VERSION;
u64 z = 0;
v = byte_swap_64 (v);
z = byte_swap_64 (z);
hc_fwrite (&v, sizeof (u64), 1, fp);
hc_fwrite (&z, sizeof (u64), 1, fp);
// data
hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp);
fclose (fp);