1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-13 18:18:12 +00:00

Fix use-after-free of hash_name

This commit is contained in:
jsteube 2019-01-21 10:00:44 +01:00
parent de690abfa6
commit b2154b7ed9
5 changed files with 16 additions and 12 deletions

View File

@ -35,8 +35,8 @@ double status_get_guess_mod_percent (const hashcat_ctx_t *hash
char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx); char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx);
int status_get_guess_mask_length (const hashcat_ctx_t *hashcat_ctx); int status_get_guess_mask_length (const hashcat_ctx_t *hashcat_ctx);
char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
const char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); char *status_get_hash_name (const hashcat_ctx_t *hashcat_ctx);
const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx);
int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx); int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx);
int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx); int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx);
double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx); double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx);

View File

@ -2056,8 +2056,8 @@ typedef struct device_info
typedef struct hashcat_status typedef struct hashcat_status
{ {
const char *hash_target; char *hash_target;
const char *hash_type; char *hash_name;
int guess_mode; int guess_mode;
char *guess_base; char *guess_base;
int guess_base_offset; int guess_base_offset;

View File

@ -1396,7 +1396,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
hashcat_status->digests_done = status_get_digests_done (hashcat_ctx); hashcat_status->digests_done = status_get_digests_done (hashcat_ctx);
hashcat_status->digests_percent = status_get_digests_percent (hashcat_ctx); hashcat_status->digests_percent = status_get_digests_percent (hashcat_ctx);
hashcat_status->hash_target = status_get_hash_target (hashcat_ctx); hashcat_status->hash_target = status_get_hash_target (hashcat_ctx);
hashcat_status->hash_type = status_get_hash_type (hashcat_ctx); hashcat_status->hash_name = status_get_hash_name (hashcat_ctx);
hashcat_status->guess_base = status_get_guess_base (hashcat_ctx); hashcat_status->guess_base = status_get_guess_base (hashcat_ctx);
hashcat_status->guess_base_offset = status_get_guess_base_offset (hashcat_ctx); hashcat_status->guess_base_offset = status_get_guess_base_offset (hashcat_ctx);
hashcat_status->guess_base_count = status_get_guess_base_count (hashcat_ctx); hashcat_status->guess_base_count = status_get_guess_base_count (hashcat_ctx);

View File

@ -289,14 +289,14 @@ int status_get_status_number (const hashcat_ctx_t *hashcat_ctx)
return status_ctx->devices_status; return status_ctx->devices_status;
} }
const char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx) char *status_get_hash_name (const hashcat_ctx_t *hashcat_ctx)
{ {
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
return hashconfig->hash_name; return hcstrdup (hashconfig->hash_name);
} }
const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx) char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
{ {
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const hashes_t *hashes = hashcat_ctx->hashes; const hashes_t *hashes = hashcat_ctx->hashes;
@ -324,7 +324,7 @@ const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
{ {
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
{ {
return hashes->hashfile; return hcstrdup (hashes->hashfile);
} }
else else
{ {
@ -346,7 +346,7 @@ const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
} }
else else
{ {
return hashes->hashfile; return hcstrdup (hashes->hashfile);
} }
} }
@ -2159,6 +2159,8 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca
if (status_ctx->accessible == false) return; if (status_ctx->accessible == false) return;
hcfree (hashcat_status->hash_target);
hcfree (hashcat_status->hash_name);
hcfree (hashcat_status->session); hcfree (hashcat_status->session);
hcfree (hashcat_status->time_estimated_absolute); hcfree (hashcat_status->time_estimated_absolute);
hcfree (hashcat_status->time_estimated_relative); hcfree (hashcat_status->time_estimated_relative);
@ -2170,6 +2172,8 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca
hcfree (hashcat_status->guess_charset); hcfree (hashcat_status->guess_charset);
hcfree (hashcat_status->cpt); hcfree (hashcat_status->cpt);
hashcat_status->hash_target = NULL;
hashcat_status->hash_name = NULL;
hashcat_status->session = NULL; hashcat_status->session = NULL;
hashcat_status->time_estimated_absolute = NULL; hashcat_status->time_estimated_absolute = NULL;
hashcat_status->time_estimated_relative = NULL; hashcat_status->time_estimated_relative = NULL;

View File

@ -933,8 +933,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
hashcat_status->status_string); hashcat_status->status_string);
event_log_info (hashcat_ctx, event_log_info (hashcat_ctx,
"Hash.Type........: %s", "Hash.Name........: %s",
hashcat_status->hash_type); hashcat_status->hash_name);
event_log_info (hashcat_ctx, event_log_info (hashcat_ctx,
"Hash.Target......: %s", "Hash.Target......: %s",