From 437e9aa3d1c40d48709e2deab918fb0ff1b61186 Mon Sep 17 00:00:00 2001 From: philsmd Date: Mon, 15 Jun 2020 15:43:49 +0200 Subject: [PATCH] allow --left and -o work with binary hash files --- include/outfile.h | 2 +- src/hashes.c | 2 +- src/outfile.c | 10 +++++++--- src/potfile.c | 12 +++++++----- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/outfile.h b/include/outfile.h index e54c09a35..7201aad42 100644 --- a/include/outfile.h +++ b/include/outfile.h @@ -20,6 +20,6 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx); int outfile_write_open (hashcat_ctx_t *hashcat_ctx); void outfile_write_close (hashcat_ctx_t *hashcat_ctx); -int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE]); +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char tmp_buf[HCBUFSIZ_LARGE]); #endif // _OUTFILE_H diff --git a/src/hashes.c b/src/hashes.c index d8dd14d29..240c2496a 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -386,7 +386,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl tmp_buf[0] = 0; - const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, plain_ptr, plain_len, crackpos, NULL, 0, (char *) tmp_buf); + const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, plain_ptr, plain_len, crackpos, NULL, 0, true, (char *) tmp_buf); EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len); diff --git a/src/outfile.c b/src/outfile.c index a0498b902..ca58aa267 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -538,7 +538,7 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx) hc_fclose (&outfile_ctx->fp); } -int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE]) +int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const bool print_eol, char tmp_buf[HCBUFSIZ_LARGE]) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const user_options_t *user_options = hashcat_ctx->user_options; @@ -687,8 +687,12 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou if (outfile_ctx->fp.pfp != NULL) { - hc_fwrite (tmp_buf, tmp_len, 1, &outfile_ctx->fp); - hc_fwrite (EOL, strlen (EOL), 1, &outfile_ctx->fp); + hc_fwrite (tmp_buf, tmp_len, 1, &outfile_ctx->fp); + + if (print_eol == true) + { + hc_fwrite (EOL, strlen (EOL), 1, &outfile_ctx->fp); + } } return tmp_len; diff --git a/src/potfile.c b/src/potfile.c index 1ef2ac383..c8864f7e3 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -768,7 +768,7 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) } } - const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) mixed_buf, mixed_len, 0, username, user_len, (char *) tmp_buf); + const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) mixed_buf, mixed_len, 0, username, user_len, true, (char *) tmp_buf); //EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); @@ -852,11 +852,11 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) const size_t pass_unhexified_len = exec_unhexify ((u8 *) hash->pw_buf, hash->pw_len, pass_unhexified, sizeof (pass_unhexified)); - tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, pass_unhexified, (u32) pass_unhexified_len, 0, username, user_len, (char *) tmp_buf); + tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, pass_unhexified, (u32) pass_unhexified_len, 0, username, user_len, true, (char *) tmp_buf); } else { - tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) hash->pw_buf, hash->pw_len, 0, username, user_len, (char *) tmp_buf); + tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, (u8 *) hash->pw_buf, hash->pw_len, 0, username, user_len, true, (char *) tmp_buf); } //EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); @@ -977,7 +977,7 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) tmp_buf[0] = 0; - const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, (char *) tmp_buf); + const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, true, (char *) tmp_buf); //EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len); @@ -1058,11 +1058,13 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) } } + const bool print_eol = (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) == 0; + u8 *tmp_buf = potfile_ctx->tmp_buf; tmp_buf[0] = 0; - const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, (char *) tmp_buf); + const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, out_len, NULL, 0, 0, username, user_len, print_eol, (char *) tmp_buf); //EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len);