From 6cb4abd526c2b8f25ac765bc1de68bba58bf4328 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 21 Jun 2019 21:56:38 +0200 Subject: [PATCH] Add zlib support v2 --- example.dict.gz | 0 example0.gz.sh | 1 + example0.hash.gz | 0 example400.gz.sh | 1 + example400.hash.gz | 0 example500.gz.sh | 1 + example500.hash.gz | 0 include/filehandling.h | 6 +- include/hlfmt.h | 3 +- include/shared.h | 20 +++- include/slow_candidates.h | 9 +- include/types.h | 19 ++- include/wordlist.h | 10 +- src/Makefile | 2 +- src/backend.c | 24 ++-- src/combinator.c | 132 ++++++++++++++------- src/cpu_crc32.c | 3 +- src/debugfile.c | 9 +- src/dictstat.c | 18 ++- src/dispatch.c | 126 +++++++++++++------- src/filehandling.c | 18 ++- src/hashes.c | 53 ++++++--- src/hlfmt.c | 10 +- src/keyboard_layout.c | 21 ++-- src/logfile.c | 3 +- src/loopback.c | 6 +- src/main.c | 51 ++++++--- src/modules/module_02500.c | 15 ++- src/modules/module_02501.c | 15 ++- src/modules/module_05200.c | 12 +- src/modules/module_06211.c | 12 +- src/modules/module_06212.c | 12 +- src/modules/module_06213.c | 12 +- src/modules/module_06221.c | 12 +- src/modules/module_06222.c | 12 +- src/modules/module_06223.c | 12 +- src/modules/module_06231.c | 12 +- src/modules/module_06232.c | 12 +- src/modules/module_06233.c | 12 +- src/modules/module_06241.c | 12 +- src/modules/module_06242.c | 12 +- src/modules/module_06243.c | 12 +- src/modules/module_09000.c | 12 +- src/modules/module_13711.c | 12 +- src/modules/module_13712.c | 12 +- src/modules/module_13713.c | 12 +- src/modules/module_13721.c | 12 +- src/modules/module_13722.c | 12 +- src/modules/module_13723.c | 12 +- src/modules/module_13731.c | 12 +- src/modules/module_13732.c | 12 +- src/modules/module_13733.c | 12 +- src/modules/module_13741.c | 12 +- src/modules/module_13742.c | 12 +- src/modules/module_13743.c | 12 +- src/modules/module_13751.c | 12 +- src/modules/module_13752.c | 12 +- src/modules/module_13753.c | 12 +- src/modules/module_13761.c | 12 +- src/modules/module_13762.c | 12 +- src/modules/module_13763.c | 12 +- src/modules/module_13771.c | 12 +- src/modules/module_13772.c | 12 +- src/modules/module_13773.c | 12 +- src/modules/module_14600.c | 63 ++++++---- src/mpsp.c | 30 ++++- src/outfile.c | 6 +- src/outfile_check.c | 8 +- src/pidfile.c | 6 +- src/potfile.c | 8 +- src/restore.c | 3 +- src/rp.c | 15 ++- src/shared.c | 229 ++++++++++++++++++++++++++++++++++++- src/slow_candidates.c | 43 ++++--- src/stdout.c | 3 +- src/straight.c | 48 +++++--- src/terminal.c | 6 +- src/tuningdb.c | 21 ++-- src/usage.c | 18 ++- src/wordlist.c | 36 ++++-- 80 files changed, 1122 insertions(+), 417 deletions(-) create mode 100644 example.dict.gz create mode 100644 example0.gz.sh create mode 100644 example0.hash.gz create mode 100644 example400.gz.sh create mode 100644 example400.hash.gz create mode 100644 example500.gz.sh create mode 100644 example500.hash.gz diff --git a/example.dict.gz b/example.dict.gz new file mode 100644 index 000000000..e69de29bb diff --git a/example0.gz.sh b/example0.gz.sh new file mode 100644 index 000000000..e8f557e41 --- /dev/null +++ b/example0.gz.sh @@ -0,0 +1 @@ +./hashcat -t 32 -a 7 example0.hash.gz ?a?a?a?a example.dict.gz diff --git a/example0.hash.gz b/example0.hash.gz new file mode 100644 index 000000000..e69de29bb diff --git a/example400.gz.sh b/example400.gz.sh new file mode 100644 index 000000000..bf0a5741d --- /dev/null +++ b/example400.gz.sh @@ -0,0 +1 @@ +cat example.dict | ./hashcat -m 400 example400.hash.gz diff --git a/example400.hash.gz b/example400.hash.gz new file mode 100644 index 000000000..e69de29bb diff --git a/example500.gz.sh b/example500.gz.sh new file mode 100644 index 000000000..d25fcd865 --- /dev/null +++ b/example500.gz.sh @@ -0,0 +1 @@ +./hashcat -m 500 example500.hash.gz example.dict.gz diff --git a/example500.hash.gz b/example500.hash.gz new file mode 100644 index 000000000..e69de29bb diff --git a/include/filehandling.h b/include/filehandling.h index 0b430284a..ebd2b4cc0 100644 --- a/include/filehandling.h +++ b/include/filehandling.h @@ -10,9 +10,11 @@ #include #include -u64 count_lines (FILE *fd); +//u64 count_lines (FILE *fd); +u64 count_lines (fp_tmp_t *fp_t); -size_t fgetl (FILE *fp, char *line_buf); +//size_t fgetl (FILE *fp, char *line_buf); +size_t fgetl (fp_tmp_t *fp_t, char *line_buf); size_t superchop_with_length (char *buf, const size_t len); diff --git a/include/hlfmt.h b/include/hlfmt.h index 05d94d76e..8fa346e5d 100644 --- a/include/hlfmt.h +++ b/include/hlfmt.h @@ -15,6 +15,7 @@ const char *strhlfmt (const u32 hashfile_format); void hlfmt_hash (hashcat_ctx_t *hashcat_ctx, u32 hashfile_format, char *line_buf, const int line_len, char **hashbuf_pos, int *hashbuf_len); void hlfmt_user (hashcat_ctx_t *hashcat_ctx, u32 hashfile_format, char *line_buf, const int line_len, char **userbuf_pos, int *userbuf_len); -u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check); +//u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check); +u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, u32 max_check); #endif // _HLFMT_H diff --git a/include/shared.h b/include/shared.h index a85f19490..7e988558d 100644 --- a/include/shared.h +++ b/include/shared.h @@ -14,6 +14,7 @@ #include #include #include +#include "zlib.h" #if defined (_WIN) #include // needed for select() @@ -61,8 +62,23 @@ bool hc_string_is_digit (const char *s); void hc_string_trim_trailing (char *s); void hc_string_trim_leading (char *s); -size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); -size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); +//size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); +//size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); +bool hc_fopen(fp_tmp_t *fp_t, const char *path, char *mode); +size_t hc_fread (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t); +size_t hc_fread_direct (void *ptr, size_t size, size_t nmemb, FILE *stream); +size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t); +void hc_fwrite_direct (const void *ptr, size_t size, size_t nmemb, FILE *stream); +int hc_fseek (fp_tmp_t *fp_t, off_t offset, int whence); +void hc_rewind (fp_tmp_t *fp_t); +off_t hc_ftell (fp_tmp_t *fp_t); +int hc_fgetc (fp_tmp_t *fp_t); +int hc_fputc (int c, fp_tmp_t *fp_t); +char *hc_fgets (char *buf, int len, fp_tmp_t *fp_t); +int hc_fileno (fp_tmp_t *fp_t); +int hc_feof (fp_tmp_t *fp_t); +//void hc_fflush (fp_tmp_t *fp_t); +void hc_fclose (fp_tmp_t *fp_t); bool hc_same_files (char *file1, char *file2); diff --git a/include/slow_candidates.h b/include/slow_candidates.h index 92f743d20..4ba0729fc 100644 --- a/include/slow_candidates.h +++ b/include/slow_candidates.h @@ -10,7 +10,8 @@ typedef struct extra_info_straight { u64 pos; - FILE *fp; +// FILE *fp; + fp_tmp_t *fp_t; u64 rule_pos_prev; u64 rule_pos; @@ -27,8 +28,10 @@ typedef struct extra_info_combi { u64 pos; - FILE *base_fp; - FILE *combs_fp; +// FILE *base_fp; +// FILE *combs_fp; + fp_tmp_t *base_fp_t; + fp_tmp_t *combs_fp_t; u64 comb_pos_prev; u64 comb_pos; diff --git a/include/types.h b/include/types.h index b665d91e9..bb7b55026 100644 --- a/include/types.h +++ b/include/types.h @@ -17,6 +17,7 @@ #include #include #include +#include "zlib.h" #if defined (_WIN) #define WINICONV_CONST @@ -988,6 +989,21 @@ typedef struct link_speed } link_speed_t; +// handling gzip files + +typedef struct fp_tmp +{ + union + { + FILE *fp; + gzFile gfp; + } f; + + short is_gzip; + const char *path; + char *mode; +} fp_tmp_t; + #include "ext_nvrtc.h" #include "ext_cuda.h" #include "ext_OpenCL.h" @@ -1149,7 +1165,8 @@ typedef struct hc_device_param char *scratch_buf; - FILE *combs_fp; +// FILE *combs_fp; + fp_tmp_t *combs_fp_t; pw_t *combs_buf; void *hooks_buf; diff --git a/include/wordlist.h b/include/wordlist.h index 8ee61ab88..52ee40629 100644 --- a/include/wordlist.h +++ b/include/wordlist.h @@ -19,9 +19,13 @@ void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off); void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off); void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off); -void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len); -int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd); -int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 *result); +//void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len); +//int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd); +//int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 *result); +void get_next_word (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, char **out_buf, u32 *out_len); +int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t); +int count_words (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, const char *dictfile, u64 *result); + int wl_data_init (hashcat_ctx_t *hashcat_ctx); void wl_data_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/src/Makefile b/src/Makefile index 8d0854e2a..2230f4a52 100644 --- a/src/Makefile +++ b/src/Makefile @@ -318,7 +318,7 @@ WIN_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).WIN.o) endif ifeq ($(USE_SYSTEM_ZLIB),0) -OBJS_ZLIB := adler32 crc32 zutil inftrees inffast inflate +OBJS_ZLIB := adler32 crc32 zutil inftrees inffast inflate compress deflate gzclose gzlib gzread gzwrite infback inftrees trees uncompr zutil NATIVE_OBJS += $(foreach OBJ,$(OBJS_ZLIB),obj/$(OBJ).NATIVE.o) LINUX_OBJS += $(foreach OBJ,$(OBJS_ZLIB),obj/$(OBJ).LINUX.o) diff --git a/src/backend.c b/src/backend.c index aad024b58..9db0c93a2 100644 --- a/src/backend.c +++ b/src/backend.c @@ -457,7 +457,8 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f char *buf = (char *) hcmalloc (st.st_size + 1 + EXTRASZ); - size_t num_read = hc_fread (buf, sizeof (char), st.st_size, fp); +// size_t num_read = hc_fread (buf, sizeof (char), st.st_size, fp); + size_t num_read = hc_fread_direct (buf, sizeof (char), st.st_size, fp); fclose (fp); @@ -521,7 +522,8 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, return false; } - hc_fwrite (binary, sizeof (char), binary_size, fp); +// hc_fwrite (binary, sizeof (char), binary_size, fp); + hc_fwrite_direct (binary, sizeof (char), binary_size, fp); fflush (fp); @@ -4375,7 +4377,8 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co device_param->kernel_params_buf32[31] = salt_buf->digests_cnt; device_param->kernel_params_buf32[32] = salt_buf->digests_offset; - FILE *combs_fp = device_param->combs_fp; +// FILE *combs_fp = device_param->combs_fp; + fp_tmp_t *combs_fp_t = device_param->combs_fp_t; if (user_options->slow_candidates == true) { @@ -4384,7 +4387,8 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co { if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))) { - rewind (combs_fp); +// rewind (combs_fp); + hc_rewind (combs_fp_t); } } @@ -4478,9 +4482,11 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co while (i < innerloop_left) { - if (feof (combs_fp)) break; +// if (feof (combs_fp)) break; + if (hc_feof (combs_fp_t)) break; - size_t line_len = fgetl (combs_fp, line_buf); +// size_t line_len = fgetl (combs_fp, line_buf); + size_t line_len = fgetl (combs_fp_t, line_buf); line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); @@ -4643,9 +4649,11 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co while (i < innerloop_left) { - if (feof (combs_fp)) break; +// if (feof (combs_fp)) break; + if (hc_feof (combs_fp_t)) break; - size_t line_len = fgetl (combs_fp, line_buf); +// size_t line_len = fgetl (combs_fp, line_buf); + size_t line_len = fgetl (combs_fp_t, line_buf); line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); diff --git a/src/combinator.c b/src/combinator.c index a8fd4f3ef..4111a0bbd 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -60,21 +60,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - FILE *fp1 = NULL; - FILE *fp2 = NULL; +// FILE *fp1 = NULL; +// FILE *fp2 = NULL; + fp_tmp_t fp1_t; + fp_tmp_t fp2_t; - if ((fp1 = fopen (dictfile1, "rb")) == NULL) +// if ((fp1 = fopen (dictfile1, "rb")) == NULL) + if (hc_fopen (&fp1_t, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if ((fp2 = fopen (dictfile2, "rb")) == NULL) +// if ((fp2 = fopen (dictfile2, "rb")) == NULL) + if (hc_fopen (&fp2_t, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); - fclose (fp1); +// fclose (fp1); + hc_fclose (&fp1_t); return -1; } @@ -83,14 +88,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words1_cnt = 0; - const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); +// const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); + const int rc1 = count_words (hashcat_ctx, &fp1_t, dictfile1, &words1_cnt); if (rc1 == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -99,8 +107,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -109,10 +119,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words2_cnt = 0; - const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); +// const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); + const int rc2 = count_words (hashcat_ctx, &fp2_t, dictfile2, &words2_cnt); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); if (rc2 == -1) { @@ -163,21 +176,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - FILE *fp1 = NULL; - FILE *fp2 = NULL; +// FILE *fp1 = NULL; +// FILE *fp2 = NULL; + fp_tmp_t fp1_t; + fp_tmp_t fp2_t; - if ((fp1 = fopen (dictfile1, "rb")) == NULL) +// if ((fp1 = fopen (dictfile1, "rb")) == NULL) + if (hc_fopen (&fp1_t, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if ((fp2 = fopen (dictfile2, "rb")) == NULL) +// if ((fp2 = fopen (dictfile2, "rb")) == NULL) + if (hc_fopen (&fp2_t, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); - fclose (fp1); +// fclose (fp1); + hc_fclose (&fp1_t); return -1; } @@ -186,14 +204,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words1_cnt = 0; - const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); +// const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); + const int rc1 = count_words (hashcat_ctx, &fp1_t, dictfile1, &words1_cnt); if (rc1 == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -202,8 +223,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -212,10 +235,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words2_cnt = 0; - const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); +// const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); + const int rc2 = count_words (hashcat_ctx, &fp2_t, dictfile2, &words2_cnt); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); if (rc2 == -1) { @@ -294,21 +320,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - FILE *fp1 = NULL; - FILE *fp2 = NULL; +// FILE *fp1 = NULL; +// FILE *fp2 = NULL; + fp_tmp_t fp1_t; + fp_tmp_t fp2_t; - if ((fp1 = fopen (dictfile1, "rb")) == NULL) +// if ((fp1 = fopen (dictfile1, "rb")) == NULL) + if (hc_fopen (&fp1_t, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if ((fp2 = fopen (dictfile2, "rb")) == NULL) +// if ((fp2 = fopen (dictfile2, "rb")) == NULL) + if (hc_fopen (&fp2_t, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); - fclose (fp1); +// fclose (fp1); + hc_fclose (&fp1_t); return -1; } @@ -317,14 +348,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words1_cnt = 0; - const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); +// const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); + const int rc1 = count_words (hashcat_ctx, &fp1_t, dictfile1, &words1_cnt); if (rc1 == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -333,8 +367,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) { event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); return -1; } @@ -343,10 +379,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words2_cnt = 0; - const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); +// const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); + const int rc2 = count_words (hashcat_ctx, &fp2_t, dictfile2, &words2_cnt); - fclose (fp1); - fclose (fp2); +// fclose (fp1); +// fclose (fp2); + hc_fclose (&fp1_t); + hc_fclose (&fp2_t); if (rc2 == -1) { @@ -387,9 +426,11 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) return -1; } - FILE *fp = NULL; +// FILE *fp = NULL; + fp_tmp_t fp_t; - if ((fp = fopen (dictfile, "rb")) == NULL) +// if ((fp = fopen (dictfile, "rb")) == NULL) + if (hc_fopen (&fp_t, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); @@ -400,18 +441,21 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) u64 words_cnt = 0; - const int rc = count_words (hashcat_ctx, fp, dictfile, &words_cnt); +// const int rc = count_words (hashcat_ctx, fp, dictfile, &words_cnt); + const int rc = count_words (hashcat_ctx, &fp_t, dictfile, &words_cnt); + + hc_fclose (&fp_t); if (rc == -1) { event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile); - fclose (fp); +// fclose (fp); return -1; } - fclose (fp); +// fclose (fp); combinator_ctx->combs_cnt = words_cnt; combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 2f5450640..86069625c 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -98,7 +98,8 @@ int cpu_crc32 (const char *filename, u8 keytab[64]) u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1); - size_t nread = hc_fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); +// size_t nread = hc_fread (buf, sizeof (u8), MAX_KEY_SIZE, fd); + size_t nread = hc_fread_direct (buf, sizeof (u8), MAX_KEY_SIZE, fd); fclose (fd); diff --git a/src/debugfile.c b/src/debugfile.c index 5e0a62bbe..bfe36ec67 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -48,7 +48,8 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ } else { - hc_fwrite (plain_ptr, plain_len, 1, debugfile_ctx->fp); +// hc_fwrite (plain_ptr, plain_len, 1, debugfile_ctx->fp); + hc_fwrite_direct (plain_ptr, plain_len, 1, debugfile_ctx->fp); } } @@ -67,7 +68,8 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp); } - hc_fwrite (rule_buf, rule_len, 1, debugfile_ctx->fp); +// hc_fwrite (rule_buf, rule_len, 1, debugfile_ctx->fp); + hc_fwrite_direct (rule_buf, rule_len, 1, debugfile_ctx->fp); if (debug_mode == 4) { @@ -76,7 +78,8 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len); } - hc_fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp); +// hc_fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, debugfile_ctx->fp); } int debugfile_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/dictstat.c b/src/dictstat.c index 7ee0e4297..fd37c3faa 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -110,8 +110,10 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) 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); +// const size_t nread1 = hc_fread (&v, sizeof (u64), 1, fp); +// const size_t nread2 = hc_fread (&z, sizeof (u64), 1, fp); + const size_t nread1 = hc_fread_direct (&v, sizeof (u64), 1, fp); + const size_t nread2 = hc_fread_direct (&z, sizeof (u64), 1, fp); if ((nread1 != 1) || (nread2 != 1)) { @@ -158,7 +160,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) { dictstat_t d; - const size_t nread = hc_fread (&d, sizeof (dictstat_t), 1, fp); +// const size_t nread = hc_fread (&d, sizeof (dictstat_t), 1, fp); + const size_t nread = hc_fread_direct (&d, sizeof (dictstat_t), 1, fp); if (nread == 0) continue; @@ -210,12 +213,15 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx) v = byte_swap_64 (v); z = byte_swap_64 (z); - hc_fwrite (&v, sizeof (u64), 1, fp); - hc_fwrite (&z, sizeof (u64), 1, fp); +// hc_fwrite (&v, sizeof (u64), 1, fp); +// hc_fwrite (&z, sizeof (u64), 1, fp); + hc_fwrite_direct (&v, sizeof (u64), 1, fp); + hc_fwrite_direct (&z, sizeof (u64), 1, fp); // data - hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp); +// hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp); + hc_fwrite_direct (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp); fclose (fp); diff --git a/src/dispatch.c b/src/dispatch.c index 6f841124a..93ab938fe 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -427,9 +427,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { char *dictfile = straight_ctx->dict; - FILE *fp = fopen (dictfile, "rb"); +// FILE *fp = fopen (dictfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) +// if (fp == NULL) + if (hc_fopen (&fp_t, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); @@ -440,7 +442,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memset (&extra_info_straight, 0, sizeof (extra_info_straight)); - extra_info_straight.fp = fp; +// extra_info_straight.fp = fp; + extra_info_straight.fp_t = &fp_t; hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); @@ -452,7 +455,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (rc_wl_data_init == -1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -663,7 +667,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -676,7 +681,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -721,7 +727,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (words_fin == 0) break; } - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); wl_data_destroy (hashcat_ctx_tmp); @@ -747,18 +754,22 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) combs_file = combinator_ctx->dict1; } - FILE *base_fp = fopen (base_file, "rb"); +// FILE *base_fp = fopen (base_file, "rb"); + fp_tmp_t base_fp_t; - if (base_fp == NULL) +// if (base_fp == NULL) + if (hc_fopen (&base_fp_t, base_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", base_file, strerror (errno)); return -1; } - FILE *combs_fp = fopen (combs_file, "rb"); +// FILE *combs_fp = fopen (combs_file, "rb"); + fp_tmp_t combs_fp_t; - if (combs_fp == NULL) +// if (combs_fp == NULL) + if (hc_fopen (&combs_fp_t, combs_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combs_file, strerror (errno)); @@ -769,8 +780,10 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) memset (&extra_info_combi, 0, sizeof (extra_info_combi)); - extra_info_combi.base_fp = base_fp; - extra_info_combi.combs_fp = combs_fp; +// extra_info_combi.base_fp = base_fp; +// extra_info_combi.combs_fp = combs_fp; + extra_info_combi.base_fp_t = &base_fp_t; + extra_info_combi.combs_fp_t = &combs_fp_t; extra_info_combi.scratch_buf = device_param->scratch_buf; hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); @@ -783,9 +796,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (rc_wl_data_init == -1) { - fclose (combs_fp); +// fclose (combs_fp); + hc_fclose (&combs_fp_t); - fclose (base_fp); +// fclose (base_fp); + hc_fclose (&base_fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -996,9 +1011,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - fclose (combs_fp); +// fclose (combs_fp); + hc_fclose (&combs_fp_t); - fclose (base_fp); +// fclose (base_fp); + hc_fclose (&base_fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -1011,9 +1028,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - fclose (combs_fp); +// fclose (combs_fp); + hc_fclose (&combs_fp_t); - fclose (base_fp); +// fclose (base_fp); + hc_fclose (&base_fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -1058,9 +1077,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (words_fin == 0) break; } - fclose (combs_fp); +// fclose (combs_fp); + hc_fclose (&combs_fp_t); - fclose (base_fp); +// fclose (base_fp); + hc_fclose (&base_fp_t); wl_data_destroy (hashcat_ctx_tmp); @@ -1322,16 +1343,19 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { char *dictfile = straight_ctx->dict; - FILE *combs_fp = fopen (dictfile, "rb"); +// FILE *combs_fp = fopen (dictfile, "rb"); + fp_tmp_t combs_fp_t; - if (combs_fp == NULL) +// if (combs_fp == NULL) + if (hc_fopen (&combs_fp_t, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); return -1; } - device_param->combs_fp = combs_fp; +// device_param->combs_fp = combs_fp; + device_param->combs_fp_t = &combs_fp_t; } while (status_ctx->run_thread_level1 == true) @@ -1388,37 +1412,45 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { const char *dictfilec = combinator_ctx->dict2; - FILE *combs_fp = fopen (dictfilec, "rb"); +// FILE *combs_fp = fopen (dictfilec, "rb"); + fp_tmp_t combs_fp_t; - if (combs_fp == NULL) +// if (combs_fp == NULL) + if (hc_fopen (&combs_fp_t, dictfilec, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); return -1; } - device_param->combs_fp = combs_fp; +// device_param->combs_fp = combs_fp; + device_param->combs_fp_t = &combs_fp_t; } else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT) { const char *dictfilec = combinator_ctx->dict1; - FILE *combs_fp = fopen (dictfilec, "rb"); +// FILE *combs_fp = fopen (dictfilec, "rb"); + fp_tmp_t combs_fp_t; - if (combs_fp == NULL) +// if (combs_fp == NULL) + if (hc_fopen (&combs_fp_t, dictfilec, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno)); return -1; } - device_param->combs_fp = combs_fp; +// device_param->combs_fp = combs_fp; + device_param->combs_fp_t = &combs_fp_t; } } - FILE *fd = fopen (dictfile, "rb"); +// FILE *fd = fopen (dictfile, "rb"); + fp_tmp_t fp_t; - if (fd == NULL) +// if (fd == NULL) + if (hc_fopen (&fp_t, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); @@ -1435,9 +1467,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (rc_wl_data_init == -1) { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); +// if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp_t); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -1476,11 +1510,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) char rule_buf_out[RP_PASSWORD_SIZE]; - for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); +// for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, &fp_t, &line_buf, &line_len); for ( ; words_cur < words_fin; words_cur++) { - get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); +// get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + get_next_word (hashcat_ctx_tmp, &fp_t, &line_buf, &line_len); line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); @@ -1567,9 +1603,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); +// if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp_t); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -1582,9 +1620,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (CL_rc == -1) { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); +// if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp_t); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); hcfree (hashcat_ctx_tmp->wl_data); @@ -1638,9 +1678,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (words_fin == 0) break; } - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); +// if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp_t); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); wl_data_destroy (hashcat_ctx_tmp); diff --git a/src/filehandling.c b/src/filehandling.c index 06867abea..84f5b8309 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -9,7 +9,8 @@ #include "shared.h" #include "filehandling.h" -u64 count_lines (FILE *fd) +//u64 count_lines (FILE *fd) +u64 count_lines (fp_tmp_t *fp_t) { u64 cnt = 0; @@ -17,9 +18,11 @@ u64 count_lines (FILE *fd) char prev = '\n'; - while (!feof (fd)) +// while (!feof (fd)) + while (!hc_feof (fp_t)) { - size_t nread = hc_fread (buf, sizeof (char), HCBUFSIZ_LARGE, fd); +// size_t nread = hc_fread (buf, sizeof (char), HCBUFSIZ_LARGE, fd); + size_t nread = hc_fread (buf, sizeof (char), HCBUFSIZ_LARGE, fp_t); if (nread < 1) continue; @@ -38,13 +41,16 @@ u64 count_lines (FILE *fd) return cnt; } -size_t fgetl (FILE *fp, char *line_buf) +//size_t fgetl (FILE *fp, char *line_buf) +size_t fgetl (fp_tmp_t *fp_t, char *line_buf) { size_t line_len = 0; - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (fp_t)) { - const int c = fgetc (fp); +// const int c = fgetc (fp); + const int c = hc_fgetc (fp_t); if (c == EOF) break; diff --git a/src/hashes.c b/src/hashes.c index 72b9aad69..ad1881624 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -228,7 +228,8 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) const int binary_len = module_ctx->module_hash_binary_save (hashes, salt_pos, digest_pos, &binary_buf); - hc_fwrite (binary_buf, binary_len, 1, fp); +// hc_fwrite (binary_buf, binary_len, 1, fp); + hc_fwrite_direct (binary_buf, binary_len, 1, fp); hcfree (binary_buf); } @@ -674,9 +675,11 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else if (hashlist_mode == HL_MODE_FILE_PLAIN) { - FILE *fp = NULL; +// FILE *fp = NULL; + fp_tmp_t fp_t; - if ((fp = fopen (hashfile, "rb")) == NULL) +// if ((fp = fopen (hashfile, "rb")) == NULL) + if (hc_fopen (&fp_t, hashfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); @@ -685,33 +688,39 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_PRE, hashfile, strlen (hashfile)); - hashes_avail = count_lines (fp); +// hashes_avail = count_lines (fp); + hashes_avail = count_lines (&fp_t); EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, strlen (hashfile)); - rewind (fp); +// rewind (fp); + hc_rewind (&fp_t); if (hashes_avail == 0) { event_log_error (hashcat_ctx, "hashfile is empty or corrupt."); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return -1; } - hashlist_format = hlfmt_detect (hashcat_ctx, fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too +// hashlist_format = hlfmt_detect (hashcat_ctx, fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too + hashlist_format = hlfmt_detect (hashcat_ctx, &fp_t, 100); // 100 = max numbers to "scan". could be hashes_avail, too + + hc_fclose (&fp_t); if ((user_options->remove == true) && (hashlist_format != HLFMT_HASHCAT)) { event_log_error (hashcat_ctx, "Use of --remove is not supported in native hashfile-format mode."); - fclose (fp); +// fclose (fp); return -1; } - fclose (fp); +// fclose (fp); } else if (hashlist_mode == HL_MODE_FILE_BINARY) { @@ -996,9 +1005,11 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else if (hashlist_mode == HL_MODE_FILE_PLAIN) { - FILE *fp; +// FILE *fp; + fp_tmp_t fp_t; - if ((fp = fopen (hashfile, "rb")) == NULL) +// if ((fp = fopen (hashfile, "rb")) == NULL) + if (hc_fopen (&fp_t, hashfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); @@ -1012,11 +1023,13 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) time_t prev = 0; time_t now = 0; - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { line_num++; - const size_t line_len = fgetl (fp, line_buf); +// const size_t line_len = fgetl (fp, line_buf); + const size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; @@ -1237,7 +1250,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hcfree (line_buf); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); } else if (hashlist_mode == HL_MODE_FILE_BINARY) { @@ -1792,7 +1806,10 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) hc_asprintf (&tmpfile_bin, "%s/selftest.hash", folder_config->session_dir); - FILE *fp = fopen (tmpfile_bin, "wb"); +// FILE *fp = fopen (tmpfile_bin, "wb"); + fp_tmp_t fp_t; + + hc_fopen (&fp_t, tmpfile_bin, "wb"); const size_t st_hash_len = strlen (hashconfig->st_hash); @@ -1800,10 +1817,12 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) { const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + i); - fputc (c, fp); +// fputc (c, fp); + hc_fputc (c, &fp_t); } - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, hash.hook_salt, hash.hash_info, tmpfile_bin, strlen (tmpfile_bin)); diff --git a/src/hlfmt.c b/src/hlfmt.c index 8bfbd69ca..ab3533799 100644 --- a/src/hlfmt.c +++ b/src/hlfmt.c @@ -8,6 +8,7 @@ #include "memory.h" #include "filehandling.h" #include "hlfmt.h" +#include "shared.h" static const char *HLFMT_TEXT_HASHCAT = "native hashcat"; static const char *HLFMT_TEXT_PWDUMP = "pwdump"; @@ -333,7 +334,8 @@ void hlfmt_user (hashcat_ctx_t *hashcat_ctx, u32 hashfile_format, char *line_buf } } -u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) +//u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) +u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, u32 max_check) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -347,9 +349,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check) char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (fp_t)) { - const size_t line_len = fgetl (fp, line_buf); +// const size_t line_len = fgetl (fp, line_buf); + const size_t line_len = fgetl (fp_t, line_buf); if (line_len == 0) continue; diff --git a/src/keyboard_layout.c b/src/keyboard_layout.c index 24778e1ba..313d28e2d 100644 --- a/src/keyboard_layout.c +++ b/src/keyboard_layout.c @@ -22,15 +22,19 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m { char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); - FILE *fp = fopen (filename, "r"); +// FILE *fp = fopen (filename, "r"); + fp_tmp_t fp_t; - if (fp == NULL) return false; + if (hc_fopen(&fp_t, filename, "r") == false) return false; +// if (fp == NULL) return false; int maps_cnt = 0; - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { - const size_t line_len = fgetl (fp, line_buf); +// const size_t line_len = fgetl (fp, line_buf); + const size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; @@ -52,7 +56,8 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m if (rc_tokenizer != PARSER_OK) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); free (line_buf); @@ -67,7 +72,8 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m if (maps_cnt == 256) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); free (line_buf); @@ -79,7 +85,8 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m *keyboard_layout_mapping_cnt = maps_cnt; - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); free (line_buf); diff --git a/src/logfile.c b/src/logfile.c index e0626f3f6..7f84c5727 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -62,7 +62,8 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) va_end (ap); - hc_fwrite (EOL, strlen (EOL), 1, fp); +// hc_fwrite (EOL, strlen (EOL), 1, fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, fp); fflush (fp); diff --git a/src/loopback.c b/src/loopback.c index 057c1e456..05ab4ff60 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -49,7 +49,8 @@ static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_p } else { - hc_fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp); +// hc_fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp); + hc_fwrite_direct (plain_ptr, plain_len, 1, loopback_ctx->fp); } } @@ -160,7 +161,8 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con lock_file (fp); - hc_fwrite (EOL, strlen (EOL), 1, fp); +// hc_fwrite (EOL, strlen (EOL), 1, fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, fp); fflush (fp); diff --git a/src/main.c b/src/main.c index c5a684f1e..6694d19d7 100644 --- a/src/main.c +++ b/src/main.c @@ -100,16 +100,21 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel) #else switch (loglevel) { - case LOGLEVEL_INFO: break; - case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); break; - case LOGLEVEL_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break; - case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 5, 1, fp); break; +// case LOGLEVEL_INFO: break; +// case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); break; +// case LOGLEVEL_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break; +// case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 5, 1, fp); break; + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: hc_fwrite_direct ("\033[33m", 5, 1, fp); break; + case LOGLEVEL_ERROR: hc_fwrite_direct ("\033[31m", 5, 1, fp); break; + case LOGLEVEL_ADVICE: hc_fwrite_direct ("\033[33m", 5, 1, fp); break; } #endif // finally, print - hc_fwrite (msg_buf, msg_len, 1, fp); +// hc_fwrite (msg_buf, msg_len, 1, fp); + hc_fwrite_direct (msg_buf, msg_len, 1, fp); // color stuff post @@ -124,10 +129,14 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel) #else switch (loglevel) { - case LOGLEVEL_INFO: break; - case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); break; - case LOGLEVEL_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break; - case LOGLEVEL_ADVICE: hc_fwrite ("\033[0m", 4, 1, fp); break; +// case LOGLEVEL_INFO: break; +// case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); break; +// case LOGLEVEL_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break; +// case LOGLEVEL_ADVICE: hc_fwrite ("\033[0m", 4, 1, fp); break; + case LOGLEVEL_INFO: break; + case LOGLEVEL_WARNING: hc_fwrite_direct ("\033[0m", 4, 1, fp); break; + case LOGLEVEL_ERROR: hc_fwrite_direct ("\033[0m", 4, 1, fp); break; + case LOGLEVEL_ADVICE: hc_fwrite_direct ("\033[0m", 4, 1, fp); break; } #endif @@ -135,13 +144,15 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel) if (msg_newline == true) { - hc_fwrite (EOL, strlen (EOL), 1, fp); +// hc_fwrite (EOL, strlen (EOL), 1, fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, fp); // on error, add another newline if (loglevel == LOGLEVEL_ERROR) { - hc_fwrite (EOL, strlen (EOL), 1, fp); +// hc_fwrite (EOL, strlen (EOL), 1, fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, fp); } } @@ -340,8 +351,10 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx); } - hc_fwrite (buf, len, 1, stdout); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (buf, len, 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (buf, len, 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { @@ -386,8 +399,10 @@ static void main_potfile_hash_show (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile - hc_fwrite (buf, len, 1, stdout); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (buf, len, 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (buf, len, 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) @@ -396,8 +411,10 @@ static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile - hc_fwrite (buf, len, 1, stdout); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (buf, len, 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (buf, len, 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) diff --git a/src/modules/module_02500.c b/src/modules/module_02500.c index 066fe55e9..4a4d65ccf 100644 --- a/src/modules/module_02500.c +++ b/src/modules/module_02500.c @@ -374,15 +374,19 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE int hashes_cnt = 0; - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return -1; +// if (fp == NULL) return -1; + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); char *in = (char *) hcmalloc (sizeof (hccapx_t)); - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { - const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, fp); +// const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, fp); + const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp_t); if (nread == 0) break; @@ -458,7 +462,8 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE hcfree (in); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return hashes_cnt; } diff --git a/src/modules/module_02501.c b/src/modules/module_02501.c index a4a6087cd..feda461ef 100644 --- a/src/modules/module_02501.c +++ b/src/modules/module_02501.c @@ -349,15 +349,19 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE int hashes_cnt = 0; - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return -1; +// if (fp == NULL) return -1; + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); char *in = (char *) hcmalloc (sizeof (hccapx_t)); - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { - const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, fp); +// const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, fp); + const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp_t); if (nread == 0) break; @@ -433,7 +437,8 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE hcfree (in); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return hashes_cnt; } diff --git a/src/modules/module_05200.c b/src/modules/module_05200.c index 4786fa276..ab2276990 100644 --- a/src/modules/module_05200.c +++ b/src/modules/module_05200.c @@ -93,17 +93,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (line_len == 0) return (PARSER_HASH_LENGTH); - FILE *fp = fopen ((const char *) line_buf, "rb"); +// FILE *fp = fopen ((const char *) line_buf, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); psafe3_t in; memset (&in, 0, sizeof (psafe3_t)); - const size_t n = hc_fread (&in, sizeof (psafe3_t), 1, fp); +// const size_t n = hc_fread (&in, sizeof (psafe3_t), 1, fp); + const size_t n = hc_fread (&in, sizeof (psafe3_t), 1, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != 1) return (PARSER_PSAFE3_FILE_SIZE); diff --git a/src/modules/module_06211.c b/src/modules/module_06211.c index cda6ab359..8af0ff397 100644 --- a/src/modules/module_06211.c +++ b/src/modules/module_06211.c @@ -146,17 +146,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06212.c b/src/modules/module_06212.c index 8f4cae1a5..4519ca378 100644 --- a/src/modules/module_06212.c +++ b/src/modules/module_06212.c @@ -146,17 +146,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06213.c b/src/modules/module_06213.c index 6283d863d..722a52535 100644 --- a/src/modules/module_06213.c +++ b/src/modules/module_06213.c @@ -144,17 +144,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06221.c b/src/modules/module_06221.c index e6e812e01..da6f9a99c 100644 --- a/src/modules/module_06221.c +++ b/src/modules/module_06221.c @@ -144,17 +144,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06222.c b/src/modules/module_06222.c index 3da847cd7..5649e9d3f 100644 --- a/src/modules/module_06222.c +++ b/src/modules/module_06222.c @@ -144,17 +144,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06223.c b/src/modules/module_06223.c index 512ee2df8..a0fc13545 100644 --- a/src/modules/module_06223.c +++ b/src/modules/module_06223.c @@ -144,17 +144,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06231.c b/src/modules/module_06231.c index 9af349d22..a92f02120 100644 --- a/src/modules/module_06231.c +++ b/src/modules/module_06231.c @@ -146,17 +146,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06232.c b/src/modules/module_06232.c index 324656885..c751dda25 100644 --- a/src/modules/module_06232.c +++ b/src/modules/module_06232.c @@ -146,17 +146,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06233.c b/src/modules/module_06233.c index 2446ba43d..e3754f393 100644 --- a/src/modules/module_06233.c +++ b/src/modules/module_06233.c @@ -146,17 +146,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index 1acf83e2b..3fcd4476f 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -158,17 +158,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index df9f4d311..40674e906 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -158,17 +158,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index d822d0313..de44e5baf 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -158,17 +158,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 char *in = (char *) hcmalloc (TC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, TC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE); diff --git a/src/modules/module_09000.c b/src/modules/module_09000.c index abfe03071..42a98712b 100644 --- a/src/modules/module_09000.c +++ b/src/modules/module_09000.c @@ -156,17 +156,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (line_len == 0) return (PARSER_HASH_LENGTH); - FILE *fp = fopen ((const char *) line_buf, "rb"); +// FILE *fp = fopen ((const char *) line_buf, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); psafe2_hdr buf; memset (&buf, 0, sizeof (psafe2_hdr)); - const size_t n = hc_fread (&buf, sizeof (psafe2_hdr), 1, fp); +// const size_t n = hc_fread (&buf, sizeof (psafe2_hdr), 1, fp); + const size_t n = hc_fread (&buf, sizeof (psafe2_hdr), 1, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != 1) return (PARSER_PSAFE2_FILE_SIZE); diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index c40bb931e..0c02be7d9 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index 281991446..6d4b073eb 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index 1932c3e30..0f589fb05 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index bfd0d8bde..70bb775bc 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -170,17 +170,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index 537d2461f..59fa510c4 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -170,17 +170,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index 3d13c9094..27d54e602 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -170,17 +170,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 3fcd893b9..80af97f3f 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index ccf993163..c0080359d 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index 0300eaa29..602ac5ffd 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index 4c1256b51..86267b528 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index ca30e757d..7b9360246 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index fc92900f2..d7677c67b 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index 1b2031365..605708734 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index f86cabfe6..457d4e51a 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index 68bb3c34d..07b19c12e 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -172,17 +172,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index 0114f8f29..ca0d7262a 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index 79ddf5c1f..0007b7cb2 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index cebeb8d89..2f33b9367 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -173,17 +173,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index 32107bcd4..a4e23cc74 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -176,17 +176,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index 5c3bcbd17..c40c85025 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -176,17 +176,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index a03df7c33..3f500a1b4 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -176,17 +176,21 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { // note: if module_hash_binary_parse exists, then module_hash_decode is not called - FILE *fp = fopen (hashes->hashfile, "rb"); +// FILE *fp = fopen (hashes->hashfile, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 char *in = (char *) hcmalloc (VC_HEADER_SIZE); - const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); +// const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, fp); + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp_t); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); diff --git a/src/modules/module_14600.c b/src/modules/module_14600.c index 3d30341ac..e9e548f65 100644 --- a/src/modules/module_14600.c +++ b/src/modules/module_14600.c @@ -351,17 +351,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (line_len == 0) return (PARSER_HASH_LENGTH); - FILE *fp = fopen ((const char *) line_buf, "rb"); +// FILE *fp = fopen ((const char *) line_buf, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) return (PARSER_HASH_FILE); +// if (fp == NULL) return (PARSER_HASH_FILE); + if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); struct luks_phdr hdr; - const size_t nread = hc_fread (&hdr, sizeof (hdr), 1, fp); +// const size_t nread = hc_fread (&hdr, sizeof (hdr), 1, fp); + const size_t nread = hc_fread (&hdr, sizeof (hdr), 1, &fp_t); if (nread != 1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_FILE_SIZE); } @@ -385,14 +389,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (memcmp (hdr.magic, luks_magic, LUKS_MAGIC_L) != 0) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_MAGIC); } if (byte_swap_16 (hdr.version) != 1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_VERSION); } @@ -411,7 +417,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_CIPHER_TYPE); } @@ -438,7 +445,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_CIPHER_MODE); } @@ -465,7 +473,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_HASH_TYPE); } @@ -486,7 +495,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_KEY_SIZE); } @@ -498,14 +508,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (active != LUKS_KEY_ENABLED) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_KEY_DISABLED); } if (stripes != LUKS_STRIPES) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_KEY_STRIPES); } @@ -533,20 +545,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 keyMaterialOffset = byte_swap_32 (hdr.keyblock[keyslot_idx].keyMaterialOffset); - const int rc_seek1 = fseeko (fp, keyMaterialOffset * 512, SEEK_SET); +// const int rc_seek1 = fseeko (fp, keyMaterialOffset * 512, SEEK_SET); + const int rc_seek1 = hc_fseek (&fp_t, keyMaterialOffset * 512, SEEK_SET); if (rc_seek1 == -1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_FILE_SIZE); } - const size_t nread2 = hc_fread (luks->af_src_buf, keyBytes, stripes, fp); +// const size_t nread2 = hc_fread (luks->af_src_buf, keyBytes, stripes, fp); + const size_t nread2 = hc_fread (luks->af_src_buf, keyBytes, stripes, &fp_t); if (nread2 != stripes) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_FILE_SIZE); } @@ -555,27 +571,32 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u32 payloadOffset = byte_swap_32 (hdr.payloadOffset); - const int rc_seek2 = fseeko (fp, payloadOffset * 512, SEEK_SET); +// const int rc_seek2 = fseeko (fp, payloadOffset * 512, SEEK_SET); + const int rc_seek2 = hc_fseek (&fp_t, payloadOffset * 512, SEEK_SET); if (rc_seek2 == -1) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_FILE_SIZE); } - const size_t nread3 = hc_fread (luks->ct_buf, sizeof (u32), 128, fp); +// const size_t nread3 = hc_fread (luks->ct_buf, sizeof (u32), 128, fp); + const size_t nread3 = hc_fread (luks->ct_buf, sizeof (u32), 128, &fp_t); if (nread3 != 128) { - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_LUKS_FILE_SIZE); } // that should be it, close the fp - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); return (PARSER_OK); } diff --git a/src/mpsp.c b/src/mpsp.c index c3a54e47d..d999ec0f5 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -594,7 +594,8 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, { char mp_file[1024]; - const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp); +// const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp); + const size_t nread = hc_fread_direct (mp_file, 1, sizeof (mp_file) - 1, fp); if (!feof (fp)) { @@ -721,7 +722,8 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) u8 *inbuf = (u8 *) hcmalloc (s.st_size); - SizeT inlen = (SizeT) hc_fread (inbuf, 1, s.st_size, fd); +// SizeT inlen = (SizeT) hc_fread (inbuf, 1, s.st_size, fd); + SizeT inlen = (SizeT) hc_fread_direct (inbuf, 1, s.st_size, fd); if (inlen != (SizeT) s.st_size) { @@ -1471,9 +1473,15 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + // workaround for new fgetl + fp_tmp_t fp_t; + fp_t.is_gzip = 0; + fp_t.f.fp = mask_fp; + while (!feof (mask_fp)) { - const size_t line_len = fgetl (mask_fp, line_buf); +// const size_t line_len = fgetl (mask_fp, line_buf); + const size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; @@ -1564,9 +1572,15 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + // workaround for new fgetl + fp_tmp_t fp_t; + fp_t.is_gzip = 0; + fp_t.f.fp = mask_fp; + while (!feof (mask_fp)) { - const size_t line_len = fgetl (mask_fp, line_buf); +// const size_t line_len = fgetl (mask_fp, line_buf); + const size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; @@ -1638,9 +1652,15 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + // workaround for new fgetl + fp_tmp_t fp_t; + fp_t.is_gzip = 0; + fp_t.f.fp = mask_fp; + while (!feof (mask_fp)) { - const size_t line_len = fgetl (mask_fp, line_buf); +// const size_t line_len = fgetl (mask_fp, line_buf); + const size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; diff --git a/src/outfile.c b/src/outfile.c index 06e5c80ed..b996657aa 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -529,8 +529,10 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou if (outfile_ctx->fp != 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); +// hc_fwrite (EOL, strlen (EOL), 1, outfile_ctx->fp); + hc_fwrite_direct (tmp_buf, tmp_len, 1, outfile_ctx->fp); + hc_fwrite_direct (EOL, strlen (EOL), 1, outfile_ctx->fp); } return tmp_len; diff --git a/src/outfile_check.c b/src/outfile_check.c index db15049c0..057c867a9 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -183,9 +183,15 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) // large portion of the following code is the same as in potfile_remove_parse // maybe subject of a future optimization + // workaround for new fgetl + fp_tmp_t fp_t; + fp_t.is_gzip = 0; + fp_t.f.fp = fp; + while (!feof (fp)) { - size_t line_len = fgetl (fp, line_buf); +// size_t line_len = fgetl (fp, line_buf); + size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; diff --git a/src/pidfile.c b/src/pidfile.c index a366d48ae..83c4bd972 100644 --- a/src/pidfile.c +++ b/src/pidfile.c @@ -22,7 +22,8 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) pidfile_data_t *pd = (pidfile_data_t *) hcmalloc (sizeof (pidfile_data_t)); - const size_t nread = hc_fread (pd, sizeof (pidfile_data_t), 1, fp); +// const size_t nread = hc_fread (pd, sizeof (pidfile_data_t), 1, fp); + const size_t nread = hc_fread_direct (pd, sizeof (pidfile_data_t), 1, fp); fclose (fp); @@ -162,7 +163,8 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx) return -1; } - hc_fwrite (pd, sizeof (pidfile_data_t), 1, fp); +// hc_fwrite (pd, sizeof (pidfile_data_t), 1, fp); + hc_fwrite_direct (pd, sizeof (pidfile_data_t), 1, fp); fflush (fp); diff --git a/src/potfile.c b/src/potfile.c index 9516d4ae5..3c39d01ff 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -527,9 +527,15 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); + // workaround for new fgetl + fp_tmp_t fp_t; + fp_t.is_gzip = 0; + fp_t.f.fp = potfile_ctx->fp; + while (!feof (potfile_ctx->fp)) { - size_t line_len = fgetl (potfile_ctx->fp, line_buf); +// size_t line_len = fgetl (potfile_ctx->fp, line_buf); + size_t line_len = fgetl (&fp_t, line_buf); if (line_len == 0) continue; diff --git a/src/restore.c b/src/restore.c index 8f61cc6ae..0e02c92a1 100644 --- a/src/restore.c +++ b/src/restore.c @@ -221,7 +221,8 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx) return -1; } - hc_fwrite (rd, sizeof (restore_data_t), 1, fp); +// hc_fwrite (rd, sizeof (restore_data_t), 1, fp); + hc_fwrite_direct (rd, sizeof (restore_data_t), 1, fp); for (u32 i = 0; i < rd->argc; i++) { diff --git a/src/rp.c b/src/rp.c index fbac6e894..87f69ced6 100644 --- a/src/rp.c +++ b/src/rp.c @@ -733,11 +733,13 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 char *rp_file = user_options->rp_files[i]; - FILE *fp = NULL; +// FILE *fp = NULL; + fp_tmp_t fp_t; u32 rule_line = 0; - if ((fp = fopen (rp_file, "rb")) == NULL) +// if ((fp = fopen (rp_file, "rb")) == NULL) + if (hc_fopen (&fp_t, rp_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno)); @@ -749,9 +751,11 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 return -1; } - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { - rule_len = (u32) fgetl (fp, rule_buf); +// rule_len = (u32) fgetl (fp, rule_buf); + rule_len = (u32) fgetl (&fp_t, rule_buf); rule_line++; @@ -793,7 +797,8 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 kernel_rules_cnt++; } - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); all_kernel_rules_cnt[i] = kernel_rules_cnt; all_kernel_rules_buf[i] = kernel_rules_buf; diff --git a/src/shared.c b/src/shared.c index 9d26f1d46..4a3ba1863 100644 --- a/src/shared.c +++ b/src/shared.c @@ -602,15 +602,242 @@ void hc_string_trim_trailing (char *s) s[new_len] = 0; } -size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream) +bool hc_fopen (fp_tmp_t *fp_t, const char *path, char *mode) +{ + unsigned char check[3] = { 0 }; + + FILE *fp = fopen (path, mode); + + if (fp == NULL) return false; + + check[0] = fgetc (fp); + + check[1] = fgetc (fp); + + check[2] = fgetc (fp); + + fp_t->is_gzip = -1; + + if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08) + { + fclose (fp); + + if (!(fp_t->f.gfp = gzopen (path, mode))) return false; + + fp_t->is_gzip = 1; + + } + else + { + fp_t->f.fp = fp; + + rewind (fp_t->f.fp); + + fp_t->is_gzip = 0; + } + + fp_t->path = path; + + fp_t->mode = mode; + + return true; +} + +size_t hc_fread (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t) +{ + size_t n = 0; + + if (fp_t == NULL) return -1; + + if (fp_t->is_gzip) + n = gzfread (ptr, size, nmemb, fp_t->f.gfp); + else + n = fread (ptr, size, nmemb, fp_t->f.fp); + + return n; +} + +size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t) +{ + size_t n = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + n = gzfwrite (ptr, size, nmemb, fp_t->f.gfp); + else + n = fwrite (ptr, size, nmemb, fp_t->f.fp); + + if (n != nmemb) return -1; + + return n; +} + +size_t hc_fread_direct (void *ptr, size_t size, size_t nmemb, FILE *stream) { return fread (ptr, size, nmemb, stream); } +/* +size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + return fread (ptr, size, nmemb, stream); +} +*/ + +void hc_fwrite_direct (const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + size_t rc = fwrite (ptr, size, nmemb, stream); + + if (rc == 0) rc = 0; +} +/* size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream) { return fwrite (ptr, size, nmemb, stream); } +*/ + +int hc_fseek (fp_tmp_t *fp_t, off_t offset, int whence) +{ + int r = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + r = gzseek (fp_t->f.gfp, (z_off_t) offset, whence); + else + r = fseeko (fp_t->f.fp, offset, whence); + + return r; +} + +void hc_rewind (fp_tmp_t *fp_t) +{ + if (fp_t == NULL || fp_t->is_gzip == -1) return; + + if (fp_t->is_gzip) + gzrewind (fp_t->f.gfp); + else + rewind (fp_t->f.fp); +} + +off_t hc_ftell (fp_tmp_t *fp_t) +{ + off_t n = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + n = (off_t) gztell (fp_t->f.gfp); + else + n = ftello (fp_t->f.fp); + + return n; +} +int hc_fputc (int c, fp_tmp_t *fp_t) +{ + int r = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + r = gzputc (fp_t->f.gfp, c); + else + r = fputc (c, fp_t->f.fp); + + return r; +} + +int hc_fgetc (fp_tmp_t *fp_t) +{ + int r = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + r = gzgetc (fp_t->f.gfp); + else + r = fgetc (fp_t->f.fp); + + return r; +} + +char *hc_fgets (char *buf, int len, fp_tmp_t *fp_t) +{ + char *r = NULL; + + if (fp_t == NULL || fp_t->is_gzip == -1) return NULL; + + if (fp_t->is_gzip) + r = gzgets (fp_t->f.gfp, buf, len); + else + r = fgets (buf, len, fp_t->f.fp); + + return r; +} + +int hc_fileno (fp_tmp_t *fp_t) +{ + int r = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + { + int rdup = fileno (fopen (fp_t->path, fp_t->mode)); + + r = dup(rdup); + + close(rdup); + } + else + r = fileno (fp_t->f.fp); + + return r; +} + +int hc_feof (fp_tmp_t *fp_t) +{ + int r = 0; + + if (fp_t == NULL || fp_t->is_gzip == -1) return -1; + + if (fp_t->is_gzip) + r = gzeof (fp_t->f.gfp); + else + r = feof (fp_t->f.fp); + + return r; +} + +/* +void hc_fflush (fp_tmp_t *fp_t) +{ + if (fp_t == NULL || fp_t->is_gzip == -1) return; + + if (fp_t->is_gzip) + gzflush (fp_t->f.gfp, Z_SYNC_FLUSH); + else + fflush (fp_t->f.fp); +} +*/ + +void hc_fclose (fp_tmp_t *fp_t) +{ + if (fp_t == NULL || fp_t->is_gzip == -1) return; + + if (fp_t->is_gzip) + gzclose (fp_t->f.gfp); + else + fclose (fp_t->f.fp); + + fp_t->is_gzip = -1; + + fp_t->path = NULL; + + fp_t->mode = NULL; +} bool hc_same_files (char *file1, char *file2) { diff --git a/src/slow_candidates.c b/src/slow_candidates.c index 03b4586e7..6134cf5e2 100644 --- a/src/slow_candidates.c +++ b/src/slow_candidates.c @@ -13,6 +13,7 @@ #include "mpsp.h" #include "filehandling.h" #include "slow_candidates.h" +#include "shared.h" void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u64 cur, const u64 end) { @@ -36,9 +37,11 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u while (1) { - FILE *fp = extra_info_straight->fp; +// FILE *fp = extra_info_straight->fp; + fp_tmp_t *fp_t = extra_info_straight->fp_t; - get_next_word (hashcat_ctx, fp, &line_buf, &line_len); +// get_next_word (hashcat_ctx, fp, &line_buf, &line_len); + get_next_word (hashcat_ctx, fp_t, &line_buf, &line_len); // post-process rule engine @@ -75,8 +78,10 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u { extra_info_combi_t *extra_info_combi = (extra_info_combi_t *) extra_info; - FILE *base_fp = extra_info_combi->base_fp; - FILE *combs_fp = extra_info_combi->combs_fp; +// FILE *base_fp = extra_info_combi->base_fp; +// FILE *combs_fp = extra_info_combi->combs_fp; + fp_tmp_t *base_fp_t = extra_info_combi->base_fp_t; + fp_tmp_t *combs_fp_t = extra_info_combi->combs_fp_t; for (u64 i = cur; i < end; i++) { @@ -87,7 +92,8 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u while (1) { - get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); +// get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); + get_next_word (hashcat_ctx, base_fp_t, &line_buf, &line_len); // post-process rule engine @@ -114,7 +120,8 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u extra_info_combi->base_len = line_len; - rewind (combs_fp); +// rewind (combs_fp); + hc_rewind (combs_fp_t); } char *line_buf = extra_info_combi->scratch_buf; @@ -122,7 +129,8 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u while (1) { - line_len = (u32) fgetl (combs_fp, line_buf); +// line_len = (u32) fgetl (combs_fp, line_buf); + line_len = (u32) fgetl (combs_fp_t, line_buf); // post-process rule engine @@ -175,9 +183,11 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) while (1) { - FILE *fp = extra_info_straight->fp; +// FILE *fp = extra_info_straight->fp; + fp_tmp_t *fp_t = extra_info_straight->fp_t; - get_next_word (hashcat_ctx, fp, &line_buf, &line_len); +// get_next_word (hashcat_ctx, fp, &line_buf, &line_len); + get_next_word (hashcat_ctx, fp_t, &line_buf, &line_len); line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); @@ -237,8 +247,10 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) { extra_info_combi_t *extra_info_combi = (extra_info_combi_t *) extra_info; - FILE *base_fp = extra_info_combi->base_fp; - FILE *combs_fp = extra_info_combi->combs_fp; +// FILE *base_fp = extra_info_combi->base_fp; +// FILE *combs_fp = extra_info_combi->combs_fp; + fp_tmp_t *base_fp_t = extra_info_combi->base_fp_t; + fp_tmp_t *combs_fp_t = extra_info_combi->combs_fp_t; if ((extra_info_combi->pos % combinator_ctx->combs_cnt) == 0) { @@ -247,7 +259,8 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) while (1) { - get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); +// get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len); + get_next_word (hashcat_ctx, base_fp_t, &line_buf, &line_len); line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); @@ -273,7 +286,8 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) extra_info_combi->base_len = line_len; - rewind (combs_fp); +// rewind (combs_fp); + hc_rewind (combs_fp_t); } memcpy (extra_info_combi->out_buf, extra_info_combi->base_buf, extra_info_combi->base_len); @@ -285,7 +299,8 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) while (1) { - line_len = (u32) fgetl (combs_fp, line_buf); +// line_len = (u32) fgetl (combs_fp, line_buf); + line_len = (u32) fgetl (combs_fp_t, line_buf); // post-process rule engine diff --git a/src/stdout.c b/src/stdout.c index d3fbcb0c7..215278357 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -18,7 +18,8 @@ static void out_flush (out_t *out) { if (out->len == 0) return; - hc_fwrite (out->buf, 1, out->len, out->fp); +// hc_fwrite (out->buf, 1, out->len, out->fp); + hc_fwrite_direct (out->buf, 1, out->len, out->fp); out->len = 0; } diff --git a/src/straight.c b/src/straight.c index 0581838ec..a74281826 100644 --- a/src/straight.c +++ b/src/straight.c @@ -70,18 +70,22 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) logfile_sub_var_string ("rulefile", user_options->rp_files[i]); } - FILE *fd = fopen (straight_ctx->dict, "rb"); +// FILE *fd = fopen (straight_ctx->dict, "rb"); + fp_tmp_t fp_t; - if (fd == NULL) +// if (fd == NULL) + if (hc_fopen (&fp_t, straight_ctx->dict, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); return -1; } - const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); +// const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); + const int rc = count_words (hashcat_ctx, &fp_t, straight_ctx->dict, &status_ctx->words_cnt); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); if (rc == -1) { @@ -105,18 +109,22 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) { - FILE *fd = fopen (combinator_ctx->dict1, "rb"); +// FILE *fd = fopen (combinator_ctx->dict1, "rb"); + fp_tmp_t fp_t; - if (fd == NULL) +// if (fd == NULL) + if (hc_fopen (&fp_t, combinator_ctx->dict1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict1, strerror (errno)); return -1; } - const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict1, &status_ctx->words_cnt); +// const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict1, &status_ctx->words_cnt); + const int rc = count_words (hashcat_ctx, &fp_t, combinator_ctx->dict1, &status_ctx->words_cnt); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); if (rc == -1) { @@ -127,18 +135,22 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) } else if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT) { - FILE *fd = fopen (combinator_ctx->dict2, "rb"); +// FILE *fd = fopen (combinator_ctx->dict2, "rb"); + fp_tmp_t fp_t; - if (fd == NULL) +// if (fd == NULL) + if (hc_fopen (&fp_t, combinator_ctx->dict2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); return -1; } - const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict2, &status_ctx->words_cnt); +// const int rc = count_words (hashcat_ctx, fd, combinator_ctx->dict2, &status_ctx->words_cnt); + const int rc = count_words (hashcat_ctx, &fp_t, combinator_ctx->dict2, &status_ctx->words_cnt); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); if (rc == -1) { @@ -173,18 +185,22 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) logfile_sub_string (straight_ctx->dict); logfile_sub_string (mask_ctx->mask); - FILE *fd = fopen (straight_ctx->dict, "rb"); +// FILE *fd = fopen (straight_ctx->dict, "rb"); + fp_tmp_t fp_t; - if (fd == NULL) +// if (fd == NULL) + if (hc_fopen (&fp_t, straight_ctx->dict, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); return -1; } - const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); +// const int rc = count_words (hashcat_ctx, fd, straight_ctx->dict, &status_ctx->words_cnt); + const int rc = count_words (hashcat_ctx, &fp_t, straight_ctx->dict, &status_ctx->words_cnt); - fclose (fd); +// fclose (fd); + hc_fclose (&fp_t); if (rc == -1) { diff --git a/src/terminal.c b/src/terminal.c index 1400ae724..469a23129 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -977,7 +977,8 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) printf ("%d\t", util); } - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); fflush (stdout); @@ -1064,7 +1065,8 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"time_start\": %" PRIu64 ",", (u64) status_ctx->runtime_start); printf (" \"estimated_stop\": %" PRIu64 " }", (u64) end); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); fflush (stdout); diff --git a/src/tuningdb.c b/src/tuningdb.c index db88cf57a..f6fc7162f 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -68,9 +68,11 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) hc_asprintf (&tuning_db_file, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE); - FILE *fp = fopen (tuning_db_file, "rb"); +// FILE *fp = fopen (tuning_db_file, "rb"); + fp_tmp_t fp_t; - if (fp == NULL) +// if (fp == NULL) + if (hc_fopen (&fp_t, tuning_db_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", tuning_db_file, strerror (errno)); @@ -79,7 +81,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) hcfree (tuning_db_file); - const size_t num_lines = count_lines (fp); +// const size_t num_lines = count_lines (fp); + const size_t num_lines = count_lines (&fp_t); // a bit over-allocated @@ -89,15 +92,18 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (num_lines + 1, sizeof (tuning_db_entry_t)); tuning_db->entry_cnt = 0; - rewind (fp); +// rewind (fp); + hc_rewind (&fp_t); int line_num = 0; char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); - while (!feof (fp)) +// while (!feof (fp)) + while (!hc_feof (&fp_t)) { - char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, fp); +// char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, fp); + char *line_buf = hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp_t); if (line_buf == NULL) break; @@ -270,7 +276,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) hcfree (buf); - fclose (fp); +// fclose (fp); + hc_fclose (&fp_t); // todo: print loaded 'cnt' message diff --git a/src/usage.c b/src/usage.c index 02cf4b179..e421f7a53 100644 --- a/src/usage.c +++ b/src/usage.c @@ -269,7 +269,8 @@ void usage_mini_print (const char *progname) { printf (USAGE_MINI[i], progname); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } } @@ -315,7 +316,8 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) { printf ("%s", USAGE_BIG_PRE_HASHMODES[i]); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } //hc_fwrite (EOL, strlen (EOL), 1, stdout); @@ -324,10 +326,12 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) { printf ("%7d | %-48s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); for (int i = 0; i < usage_sort_cnt; i++) { @@ -340,8 +344,10 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) { printf ("%s", USAGE_BIG_POST_HASHMODES[i]); - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } - hc_fwrite (EOL, strlen (EOL), 1, stdout); +// hc_fwrite (EOL, strlen (EOL), 1, stdout); + hc_fwrite_direct (EOL, strlen (EOL), 1, stdout); } diff --git a/src/wordlist.c b/src/wordlist.c index 34b595729..80e1a37a0 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -47,7 +47,8 @@ size_t convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const size_ return (line_len); } -int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) +//int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) +int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t) { wl_data_t *wl_data = hashcat_ctx->wl_data; @@ -55,7 +56,8 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) wl_data->pos = 0; - wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fd); +// wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fd); + wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fp_t); wl_data->buf[wl_data->cnt] = 0; @@ -63,7 +65,8 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0; - while (!feof (fd)) +// while (!feof (fd)) + while (!hc_feof (fp_t)) { if (wl_data->cnt == wl_data->avail) { @@ -72,7 +75,8 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd) wl_data->avail += wl_data->incr; } - const int c = fgetc (fd); +// const int c = fgetc (fd); + const int c = hc_fgetc (fp_t); if (c == EOF) break; @@ -170,7 +174,8 @@ void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off) *len = sz; } -void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len) +//void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len) +void get_next_word (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, char **out_buf, u32 *out_len) { user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -225,16 +230,19 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *o return; } - if (feof (fd)) +// if (feof (fd)) + if (hc_feof (fp_t)) { fprintf (stderr, "BUG feof()!!\n"); return; } - load_segment (hashcat_ctx, fd); +// load_segment (hashcat_ctx, fd); + load_segment (hashcat_ctx, fp_t); - get_next_word (hashcat_ctx, fd, out_buf, out_len); +// get_next_word (hashcat_ctx, fd, out_buf, out_len); + get_next_word (hashcat_ctx, fp_t, out_buf, out_len); } void pw_pre_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len, const u8 *base_buf, const int base_len, const int rule_idx) @@ -317,7 +325,8 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len } } -int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 *result) +//int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 *result) +int count_words (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, const char *dictfile, u64 *result) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -333,7 +342,8 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 d.cnt = 0; - if (fstat (fileno (fd), &d.stat)) +// if (fstat (fileno (fd), &d.stat)) + if (fstat (hc_fileno (fp_t), &d.stat)) { *result = 0; @@ -425,9 +435,11 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 u64 cnt = 0; u64 cnt2 = 0; - while (!feof (fd)) +// while (!feof (fd)) + while (!hc_feof (fp_t)) { - load_segment (hashcat_ctx, fd); +// load_segment (hashcat_ctx, fd); + load_segment (hashcat_ctx, fp_t); comp += wl_data->cnt;