Move old ascii_digest() to hashes.c and rename it to hash_encode(), also remove some unused includes

pull/1977/head
jsteube 5 years ago
parent f9110c6863
commit 708a86fb59

@ -12,6 +12,8 @@ int sort_by_salt (const void *v1, const void *v2);
int sort_by_hash (const void *v1, const void *v2, void *v3);
int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3);
int hash_encode (const hashconfig_t *hashconfig, const hashes_t *hashes, const module_ctx_t *module_ctx, char *out_buf, const int out_size, const u32 salt_pos, const u32 digest_pos);
int save_hash (hashcat_ctx_t *hashcat_ctx);
void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain);

@ -21,8 +21,6 @@ static const int MODULE_HASH_MODES_MAXIMUM = 100000;
* output functions
*/
int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const module_ctx_t *module_ctx, char *out_buf, const int out_size, const u32 salt_pos, const u32 digest_pos);
int module_filename (const folder_config_t *folder_config, const int hash_mode, char *out_buf, const size_t out_size);
bool module_load (hashcat_ctx_t *hashcat_ctx, module_ctx_t *module_ctx, const u32 hash_mode);
void module_unload (module_ctx_t *module_ctx);

@ -8,7 +8,6 @@
#include "event.h"
#include "opencl.h"
#include "status.h"
#include "terminal.h"
#include "autotune.h"
static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kernel_accel, const u32 kernel_loops)

