mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-29 19:38:18 +00:00
Rudimentary --show support is back
This commit is contained in:
parent
9b2c69a00d
commit
f5a92900c6
@ -476,6 +476,8 @@ typedef struct hash
|
||||
void *esalt;
|
||||
int cracked;
|
||||
hashinfo_t *hash_info;
|
||||
char *pw_buf;
|
||||
int pw_len;
|
||||
|
||||
} hash_t;
|
||||
|
||||
|
16
src/hashes.c
16
src/hashes.c
@ -1220,13 +1220,6 @@ int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx)
|
||||
hashes->salts_cnt = salts_cnt;
|
||||
hashes->salts_done = salts_done;
|
||||
|
||||
// at this point we no longer need hash_t* structure
|
||||
|
||||
hcfree (hashes_buf);
|
||||
|
||||
hashes->hashes_cnt = 0;
|
||||
hashes->hashes_buf = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1279,6 +1272,15 @@ int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// at this point we no longer need hash_t* structure
|
||||
|
||||
hash_t *hashes_buf = hashes->hashes_buf;
|
||||
|
||||
hcfree (hashes_buf);
|
||||
|
||||
hashes->hashes_cnt = 0;
|
||||
hashes->hashes_buf = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
u32 outfile_check_timer = user_options->outfile_check_timer;
|
||||
|
||||
// buffers
|
||||
hash_t hash_buf = { 0, 0, 0, 0, 0 };
|
||||
hash_t hash_buf = { 0, 0, 0, 0, 0, NULL, 0 };
|
||||
|
||||
hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest);
|
||||
|
||||
|
@ -785,14 +785,12 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
while (!feof (potfile_ctx->fp))
|
||||
{
|
||||
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, potfile_ctx->fp);
|
||||
|
||||
if (ptr == NULL) break;
|
||||
|
||||
int line_len = strlen (line_buf);
|
||||
int line_len = fgetl (potfile_ctx->fp, line_buf);
|
||||
|
||||
if (line_len == 0) continue;
|
||||
|
||||
const int line_len_orig = line_len;
|
||||
|
||||
int iter = MAX_CUT_TRIES;
|
||||
|
||||
for (int i = line_len - 1; i && iter; i--, line_len--)
|
||||
@ -910,6 +908,16 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (found == NULL) continue;
|
||||
|
||||
char *pw_buf = line_buf + line_len;
|
||||
int pw_len = line_len_orig - line_len;
|
||||
|
||||
found->pw_buf = (char *) hcmalloc (hashcat_ctx, pw_len + 1); VERIFY_PTR (found->pw_buf);
|
||||
found->pw_len = pw_len;
|
||||
|
||||
memcpy (found->pw_buf, pw_buf, pw_len);
|
||||
|
||||
found->pw_buf[found->pw_len] = 0;
|
||||
|
||||
found->cracked = 1;
|
||||
|
||||
if (found) break;
|
||||
@ -939,10 +947,42 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int potfile_handle_show (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "The --show feature is currently not available");
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
|
||||
hash_t *hashes_buf = hashes->hashes_buf;
|
||||
|
||||
u32 salts_cnt = hashes->salts_cnt;
|
||||
salt_t *salts_buf = hashes->salts_buf;
|
||||
|
||||
for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++)
|
||||
{
|
||||
salt_t *salt_buf = salts_buf + salt_idx;
|
||||
|
||||
u32 digests_cnt = salt_buf->digests_cnt;
|
||||
|
||||
for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++)
|
||||
{
|
||||
const u32 hashes_idx = salt_buf->digests_offset + digest_idx;
|
||||
|
||||
u32 *digests_shown = hashes->digests_shown;
|
||||
|
||||
if (digests_shown[hashes_idx] == 0) continue;
|
||||
|
||||
char out_buf[HCBUFSIZ_LARGE]; // scratch buffer
|
||||
|
||||
out_buf[0] = 0;
|
||||
|
||||
ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx);
|
||||
|
||||
char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer
|
||||
|
||||
const int tmp_len = outfile_write (hashcat_ctx, out_buf, (unsigned char *) hashes_buf[hashes_idx].pw_buf, hashes->hashes_buf[hashes_idx].pw_len, 0, NULL, 0, tmp_buf);
|
||||
|
||||
EVENT_DATA (EVENT_POTFILE_HASH_CRACKED, tmp_buf, tmp_len);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user