1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 01:50:10 +00:00

Add zlib support v2

This commit is contained in:
Gabriele Gristina 2019-06-21 21:56:38 +02:00
parent f4acae6c5f
commit 6cb4abd526
80 changed files with 1122 additions and 417 deletions

0
example.dict.gz Normal file
View File

1
example0.gz.sh Normal file
View File

@ -0,0 +1 @@
./hashcat -t 32 -a 7 example0.hash.gz ?a?a?a?a example.dict.gz

0
example0.hash.gz Normal file
View File

1
example400.gz.sh Normal file
View File

@ -0,0 +1 @@
cat example.dict | ./hashcat -m 400 example400.hash.gz

0
example400.hash.gz Normal file
View File

1
example500.gz.sh Normal file
View File

@ -0,0 +1 @@
./hashcat -m 500 example500.hash.gz example.dict.gz

0
example500.hash.gz Normal file
View File

View File

@ -10,9 +10,11 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
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); size_t superchop_with_length (char *buf, const size_t len);

View File

@ -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_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); 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 #endif // _HLFMT_H

View File

@ -14,6 +14,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <ctype.h> #include <ctype.h>
#include <math.h> #include <math.h>
#include "zlib.h"
#if defined (_WIN) #if defined (_WIN)
#include <winsock2.h> // needed for select() #include <winsock2.h> // 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_trailing (char *s);
void hc_string_trim_leading (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_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_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); bool hc_same_files (char *file1, char *file2);

View File

@ -10,7 +10,8 @@ typedef struct extra_info_straight
{ {
u64 pos; u64 pos;
FILE *fp; // FILE *fp;
fp_tmp_t *fp_t;
u64 rule_pos_prev; u64 rule_pos_prev;
u64 rule_pos; u64 rule_pos;
@ -27,8 +28,10 @@ typedef struct extra_info_combi
{ {
u64 pos; u64 pos;
FILE *base_fp; // FILE *base_fp;
FILE *combs_fp; // FILE *combs_fp;
fp_tmp_t *base_fp_t;
fp_tmp_t *combs_fp_t;
u64 comb_pos_prev; u64 comb_pos_prev;
u64 comb_pos; u64 comb_pos;

View File

@ -17,6 +17,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
#include "zlib.h"
#if defined (_WIN) #if defined (_WIN)
#define WINICONV_CONST #define WINICONV_CONST
@ -988,6 +989,21 @@ typedef struct link_speed
} link_speed_t; } 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_nvrtc.h"
#include "ext_cuda.h" #include "ext_cuda.h"
#include "ext_OpenCL.h" #include "ext_OpenCL.h"
@ -1149,7 +1165,8 @@ typedef struct hc_device_param
char *scratch_buf; char *scratch_buf;
FILE *combs_fp; // FILE *combs_fp;
fp_tmp_t *combs_fp_t;
pw_t *combs_buf; pw_t *combs_buf;
void *hooks_buf; void *hooks_buf;

View File

@ -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_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_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); //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 load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
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);
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); int wl_data_init (hashcat_ctx_t *hashcat_ctx);
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx); void wl_data_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -318,7 +318,7 @@ WIN_OBJS += $(foreach OBJ,$(OBJS_LZMA),obj/$(OBJ).WIN.o)
endif endif
ifeq ($(USE_SYSTEM_ZLIB),0) 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) NATIVE_OBJS += $(foreach OBJ,$(OBJS_ZLIB),obj/$(OBJ).NATIVE.o)
LINUX_OBJS += $(foreach OBJ,$(OBJS_ZLIB),obj/$(OBJ).LINUX.o) LINUX_OBJS += $(foreach OBJ,$(OBJS_ZLIB),obj/$(OBJ).LINUX.o)

View File

@ -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); 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); fclose (fp);
@ -521,7 +522,8 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
return false; 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); 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[31] = salt_buf->digests_cnt;
device_param->kernel_params_buf32[32] = salt_buf->digests_offset; 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) 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))) 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) 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); 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) 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); line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);

View File