@ -6,9 +6,9 @@
#include "common.h"
#include "types.h"
#include "interface.h"
#include "benchmark.h"
#include "memory.h"
#include "shared.h"
#include "benchmark.h"
static const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[] =
{

@ -6,8 +6,8 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "bitmap.h"
#include "event.h"
#include "bitmap.h"
static void selftest_to_bitmap (const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d)
{

@ -5,15 +5,13 @@
#include "common.h"
#include "types.h"
#include "bitops.h"
#include "timer.h"
#include "memory.h"
#include "thread.h"
#include "bitops.h"
#include "convert.h"
#include "shared.h"
#include "interface.h"
#include "hashes.h"
#include "shared.h"
#include "brain.h"
static bool keep_running = true;
@ -96,7 +94,7 @@ u32 brain_compute_session (hashcat_ctx_t *hashcat_ctx)
}
else
{
// using ascii_digest is an easy workaround for dealing with optimizations
// using hash_encode is an easy workaround for dealing with optimizations
// like OPTI_TYPE_PRECOMPUTE_MERKLE which cause diffrent hashes in digests_buf
// in case -O is used
@ -114,7 +112,7 @@ u32 brain_compute_session (hashcat_ctx_t *hashcat_ctx)
for (u32 digest_idx = 0; digest_idx < salt_buf->digests_cnt; digest_idx++)
{
const int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salts_idx, digest_idx);
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salts_idx, digest_idx);
out_buf[out_len] = 0;

@ -6,10 +6,9 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "combinator.h"
#include "shared.h"
#include "wordlist.h"
#include "combinator.h"
int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
{

@ -7,7 +7,6 @@
#include "types.h"
#include "memory.h"
#include "cpt.h"
#include "shared.h"
int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
{

@ -5,11 +5,10 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "debugfile.h"
#include "shared.h"
#include "locking.h"
#include "debugfile.h"
static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len)
{

@ -8,9 +8,9 @@
#include "memory.h"
#include "bitops.h"
#include "event.h"
#include "dictstat.h"
#include "locking.h"
#include "shared.h"
#include "dictstat.h"
int sort_by_dictstat (const void *s1, const void *s2)
{

@ -5,7 +5,6 @@
#include "common.h"
#include "types.h"
#include "convert.h"
#include "event.h"
#include "memory.h"
#include "opencl.h"
@ -16,7 +15,6 @@
#include "rp.h"
#include "rp_cpu.h"
#include "slow_candidates.h"
#include "user_options.h"
#include "dispatch.h"
#ifdef WITH_BRAIN

@ -5,8 +5,6 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "ext_OpenCL.h"
const char *val2cstr_cl (cl_int CL_err)

@ -6,7 +6,6 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "ext_lzma.h"
void *hc_lzma_alloc (MAYBE_UNUSED ISzAllocPtr p, size_t size)

@ -5,6 +5,4 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "ext_nvapi.h"

@ -5,7 +5,4 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "dynloader.h"
#include "ext_nvml.h"

@ -9,7 +9,6 @@
#include "types.h"
#include "folder.h"
#include "locking.h"
#include "memory.h"
#include "shared.h"
#include "thread.h"
@ -27,7 +26,6 @@
#include "dictstat.h"
#include "dispatch.h"
#include "event.h"
#include "hashcat.h"
#include "hashes.h"
#include "hwmon.h"
#include "induct.h"
@ -42,14 +40,13 @@
#include "pidfile.h"
#include "potfile.h"
#include "restore.h"
#include "rp.h"
#include "selftest.h"
#include "status.h"
#include "straight.h"
#include "tuningdb.h"
#include "usage.h"
#include "user_options.h"
#include "wordlist.h"
#include "hashcat.h"
#ifdef WITH_BRAIN
#include "brain.h"

@ -7,26 +7,21 @@
#include "types.h"
#include "memory.h"
#include "event.h"
#include "hashes.h"
#include "convert.h"
#include "debugfile.h"
#include "filehandling.h"
#include "hlfmt.h"
#include "interface.h"
#include "terminal.h"
#include "logfile.h"
#include "loopback.h"
#include "mpsp.h"
#include "opencl.h"
#include "outfile.h"
#include "potfile.h"
#include "rp.h"
#include "shared.h"
#include "thread.h"
#include "timer.h"
#include "locking.h"
#include "cpu_crc32.h"
#include "hashes.h"
#ifdef WITH_BRAIN
#include "brain.h"
@ -126,6 +121,50 @@ int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3)
return sort_by_digest_p0p1 (d1, d2, v3);
}
int hash_encode (const hashconfig_t *hashconfig, const hashes_t *hashes, const module_ctx_t *module_ctx, char *out_buf, const int out_size, const u32 salt_pos, const u32 digest_pos)
{
if (module_ctx->module_hash_encode == MODULE_DEFAULT)
{
return snprintf (out_buf, out_size, "%s", hashes->hashfile);
}
salt_t *salts_buf = hashes->salts_buf;
salts_buf += salt_pos;
const u32 digest_cur = salts_buf[salt_pos].digests_offset + digest_pos;
void *digests_buf = hashes->digests_buf;
void *esalts_buf = hashes->esalts_buf;
void *hook_salts_buf = hashes->hook_salts_buf;
hashinfo_t **hash_info = hashes->hash_info;
char *digests_buf_ptr = (char *) digests_buf;
char *esalts_buf_ptr = (char *) esalts_buf;
char *hook_salts_buf_ptr = (char *) hook_salts_buf;
hashinfo_t *hash_info_ptr = NULL;
digests_buf_ptr += digest_cur * hashconfig->dgst_size;
esalts_buf_ptr += digest_cur * hashconfig->esalt_size;
hook_salts_buf_ptr += digest_cur * hashconfig->hook_salt_size;
if (hash_info) hash_info_ptr = hash_info[digest_cur];
const int out_len = module_ctx->module_hash_encode
(
hashconfig,
digests_buf_ptr,
salts_buf,
esalts_buf_ptr,
hook_salts_buf_ptr,
hash_info_ptr,
out_buf,
out_size
);
return out_len;
}
int save_hash (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
@ -206,7 +245,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
fputc (separator, fp);
}
const int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
out_buf[out_len] = 0;
@ -277,7 +316,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
u8 *out_buf = hashes->out_buf;
const int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
out_buf[out_len] = 0;

@ -5,64 +5,18 @@
#include "common.h"
#include "types.h"
#include "bitops.h"
#include "memory.h"
#include "convert.h"
#include "event.h"
#include "shared.h"
#include "opencl.h"
#include "interface.h"
#include "filehandling.h"
#include "modules.h"
#include "dynloader.h"
#include "interface.h"
/**
* parsing
*/
int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const module_ctx_t *module_ctx, char *out_buf, const int out_size, const u32 salt_pos, const u32 digest_pos)
{
void *digests_buf = hashes->digests_buf;
salt_t *salts_buf = hashes->salts_buf;
void *esalts_buf = hashes->esalts_buf;
void *hook_salts_buf = hashes->hook_salts_buf;
hashinfo_t **hash_info = hashes->hash_info;
const char *hashfile = hashes->hashfile;
const u32 dgst_size = hashconfig->dgst_size;
const u64 esalt_size = hashconfig->esalt_size;
const u64 hook_salt_size = hashconfig->hook_salt_size;
if (module_ctx->module_hash_encode == MODULE_DEFAULT)
{
return snprintf (out_buf, out_size, "%s", hashfile);
}
char *digests_buf_ptr = (char *) digests_buf;
char *esalts_buf_ptr = (char *) esalts_buf;
char *hook_salts_buf_ptr = (char *) hook_salts_buf;
const u32 digest_cur = salts_buf[salt_pos].digests_offset + digest_pos;
hashinfo_t *hash_info_ptr = NULL;
if (hash_info) hash_info_ptr = hash_info[digest_cur];
const int out_len = module_ctx->module_hash_encode
(
hashconfig,
digests_buf_ptr + (digest_cur * dgst_size),
salts_buf + salt_pos,
esalts_buf_ptr + (digest_cur * esalt_size),
hook_salts_buf_ptr + (digest_cur * hook_salt_size),
hash_info_ptr,
out_buf,
out_size
);
return out_len;
}
int module_filename (const folder_config_t *folder_config, const int hash_mode, char *out_buf, const size_t out_size)
{
// native compiled

@ -5,7 +5,6 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "locking.h"
#if defined (F_SETLKW)

@ -7,9 +7,9 @@
#include "types.h"
#include "memory.h"
#include "event.h"
#include "logfile.h"
#include "locking.h"
#include "shared.h"
#include "logfile.h"
void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx)
{

@ -8,8 +8,8 @@
#include "memory.h"
#include "event.h"
#include "shared.h"
#include "loopback.h"
#include "locking.h"
#include "loopback.h"
static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const unsigned int plain_len)
{

@ -17,7 +17,6 @@
#include "terminal.h"
#include "thread.h"
#include "status.h"
#include "interface.h"
#include "shared.h"
#include "event.h"
@ -520,7 +519,7 @@ static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
event_log_advice (hashcat_ctx, NULL);
}
}
if (user_options->keep_guessing == true)
{
event_log_advice (hashcat_ctx, "ATTENTION! --keep-guessing mode is enabled.");

@ -6,13 +6,11 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "hwmon.h"
#include "timer.h"
#include "hashes.h"
#include "thread.h"
#include "restore.h"
#include "shared.h"
#include "status.h"
#include "monitor.h"

@ -11,7 +11,6 @@
#include "logfile.h"
#include "convert.h"
#include "filehandling.h"
#include "interface.h"
#include "opencl.h"
#include "shared.h"
#include "ext_lzma.h"

@ -13,12 +13,9 @@
#include "rp.h"
#include "rp_cpu.h"
#include "mpsp.h"
#include "straight.h"
#include "combinator.h"
#include "convert.h"
#include "stdout.h"
#include "filehandling.h"
#include "interface.h"
#include "wordlist.h"
#include "shared.h"
#include "hashes.h"

@ -5,19 +5,16 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "convert.h"
#include "interface.h"
#include "hashes.h"
#include "mpsp.h"
#include "rp.h"
#include "emu_inc_rp.h"
#include "emu_inc_rp_optimized.h"
#include "opencl.h"
#include "shared.h"
#include "outfile.h"
#include "locking.h"
#include "outfile.h"
int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len)
{

@ -7,15 +7,12 @@
#include "types.h"
#include "memory.h"
#include "event.h"
#include "outfile_check.h"
#include "filehandling.h"
#include "convert.h"
#include "folder.h"
#include "hashes.h"
#include "interface.h"
#include "shared.h"
#include "thread.h"
#include "bitops.h"
#include "outfile_check.h"
static int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED void * v3)
{

@ -7,7 +7,6 @@
#include "types.h"
#include "memory.h"
#include "event.h"
#include "user_options.h"
#include "shared.h"
#include "pidfile.h"

@ -5,17 +5,16 @@
#include "common.h"
#include "types.h"
#include "bitops.h"
#include "convert.h"
#include "memory.h"
#include "event.h"
#include "interface.h"
#include "hashes.h"
#include "filehandling.h"
#include "loopback.h"
#include "outfile.h"
#include "potfile.h"
#include "locking.h"
#include "shared.h"
#include "potfile.h"
static const char MASKED_PLAIN[] = "[notfound]";
@ -378,7 +377,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->enabled == false) return 0;
if (hashconfig->potfile_disable == true) return 0;
if (hashconfig->opts_type & OPTS_TYPE_PT_NEVERCRACK) return 0;
// if no potfile exists yet we don't need to do anything here
@ -667,11 +666,11 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx)
u8 *out_buf = potfile_ctx->out_buf;
int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 0, HCBUFSIZ_LARGE - 0, salt_idx, digest_idx);
int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 0, HCBUFSIZ_LARGE - 0, salt_idx, digest_idx);
if (hash2)
{
out_len += ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 16, HCBUFSIZ_LARGE - 16, salt_idx, split_neighbor);
out_len += hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 16, HCBUFSIZ_LARGE - 16, salt_idx, split_neighbor);
}
out_buf[out_len] = 0;
@ -755,7 +754,7 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx)
u8 *out_buf = potfile_ctx->out_buf;
const int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_idx, digest_idx);
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_idx, digest_idx);
out_buf[out_len] = 0;
@ -875,11 +874,11 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx)
u8 *out_buf = potfile_ctx->out_buf;
int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 0, HCBUFSIZ_LARGE - 0, salt_idx, digest_idx);
int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 0, HCBUFSIZ_LARGE - 0, salt_idx, digest_idx);
if (hash2)
{
out_len += ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 16, HCBUFSIZ_LARGE - 16, salt_idx, split_neighbor);
out_len += hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf + 16, HCBUFSIZ_LARGE - 16, salt_idx, split_neighbor);
}
out_buf[out_len] = 0;
@ -928,7 +927,7 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx)
u8 *out_buf = potfile_ctx->out_buf;
const int out_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_idx, digest_idx);
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_idx, digest_idx);
out_buf[out_len] = 0;