@ -60,21 +60,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
FILE *fp1 = NULL; // FILE *fp1 = NULL;
FILE *fp2 = 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
return -1; 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1); // fclose (fp1);
hc_fclose (&fp1_t);
return -1; return -1;
} }
@ -83,14 +88,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words1_cnt = 0; 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) if (rc1 == -1)
{ {
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -99,8 +107,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
{ {
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -109,10 +119,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words2_cnt = 0; 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 (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
if (rc2 == -1) if (rc2 == -1)
{ {
@ -163,21 +176,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
FILE *fp1 = NULL; // FILE *fp1 = NULL;
FILE *fp2 = 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
return -1; 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1); // fclose (fp1);
hc_fclose (&fp1_t);
return -1; return -1;
} }
@ -186,14 +204,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words1_cnt = 0; 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) if (rc1 == -1)
{ {
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -202,8 +223,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
{ {
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -212,10 +235,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words2_cnt = 0; 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 (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
if (rc2 == -1) if (rc2 == -1)
{ {
@ -294,21 +320,26 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1; return -1;
} }
FILE *fp1 = NULL; // FILE *fp1 = NULL;
FILE *fp2 = 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
return -1; 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1); // fclose (fp1);
hc_fclose (&fp1_t);
return -1; return -1;
} }
@ -317,14 +348,17 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words1_cnt = 0; 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) if (rc1 == -1)
{ {
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -333,8 +367,10 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
{ {
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
fclose (fp1); // fclose (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
return -1; return -1;
} }
@ -343,10 +379,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
u64 words2_cnt = 0; 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 (fp1);
fclose (fp2); // fclose (fp2);
hc_fclose (&fp1_t);
hc_fclose (&fp2_t);
if (rc2 == -1) if (rc2 == -1)
{ {
@ -387,9 +426,11 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
return -1; 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)); 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; 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) if (rc == -1)
{ {
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile); event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile);
fclose (fp); // fclose (fp);
return -1; return -1;
} }
fclose (fp); // fclose (fp);
combinator_ctx->combs_cnt = words_cnt; combinator_ctx->combs_cnt = words_cnt;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;

View File

@ -98,7 +98,8 @@ int cpu_crc32 (const char *filename, u8 keytab[64])
u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1); 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); fclose (fd);

View File

@ -48,7 +48,8 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_
} }
else 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); 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) 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); 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) int debugfile_init (hashcat_ctx_t *hashcat_ctx)

View File

@ -110,8 +110,10 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
u64 v; u64 v;
u64 z; u64 z;
const size_t nread1 = hc_fread (&v, 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 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)) if ((nread1 != 1) || (nread2 != 1))
{ {
@ -158,7 +160,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_t d; 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; if (nread == 0) continue;
@ -210,12 +213,15 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
v = byte_swap_64 (v); v = byte_swap_64 (v);
z = byte_swap_64 (z); z = byte_swap_64 (z);
hc_fwrite (&v, sizeof (u64), 1, fp); // hc_fwrite (&v, sizeof (u64), 1, fp);
hc_fwrite (&z, 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 // 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); fclose (fp);

View File

@ -427,9 +427,11 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{ {
char *dictfile = straight_ctx->dict; 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)); 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)); 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)); 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) if (rc_wl_data_init == -1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
hcfree (hashcat_ctx_tmp->wl_data); 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) if (CL_rc == -1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
hcfree (hashcat_ctx_tmp->wl_data); 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) if (CL_rc == -1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
hcfree (hashcat_ctx_tmp->wl_data); 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; if (words_fin == 0) break;
} }
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
wl_data_destroy (hashcat_ctx_tmp); 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; 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)); event_log_error (hashcat_ctx, "%s: %s", base_file, strerror (errno));
return -1; 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)); 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)); memset (&extra_info_combi, 0, sizeof (extra_info_combi));
extra_info_combi.base_fp = base_fp; // extra_info_combi.base_fp = base_fp;
extra_info_combi.combs_fp = combs_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; extra_info_combi.scratch_buf = device_param->scratch_buf;
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); 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) 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); 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) 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); 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) 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); 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; 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); 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; 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)); event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return -1; 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) 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; 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)); event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno));
return -1; 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) else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
{ {
const char *dictfilec = combinator_ctx->dict1; 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)); event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno));
return -1; 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)); 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 (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); 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]; 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++) 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); 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 (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); 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 (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); 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 (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); wl_data_destroy (hashcat_ctx_tmp);

View File

@ -9,7 +9,8 @@
#include "shared.h" #include "shared.h"
#include "filehandling.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; u64 cnt = 0;
@ -17,9 +18,11 @@ u64 count_lines (FILE *fd)
char prev = '\n'; 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; if (nread < 1) continue;
@ -38,13 +41,16 @@ u64 count_lines (FILE *fd)
return cnt; 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; 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; if (c == EOF) break;

View File

@ -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); 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); hcfree (binary_buf);
} }
@ -674,9 +675,11 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
} }
else if (hashlist_mode == HL_MODE_FILE_PLAIN) 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)); 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)); 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)); EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, strlen (hashfile));
rewind (fp); // rewind (fp);
hc_rewind (&fp_t);
if (hashes_avail == 0) if (hashes_avail == 0)
{ {
event_log_error (hashcat_ctx, "hashfile is empty or corrupt."); event_log_error (hashcat_ctx, "hashfile is empty or corrupt.");
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return -1; 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)) 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."); event_log_error (hashcat_ctx, "Use of --remove is not supported in native hashfile-format mode.");
fclose (fp); // fclose (fp);
return -1; return -1;
} }
fclose (fp); // fclose (fp);
} }
else if (hashlist_mode == HL_MODE_FILE_BINARY) 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) 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)); 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 prev = 0;
time_t now = 0; time_t now = 0;
while (!feof (fp)) // while (!feof (fp))
while (!hc_feof (&fp_t))
{ {
line_num++; 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; if (line_len == 0) continue;
@ -1237,7 +1250,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
hcfree (line_buf); hcfree (line_buf);
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
} }
else if (hashlist_mode == HL_MODE_FILE_BINARY) 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); 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); 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); 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)); 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));

View File

@ -8,6 +8,7 @@
#include "memory.h" #include "memory.h"
#include "filehandling.h" #include "filehandling.h"
#include "hlfmt.h" #include "hlfmt.h"
#include "shared.h"
static const char *HLFMT_TEXT_HASHCAT = "native hashcat"; static const char *HLFMT_TEXT_HASHCAT = "native hashcat";
static const char *HLFMT_TEXT_PWDUMP = "pwdump"; 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; 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); 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; if (line_len == 0) continue;

View File

@ -22,15 +22,19 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
{ {
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); 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; 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; 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) if (rc_tokenizer != PARSER_OK)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
free (line_buf); free (line_buf);
@ -67,7 +72,8 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
if (maps_cnt == 256) if (maps_cnt == 256)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
free (line_buf); free (line_buf);
@ -79,7 +85,8 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
*keyboard_layout_mapping_cnt = maps_cnt; *keyboard_layout_mapping_cnt = maps_cnt;
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
free (line_buf); free (line_buf);

View File

@ -62,7 +62,8 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
va_end (ap); 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); fflush (fp);

View File

@ -49,7 +49,8 @@ static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_p
} }
else 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); 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); fflush (fp);

View File

@ -100,16 +100,21 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
#else #else
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; // case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: hc_fwrite ("\033[33m", 5, 1, fp); 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_ERROR: hc_fwrite ("\033[31m", 5, 1, fp); break;
case LOGLEVEL_ADVICE: hc_fwrite ("\033[33m", 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 #endif
// finally, print // 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 // color stuff post
@ -124,10 +129,14 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
#else #else
switch (loglevel) switch (loglevel)
{ {
case LOGLEVEL_INFO: break; // case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: hc_fwrite ("\033[0m", 4, 1, fp); 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_ERROR: hc_fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ADVICE: 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 #endif
@ -135,13 +144,15 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
if (msg_newline == true) 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 // on error, add another newline
if (loglevel == LOGLEVEL_ERROR) 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); if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx);
} }
hc_fwrite (buf, len, 1, stdout); // hc_fwrite (buf, len, 1, stdout);
hc_fwrite (EOL, strlen (EOL), 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)) 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 if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
hc_fwrite (buf, len, 1, stdout); // hc_fwrite (buf, len, 1, stdout);
hc_fwrite (EOL, strlen (EOL), 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) 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 if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
hc_fwrite (buf, len, 1, stdout); // hc_fwrite (buf, len, 1, stdout);
hc_fwrite (EOL, strlen (EOL), 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) static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)