@ -9,7 +9,6 @@
#include "bitops.h"
#include "convert.h"
#include "opencl.h"
#include "interface.h"
#include "thread.h"
#include "selftest.h"

@ -5,7 +5,6 @@
#include "common.h"
#include "types.h"
#include "bitops.h"
#include "convert.h"
#include "shared.h"

@ -6,19 +6,17 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "convert.h"
#include "restore.h"
#include "thread.h"
#include "timer.h"
#include "interface.h"
#include "hashes.h"
#include "hwmon.h"
#include "outfile.h"
#include "monitor.h"
#include "mpsp.h"
#include "terminal.h"
#include "status.h"
#include "shared.h"
#include "status.h"
static const char *ST_0000 = "Initializing";
static const char *ST_0001 = "Autotuning";
@ -339,7 +337,7 @@ char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
{
char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
const int tmp_len = ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, tmp_buf, HCBUFSIZ_LARGE, 0, 0);
const int tmp_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, tmp_buf, HCBUFSIZ_LARGE, 0, 0);
tmp_buf[tmp_len] = 0;

@ -9,12 +9,10 @@
#include "event.h"
#include "logfile.h"
#include "shared.h"
#include "filehandling.h"
#include "folder.h"
#include "rp.h"
#include "rp_cpu.h"
#include "straight.h"
#include "wordlist.h"
#include "straight.h"
static int straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict)
{

@ -9,15 +9,12 @@
#include "event.h"
#include "convert.h"
#include "thread.h"
#include "timer.h"
#include "status.h"
#include "restore.h"
#include "shared.h"
#include "hwmon.h"
#include "interface.h"
#include "outfile.h"
#include "terminal.h"
#include "hashcat.h"
#include "terminal.h"
static const size_t TERMINAL_LINE_LENGTH = 79;

@ -5,10 +5,8 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "event.h"
#include "timer.h"
#include "shared.h"
#include "thread.h"
/*

@ -5,17 +5,11 @@
#include "common.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "event.h"
#include "memory.h"
#include "filehandling.h"
#include "ext_OpenCL.h"
#include "tuningdb.h"
#include "thread.h"
#include "opencl.h"
#include "hashes.h"
#include "shared.h"
#include "tuningdb.h"
static int sort_by_tuning_db_alias (const void *v1, const void *v2)
{

@ -5,9 +5,9 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "shared.h"
#include "interface.h"
#include "memory.h"
#include "usage.h"
static const char *const USAGE_MINI[] =

@ -11,7 +11,6 @@
#include "interface.h"
#include "shared.h"
#include "usage.h"
#include "outfile.h"
#include "opencl.h"
#include "user_options.h"

@ -9,7 +9,6 @@
#include "event.h"
#include "convert.h"
#include "dictstat.h"
#include "thread.h"
#include "rp.h"
#include "rp_cpu.h"
#include "shared.h"

Loading…
Cancel
Save