View File

@ -374,15 +374,19 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
int hashes_cnt = 0; 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)); 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; if (nread == 0) break;
@ -458,7 +462,8 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
hcfree (in); hcfree (in);
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return hashes_cnt; return hashes_cnt;
} }

View File

@ -349,15 +349,19 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
int hashes_cnt = 0; 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)); 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; if (nread == 0) break;
@ -433,7 +437,8 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
hcfree (in); hcfree (in);
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return hashes_cnt; return hashes_cnt;
} }

View File

@ -93,17 +93,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (line_len == 0) return (PARSER_HASH_LENGTH); 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; psafe3_t in;
memset (&in, 0, sizeof (psafe3_t)); 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); if (n != 1) return (PARSER_PSAFE3_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -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 // 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 #define TC_HEADER_SIZE 512
char *in = (char *) hcmalloc (TC_HEADER_SIZE); 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); if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);

View File

@ -156,17 +156,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (line_len == 0) return (PARSER_HASH_LENGTH); 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; psafe2_hdr buf;
memset (&buf, 0, sizeof (psafe2_hdr)); 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); if (n != 1) return (PARSER_PSAFE2_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -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 // 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 #define VC_HEADER_SIZE 512
char *in = (char *) hcmalloc (VC_HEADER_SIZE); 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); if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);

View File

@ -351,17 +351,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (line_len == 0) return (PARSER_HASH_LENGTH); 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; 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) if (nread != 1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_FILE_SIZE); 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) if (memcmp (hdr.magic, luks_magic, LUKS_MAGIC_L) != 0)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_MAGIC); return (PARSER_LUKS_MAGIC);
} }
if (byte_swap_16 (hdr.version) != 1) if (byte_swap_16 (hdr.version) != 1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_VERSION); return (PARSER_LUKS_VERSION);
} }
@ -411,7 +417,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
} }
else else
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_CIPHER_TYPE); return (PARSER_LUKS_CIPHER_TYPE);
} }
@ -438,7 +445,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
} }
else else
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_CIPHER_MODE); return (PARSER_LUKS_CIPHER_MODE);
} }
@ -465,7 +473,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
} }
else else
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_HASH_TYPE); return (PARSER_LUKS_HASH_TYPE);
} }
@ -486,7 +495,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
} }
else else
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_KEY_SIZE); 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) if (active != LUKS_KEY_ENABLED)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_KEY_DISABLED); return (PARSER_LUKS_KEY_DISABLED);
} }
if (stripes != LUKS_STRIPES) if (stripes != LUKS_STRIPES)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_KEY_STRIPES); 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 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) if (rc_seek1 == -1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_FILE_SIZE); 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) if (nread2 != stripes)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_FILE_SIZE); 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 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) if (rc_seek2 == -1)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_FILE_SIZE); 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) if (nread3 != 128)
{ {
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_LUKS_FILE_SIZE); return (PARSER_LUKS_FILE_SIZE);
} }
// that should be it, close the fp // that should be it, close the fp
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
return (PARSER_OK); return (PARSER_OK);
} }

View File

@ -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]; 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)) if (!feof (fp))
{ {
@ -721,7 +722,8 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
u8 *inbuf = (u8 *) hcmalloc (s.st_size); 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) 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); 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)) 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; 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); 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)) 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; 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); 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)) 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; if (line_len == 0) continue;

View File

@ -529,8 +529,10 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou
if (outfile_ctx->fp != NULL) if (outfile_ctx->fp != NULL)
{ {
hc_fwrite (tmp_buf, tmp_len, 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 (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; return tmp_len;

View File

@ -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 // large portion of the following code is the same as in potfile_remove_parse
// maybe subject of a future optimization // 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)) 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; if (line_len == 0) continue;

View File

@ -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)); 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); fclose (fp);
@ -162,7 +163,8 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
return -1; 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); fflush (fp);

View File

@ -527,9 +527,15 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); 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)) 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; if (line_len == 0) continue;

View File

@ -221,7 +221,8 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
return -1; 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++) for (u32 i = 0; i < rd->argc; i++)
{ {

View File

@ -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]; char *rp_file = user_options->rp_files[i];
FILE *fp = NULL; // FILE *fp = NULL;
fp_tmp_t fp_t;
u32 rule_line = 0; 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)); 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; 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++; rule_line++;
@ -793,7 +797,8 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
kernel_rules_cnt++; kernel_rules_cnt++;
} }
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
all_kernel_rules_cnt[i] = kernel_rules_cnt; all_kernel_rules_cnt[i] = kernel_rules_cnt;
all_kernel_rules_buf[i] = kernel_rules_buf; all_kernel_rules_buf[i] = kernel_rules_buf;

View File

@ -602,15 +602,242 @@ void hc_string_trim_trailing (char *s)
s[new_len] = 0; 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); 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) size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
{ {
return fwrite (ptr, size, nmemb, 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) bool hc_same_files (char *file1, char *file2)
{ {

View File

@ -13,6 +13,7 @@
#include "mpsp.h" #include "mpsp.h"
#include "filehandling.h" #include "filehandling.h"
#include "slow_candidates.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) 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) 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 // 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; extra_info_combi_t *extra_info_combi = (extra_info_combi_t *) extra_info;
FILE *base_fp = extra_info_combi->base_fp; // FILE *base_fp = extra_info_combi->base_fp;
FILE *combs_fp = extra_info_combi->combs_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++) 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) 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 // 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; 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; 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) 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 // post-process rule engine
@ -175,9 +183,11 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
while (1) 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); 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; extra_info_combi_t *extra_info_combi = (extra_info_combi_t *) extra_info;
FILE *base_fp = extra_info_combi->base_fp; // FILE *base_fp = extra_info_combi->base_fp;
FILE *combs_fp = extra_info_combi->combs_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) 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) 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); 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; 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); 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) 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 // post-process rule engine

View File

@ -18,7 +18,8 @@ static void out_flush (out_t *out)
{ {
if (out->len == 0) return; 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; out->len = 0;
} }

View File

@ -70,18 +70,22 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
logfile_sub_var_string ("rulefile", user_options->rp_files[i]); 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)); event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno));
return -1; 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) 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) 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)); event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict1, strerror (errno));
return -1; 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) 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) 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)); event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno));
return -1; 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) 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 (straight_ctx->dict);
logfile_sub_string (mask_ctx->mask); 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)); event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno));
return -1; 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) if (rc == -1)
{ {

View File

@ -977,7 +977,8 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
printf ("%d\t", util); 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); 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 (" \"time_start\": %" PRIu64 ",", (u64) status_ctx->runtime_start);
printf (" \"estimated_stop\": %" PRIu64 " }", (u64) end); 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); fflush (stdout);

View File

@ -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); 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)); 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); 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 // 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_buf = (tuning_db_entry_t *) hccalloc (num_lines + 1, sizeof (tuning_db_entry_t));
tuning_db->entry_cnt = 0; tuning_db->entry_cnt = 0;
rewind (fp); // rewind (fp);
hc_rewind (&fp_t);
int line_num = 0; int line_num = 0;
char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE); 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; if (line_buf == NULL) break;
@ -270,7 +276,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
hcfree (buf); hcfree (buf);
fclose (fp); // fclose (fp);
hc_fclose (&fp_t);
// todo: print loaded 'cnt' message // todo: print loaded 'cnt' message

View File

@ -269,7 +269,8 @@ void usage_mini_print (const char *progname)
{ {
printf (USAGE_MINI[i], 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]); 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); //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)); 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++) 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]); 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);
} }

View File

@ -47,7 +47,8 @@ size_t convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const size_
return (line_len); 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; 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->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; 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; 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) 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; 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; if (c == EOF) break;
@ -170,7 +174,8 @@ void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off)
*len = sz; *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_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; 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; return;
} }
if (feof (fd)) // if (feof (fd))
if (hc_feof (fp_t))
{ {
fprintf (stderr, "BUG feof()!!\n"); fprintf (stderr, "BUG feof()!!\n");
return; 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) 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; combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig; 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; 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; *result = 0;
@ -425,9 +435,11 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64
u64 cnt = 0; u64 cnt = 0;
u64 cnt2 = 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; comp += wl_data->cnt;