mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-16 17:42:04 +00:00
switch almost all FILE ops, potfile is the only missing
This commit is contained in:
parent
084ea69b3b
commit
398c89c75c
@ -18,7 +18,7 @@ Philipp "philsmd" Schmidt <philsmd@hashcat.net> (@philsmd)
|
|||||||
|
|
||||||
Gabriele "matrix" Gristina <matrix@hashcat.net> (@gm4tr1x)
|
Gabriele "matrix" Gristina <matrix@hashcat.net> (@gm4tr1x)
|
||||||
|
|
||||||
* Load gzip hashes/wordlists feature
|
* gzip wordlists feature
|
||||||
* SHA-224 kernel module + optimizations
|
* SHA-224 kernel module + optimizations
|
||||||
* Some AES OpenCL kernel module optimizations
|
* Some AES OpenCL kernel module optimizations
|
||||||
* OpenCL Info feature
|
* OpenCL Info feature
|
||||||
|
@ -1 +1 @@
|
|||||||
./hashcat -t 32 -a 7 example0.hash.gz ?a?a?a?a example.dict.gz
|
./hashcat -t 32 -a 7 example0.hash ?a?a?a?a example.dict.gz
|
||||||
|
BIN
example0.hash.gz
BIN
example0.hash.gz
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
cat example.dict | ./hashcat -m 400 example400.hash.gz
|
|
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
./hashcat -m 500 example500.hash.gz example.dict.gz
|
|
Binary file not shown.
@ -10,9 +10,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
u64 count_lines (fp_tmp_t *fp_t);
|
u64 count_lines (HCFILE *fp);
|
||||||
|
|
||||||
size_t fgetl (fp_tmp_t *fp_t, char *line_buf);
|
size_t fgetl (HCFILE *fp, 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);
|
||||||
|
|
||||||
|
@ -15,6 +15,6 @@ 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, fp_tmp_t *fp_t, u32 max_check);
|
u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, u32 max_check);
|
||||||
|
|
||||||
#endif // _HLFMT_H
|
#endif // _HLFMT_H
|
||||||
|
@ -62,21 +62,24 @@ 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);
|
||||||
|
|
||||||
bool hc_fopen(fp_tmp_t *fp_t, const char *path, char *mode);
|
bool hc_fopen (HCFILE *fp, 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 (void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
size_t hc_fread_direct (void *ptr, size_t size, size_t nmemb, FILE *stream);
|
void hc_fwrite (const 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);
|
int hc_fscanf (HCFILE *fp, const char *format, void *ptr);
|
||||||
void hc_fwrite_direct (const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
int hc_fprintf (HCFILE *fp, const char *format, ...);
|
||||||
int hc_fseek (fp_tmp_t *fp_t, off_t offset, int whence);
|
int hc_vfprintf (HCFILE *fp, const char *format, va_list ap);
|
||||||
void hc_rewind (fp_tmp_t *fp_t);
|
int hc_fseek (HCFILE *fp, off_t offset, int whence);
|
||||||
off_t hc_ftell (fp_tmp_t *fp_t);
|
void hc_rewind (HCFILE *fp);
|
||||||
int hc_fgetc (fp_tmp_t *fp_t);
|
off_t hc_ftell (HCFILE *fp);
|
||||||
int hc_fputc (int c, fp_tmp_t *fp_t);
|
int hc_fgetc (HCFILE *fp);
|
||||||
char *hc_fgets (char *buf, int len, fp_tmp_t *fp_t);
|
int hc_fputc (int c, HCFILE *fp);
|
||||||
int hc_fileno (fp_tmp_t *fp_t);
|
char *hc_fgets (char *buf, int len, HCFILE *fp);
|
||||||
int hc_feof (fp_tmp_t *fp_t);
|
int hc_fileno (HCFILE *fp);
|
||||||
//void hc_fflush (fp_tmp_t *fp_t);
|
int hc_feof (HCFILE *fp);
|
||||||
void hc_fclose (fp_tmp_t *fp_t);
|
void hc_fflush (HCFILE *fp);
|
||||||
|
void hc_fclose (HCFILE *fp);
|
||||||
|
size_t hc_fwrite_compress (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
|
||||||
|
size_t hc_fread_compress (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
|
||||||
|
|
||||||
bool hc_same_files (char *file1, char *file2);
|
bool hc_same_files (char *file1, char *file2);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ typedef struct extra_info_straight
|
|||||||
{
|
{
|
||||||
u64 pos;
|
u64 pos;
|
||||||
|
|
||||||
fp_tmp_t *fp_t;
|
HCFILE *fp;
|
||||||
|
|
||||||
u64 rule_pos_prev;
|
u64 rule_pos_prev;
|
||||||
u64 rule_pos;
|
u64 rule_pos;
|
||||||
@ -27,8 +27,8 @@ typedef struct extra_info_combi
|
|||||||
{
|
{
|
||||||
u64 pos;
|
u64 pos;
|
||||||
|
|
||||||
fp_tmp_t *base_fp_t;
|
HCFILE *base_fp;
|
||||||
fp_tmp_t *combs_fp_t;
|
HCFILE *combs_fp;
|
||||||
|
|
||||||
u64 comb_pos_prev;
|
u64 comb_pos_prev;
|
||||||
u64 comb_pos;
|
u64 comb_pos;
|
||||||
|
@ -991,7 +991,7 @@ typedef struct link_speed
|
|||||||
|
|
||||||
// handling gzip files
|
// handling gzip files
|
||||||
|
|
||||||
typedef struct fp_tmp
|
typedef struct hc_fp
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
@ -1002,7 +1002,7 @@ typedef struct fp_tmp
|
|||||||
short is_gzip;
|
short is_gzip;
|
||||||
const char *path;
|
const char *path;
|
||||||
char *mode;
|
char *mode;
|
||||||
} fp_tmp_t;
|
} HCFILE;
|
||||||
|
|
||||||
#include "ext_nvrtc.h"
|
#include "ext_nvrtc.h"
|
||||||
#include "ext_cuda.h"
|
#include "ext_cuda.h"
|
||||||
@ -1165,7 +1165,7 @@ typedef struct hc_device_param
|
|||||||
|
|
||||||
char *scratch_buf;
|
char *scratch_buf;
|
||||||
|
|
||||||
fp_tmp_t *combs_fp_t;
|
HCFILE *combs_fp;
|
||||||
pw_t *combs_buf;
|
pw_t *combs_buf;
|
||||||
|
|
||||||
void *hooks_buf;
|
void *hooks_buf;
|
||||||
@ -1559,7 +1559,8 @@ typedef struct debugfile_ctx
|
|||||||
{
|
{
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
FILE *fp;
|
// FILE *fp;
|
||||||
|
HCFILE *fp;
|
||||||
char *filename;
|
char *filename;
|
||||||
u32 mode;
|
u32 mode;
|
||||||
|
|
||||||
@ -1605,7 +1606,8 @@ typedef struct loopback_ctx
|
|||||||
bool enabled;
|
bool enabled;
|
||||||
bool unused;
|
bool unused;
|
||||||
|
|
||||||
FILE *fp;
|
// FILE *fp;
|
||||||
|
HCFILE *fp;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
} loopback_ctx_t;
|
} loopback_ctx_t;
|
||||||
@ -1621,7 +1623,8 @@ typedef struct outfile_ctx
|
|||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
FILE *fp;
|
// FILE *fp;
|
||||||
|
HCFILE *fp;
|
||||||
|
|
||||||
u32 outfile_format;
|
u32 outfile_format;
|
||||||
bool outfile_autohex;
|
bool outfile_autohex;
|
||||||
@ -1642,6 +1645,7 @@ typedef struct potfile_ctx
|
|||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
// HCFILE *fp;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
u8 *out_buf; // allocates [HCBUFSIZ_LARGE];
|
u8 *out_buf; // allocates [HCBUFSIZ_LARGE];
|
||||||
@ -1723,7 +1727,8 @@ typedef struct pidfile_ctx
|
|||||||
|
|
||||||
typedef struct out
|
typedef struct out
|
||||||
{
|
{
|
||||||
FILE *fp;
|
// FILE *fp;
|
||||||
|
HCFILE *fp;
|
||||||
|
|
||||||
char buf[HCBUFSIZ_SMALL];
|
char buf[HCBUFSIZ_SMALL];
|
||||||
int len;
|
int len;
|
||||||
|
@ -19,9 +19,9 @@ 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, fp_tmp_t *fp_t, char **out_buf, u32 *out_len);
|
void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, char **out_buf, u32 *out_len);
|
||||||
int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t);
|
int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp);
|
||||||
int count_words (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, const char *dictfile, u64 *result);
|
int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, 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);
|
||||||
|
@ -344,6 +344,7 @@ default: $(HASHCAT_FRONTEND) modules
|
|||||||
clean:
|
clean:
|
||||||
$(RM) -f $(HASHCAT_FRONTEND)
|
$(RM) -f $(HASHCAT_FRONTEND)
|
||||||
$(RM) -f $(HASHCAT_LIBRARY)
|
$(RM) -f $(HASHCAT_LIBRARY)
|
||||||
|
$(RM) -rf modules/*.dSYM
|
||||||
$(RM) -f modules/*.dll
|
$(RM) -f modules/*.dll
|
||||||
$(RM) -f modules/*.so
|
$(RM) -f modules/*.so
|
||||||
$(RM) -f obj/*.o
|
$(RM) -f obj/*.o
|
||||||
|
@ -137,26 +137,31 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
// Now we need to check if this an AMD vendor, because this is when the problems start
|
// Now we need to check if this an AMD vendor, because this is when the problems start
|
||||||
|
|
||||||
FILE *fd_drm = fopen (drm_card0_vendor_path, "rb");
|
HCFILE fp_drm;
|
||||||
|
// FILE *fd_drm = fopen (drm_card0_vendor_path, "rb");
|
||||||
|
|
||||||
if (fd_drm == NULL) return 0;
|
if (hc_fopen (&fp_drm, drm_card0_vendor_path, "rb") == false) return 0;
|
||||||
|
// if (fd_drm == NULL) return 0;
|
||||||
|
|
||||||
u32 vendor = 0;
|
u32 vendor = 0;
|
||||||
|
|
||||||
if (fscanf (fd_drm, "0x%x", &vendor) != 1)
|
// if (fscanf (fd_drm, "0x%x", &vendor) != 1)
|
||||||
|
if (hc_fscanf (&fp_drm, "0x%x", &vendor) != 1)
|
||||||
{
|
{
|
||||||
fclose (fd_drm);
|
// fclose (fd_drm);
|
||||||
|
hc_fclose (&fp_drm);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd_drm);
|
// fclose (fd_drm);
|
||||||
|
hc_fclose (&fp_drm);
|
||||||
|
|
||||||
if (vendor != 4098) return 0;
|
if (vendor != 4098) return 0;
|
||||||
|
|
||||||
// Now the problem is only with AMDGPU-PRO, not with oldschool AMD driver
|
// Now the problem is only with AMDGPU-PRO, not with oldschool AMD driver
|
||||||
|
|
||||||
char buf[HCBUFSIZ_TINY];
|
char buf[HCBUFSIZ_TINY] = { 0 };
|
||||||
|
|
||||||
const ssize_t len = readlink (drm_card0_driver_path, buf, HCBUFSIZ_TINY - 1);
|
const ssize_t len = readlink (drm_card0_driver_path, buf, HCBUFSIZ_TINY - 1);
|
||||||
|
|
||||||
@ -168,9 +173,11 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
// Now do the real check
|
// Now do the real check
|
||||||
|
|
||||||
FILE *fd_dri = fopen (dri_card0_path, "rb");
|
HCFILE fp_dri;
|
||||||
|
// FILE *fd_dri = fopen (dri_card0_path, "rb");
|
||||||
|
|
||||||
if (fd_dri == NULL)
|
if (hc_fopen (&fp_dri, dri_card0_path, "rb") == false)
|
||||||
|
// if (fd_dri == NULL)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Cannot access %s: %m.", dri_card0_path);
|
event_log_error (hashcat_ctx, "Cannot access %s: %m.", dri_card0_path);
|
||||||
|
|
||||||
@ -182,7 +189,8 @@ static int ocl_check_dri (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd_dri);
|
// fclose (fd_dri);
|
||||||
|
hc_fclose (&fp_drm);
|
||||||
|
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
||||||
@ -440,15 +448,18 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont
|
|||||||
|
|
||||||
static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources, const bool force_recompile)
|
static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_file, size_t *kernel_lengths, char **kernel_sources, const bool force_recompile)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (kernel_file, "rb");
|
// FILE *fp = fopen (kernel_file, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp != NULL)
|
// if (fp != NULL)
|
||||||
|
if (hc_fopen (&fp, kernel_file, "rb") != false)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat (kernel_file, &st))
|
if (stat (kernel_file, &st))
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -457,9 +468,11 @@ 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_direct (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_compress (buf, sizeof (char), st.st_size, &fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (num_read != (size_t) st.st_size)
|
if (num_read != (size_t) st.st_size)
|
||||||
{
|
{
|
||||||
@ -503,29 +516,39 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file,
|
|||||||
{
|
{
|
||||||
if (binary_size > 0)
|
if (binary_size > 0)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (kernel_file, "wb");
|
// FILE *fp = fopen (kernel_file, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, kernel_file, "wb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
// set gzip to false
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (binary, sizeof (char), binary_size, fp);
|
// hc_fwrite (binary, sizeof (char), binary_size, fp);
|
||||||
|
hc_fwrite_compress (binary, sizeof (char), binary_size, &fp);
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (&fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -4375,7 +4398,7 @@ 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;
|
||||||
|
|
||||||
fp_tmp_t *combs_fp_t = device_param->combs_fp_t;
|
HCFILE *combs_fp = device_param->combs_fp;
|
||||||
|
|
||||||
if (user_options->slow_candidates == true)
|
if (user_options->slow_candidates == true)
|
||||||
{
|
{
|
||||||
@ -4384,7 +4407,7 @@ 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)))
|
||||||
{
|
{
|
||||||
hc_rewind (combs_fp_t);
|
hc_rewind (combs_fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4478,9 +4501,9 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
|||||||
|
|
||||||
while (i < innerloop_left)
|
while (i < innerloop_left)
|
||||||
{
|
{
|
||||||
if (hc_feof (combs_fp_t)) break;
|
if (hc_feof (combs_fp)) break;
|
||||||
|
|
||||||
size_t line_len = fgetl (combs_fp_t, line_buf);
|
size_t line_len = fgetl (combs_fp, 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 +4666,9 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
|||||||
|
|
||||||
while (i < innerloop_left)
|
while (i < innerloop_left)
|
||||||
{
|
{
|
||||||
if (hc_feof (combs_fp_t)) break;
|
if (hc_feof (combs_fp)) break;
|
||||||
|
|
||||||
size_t line_len = fgetl (combs_fp_t, line_buf);
|
size_t line_len = fgetl (combs_fp, line_buf);
|
||||||
|
|
||||||
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
|
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
|
||||||
|
|
||||||
|
101
src/brain.c
101
src/brain.c
@ -539,16 +539,22 @@ u64 brain_compute_attack_wordlist (const char *filename)
|
|||||||
|
|
||||||
char buf[FBUFSZ];
|
char buf[FBUFSZ];
|
||||||
|
|
||||||
FILE *fd = fopen (filename, "rb");
|
// FILE *fd = fopen (filename, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
while (!feof (fd))
|
hc_fopen (&fp, filename, "rb");
|
||||||
|
|
||||||
|
// while (!feof (fd))
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
const size_t nread = fread (buf, 1, FBUFSZ, fd);
|
// const size_t nread = fread (buf, 1, FBUFSZ, fd);
|
||||||
|
const size_t nread = hc_fread_compress (buf, 1, FBUFSZ, &fp);
|
||||||
|
|
||||||
XXH64_update (state, buf, nread);
|
XXH64_update (state, buf, nread);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
const u64 hash = XXH64_digest (state);
|
const u64 hash = XXH64_digest (state);
|
||||||
|
|
||||||
@ -609,25 +615,30 @@ u32 brain_auth_challenge (void)
|
|||||||
|
|
||||||
static const char *urandom = "/dev/urandom";
|
static const char *urandom = "/dev/urandom";
|
||||||
|
|
||||||
FILE *fd = fopen (urandom, "rb");
|
// FILE *fd = fopen (urandom, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, urandom, "rb") == false)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fread (&val, sizeof (val), 1, fd) != 1)
|
// if (fread (&val, sizeof (val), 1, fd) != 1)
|
||||||
|
if (hc_fread_compress (&val, sizeof (val), 1, &fp) != 1)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno));
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1595,9 +1606,11 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fd = fopen (file, "rb");
|
// FILE *fd = fopen (file, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, file, "rb") == false)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||||
|
|
||||||
@ -1611,18 +1624,21 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
|||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t nread = fread (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), temp_cnt, fd);
|
// const size_t nread = fread (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), temp_cnt, fd);
|
||||||
|
const size_t nread = hc_fread_compress (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), temp_cnt, &fp);
|
||||||
|
|
||||||
if (nread != (size_t) temp_cnt)
|
if (nread != (size_t) temp_cnt)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_hash_long_t));
|
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_hash_long_t));
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1631,7 +1647,8 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
|||||||
|
|
||||||
brain_server_db_hash->write_hashes = false;
|
brain_server_db_hash->write_hashes = false;
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const double ms = hc_timer_get (timer_dump);
|
const double ms = hc_timer_get (timer_dump);
|
||||||
@ -1651,9 +1668,11 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
|||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
|
|
||||||
FILE *fd = fopen (file, "wb");
|
// FILE *fd = fopen (file, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, file, "wb") == false)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||||
|
|
||||||
@ -1661,18 +1680,24 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t nwrite = fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, fd);
|
// force gzip to false
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// const size_t nwrite = fwrite (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, fd);
|
||||||
|
const size_t nwrite = hc_fwrite_compress (brain_server_db_hash->long_buf, sizeof (brain_server_hash_long_t), brain_server_db_hash->long_cnt, &fp);
|
||||||
|
|
||||||
if (nwrite != (size_t) brain_server_db_hash->long_cnt)
|
if (nwrite != (size_t) brain_server_db_hash->long_cnt)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_hash_long_t));
|
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_hash_long_t));
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
brain_server_db_hash->write_hashes = false;
|
brain_server_db_hash->write_hashes = false;
|
||||||
}
|
}
|
||||||
@ -1794,9 +1819,11 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fd = fopen (file, "rb");
|
// FILE *fd = fopen (file, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, file, "rb") == false)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||||
|
|
||||||
@ -1810,18 +1837,21 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
|||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
brain_logging (stderr, 0, "%s\n", MSG_ENOMEM);
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t nread = fread (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), temp_cnt, fd);
|
// const size_t nread = fread (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), temp_cnt, fd);
|
||||||
|
const size_t nread = hc_fread_compress (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), temp_cnt, &fp);
|
||||||
|
|
||||||
if (nread != (size_t) temp_cnt)
|
if (nread != (size_t) temp_cnt)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_attack_long_t));
|
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes read\n", file, (u64) nread * sizeof (brain_server_attack_long_t));
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1830,7 +1860,8 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at
|
|||||||
|
|
||||||
brain_server_db_attack->write_attacks = false;
|
brain_server_db_attack->write_attacks = false;
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const double ms = hc_timer_get (timer_dump);
|
const double ms = hc_timer_get (timer_dump);
|
||||||
@ -1850,9 +1881,11 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a
|
|||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
|
|
||||||
FILE *fd = fopen (file, "wb");
|
// FILE *fd = fopen (file, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, file, "wb") == false)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno));
|
||||||
|
|
||||||
@ -1860,20 +1893,26 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// force gzip to false
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
// storing should not include reserved attacks only finished
|
// storing should not include reserved attacks only finished
|
||||||
|
|
||||||
const size_t nwrite = fwrite (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), brain_server_db_attack->long_cnt, fd);
|
// const size_t nwrite = fwrite (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), brain_server_db_attack->long_cnt, fd);
|
||||||
|
const size_t nwrite = hc_fwrite_compress (brain_server_db_attack->long_buf, sizeof (brain_server_attack_long_t), brain_server_db_attack->long_cnt, &fp);
|
||||||
|
|
||||||
if (nwrite != (size_t) brain_server_db_attack->long_cnt)
|
if (nwrite != (size_t) brain_server_db_attack->long_cnt)
|
||||||
{
|
{
|
||||||
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_attack_long_t));
|
brain_logging (stderr, 0, "%s: only %" PRIu64 " bytes written\n", file, (u64) nwrite * sizeof (brain_server_attack_long_t));
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
brain_server_db_attack->write_attacks = false;
|
brain_server_db_attack->write_attacks = false;
|
||||||
}
|
}
|
||||||
|
@ -60,21 +60,21 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp1_t;
|
HCFILE fp1;
|
||||||
fp_tmp_t fp2_t;
|
HCFILE fp2;
|
||||||
|
|
||||||
if (hc_fopen (&fp1_t, dictfile1, "rb") == false)
|
if (hc_fopen (&fp1, 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 (hc_fopen (&fp2_t, dictfile2, "rb") == false)
|
if (hc_fopen (&fp2, dictfile2, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -83,14 +83,14 @@ 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_t, dictfile1, &words1_cnt);
|
const int rc1 = count_words (hashcat_ctx, &fp1, 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -99,8 +99,8 @@ 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -109,10 +109,10 @@ 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_t, dictfile2, &words2_cnt);
|
const int rc2 = count_words (hashcat_ctx, &fp2, dictfile2, &words2_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
if (rc2 == -1)
|
if (rc2 == -1)
|
||||||
{
|
{
|
||||||
@ -163,21 +163,21 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp1_t;
|
HCFILE fp1;
|
||||||
fp_tmp_t fp2_t;
|
HCFILE fp2;
|
||||||
|
|
||||||
if (hc_fopen (&fp1_t, dictfile1, "rb") == false)
|
if (hc_fopen (&fp1, 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 (hc_fopen (&fp2_t, dictfile2, "rb") == false)
|
if (hc_fopen (&fp2, dictfile2, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -186,14 +186,14 @@ 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_t, dictfile1, &words1_cnt);
|
const int rc1 = count_words (hashcat_ctx, &fp1, 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -202,8 +202,8 @@ 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -212,10 +212,10 @@ 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_t, dictfile2, &words2_cnt);
|
const int rc2 = count_words (hashcat_ctx, &fp2, dictfile2, &words2_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
if (rc2 == -1)
|
if (rc2 == -1)
|
||||||
{
|
{
|
||||||
@ -294,21 +294,21 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp1_t;
|
HCFILE fp1;
|
||||||
fp_tmp_t fp2_t;
|
HCFILE fp2;
|
||||||
|
|
||||||
if (hc_fopen (&fp1_t, dictfile1, "rb") == false)
|
if (hc_fopen (&fp1, 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 (hc_fopen (&fp2_t, dictfile2, "rb") == false)
|
if (hc_fopen (&fp2, dictfile2, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -317,14 +317,14 @@ 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_t, dictfile1, &words1_cnt);
|
const int rc1 = count_words (hashcat_ctx, &fp1, 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -333,8 +333,8 @@ 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);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -343,10 +343,10 @@ 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_t, dictfile2, &words2_cnt);
|
const int rc2 = count_words (hashcat_ctx, &fp2, dictfile2, &words2_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp1_t);
|
hc_fclose (&fp1);
|
||||||
hc_fclose (&fp2_t);
|
hc_fclose (&fp2);
|
||||||
|
|
||||||
if (rc2 == -1)
|
if (rc2 == -1)
|
||||||
{
|
{
|
||||||
@ -387,9 +387,9 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, dictfile, "rb") == false)
|
if (hc_fopen (&fp, dictfile, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
|
||||||
|
|
||||||
@ -400,9 +400,9 @@ 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_t, dictfile, &words_cnt);
|
const int rc = count_words (hashcat_ctx, &fp, dictfile, &words_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
|
@ -92,15 +92,20 @@ int cpu_crc32 (const char *filename, u8 keytab[64])
|
|||||||
{
|
{
|
||||||
u32 crc = ~0u;
|
u32 crc = ~0u;
|
||||||
|
|
||||||
FILE *fd = fopen (filename, "rb");
|
// FILE *fd = fopen (filename, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
|
hc_fopen (&fp, filename, "rb");
|
||||||
|
|
||||||
#define MAX_KEY_SIZE (1024 * 1024)
|
#define MAX_KEY_SIZE (1024 * 1024)
|
||||||
|
|
||||||
u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1);
|
u8 *buf = (u8 *) hcmalloc (MAX_KEY_SIZE + 1);
|
||||||
|
|
||||||
size_t nread = hc_fread_direct (buf, sizeof (u8), MAX_KEY_SIZE, fd);
|
// size_t nread = hc_fread (buf, sizeof (u8), MAX_KEY_SIZE, fd);
|
||||||
|
size_t nread = hc_fread_compress (buf, sizeof (u8), MAX_KEY_SIZE, &fp);
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
size_t kpos = 0;
|
size_t kpos = 0;
|
||||||
|
|
||||||
|
@ -37,18 +37,22 @@ static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_
|
|||||||
|
|
||||||
if (needs_hexify == 1)
|
if (needs_hexify == 1)
|
||||||
{
|
{
|
||||||
fprintf (debugfile_ctx->fp, "$HEX[");
|
// fprintf (debugfile_ctx->fp, "$HEX[");
|
||||||
|
hc_fprintf (debugfile_ctx->fp, "$HEX[");
|
||||||
|
|
||||||
for (u32 i = 0; i < plain_len; i++)
|
for (u32 i = 0; i < plain_len; i++)
|
||||||
{
|
{
|
||||||
fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
|
// fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
|
||||||
|
hc_fprintf (debugfile_ctx->fp, "%02x", plain_ptr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (debugfile_ctx->fp, "]");
|
// fprintf (debugfile_ctx->fp, "]");
|
||||||
|
hc_fprintf (debugfile_ctx->fp, "]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fwrite_direct (plain_ptr, plain_len, 1, debugfile_ctx->fp);
|
// hc_fwrite (plain_ptr, plain_len, 1, debugfile_ctx->fp);
|
||||||
|
hc_fwrite_compress ((void *)plain_ptr, plain_len, 1, debugfile_ctx->fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,19 +68,23 @@ void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, con
|
|||||||
{
|
{
|
||||||
debugfile_format_plain (hashcat_ctx, orig_plain_ptr, orig_plain_len);
|
debugfile_format_plain (hashcat_ctx, orig_plain_ptr, orig_plain_len);
|
||||||
|
|
||||||
if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp);
|
// if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp);
|
||||||
|
if ((debug_mode == 3) || (debug_mode == 4)) hc_fputc (':', debugfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (rule_buf, rule_len, 1, debugfile_ctx->fp);
|
// hc_fwrite (rule_buf, rule_len, 1, debugfile_ctx->fp);
|
||||||
|
hc_fwrite_compress ((void *)rule_buf, rule_len, 1, debugfile_ctx->fp);
|
||||||
|
|
||||||
if (debug_mode == 4)
|
if (debug_mode == 4)
|
||||||
{
|
{
|
||||||
fputc (':', debugfile_ctx->fp);
|
// fputc (':', debugfile_ctx->fp);
|
||||||
|
hc_fputc (':', debugfile_ctx->fp);
|
||||||
|
|
||||||
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
|
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, debugfile_ctx->fp);
|
// hc_fwrite (EOL, strlen (EOL), 1, debugfile_ctx->fp);
|
||||||
|
hc_fwrite_compress (EOL, strlen (EOL), 1, debugfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
||||||
@ -107,29 +115,42 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (debugfile_ctx->filename)
|
if (debugfile_ctx->filename)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (debugfile_ctx->filename, "ab");
|
// FILE *fp = fopen (debugfile_ctx->filename, "ab");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, debugfile_ctx->filename, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Could not open --debug-file file for writing.");
|
event_log_error (hashcat_ctx, "Could not open --debug-file file for writing.");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
// force gzip to false
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", debugfile_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugfile_ctx->fp = fp;
|
// debugfile_ctx->fp = fp;
|
||||||
|
debugfile_ctx->fp = &fp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debugfile_ctx->fp = stdout;
|
HCFILE fp_tmp;
|
||||||
|
fp_tmp.is_gzip = 0;
|
||||||
|
fp_tmp.f.fp = stdout;
|
||||||
|
|
||||||
|
// debugfile_ctx->fp = stdout;
|
||||||
|
debugfile_ctx->fp = &fp_tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -143,7 +164,8 @@ void debugfile_destroy (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (debugfile_ctx->filename)
|
if (debugfile_ctx->filename)
|
||||||
{
|
{
|
||||||
fclose (debugfile_ctx->fp);
|
// fclose (debugfile_ctx->fp);
|
||||||
|
hc_fclose (debugfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (debugfile_ctx, 0, sizeof (debugfile_ctx_t));
|
memset (debugfile_ctx, 0, sizeof (debugfile_ctx_t));
|
||||||
|
@ -96,9 +96,11 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (hashconfig->dictstat_disable == true) return;
|
if (hashconfig->dictstat_disable == true) return;
|
||||||
|
|
||||||
FILE *fp = fopen (dictstat_ctx->filename, "rb");
|
// FILE *fp = fopen (dictstat_ctx->filename, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, dictstat_ctx->filename, "rb") == false)
|
||||||
{
|
{
|
||||||
// first run, file does not exist, do not error out
|
// first run, file does not exist, do not error out
|
||||||
|
|
||||||
@ -110,14 +112,17 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
u64 v;
|
u64 v;
|
||||||
u64 z;
|
u64 z;
|
||||||
|
|
||||||
const size_t nread1 = hc_fread_direct (&v, sizeof (u64), 1, fp);
|
// const size_t nread1 = hc_fread (&v, sizeof (u64), 1, fp);
|
||||||
const size_t nread2 = hc_fread_direct (&z, sizeof (u64), 1, fp);
|
const size_t nread1 = hc_fread_compress (&v, sizeof (u64), 1, &fp);
|
||||||
|
// const size_t nread2 = hc_fread (&z, sizeof (u64), 1, fp);
|
||||||
|
const size_t nread2 = hc_fread_compress (&z, sizeof (u64), 1, &fp);
|
||||||
|
|
||||||
if ((nread1 != 1) || (nread2 != 1))
|
if ((nread1 != 1) || (nread2 != 1))
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
|
event_log_error (hashcat_ctx, "%s: Invalid header", dictstat_ctx->filename);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,7 +134,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -138,7 +144,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
event_log_error (hashcat_ctx, "%s: Invalid header, ignoring content", dictstat_ctx->filename);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -147,18 +154,21 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
event_log_warning (hashcat_ctx, "%s: Outdated header version, ignoring content", dictstat_ctx->filename);
|
event_log_warning (hashcat_ctx, "%s: Outdated header version, ignoring content", dictstat_ctx->filename);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse data
|
// parse data
|
||||||
|
|
||||||
while (!feof (fp))
|
// while (!feof (fp))
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
dictstat_t d;
|
dictstat_t d;
|
||||||
|
|
||||||
const size_t nread = hc_fread_direct (&d, sizeof (dictstat_t), 1, fp);
|
// const size_t nread = hc_fread (&d, sizeof (dictstat_t), 1, fp);
|
||||||
|
const size_t nread = hc_fread_compress (&d, sizeof (dictstat_t), 1, &fp);
|
||||||
|
|
||||||
if (nread == 0) continue;
|
if (nread == 0) continue;
|
||||||
|
|
||||||
@ -172,7 +182,8 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
||||||
@ -184,18 +195,24 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (hashconfig->dictstat_disable == true) return 0;
|
if (hashconfig->dictstat_disable == true) return 0;
|
||||||
|
|
||||||
FILE *fp = fopen (dictstat_ctx->filename, "wb");
|
// FILE *fp = fopen (dictstat_ctx->filename, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, dictstat_ctx->filename, "wb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
@ -210,14 +227,18 @@ 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_direct (&v, sizeof (u64), 1, fp);
|
// hc_fwrite (&v, sizeof (u64), 1, fp);
|
||||||
hc_fwrite_direct (&z, sizeof (u64), 1, fp);
|
hc_fwrite_compress (&v, sizeof (u64), 1, &fp);
|
||||||
|
// hc_fwrite (&z, sizeof (u64), 1, fp);
|
||||||
|
hc_fwrite_compress (&z, sizeof (u64), 1, &fp);
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
|
||||||
hc_fwrite_direct (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp);
|
// hc_fwrite (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, fp);
|
||||||
|
hc_fwrite_compress (dictstat_ctx->base, sizeof (dictstat_t), dictstat_ctx->cnt, &fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -427,9 +427,9 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
{
|
{
|
||||||
char *dictfile = straight_ctx->dict;
|
char *dictfile = straight_ctx->dict;
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, dictfile, "rb") == false)
|
if (hc_fopen (&fp, 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 +440,7 @@ 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_t = &fp_t;
|
extra_info_straight.fp = &fp;
|
||||||
|
|
||||||
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 +452,7 @@ 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)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
|
|
||||||
if (CL_rc == -1)
|
if (CL_rc == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
|
|
||||||
if (CL_rc == -1)
|
if (CL_rc == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
if (words_fin == 0) break;
|
if (words_fin == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
wl_data_destroy (hashcat_ctx_tmp);
|
wl_data_destroy (hashcat_ctx_tmp);
|
||||||
|
|
||||||
@ -747,18 +747,18 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
combs_file = combinator_ctx->dict1;
|
combs_file = combinator_ctx->dict1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t base_fp_t;
|
HCFILE base_fp;
|
||||||
|
|
||||||
if (hc_fopen (&base_fp_t, base_file, "rb") == false)
|
if (hc_fopen (&base_fp, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t combs_fp_t;
|
HCFILE combs_fp;
|
||||||
|
|
||||||
if (hc_fopen (&combs_fp_t, combs_file, "rb") == false)
|
if (hc_fopen (&combs_fp, 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 +769,8 @@ 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_t = &base_fp_t;
|
extra_info_combi.base_fp = &base_fp;
|
||||||
extra_info_combi.combs_fp_t = &combs_fp_t;
|
extra_info_combi.combs_fp = &combs_fp;
|
||||||
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 +783,9 @@ 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)
|
||||||
{
|
{
|
||||||
hc_fclose (&combs_fp_t);
|
hc_fclose (&combs_fp);
|
||||||
|
|
||||||
hc_fclose (&base_fp_t);
|
hc_fclose (&base_fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -996,9 +996,9 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
|
|
||||||
if (CL_rc == -1)
|
if (CL_rc == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&combs_fp_t);
|
hc_fclose (&combs_fp);
|
||||||
|
|
||||||
hc_fclose (&base_fp_t);
|
hc_fclose (&base_fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -1011,9 +1011,9 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
|
|
||||||
if (CL_rc == -1)
|
if (CL_rc == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&combs_fp_t);
|
hc_fclose (&combs_fp);
|
||||||
|
|
||||||
hc_fclose (&base_fp_t);
|
hc_fclose (&base_fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -1058,9 +1058,9 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
if (words_fin == 0) break;
|
if (words_fin == 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fclose (&combs_fp_t);
|
hc_fclose (&combs_fp);
|
||||||
|
|
||||||
hc_fclose (&base_fp_t);
|
hc_fclose (&base_fp);
|
||||||
|
|
||||||
wl_data_destroy (hashcat_ctx_tmp);
|
wl_data_destroy (hashcat_ctx_tmp);
|
||||||
|
|
||||||
@ -1322,16 +1322,16 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|||||||
{
|
{
|
||||||
char *dictfile = straight_ctx->dict;
|
char *dictfile = straight_ctx->dict;
|
||||||
|
|
||||||
fp_tmp_t combs_fp_t;
|
HCFILE combs_fp;
|
||||||
|
|
||||||
if (hc_fopen (&combs_fp_t, dictfile, "rb") == false)
|
if (hc_fopen (&combs_fp, 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_t = &combs_fp_t;
|
device_param->combs_fp = &combs_fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (status_ctx->run_thread_level1 == true)
|
while (status_ctx->run_thread_level1 == true)
|
||||||
@ -1388,37 +1388,37 @@ 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;
|
||||||
|
|
||||||
fp_tmp_t combs_fp_t;
|
HCFILE combs_fp;
|
||||||
|
|
||||||
if (hc_fopen (&combs_fp_t, dictfilec, "rb") == false)
|
if (hc_fopen (&combs_fp, 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_t = &combs_fp_t;
|
device_param->combs_fp = &combs_fp;
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
fp_tmp_t combs_fp_t;
|
HCFILE combs_fp;
|
||||||
|
|
||||||
if (hc_fopen (&combs_fp_t, dictfilec, "rb") == false)
|
if (hc_fopen (&combs_fp, 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_t = &combs_fp_t;
|
device_param->combs_fp = &combs_fp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, dictfile, "rb") == false)
|
if (hc_fopen (&fp, 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 +1435,9 @@ 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) hc_fclose (device_param->combs_fp_t);
|
if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -1476,11 +1476,11 @@ 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, &fp_t, &line_buf, &line_len);
|
for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, &fp, &line_buf, &line_len);
|
||||||
|
|
||||||
for ( ; words_cur < words_fin; words_cur++)
|
for ( ; words_cur < words_fin; words_cur++)
|
||||||
{
|
{
|
||||||
get_next_word (hashcat_ctx_tmp, &fp_t, &line_buf, &line_len);
|
get_next_word (hashcat_ctx_tmp, &fp, &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 +1567,9 @@ 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) hc_fclose (device_param->combs_fp_t);
|
if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -1582,9 +1582,9 @@ 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) hc_fclose (device_param->combs_fp_t);
|
if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (hashcat_ctx_tmp->wl_data);
|
hcfree (hashcat_ctx_tmp->wl_data);
|
||||||
|
|
||||||
@ -1638,9 +1638,9 @@ 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) hc_fclose (device_param->combs_fp_t);
|
if (attack_mode == ATTACK_MODE_COMBI) hc_fclose (device_param->combs_fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
wl_data_destroy (hashcat_ctx_tmp);
|
wl_data_destroy (hashcat_ctx_tmp);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "filehandling.h"
|
#include "filehandling.h"
|
||||||
|
|
||||||
u64 count_lines (fp_tmp_t *fp_t)
|
u64 count_lines (HCFILE *fp)
|
||||||
{
|
{
|
||||||
u64 cnt = 0;
|
u64 cnt = 0;
|
||||||
|
|
||||||
@ -17,9 +17,9 @@ u64 count_lines (fp_tmp_t *fp_t)
|
|||||||
|
|
||||||
char prev = '\n';
|
char prev = '\n';
|
||||||
|
|
||||||
while (!hc_feof (fp_t))
|
while (!hc_feof (fp))
|
||||||
{
|
{
|
||||||
size_t nread = hc_fread (buf, sizeof (char), HCBUFSIZ_LARGE, fp_t);
|
size_t nread = hc_fread_compress (buf, sizeof (char), HCBUFSIZ_LARGE, fp);
|
||||||
|
|
||||||
if (nread < 1) continue;
|
if (nread < 1) continue;
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ u64 count_lines (fp_tmp_t *fp_t)
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t fgetl (fp_tmp_t *fp_t, char *line_buf)
|
size_t fgetl (HCFILE *fp, char *line_buf)
|
||||||
{
|
{
|
||||||
size_t line_len = 0;
|
size_t line_len = 0;
|
||||||
|
|
||||||
while (!hc_feof (fp_t))
|
while (!hc_feof (fp))
|
||||||
{
|
{
|
||||||
const int c = hc_fgetc (fp_t);
|
const int c = hc_fgetc (fp);
|
||||||
|
|
||||||
if (c == EOF) break;
|
if (c == EOF) break;
|
||||||
|
|
||||||
|
64
src/hashes.c
64
src/hashes.c
@ -184,9 +184,11 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char separator = hashconfig->separator;
|
char separator = hashconfig->separator;
|
||||||
|
|
||||||
FILE *fp = fopen (new_hashfile, "wb");
|
// FILE *fp = fopen (new_hashfile, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, new_hashfile, "wb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
||||||
|
|
||||||
@ -196,9 +198,13 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno));
|
||||||
|
|
||||||
@ -228,7 +234,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_direct (binary_buf, binary_len, 1, fp);
|
// hc_fwrite (binary_buf, binary_len, 1, fp);
|
||||||
|
hc_fwrite_compress (binary_buf, binary_len, 1, &fp);
|
||||||
|
|
||||||
hcfree (binary_buf);
|
hcfree (binary_buf);
|
||||||
}
|
}
|
||||||
@ -240,25 +247,30 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
|
// for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
|
||||||
|
for (i = 0; i < user->user_len; i++) hc_fputc (user->user_name[i], &fp);
|
||||||
|
|
||||||
fputc (separator, fp);
|
// fputc (separator, fp);
|
||||||
|
hc_fputc (separator, &fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
|
const int out_len = hash_encode (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, (char *) out_buf, HCBUFSIZ_LARGE, salt_pos, digest_pos);
|
||||||
|
|
||||||
out_buf[out_len] = 0;
|
out_buf[out_len] = 0;
|
||||||
|
|
||||||
fprintf (fp, "%s" EOL, out_buf);
|
// fprintf (fp, "%s" EOL, out_buf);
|
||||||
|
hc_fprintf (&fp, "%s" EOL, out_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hcfree (out_buf);
|
hcfree (out_buf);
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (&fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
unlink (old_hashfile);
|
unlink (old_hashfile);
|
||||||
|
|
||||||
@ -674,9 +686,9 @@ 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)
|
||||||
{
|
{
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashfile, "rb") == false)
|
if (hc_fopen (&fp, hashfile, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno));
|
||||||
|
|
||||||
@ -685,24 +697,24 @@ 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_t);
|
hashes_avail = count_lines (&fp);
|
||||||
|
|
||||||
EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, strlen (hashfile));
|
EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, strlen (hashfile));
|
||||||
|
|
||||||
hc_rewind (&fp_t);
|
hc_rewind (&fp);
|
||||||
|
|
||||||
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.");
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hashlist_format = hlfmt_detect (hashcat_ctx, &fp_t, 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
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if ((user_options->remove == true) && (hashlist_format != HLFMT_HASHCAT))
|
if ((user_options->remove == true) && (hashlist_format != HLFMT_HASHCAT))
|
||||||
{
|
{
|
||||||
@ -994,9 +1006,9 @@ 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)
|
||||||
{
|
{
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashfile, "rb") == false)
|
if (hc_fopen (&fp, hashfile, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno));
|
||||||
|
|
||||||
@ -1010,11 +1022,11 @@ 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 (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
line_num++;
|
line_num++;
|
||||||
|
|
||||||
const size_t line_len = fgetl (&fp_t, line_buf);
|
const size_t line_len = fgetl (&fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -1235,7 +1247,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (line_buf);
|
hcfree (line_buf);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
else if (hashlist_mode == HL_MODE_FILE_BINARY)
|
else if (hashlist_mode == HL_MODE_FILE_BINARY)
|
||||||
{
|
{
|
||||||
@ -1790,9 +1802,9 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
hc_fopen (&fp_t, tmpfile_bin, "wb");
|
hc_fopen (&fp, 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 +1812,10 @@ 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);
|
||||||
|
|
||||||
hc_fputc (c, &fp_t);
|
hc_fputc (c, &fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ void hlfmt_user (hashcat_ctx_t *hashcat_ctx, u32 hashfile_format, char *line_buf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, u32 max_check)
|
u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, u32 max_check)
|
||||||
{
|
{
|
||||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||||
|
|
||||||
@ -348,9 +348,9 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, u32 max_check)
|
|||||||
|
|
||||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||||
|
|
||||||
while (!hc_feof (fp_t))
|
while (!hc_feof (fp))
|
||||||
{
|
{
|
||||||
const size_t line_len = fgetl (fp_t, line_buf);
|
const size_t line_len = fgetl (fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
|
102
src/hwmon.c
102
src/hwmon.c
@ -110,9 +110,11 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
|||||||
|
|
||||||
hcfree (syspath);
|
hcfree (syspath);
|
||||||
|
|
||||||
FILE *fd_cur = fopen (path_cur, "r");
|
// FILE *fd_cur = fopen (path_cur, "r");
|
||||||
|
HCFILE fp_cur;
|
||||||
|
|
||||||
if (fd_cur == NULL)
|
// if (fd_cur == NULL)
|
||||||
|
if (hc_fopen (&fp_cur, path_cur, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno));
|
||||||
|
|
||||||
@ -124,9 +126,11 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
|||||||
|
|
||||||
int pwm1_cur = 0;
|
int pwm1_cur = 0;
|
||||||
|
|
||||||
if (fscanf (fd_cur, "%d", &pwm1_cur) != 1)
|
// if (fscanf (fd_cur, "%d", &pwm1_cur) != 1)
|
||||||
|
if (hc_fscanf (&fp_cur, "%d", &pwm1_cur) != 1)
|
||||||
{
|
{
|
||||||
fclose (fd_cur);
|
// fclose (fd_cur);
|
||||||
|
hc_fclose (&fp_cur);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path_cur);
|
event_log_error (hashcat_ctx, "%s: unexpected data.", path_cur);
|
||||||
|
|
||||||
@ -136,11 +140,14 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd_cur);
|
// fclose (fd_cur);
|
||||||
|
hc_fclose (&fp_cur);
|
||||||
|
|
||||||
FILE *fd_max = fopen (path_max, "r");
|
// FILE *fd_max = fopen (path_max, "r");
|
||||||
|
HCFILE fp_max;
|
||||||
|
|
||||||
if (fd_max == NULL)
|
// if (fd_max == NULL)
|
||||||
|
if (hc_fopen (&fp_max, path_max, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno));
|
||||||
|
|
||||||
@ -152,9 +159,11 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
|||||||
|
|
||||||
int pwm1_max = 0;
|
int pwm1_max = 0;
|
||||||
|
|
||||||
if (fscanf (fd_max, "%d", &pwm1_max) != 1)
|
// if (fscanf (fd_max, "%d", &pwm1_max) != 1)
|
||||||
|
if (hc_fscanf (&fp_max, "%d", &pwm1_max) != 1)
|
||||||
{
|
{
|
||||||
fclose (fd_max);
|
// fclose (fd_max);
|
||||||
|
hc_fclose (&fp_max);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path_max);
|
event_log_error (hashcat_ctx, "%s: unexpected data.", path_max);
|
||||||
|
|
||||||
@ -164,7 +173,8 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd_max);
|
// fclose (fd_max);
|
||||||
|
hc_fclose (&fp_max);
|
||||||
|
|
||||||
if (pwm1_max == 0)
|
if (pwm1_max == 0)
|
||||||
{
|
{
|
||||||
@ -200,9 +210,11 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
|||||||
|
|
||||||
hcfree (syspath);
|
hcfree (syspath);
|
||||||
|
|
||||||
FILE *fd = fopen (path, "r");
|
// FILE *fd = fopen (path, "r");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, path, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||||
|
|
||||||
@ -213,9 +225,11 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
|||||||
|
|
||||||
int temperature = 0;
|
int temperature = 0;
|
||||||
|
|
||||||
if (fscanf (fd, "%d", &temperature) != 1)
|
// if (fscanf (fd, "%d", &temperature) != 1)
|
||||||
|
if (hc_fscanf (&fp, "%d", &temperature) != 1)
|
||||||
{
|
{
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: unexpected data.", path);
|
event_log_error (hashcat_ctx, "%s: unexpected data.", path);
|
||||||
|
|
||||||
@ -224,7 +238,8 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
*val = temperature / 1000;
|
*val = temperature / 1000;
|
||||||
|
|
||||||
@ -245,9 +260,11 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
hcfree (syspath);
|
hcfree (syspath);
|
||||||
|
|
||||||
FILE *fd = fopen (path, "r");
|
// FILE *fd = fopen (path, "r");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, path, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||||
|
|
||||||
@ -258,11 +275,13 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
int clockfreq = 0;
|
int clockfreq = 0;
|
||||||
|
|
||||||
while (!feof (fd))
|
// while (!feof (fd))
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
char buf[HCBUFSIZ_TINY];
|
char buf[HCBUFSIZ_TINY];
|
||||||
|
|
||||||
char *ptr = fgets (buf, sizeof (buf), fd);
|
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||||
|
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||||
|
|
||||||
if (ptr == NULL) continue;
|
if (ptr == NULL) continue;
|
||||||
|
|
||||||
@ -279,7 +298,8 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
if (rc == 2) break;
|
if (rc == 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
*val = clockfreq;
|
*val = clockfreq;
|
||||||
|
|
||||||
@ -300,9 +320,11 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
hcfree (syspath);
|
hcfree (syspath);
|
||||||
|
|
||||||
FILE *fd = fopen (path, "r");
|
// FILE *fd = fopen (path, "r");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, path, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||||
|
|
||||||
@ -313,11 +335,13 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
int clockfreq = 0;
|
int clockfreq = 0;
|
||||||
|
|
||||||
while (!feof (fd))
|
// while (!feof (fd))
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
char buf[HCBUFSIZ_TINY];
|
char buf[HCBUFSIZ_TINY];
|
||||||
|
|
||||||
char *ptr = fgets (buf, sizeof (buf), fd);
|
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||||
|
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||||
|
|
||||||
if (ptr == NULL) continue;
|
if (ptr == NULL) continue;
|
||||||
|
|
||||||
@ -334,7 +358,8 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
if (rc == 2) break;
|
if (rc == 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
*val = clockfreq;
|
*val = clockfreq;
|
||||||
|
|
||||||
@ -355,9 +380,11 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
hcfree (syspath);
|
hcfree (syspath);
|
||||||
|
|
||||||
FILE *fd = fopen (path, "r");
|
// FILE *fd = fopen (path, "r");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, path, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno));
|
||||||
|
|
||||||
@ -368,11 +395,13 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
|
|
||||||
int lanes = 0;
|
int lanes = 0;
|
||||||
|
|
||||||
while (!feof (fd))
|
// while (!feof (fd))
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
char buf[HCBUFSIZ_TINY];
|
char buf[HCBUFSIZ_TINY];
|
||||||
|
|
||||||
char *ptr = fgets (buf, sizeof (buf), fd);
|
// char *ptr = fgets (buf, sizeof (buf), fd);
|
||||||
|
char *ptr = hc_fgets (buf, sizeof (buf), &fp);
|
||||||
|
|
||||||
if (ptr == NULL) continue;
|
if (ptr == NULL) continue;
|
||||||
|
|
||||||
@ -390,7 +419,8 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe
|
|||||||
if (rc == 3) break;
|
if (rc == 3) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
*val = lanes;
|
*val = lanes;
|
||||||
|
|
||||||
@ -460,9 +490,11 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (!nvml->lib)
|
if (!nvml->lib)
|
||||||
{
|
{
|
||||||
FILE *nvml_lib = fopen ("/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb");
|
// FILE *nvml_lib = fopen ("/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb");
|
||||||
|
HCFILE nvml_lib;
|
||||||
|
|
||||||
if (nvml_lib == NULL)
|
// if (nvml_lib == NULL)
|
||||||
|
if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb") == false)
|
||||||
{
|
{
|
||||||
//if (user_options->quiet == false)
|
//if (user_options->quiet == false)
|
||||||
// event_log_error (hashcat_ctx, "NVML library load failed: %m. Proceeding without NVML HWMon enabled.");
|
// event_log_error (hashcat_ctx, "NVML library load failed: %m. Proceeding without NVML HWMon enabled.");
|
||||||
@ -474,9 +506,11 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
nvml_winpath = (char *) hcmalloc (100);
|
nvml_winpath = (char *) hcmalloc (100);
|
||||||
|
|
||||||
hc_fread_direct (nvml_winpath, 100, 1, nvml_lib);
|
// hc_fread (nvml_winpath, 100, 1, nvml_lib);
|
||||||
|
hc_fread_compress (nvml_winpath, 100, 1, &nvml_lib);
|
||||||
|
|
||||||
fclose (nvml_lib);
|
// fclose (nvml_lib);
|
||||||
|
hc_fclose (&nvml_lib);
|
||||||
|
|
||||||
ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0);
|
ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0);
|
||||||
|
|
||||||
|
@ -22,15 +22,15 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen(&fp_t, filename, "r") == false) return false;
|
if (hc_fopen (&fp, filename, "r") == false) return false;
|
||||||
|
|
||||||
int maps_cnt = 0;
|
int maps_cnt = 0;
|
||||||
|
|
||||||
while (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
const size_t line_len = fgetl (&fp_t, line_buf);
|
const size_t line_len = fgetl (&fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
|
|||||||
|
|
||||||
if (rc_tokenizer != PARSER_OK)
|
if (rc_tokenizer != PARSER_OK)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
free (line_buf);
|
free (line_buf);
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
|
|||||||
|
|
||||||
if (maps_cnt == 256)
|
if (maps_cnt == 256)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
free (line_buf);
|
free (line_buf);
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m
|
|||||||
|
|
||||||
*keyboard_layout_mapping_cnt = maps_cnt;
|
*keyboard_layout_mapping_cnt = maps_cnt;
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
free (line_buf);
|
free (line_buf);
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
int lock_file (FILE *fp)
|
int lock_file (FILE *fp)
|
||||||
{
|
{
|
||||||
|
if (!fp) return -1;
|
||||||
|
|
||||||
struct flock lock;
|
struct flock lock;
|
||||||
|
|
||||||
memset (&lock, 0, sizeof (struct flock));
|
memset (&lock, 0, sizeof (struct flock));
|
||||||
@ -28,6 +30,8 @@ int lock_file (FILE *fp)
|
|||||||
|
|
||||||
int unlock_file (FILE *fp)
|
int unlock_file (FILE *fp)
|
||||||
{
|
{
|
||||||
|
if (!fp) return -1;
|
||||||
|
|
||||||
struct flock lock;
|
struct flock lock;
|
||||||
|
|
||||||
memset (&lock, 0, sizeof (struct flock));
|
memset (&lock, 0, sizeof (struct flock));
|
||||||
|
@ -43,30 +43,39 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
|||||||
|
|
||||||
if (logfile_ctx->enabled == false) return;
|
if (logfile_ctx->enabled == false) return;
|
||||||
|
|
||||||
FILE *fp = fopen (logfile_ctx->logfile, "ab");
|
// FILE *fp = fopen (logfile_ctx->logfile, "ab");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, logfile_ctx->logfile, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_file (fp);
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// lock_file (fp);
|
||||||
|
lock_file (fp.f.fp);
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
|
|
||||||
vfprintf (fp, fmt, ap);
|
// vfprintf (fp, fmt, ap);
|
||||||
|
hc_vfprintf (&fp, fmt, ap);
|
||||||
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, fp);
|
// hc_fwrite (EOL, strlen (EOL), 1, fp);
|
||||||
|
hc_fwrite_compress (EOL, strlen (EOL), 1, &fp);
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (&fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int logfile_init (hashcat_ctx_t *hashcat_ctx)
|
int logfile_init (hashcat_ctx_t *hashcat_ctx)
|
||||||
|
@ -38,18 +38,22 @@ static void loopback_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_p
|
|||||||
|
|
||||||
if (needs_hexify == 1)
|
if (needs_hexify == 1)
|
||||||
{
|
{
|
||||||
fprintf (loopback_ctx->fp, "$HEX[");
|
// fprintf (loopback_ctx->fp, "$HEX[");
|
||||||
|
hc_fprintf (loopback_ctx->fp, "$HEX[");
|
||||||
|
|
||||||
for (u32 i = 0; i < plain_len; i++)
|
for (u32 i = 0; i < plain_len; i++)
|
||||||
{
|
{
|
||||||
fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
|
// fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
|
||||||
|
hc_fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (loopback_ctx->fp, "]");
|
// fprintf (loopback_ctx->fp, "]");
|
||||||
|
hc_fprintf (loopback_ctx->fp, "]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fwrite_direct (plain_ptr, plain_len, 1, loopback_ctx->fp);
|
// hc_fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp);
|
||||||
|
hc_fwrite_compress ((void *)plain_ptr, plain_len, 1, loopback_ctx->fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,16 +109,21 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hc_asprintf (&loopback_ctx->filename, "%s/%s.%d_%u", induct_ctx->root_directory, LOOPBACK_FILE, (int) now, random_num);
|
hc_asprintf (&loopback_ctx->filename, "%s/%s.%d_%u", induct_ctx->root_directory, LOOPBACK_FILE, (int) now, random_num);
|
||||||
|
|
||||||
FILE *fp = fopen (loopback_ctx->filename, "ab");
|
// FILE *fp = fopen (loopback_ctx->filename, "ab");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, loopback_ctx->filename, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
loopback_ctx->fp = fp;
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// loopback_ctx->fp = fp;
|
||||||
|
loopback_ctx->fp = &fp;
|
||||||
|
|
||||||
loopback_ctx->unused = true;
|
loopback_ctx->unused = true;
|
||||||
|
|
||||||
@ -140,7 +149,8 @@ void loopback_write_close (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (loopback_ctx->fp == NULL) return;
|
if (loopback_ctx->fp == NULL) return;
|
||||||
|
|
||||||
fclose (loopback_ctx->fp);
|
// fclose (loopback_ctx->fp);
|
||||||
|
hc_fclose (loopback_ctx->fp);
|
||||||
|
|
||||||
if (loopback_ctx->unused == true)
|
if (loopback_ctx->unused == true)
|
||||||
{
|
{
|
||||||
@ -154,17 +164,22 @@ void loopback_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, con
|
|||||||
|
|
||||||
if (loopback_ctx->enabled == false) return;
|
if (loopback_ctx->enabled == false) return;
|
||||||
|
|
||||||
FILE *fp = loopback_ctx->fp;
|
// FILE *fp = loopback_ctx->fp;
|
||||||
|
HCFILE *fp = loopback_ctx->fp;
|
||||||
|
|
||||||
loopback_format_plain (hashcat_ctx, plain_ptr, plain_len);
|
loopback_format_plain (hashcat_ctx, plain_ptr, plain_len);
|
||||||
|
|
||||||
lock_file (fp);
|
// lock_file (fp);
|
||||||
|
lock_file (fp->f.fp);
|
||||||
|
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, fp);
|
// hc_fwrite (EOL, strlen (EOL), 1, fp);
|
||||||
|
hc_fwrite_compress (EOL, strlen (EOL), 1, fp);
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (fp);
|
||||||
|
|
||||||
if (unlock_file (fp))
|
// if (unlock_file (fp))
|
||||||
|
if (unlock_file (fp->f.fp))
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Failed to unlock file", loopback_ctx->filename);
|
event_log_error (hashcat_ctx, "%s: Failed to unlock file", loopback_ctx->filename);
|
||||||
}
|
}
|
||||||
|
83
src/main.c
83
src/main.c
@ -28,27 +28,34 @@
|
|||||||
int _dowildcard = -1;
|
int _dowildcard = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED FILE *fp)
|
//static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED FILE *fp)
|
||||||
|
static void main_log_clear_line (MAYBE_UNUSED const size_t prev_len, MAYBE_UNUSED HCFILE *fp)
|
||||||
{
|
{
|
||||||
#if defined (_WIN)
|
#if defined (_WIN)
|
||||||
|
|
||||||
fputc ('\r', fp);
|
// fputc ('\r', fp);
|
||||||
|
hc_fputc ('\r', fp);
|
||||||
|
|
||||||
for (size_t i = 0; i < prev_len; i++)
|
for (size_t i = 0; i < prev_len; i++)
|
||||||
{
|
{
|
||||||
fputc (' ', fp);
|
// fputc (' ', fp);
|
||||||
|
hc_fputc (' ', fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fputc ('\r', fp);
|
// fputc ('\r', fp);
|
||||||
|
hc_fputc ('\r', fp);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
fputs ("\033[2K\r", fp);
|
// fputs ("\033[2K\r", fp);
|
||||||
|
hc_fprintf(fp, "\033[2K\r");
|
||||||
|
// fputs ("\033[2K\r", fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
//static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
||||||
|
static void main_log (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const int loglevel)
|
||||||
{
|
{
|
||||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||||
|
|
||||||
@ -101,15 +108,16 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
|||||||
switch (loglevel)
|
switch (loglevel)
|
||||||
{
|
{
|
||||||
case LOGLEVEL_INFO: break;
|
case LOGLEVEL_INFO: break;
|
||||||
case LOGLEVEL_WARNING: hc_fwrite_direct ("\033[33m", 5, 1, fp); break;
|
case LOGLEVEL_WARNING: hc_fwrite_compress ("\033[33m", 5, 1, fp); break;
|
||||||
case LOGLEVEL_ERROR: hc_fwrite_direct ("\033[31m", 5, 1, fp); break;
|
case LOGLEVEL_ERROR: hc_fwrite_compress ("\033[31m", 5, 1, fp); break;
|
||||||
case LOGLEVEL_ADVICE: hc_fwrite_direct ("\033[33m", 5, 1, fp); break;
|
case LOGLEVEL_ADVICE: hc_fwrite_compress ("\033[33m", 5, 1, fp); break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// finally, print
|
// finally, print
|
||||||
|
|
||||||
hc_fwrite_direct (msg_buf, msg_len, 1, fp);
|
// hc_fwrite (msg_buf, msg_len, 1, fp);
|
||||||
|
hc_fwrite_compress ((void *)msg_buf, msg_len, 1, fp);
|
||||||
|
|
||||||
// color stuff post
|
// color stuff post
|
||||||
|
|
||||||
@ -125,9 +133,9 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
|||||||
switch (loglevel)
|
switch (loglevel)
|
||||||
{
|
{
|
||||||
case LOGLEVEL_INFO: break;
|
case LOGLEVEL_INFO: break;
|
||||||
case LOGLEVEL_WARNING: hc_fwrite_direct ("\033[0m", 4, 1, fp); break;
|
case LOGLEVEL_WARNING: hc_fwrite_compress ("\033[0m", 4, 1, fp); break;
|
||||||
case LOGLEVEL_ERROR: hc_fwrite_direct ("\033[0m", 4, 1, fp); break;
|
case LOGLEVEL_ERROR: hc_fwrite_compress ("\033[0m", 4, 1, fp); break;
|
||||||
case LOGLEVEL_ADVICE: hc_fwrite_direct ("\033[0m", 4, 1, fp); break;
|
case LOGLEVEL_ADVICE: hc_fwrite_compress ("\033[0m", 4, 1, fp); break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -135,17 +143,20 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
|
|||||||
|
|
||||||
if (msg_newline == true)
|
if (msg_newline == true)
|
||||||
{
|
{
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, fp);
|
// hc_fwrite (EOL, strlen (EOL), 1, fp);
|
||||||
|
hc_fwrite_compress (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_direct (EOL, strlen (EOL), 1, fp);
|
// hc_fwrite (EOL, strlen (EOL), 1, fp);
|
||||||
|
hc_fwrite_compress (EOL, strlen (EOL), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
@ -154,22 +165,42 @@ static void main_log_advice (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUS
|
|||||||
|
|
||||||
if (user_options->advice_disable == true) return;
|
if (user_options->advice_disable == true) return;
|
||||||
|
|
||||||
main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
|
HCFILE fp;
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
fp.f.fp = stdout;
|
||||||
|
|
||||||
|
// main_log (hashcat_ctx, stdout, LOGLEVEL_ADVICE);
|
||||||
|
main_log (hashcat_ctx, &fp, LOGLEVEL_ADVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
{
|
{
|
||||||
main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
|
HCFILE fp;
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
fp.f.fp = stdout;
|
||||||
|
|
||||||
|
// main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
|
||||||
|
main_log (hashcat_ctx, &fp, LOGLEVEL_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
{
|
{
|
||||||
main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
|
HCFILE fp;
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
fp.f.fp = stdout;
|
||||||
|
|
||||||
|
// main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
|
||||||
|
main_log (hashcat_ctx, &fp, LOGLEVEL_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
{
|
{
|
||||||
main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);
|
HCFILE fp;
|
||||||
|
fp.is_gzip = 0;
|
||||||
|
fp.f.fp = stderr;
|
||||||
|
|
||||||
|
// main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);
|
||||||
|
main_log (hashcat_ctx, &fp, LOGLEVEL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
|
||||||
@ -340,8 +371,8 @@ 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_direct (buf, len, 1, stdout);
|
hc_fwrite (buf, len, 1, stdout);
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (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 +417,8 @@ 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_direct (buf, len, 1, stdout);
|
hc_fwrite (buf, len, 1, stdout);
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (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 +427,8 @@ 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_direct (buf, len, 1, stdout);
|
hc_fwrite (buf, len, 1, stdout);
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (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)
|
||||||
|
@ -192,7 +192,7 @@ static int check_old_hccap (const char *hashfile)
|
|||||||
|
|
||||||
u32 signature;
|
u32 signature;
|
||||||
|
|
||||||
const size_t nread = hc_fread (&signature, sizeof (u32), 1, fp);
|
const size_t nread = hc_fread_compress (&signature, sizeof (u32), 1, fp);
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
@ -374,15 +374,15 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
|
|||||||
|
|
||||||
int hashes_cnt = 0;
|
int hashes_cnt = 0;
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return -1;
|
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
|
||||||
|
|
||||||
char *in = (char *) hcmalloc (sizeof (hccapx_t));
|
char *in = (char *) hcmalloc (sizeof (hccapx_t));
|
||||||
|
|
||||||
while (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp_t);
|
const size_t nread = hc_fread_compress (in, sizeof (hccapx_t), 1, &fp);
|
||||||
|
|
||||||
if (nread == 0) break;
|
if (nread == 0) break;
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
|
|||||||
|
|
||||||
hcfree (in);
|
hcfree (in);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return hashes_cnt;
|
return hashes_cnt;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ static int check_old_hccap (const char *hashfile)
|
|||||||
|
|
||||||
u32 signature;
|
u32 signature;
|
||||||
|
|
||||||
const size_t nread = hc_fread (&signature, sizeof (u32), 1, fp);
|
const size_t nread = hc_fread_compress (&signature, sizeof (u32), 1, fp);
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
|
||||||
@ -349,15 +349,15 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
|
|||||||
|
|
||||||
int hashes_cnt = 0;
|
int hashes_cnt = 0;
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return -1;
|
if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1;
|
||||||
|
|
||||||
char *in = (char *) hcmalloc (sizeof (hccapx_t));
|
char *in = (char *) hcmalloc (sizeof (hccapx_t));
|
||||||
|
|
||||||
while (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
const size_t nread = hc_fread (in, sizeof (hccapx_t), 1, &fp_t);
|
const size_t nread = hc_fread_compress (in, sizeof (hccapx_t), 1, &fp);
|
||||||
|
|
||||||
if (nread == 0) break;
|
if (nread == 0) break;
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
|
|||||||
|
|
||||||
hcfree (in);
|
hcfree (in);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return hashes_cnt;
|
return hashes_cnt;
|
||||||
}
|
}
|
||||||
|
@ -93,17 +93,17 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, (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_t);
|
const size_t n = hc_fread_compress (&in, sizeof (psafe3_t), 1, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != 1) return (PARSER_PSAFE3_FILE_SIZE);
|
if (n != 1) return (PARSER_PSAFE3_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -146,17 +146,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -146,17 +146,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -144,17 +144,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -144,17 +144,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -144,17 +144,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -144,17 +144,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -146,17 +146,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -146,17 +146,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -146,17 +146,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -158,17 +158,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -158,17 +158,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -158,17 +158,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, TC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
if (n != TC_HEADER_SIZE) return (PARSER_TC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -156,17 +156,17 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, (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_t);
|
const size_t n = hc_fread_compress (&buf, sizeof (psafe2_hdr), 1, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != 1) return (PARSER_PSAFE2_FILE_SIZE);
|
if (n != 1) return (PARSER_PSAFE2_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -170,17 +170,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -170,17 +170,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -170,17 +170,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -172,17 +172,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -173,17 +173,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -176,17 +176,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -176,17 +176,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -176,17 +176,17 @@ 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
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, 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_t);
|
const size_t n = hc_fread_compress (in, 1, VC_HEADER_SIZE, &fp);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE);
|
||||||
|
|
||||||
|
@ -351,17 +351,17 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE);
|
if (hc_fopen (&fp, (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_t);
|
const size_t nread = hc_fread_compress (&hdr, sizeof (hdr), 1, &fp);
|
||||||
|
|
||||||
if (nread != 1)
|
if (nread != 1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_FILE_SIZE);
|
return (PARSER_LUKS_FILE_SIZE);
|
||||||
}
|
}
|
||||||
@ -385,14 +385,14 @@ 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)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_MAGIC);
|
return (PARSER_LUKS_MAGIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (byte_swap_16 (hdr.version) != 1)
|
if (byte_swap_16 (hdr.version) != 1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_VERSION);
|
return (PARSER_LUKS_VERSION);
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_CIPHER_TYPE);
|
return (PARSER_LUKS_CIPHER_TYPE);
|
||||||
}
|
}
|
||||||
@ -438,7 +438,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_CIPHER_MODE);
|
return (PARSER_LUKS_CIPHER_MODE);
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_HASH_TYPE);
|
return (PARSER_LUKS_HASH_TYPE);
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_KEY_SIZE);
|
return (PARSER_LUKS_KEY_SIZE);
|
||||||
}
|
}
|
||||||
@ -498,14 +498,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
if (active != LUKS_KEY_ENABLED)
|
if (active != LUKS_KEY_ENABLED)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_KEY_DISABLED);
|
return (PARSER_LUKS_KEY_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripes != LUKS_STRIPES)
|
if (stripes != LUKS_STRIPES)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_KEY_STRIPES);
|
return (PARSER_LUKS_KEY_STRIPES);
|
||||||
}
|
}
|
||||||
@ -533,20 +533,20 @@ 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 = hc_fseek (&fp_t, keyMaterialOffset * 512, SEEK_SET);
|
const int rc_seek1 = hc_fseek (&fp, keyMaterialOffset * 512, SEEK_SET);
|
||||||
|
|
||||||
if (rc_seek1 == -1)
|
if (rc_seek1 == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_FILE_SIZE);
|
return (PARSER_LUKS_FILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t nread2 = hc_fread (luks->af_src_buf, keyBytes, stripes, &fp_t);
|
const size_t nread2 = hc_fread_compress (luks->af_src_buf, keyBytes, stripes, &fp);
|
||||||
|
|
||||||
if (nread2 != stripes)
|
if (nread2 != stripes)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_FILE_SIZE);
|
return (PARSER_LUKS_FILE_SIZE);
|
||||||
}
|
}
|
||||||
@ -555,27 +555,27 @@ 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 = hc_fseek (&fp_t, payloadOffset * 512, SEEK_SET);
|
const int rc_seek2 = hc_fseek (&fp, payloadOffset * 512, SEEK_SET);
|
||||||
|
|
||||||
if (rc_seek2 == -1)
|
if (rc_seek2 == -1)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_FILE_SIZE);
|
return (PARSER_LUKS_FILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t nread3 = hc_fread (luks->ct_buf, sizeof (u32), 128, &fp_t);
|
const size_t nread3 = hc_fread_compress (luks->ct_buf, sizeof (u32), 128, &fp);
|
||||||
|
|
||||||
if (nread3 != 128)
|
if (nread3 != 128)
|
||||||
{
|
{
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_LUKS_FILE_SIZE);
|
return (PARSER_LUKS_FILE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// that should be it, close the fp
|
// that should be it, close the fp
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return (PARSER_OK);
|
return (PARSER_OK);
|
||||||
}
|
}
|
||||||
|
106
src/mpsp.c
106
src/mpsp.c
@ -582,9 +582,11 @@ static void mp_setup_sys (cs_t *mp_sys)
|
|||||||
|
|
||||||
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, const char *buf, const u32 userindex)
|
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, const char *buf, const u32 userindex)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (buf, "rb");
|
// FILE *fp = fopen (buf, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL) // feof() in case if file is empty
|
// if (fp == NULL) // feof() in case if file is empty
|
||||||
|
if (hc_fopen (&fp, buf, "rb") == false)
|
||||||
{
|
{
|
||||||
const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1);
|
const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1);
|
||||||
|
|
||||||
@ -594,18 +596,22 @@ 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_direct (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_compress (mp_file, 1, sizeof (mp_file) - 1, &fp);
|
||||||
|
|
||||||
if (!feof (fp))
|
// if (!feof (fp))
|
||||||
|
if (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Custom charset file is too large.", buf);
|
event_log_error (hashcat_ctx, "%s: Custom charset file is too large.", buf);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (nread == 0)
|
if (nread == 0)
|
||||||
{
|
{
|
||||||
@ -710,9 +716,11 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fd = fopen (hcstat, "rb");
|
// FILE *fd = fopen (hcstat, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fd == NULL)
|
// if (fd == NULL)
|
||||||
|
if (hc_fopen (&fp, hcstat, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno));
|
||||||
|
|
||||||
@ -721,20 +729,23 @@ 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_direct (inbuf, 1, s.st_size, fd);
|
// SizeT inlen = (SizeT) hc_fread (inbuf, 1, s.st_size, fd);
|
||||||
|
SizeT inlen = (SizeT) hc_fread_compress (inbuf, 1, s.st_size, &fp);
|
||||||
|
|
||||||
if (inlen != (SizeT) s.st_size)
|
if (inlen != (SizeT) s.st_size)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Could not read data.", hcstat);
|
event_log_error (hashcat_ctx, "%s: Could not read data.", hcstat);
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
hcfree (inbuf);
|
hcfree (inbuf);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fd);
|
// fclose (fd);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
u8 *outbuf = (u8 *) hcmalloc (SP_FILESZ);
|
u8 *outbuf = (u8 *) hcmalloc (SP_FILESZ);
|
||||||
|
|
||||||
@ -1460,9 +1471,11 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (hc_path_is_file (arg) == true)
|
if (hc_path_is_file (arg) == true)
|
||||||
{
|
{
|
||||||
FILE *mask_fp = fopen (arg, "r");
|
// FILE *mask_fp = fopen (arg, "r");
|
||||||
|
HCFILE mask_fp;
|
||||||
|
|
||||||
if (mask_fp == NULL)
|
// if (mask_fp == NULL)
|
||||||
|
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||||
|
|
||||||
@ -1472,13 +1485,14 @@ 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
|
// workaround for new fgetl
|
||||||
fp_tmp_t fp_t;
|
/* HCFILE fp;
|
||||||
fp_t.is_gzip = 0;
|
fp.is_gzip = 0;
|
||||||
fp_t.f.fp = mask_fp;
|
fp.f.fp = mask_fp;
|
||||||
|
*/
|
||||||
while (!feof (mask_fp))
|
// while (!feof (mask_fp))
|
||||||
|
while (!hc_feof (&mask_fp))
|
||||||
{
|
{
|
||||||
const size_t line_len = fgetl (&fp_t, line_buf);
|
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -1501,7 +1515,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1509,7 +1524,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (line_buf);
|
hcfree (line_buf);
|
||||||
|
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1558,9 +1574,11 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
mask_ctx->mask_from_file = true;
|
mask_ctx->mask_from_file = true;
|
||||||
|
|
||||||
FILE *mask_fp = fopen (arg, "r");
|
// FILE *mask_fp = fopen (arg, "r");
|
||||||
|
HCFILE mask_fp;
|
||||||
|
|
||||||
if (mask_fp == NULL)
|
// if (mask_fp == NULL)
|
||||||
|
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||||
|
|
||||||
@ -1568,15 +1586,17 @@ 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
|
// workaround for new fgetl
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
fp_t.is_gzip = 0;
|
fp.is_gzip = 0;
|
||||||
fp_t.f.fp = mask_fp;
|
fp.f.fp = mask_fp;
|
||||||
|
|
||||||
while (!feof (mask_fp))
|
while (!feof (mask_fp))
|
||||||
|
*/
|
||||||
|
while (!hc_feof (&mask_fp))
|
||||||
{
|
{
|
||||||
const size_t line_len = fgetl (&fp_t, line_buf);
|
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -1599,7 +1619,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1607,7 +1628,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (line_buf);
|
hcfree (line_buf);
|
||||||
|
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1637,9 +1659,11 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
mask_ctx->mask_from_file = true;
|
mask_ctx->mask_from_file = true;
|
||||||
|
|
||||||
FILE *mask_fp = fopen (arg, "r");
|
// FILE *mask_fp = fopen (arg, "r");
|
||||||
|
HCFILE mask_fp;
|
||||||
|
|
||||||
if (mask_fp == NULL)
|
// if (mask_fp == NULL)
|
||||||
|
if (hc_fopen (&mask_fp, arg, "r") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
||||||
|
|
||||||
@ -1647,15 +1671,17 @@ 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
|
// workaround for new fgetl
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
fp_t.is_gzip = 0;
|
fp.is_gzip = 0;
|
||||||
fp_t.f.fp = mask_fp;
|
fp.f.fp = mask_fp;
|
||||||
|
|
||||||
while (!feof (mask_fp))
|
while (!feof (mask_fp))
|
||||||
|
*/
|
||||||
|
while (!hc_feof (&mask_fp))
|
||||||
{
|
{
|
||||||
const size_t line_len = fgetl (&fp_t, line_buf);
|
const size_t line_len = fgetl (&mask_fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -1678,7 +1704,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1686,7 +1713,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (line_buf);
|
hcfree (line_buf);
|
||||||
|
|
||||||
fclose (mask_fp);
|
// fclose (mask_fp);
|
||||||
|
hc_fclose (&mask_fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -390,25 +390,32 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (outfile_ctx->filename == NULL) return 0;
|
if (outfile_ctx->filename == NULL) return 0;
|
||||||
|
|
||||||
FILE *fp = fopen (outfile_ctx->filename, "ab");
|
// FILE *fp = fopen (outfile_ctx->filename, "ab");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, outfile_ctx->filename, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
outfile_ctx->fp = fp;
|
// outfile_ctx->fp = fp;
|
||||||
|
outfile_ctx->fp = &fp;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -419,7 +426,8 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (outfile_ctx->fp == NULL) return;
|
if (outfile_ctx->fp == NULL) return;
|
||||||
|
|
||||||
fclose (outfile_ctx->fp);
|
// fclose (outfile_ctx->fp);
|
||||||
|
hc_fclose (outfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE])
|
int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE])
|
||||||
@ -529,8 +537,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_direct (tmp_buf, tmp_len, 1, outfile_ctx->fp);
|
// hc_fwrite (tmp_buf, tmp_len, 1, outfile_ctx->fp);
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, outfile_ctx->fp);
|
hc_fwrite_compress (tmp_buf, tmp_len, 1, outfile_ctx->fp);
|
||||||
|
// hc_fwrite (EOL, strlen (EOL), 1, outfile_ctx->fp);
|
||||||
|
hc_fwrite_compress (EOL, strlen (EOL), 1, outfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp_len;
|
return tmp_len;
|
||||||
|
@ -155,17 +155,21 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
for (int j = 0; j < out_cnt; j++)
|
for (int j = 0; j < out_cnt; j++)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (out_info[j].file_name, "rb");
|
// FILE *fp = fopen (out_info[j].file_name, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL) continue;
|
// if (fp == NULL) continue;
|
||||||
|
if (hc_fopen (&fp, out_info[j].file_name, "rb") == false) continue;
|
||||||
|
|
||||||
//hc_thread_mutex_lock (status_ctx->mux_display);
|
//hc_thread_mutex_lock (status_ctx->mux_display);
|
||||||
|
|
||||||
struct stat outfile_stat;
|
struct stat outfile_stat;
|
||||||
|
|
||||||
if (fstat (fileno (fp), &outfile_stat))
|
// if (fstat (fileno (fp), &outfile_stat))
|
||||||
|
if (fstat (hc_fileno (&fp), &outfile_stat))
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -176,21 +180,24 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
|||||||
out_info[j].seek = 0;
|
out_info[j].seek = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseeko (fp, out_info[j].seek, SEEK_SET);
|
// fseeko (fp, out_info[j].seek, SEEK_SET);
|
||||||
|
hc_fseek (&fp, out_info[j].seek, SEEK_SET);
|
||||||
|
|
||||||
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||||
|
|
||||||
// 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
|
// workaround for new fgetl
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp_tmp;
|
||||||
fp_t.is_gzip = 0;
|
fp_tmp.is_gzip = 0;
|
||||||
fp_t.f.fp = fp;
|
fp_tmp.f.fp = fp;
|
||||||
|
|
||||||
while (!feof (fp))
|
while (!feof (fp))
|
||||||
|
*/
|
||||||
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
size_t line_len = fgetl (&fp_t, line_buf);
|
size_t line_len = fgetl (&fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
@ -312,11 +319,13 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (line_buf);
|
hcfree (line_buf);
|
||||||
|
|
||||||
out_info[j].seek = ftello (fp);
|
// out_info[j].seek = ftello (fp);
|
||||||
|
out_info[j].seek = hc_ftell (&fp);
|
||||||
|
|
||||||
//hc_thread_mutex_unlock (status_ctx->mux_display);
|
//hc_thread_mutex_unlock (status_ctx->mux_display);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (status_ctx->shutdown_inner == true) break;
|
if (status_ctx->shutdown_inner == true) break;
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,19 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char *pidfile_filename = pidfile_ctx->filename;
|
char *pidfile_filename = pidfile_ctx->filename;
|
||||||
|
|
||||||
FILE *fp = fopen (pidfile_filename, "rb");
|
// FILE *fp = fopen (pidfile_filename, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL) return 0;
|
// if (fp == NULL) return 0;
|
||||||
|
if (hc_fopen (&fp, pidfile_filename, "rb") == false) return 0;
|
||||||
|
|
||||||
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_direct (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_compress (pd, sizeof (pidfile_data_t), 1, &fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (nread != 1)
|
if (nread != 1)
|
||||||
{
|
{
|
||||||
@ -153,20 +157,27 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char *pidfile_filename = pidfile_ctx->filename;
|
char *pidfile_filename = pidfile_ctx->filename;
|
||||||
|
|
||||||
FILE *fp = fopen (pidfile_filename, "wb");
|
// FILE *fp = fopen (pidfile_filename, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, pidfile_filename, "wb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", pidfile_filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", pidfile_filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (pd, sizeof (pidfile_data_t), 1, fp);
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
fflush (fp);
|
// hc_fwrite (pd, sizeof (pidfile_data_t), 1, fp);
|
||||||
|
hc_fwrite_compress (pd, sizeof (pidfile_data_t), 1, &fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (&fp);
|
||||||
|
|
||||||
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,7 @@ void potfile_read_close (hashcat_ctx_t *hashcat_ctx)
|
|||||||
if (potfile_ctx->fp == NULL) return;
|
if (potfile_ctx->fp == NULL) return;
|
||||||
|
|
||||||
fclose (potfile_ctx->fp);
|
fclose (potfile_ctx->fp);
|
||||||
|
// hc_fclose (potfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
||||||
@ -214,15 +215,20 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
|
|||||||
if (potfile_ctx->enabled == false) return 0;
|
if (potfile_ctx->enabled == false) return 0;
|
||||||
|
|
||||||
FILE *fp = fopen (potfile_ctx->filename, "ab");
|
FILE *fp = fopen (potfile_ctx->filename, "ab");
|
||||||
|
/// HCFILE *fp = (HCFILE *) hcmalloc (sizeof(HCFILE));
|
||||||
|
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
|
// if (hc_fopen (fp, potfile_ctx->filename, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fp->is_gzip = 0;
|
||||||
|
|
||||||
potfile_ctx->fp = fp;
|
potfile_ctx->fp = fp;
|
||||||
|
// potfile_ctx->fp = &fp;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -237,6 +243,7 @@ void potfile_write_close (hashcat_ctx_t *hashcat_ctx)
|
|||||||
if (hashconfig->potfile_disable == true) return;
|
if (hashconfig->potfile_disable == true) return;
|
||||||
|
|
||||||
fclose (potfile_ctx->fp);
|
fclose (potfile_ctx->fp);
|
||||||
|
// hc_fclose (potfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, u8 *plain_ptr, unsigned int plain_len)
|
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int out_len, u8 *plain_ptr, unsigned int plain_len)
|
||||||
@ -293,12 +300,16 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, cons
|
|||||||
tmp_buf[tmp_len] = 0;
|
tmp_buf[tmp_len] = 0;
|
||||||
|
|
||||||
lock_file (potfile_ctx->fp);
|
lock_file (potfile_ctx->fp);
|
||||||
|
// lock_file (potfile_ctx->fp->f.fp);
|
||||||
|
|
||||||
fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf);
|
fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf);
|
||||||
|
// hc_fprintf (potfile_ctx->fp, "%s" EOL, tmp_buf);
|
||||||
|
|
||||||
fflush (potfile_ctx->fp);
|
fflush (potfile_ctx->fp);
|
||||||
|
// hc_fflush (potfile_ctx->fp);
|
||||||
|
|
||||||
if (unlock_file (potfile_ctx->fp))
|
if (unlock_file (potfile_ctx->fp))
|
||||||
|
// if (unlock_file (potfile_ctx->fp->f.fp))
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: Failed to unlock file.", potfile_ctx->filename);
|
event_log_error (hashcat_ctx, "%s: Failed to unlock file.", potfile_ctx->filename);
|
||||||
}
|
}
|
||||||
@ -351,7 +362,6 @@ void potfile_update_hashes (hashcat_ctx_t *hashcat_ctx, hash_t *hash_buf, char *
|
|||||||
search_entry.nodes = &search_node;
|
search_entry.nodes = &search_node;
|
||||||
search_entry.hashconfig = hashconfig;
|
search_entry.hashconfig = hashconfig;
|
||||||
|
|
||||||
|
|
||||||
// the main search function is this:
|
// the main search function is this:
|
||||||
|
|
||||||
void **found = tfind (&search_entry, (void **) &tree, sort_pot_tree_by_hash);
|
void **found = tfind (&search_entry, (void **) &tree, sort_pot_tree_by_hash);
|
||||||
@ -527,13 +537,14 @@ 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
|
// workaround for new fgetl
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
fp_t.is_gzip = 0;
|
fp.is_gzip = 0;
|
||||||
fp_t.f.fp = potfile_ctx->fp;
|
fp.f.fp = potfile_ctx->fp;
|
||||||
|
|
||||||
while (!feof (potfile_ctx->fp))
|
while (!feof (potfile_ctx->fp))
|
||||||
|
// while (!hc_feof (potfile_ctx->fp))
|
||||||
{
|
{
|
||||||
size_t line_len = fgetl (&fp_t, line_buf);
|
size_t line_len = fgetl (&fp, line_buf);
|
||||||
|
|
||||||
if (line_len == 0) continue;
|
if (line_len == 0) continue;
|
||||||
|
|
||||||
|
@ -54,9 +54,11 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char *eff_restore_file = restore_ctx->eff_restore_file;
|
char *eff_restore_file = restore_ctx->eff_restore_file;
|
||||||
|
|
||||||
FILE *fp = fopen (eff_restore_file, "rb");
|
// FILE *fp = fopen (eff_restore_file, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, eff_restore_file, "rb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno));
|
event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno));
|
||||||
|
|
||||||
@ -65,11 +67,13 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
restore_data_t *rd = restore_ctx->rd;
|
restore_data_t *rd = restore_ctx->rd;
|
||||||
|
|
||||||
if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
|
// if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
|
||||||
|
if (hc_fread_compress (rd, sizeof (restore_data_t), 1, &fp) != 1)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -80,7 +84,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Unusually low number of arguments (argc) within restore file %s", eff_restore_file);
|
event_log_error (hashcat_ctx, "Unusually low number of arguments (argc) within restore file %s", eff_restore_file);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -89,7 +94,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Unusually high number of arguments (argc) within restore file %s", eff_restore_file);
|
event_log_error (hashcat_ctx, "Unusually high number of arguments (argc) within restore file %s", eff_restore_file);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -100,11 +106,13 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
for (u32 i = 0; i < rd->argc; i++)
|
for (u32 i = 0; i < rd->argc; i++)
|
||||||
{
|
{
|
||||||
if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL)
|
// if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL)
|
||||||
|
if (hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp) == NULL)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -118,7 +126,8 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (buf);
|
hcfree (buf);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (hc_path_exist (rd->cwd) == false)
|
if (hc_path_exist (rd->cwd) == false)
|
||||||
{
|
{
|
||||||
@ -203,38 +212,50 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char *new_restore_file = restore_ctx->new_restore_file;
|
char *new_restore_file = restore_ctx->new_restore_file;
|
||||||
|
|
||||||
FILE *fp = fopen (new_restore_file, "wb");
|
// FILE *fp = fopen (new_restore_file, "wb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, new_restore_file, "wb") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setvbuf (fp, NULL, _IONBF, 0))
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (setvbuf (fp, NULL, _IONBF, 0))
|
||||||
|
if (setvbuf (fp.f.fp, NULL, _IONBF, 0))
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
|
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (rd, sizeof (restore_data_t), 1, fp);
|
// hc_fwrite (rd, sizeof (restore_data_t), 1, fp);
|
||||||
|
hc_fwrite_compress (rd, sizeof (restore_data_t), 1, &fp);
|
||||||
|
|
||||||
for (u32 i = 0; i < rd->argc; i++)
|
for (u32 i = 0; i < rd->argc; i++)
|
||||||
{
|
{
|
||||||
fprintf (fp, "%s", rd->argv[i]);
|
// fprintf (fp, "%s", rd->argv[i]);
|
||||||
|
hc_fprintf (&fp, "%s", rd->argv[i]);
|
||||||
|
|
||||||
fputc ('\n', fp);
|
// fputc ('\n', fp);
|
||||||
|
hc_fputc ('\n', &fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush (fp);
|
// fflush (fp);
|
||||||
|
hc_fflush (&fp);
|
||||||
|
|
||||||
fsync (fileno (fp));
|
// fsync (fileno (fp));
|
||||||
|
fsync (hc_fileno (&fp));
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
rd->masks_pos = 0;
|
rd->masks_pos = 0;
|
||||||
rd->dicts_pos = 0;
|
rd->dicts_pos = 0;
|
||||||
|
10
src/rp.c
10
src/rp.c
@ -733,11 +733,11 @@ 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];
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
u32 rule_line = 0;
|
u32 rule_line = 0;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, rp_file, "rb") == false)
|
if (hc_fopen (&fp, 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 +749,9 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
rule_len = (u32) fgetl (&fp_t, rule_buf);
|
rule_len = (u32) fgetl (&fp, rule_buf);
|
||||||
|
|
||||||
rule_line++;
|
rule_line++;
|
||||||
|
|
||||||
@ -793,7 +793,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
|
|||||||
kernel_rules_cnt++;
|
kernel_rules_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
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;
|
||||||
|
276
src/shared.c
276
src/shared.c
@ -349,13 +349,17 @@ bool hc_path_has_bom (const char *path)
|
|||||||
{
|
{
|
||||||
u8 buf[8] = { 0 };
|
u8 buf[8] = { 0 };
|
||||||
|
|
||||||
FILE *fp = fopen (path, "rb");
|
// FILE *fp = fopen (path, "rb");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL) return false;
|
// if (fp == NULL) return false;
|
||||||
|
if (hc_fopen (&fp, path, "rb") == false) return false;
|
||||||
|
|
||||||
const size_t nread = fread (buf, 1, sizeof (buf), fp);
|
// const size_t nread = fread (buf, 1, sizeof (buf), fp);
|
||||||
|
const size_t nread = hc_fread_compress (buf, 1, sizeof (buf), &fp);
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (nread < 1) return false;
|
if (nread < 1) return false;
|
||||||
|
|
||||||
@ -602,228 +606,279 @@ void hc_string_trim_trailing (char *s)
|
|||||||
s[new_len] = 0;
|
s[new_len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hc_fopen (fp_tmp_t *fp_t, const char *path, char *mode)
|
bool hc_fopen (HCFILE *fp, const char *path, char *mode)
|
||||||
{
|
{
|
||||||
unsigned char check[3] = { 0 };
|
unsigned char check[3] = { 0 };
|
||||||
|
|
||||||
FILE *fp = fopen (path, mode);
|
FILE *fp_tmp = fopen (path, mode);
|
||||||
|
|
||||||
if (fp == NULL) return false;
|
if (fp_tmp == NULL) return false;
|
||||||
|
|
||||||
check[0] = fgetc (fp);
|
check[0] = fgetc (fp_tmp);
|
||||||
|
check[1] = fgetc (fp_tmp);
|
||||||
|
check[2] = fgetc (fp_tmp);
|
||||||
|
|
||||||
check[1] = fgetc (fp);
|
fp->is_gzip = -1;
|
||||||
|
|
||||||
check[2] = fgetc (fp);
|
|
||||||
|
|
||||||
fp_t->is_gzip = -1;
|
|
||||||
|
|
||||||
if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08)
|
if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
fclose (fp_tmp);
|
||||||
|
|
||||||
if (!(fp_t->f.gfp = gzopen (path, mode))) return false;
|
if (!(fp->f.gfp = gzopen (path, mode))) return false;
|
||||||
|
|
||||||
fp_t->is_gzip = 1;
|
|
||||||
|
|
||||||
|
fp->is_gzip = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fp_t->f.fp = fp;
|
fp->f.fp = fp_tmp;
|
||||||
|
|
||||||
rewind (fp_t->f.fp);
|
rewind (fp->f.fp);
|
||||||
|
|
||||||
fp_t->is_gzip = 0;
|
fp->is_gzip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_t->path = path;
|
fp->path = path;
|
||||||
|
fp->mode = mode;
|
||||||
fp_t->mode = mode;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hc_fread (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t)
|
size_t hc_fread_compress (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
if (fp_t == NULL) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
n = gzfread (ptr, size, nmemb, fp_t->f.gfp);
|
n = gzfread (ptr, size, nmemb, fp->f.gfp);
|
||||||
else
|
else
|
||||||
n = fread (ptr, size, nmemb, fp_t->f.fp);
|
n = fread (ptr, size, nmemb, fp->f.fp);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, fp_tmp_t *fp_t)
|
size_t hc_fwrite_compress (void *ptr, size_t size, size_t nmemb, HCFILE *fp)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
n = gzfwrite (ptr, size, nmemb, fp_t->f.gfp);
|
n = gzfwrite (ptr, size, nmemb, fp->f.gfp);
|
||||||
else
|
else
|
||||||
n = fwrite (ptr, size, nmemb, fp_t->f.fp);
|
n = fwrite (ptr, size, nmemb, fp->f.fp);
|
||||||
|
|
||||||
if (n != nmemb) return -1;
|
if (n != nmemb) return -1;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t hc_fread_direct (void *ptr, size_t size, size_t nmemb, FILE *stream)
|
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||||
{
|
{
|
||||||
return fread (ptr, size, nmemb, stream);
|
return fread (ptr, size, nmemb, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hc_fwrite_direct (const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||||
{
|
{
|
||||||
size_t rc = fwrite (ptr, size, nmemb, stream);
|
size_t rc = fwrite (ptr, size, nmemb, stream);
|
||||||
|
|
||||||
if (rc == 0) rc = 0;
|
if (rc == 0) rc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hc_fseek (fp_tmp_t *fp_t, off_t offset, int whence)
|
int hc_fseek (HCFILE *fp, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
r = gzseek (fp_t->f.gfp, (z_off_t) offset, whence);
|
r = gzseek (fp->f.gfp, (z_off_t) offset, whence);
|
||||||
else
|
else
|
||||||
r = fseeko (fp_t->f.fp, offset, whence);
|
r = fseeko (fp->f.fp, offset, whence);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hc_rewind (fp_tmp_t *fp_t)
|
void hc_rewind (HCFILE *fp)
|
||||||
{
|
{
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return;
|
if (fp == NULL || fp->is_gzip == -1) return;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
gzrewind (fp_t->f.gfp);
|
gzrewind (fp->f.gfp);
|
||||||
else
|
else
|
||||||
rewind (fp_t->f.fp);
|
rewind (fp->f.fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t hc_ftell (fp_tmp_t *fp_t)
|
off_t hc_ftell (HCFILE *fp)
|
||||||
{
|
{
|
||||||
off_t n = 0;
|
off_t n = 0;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
n = (off_t) gztell (fp_t->f.gfp);
|
n = (off_t) gztell (fp->f.gfp);
|
||||||
else
|
else
|
||||||
n = ftello (fp_t->f.fp);
|
n = ftello (fp->f.fp);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
int hc_fputc (int c, fp_tmp_t *fp_t)
|
|
||||||
|
int hc_fputc (int c, HCFILE *fp)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
r = gzputc (fp_t->f.gfp, c);
|
r = gzputc (fp->f.gfp, c);
|
||||||
else
|
else
|
||||||
r = fputc (c, fp_t->f.fp);
|
r = fputc (c, fp->f.fp);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hc_fgetc (fp_tmp_t *fp_t)
|
int hc_fgetc (HCFILE *fp)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
r = gzgetc (fp_t->f.gfp);
|
r = gzgetc (fp->f.gfp);
|
||||||
else
|
else
|
||||||
r = fgetc (fp_t->f.fp);
|
r = fgetc (fp->f.fp);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *hc_fgets (char *buf, int len, fp_tmp_t *fp_t)
|
char *hc_fgets (char *buf, int len, HCFILE *fp)
|
||||||
{
|
{
|
||||||
char *r = NULL;
|
char *r = NULL;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return NULL;
|
if (fp == NULL || fp->is_gzip == -1) return NULL;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
r = gzgets (fp_t->f.gfp, buf, len);
|
r = gzgets (fp->f.gfp, buf, len);
|
||||||
else
|
else
|
||||||
r = fgets (buf, len, fp_t->f.fp);
|
r = fgets (buf, len, fp->f.fp);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hc_fileno (fp_tmp_t *fp_t)
|
int hc_vfprintf (HCFILE *fp, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = -1;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
|
r = gzvprintf (fp->f.gfp, format, ap);
|
||||||
|
else
|
||||||
|
r = vfprintf (fp->f.fp, format, ap);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hc_fprintf (HCFILE *fp, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int r = -1;
|
||||||
|
|
||||||
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
|
va_start (ap, format);
|
||||||
|
|
||||||
|
if (fp->is_gzip)
|
||||||
|
r = gzvprintf (fp->f.gfp, format, ap);
|
||||||
|
else
|
||||||
|
r = vfprintf (fp->f.fp, format, ap);
|
||||||
|
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hc_fscanf (HCFILE *fp, const char *format, void *ptr)
|
||||||
|
{
|
||||||
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
|
char *buf = (char *) hcmalloc (HCBUFSIZ_TINY);
|
||||||
|
|
||||||
|
if (!buf) return -1;
|
||||||
|
|
||||||
|
char *b = hc_fgets (buf, HCBUFSIZ_TINY - 1, fp);
|
||||||
|
|
||||||
|
if (!b)
|
||||||
{
|
{
|
||||||
int rdup = fileno (fopen (fp_t->path, fp_t->mode));
|
hcfree (buf);
|
||||||
|
|
||||||
r = dup(rdup);
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
close(rdup);
|
sscanf (b, format, (void *) ptr);
|
||||||
|
|
||||||
|
hcfree (buf);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hc_fileno (HCFILE *fp)
|
||||||
|
{
|
||||||
|
int r = -1;
|
||||||
|
|
||||||
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
|
if (fp->is_gzip)
|
||||||
|
{
|
||||||
|
int rdup = fileno (fopen (fp->path, fp->mode));
|
||||||
|
|
||||||
|
r = dup (rdup);
|
||||||
|
|
||||||
|
close (rdup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
r = fileno (fp_t->f.fp);
|
r = fileno (fp->f.fp);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hc_feof (fp_tmp_t *fp_t)
|
int hc_feof (HCFILE *fp)
|
||||||
{
|
{
|
||||||
int r = 0;
|
int r = -1;
|
||||||
|
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return -1;
|
if (fp == NULL || fp->is_gzip == -1) return -1;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
r = gzeof (fp_t->f.gfp);
|
r = gzeof (fp->f.gfp);
|
||||||
else
|
else
|
||||||
r = feof (fp_t->f.fp);
|
r = feof (fp->f.fp);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void hc_fflush (HCFILE *fp)
|
||||||
void hc_fflush (fp_tmp_t *fp_t)
|
|
||||||
{
|
{
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return;
|
if (fp == NULL || fp->is_gzip == -1) return;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
gzflush (fp_t->f.gfp, Z_SYNC_FLUSH);
|
gzflush (fp->f.gfp, Z_SYNC_FLUSH);
|
||||||
else
|
else
|
||||||
fflush (fp_t->f.fp);
|
fflush (fp->f.fp);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void hc_fclose (fp_tmp_t *fp_t)
|
void hc_fclose (HCFILE *fp)
|
||||||
{
|
{
|
||||||
if (fp_t == NULL || fp_t->is_gzip == -1) return;
|
if (fp == NULL || fp->is_gzip == -1) return;
|
||||||
|
|
||||||
if (fp_t->is_gzip)
|
if (fp->is_gzip)
|
||||||
gzclose (fp_t->f.gfp);
|
gzclose (fp->f.gfp);
|
||||||
else
|
else
|
||||||
fclose (fp_t->f.fp);
|
fclose (fp->f.fp);
|
||||||
|
|
||||||
fp_t->is_gzip = -1;
|
fp->is_gzip = -1;
|
||||||
|
|
||||||
fp_t->path = NULL;
|
fp->path = NULL;
|
||||||
|
fp->mode = NULL;
|
||||||
fp_t->mode = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hc_same_files (char *file1, char *file2)
|
bool hc_same_files (char *file1, char *file2)
|
||||||
@ -835,36 +890,45 @@ bool hc_same_files (char *file1, char *file2)
|
|||||||
|
|
||||||
int do_check = 0;
|
int do_check = 0;
|
||||||
|
|
||||||
FILE *fp;
|
// FILE *fp;
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
fp = fopen (file1, "r");
|
// fp = fopen (file1, "r");
|
||||||
|
|
||||||
if (fp)
|
// if (fp)
|
||||||
|
if (hc_fopen (&fp, file1, "r") == true)
|
||||||
{
|
{
|
||||||
if (fstat (fileno (fp), &tmpstat_file1))
|
// if (fstat (fileno (fp), &tmpstat_file1))
|
||||||
|
if (fstat (hc_fileno (&fp), &tmpstat_file1))
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
do_check++;
|
do_check++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen (file2, "r");
|
// fp = fopen (file2, "r");
|
||||||
|
|
||||||
if (fp)
|
// if (fp)
|
||||||
|
if (hc_fopen (&fp, file2, "r") == true)
|
||||||
{
|
{
|
||||||
if (fstat (fileno (fp), &tmpstat_file2))
|
// if (fstat (fileno (fp), &tmpstat_file2))
|
||||||
|
if (fstat (hc_fileno (&fp), &tmpstat_file2))
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
do_check++;
|
do_check++;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
fp_tmp_t *fp_t = extra_info_straight->fp_t;
|
HCFILE *fp = extra_info_straight->fp;
|
||||||
|
|
||||||
get_next_word (hashcat_ctx, fp_t, &line_buf, &line_len);
|
get_next_word (hashcat_ctx, fp, &line_buf, &line_len);
|
||||||
|
|
||||||
// post-process rule engine
|
// post-process rule engine
|
||||||
|
|
||||||
@ -76,8 +76,8 @@ 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;
|
||||||
|
|
||||||
fp_tmp_t *base_fp_t = extra_info_combi->base_fp_t;
|
HCFILE *base_fp = extra_info_combi->base_fp;
|
||||||
fp_tmp_t *combs_fp_t = extra_info_combi->combs_fp_t;
|
HCFILE *combs_fp = extra_info_combi->combs_fp;
|
||||||
|
|
||||||
for (u64 i = cur; i < end; i++)
|
for (u64 i = cur; i < end; i++)
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ 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_t, &line_buf, &line_len);
|
get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len);
|
||||||
|
|
||||||
// post-process rule engine
|
// post-process rule engine
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ 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;
|
||||||
|
|
||||||
hc_rewind (combs_fp_t);
|
hc_rewind (combs_fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *line_buf = extra_info_combi->scratch_buf;
|
char *line_buf = extra_info_combi->scratch_buf;
|
||||||
@ -123,7 +123,7 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
line_len = (u32) fgetl (combs_fp_t, line_buf);
|
line_len = (u32) fgetl (combs_fp, line_buf);
|
||||||
|
|
||||||
// post-process rule engine
|
// post-process rule engine
|
||||||
|
|
||||||
@ -176,9 +176,9 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
fp_tmp_t *fp_t = extra_info_straight->fp_t;
|
HCFILE *fp = extra_info_straight->fp;
|
||||||
|
|
||||||
get_next_word (hashcat_ctx, fp_t, &line_buf, &line_len);
|
get_next_word (hashcat_ctx, fp, &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);
|
||||||
|
|
||||||
@ -238,8 +238,8 @@ 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;
|
||||||
|
|
||||||
fp_tmp_t *base_fp_t = extra_info_combi->base_fp_t;
|
HCFILE *base_fp = extra_info_combi->base_fp;
|
||||||
fp_tmp_t *combs_fp_t = extra_info_combi->combs_fp_t;
|
HCFILE *combs_fp = extra_info_combi->combs_fp;
|
||||||
|
|
||||||
if ((extra_info_combi->pos % combinator_ctx->combs_cnt) == 0)
|
if ((extra_info_combi->pos % combinator_ctx->combs_cnt) == 0)
|
||||||
{
|
{
|
||||||
@ -248,7 +248,7 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
get_next_word (hashcat_ctx, base_fp_t, &line_buf, &line_len);
|
get_next_word (hashcat_ctx, base_fp, &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);
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ 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;
|
||||||
|
|
||||||
hc_rewind (combs_fp_t);
|
hc_rewind (combs_fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -286,7 +286,7 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
line_len = (u32) fgetl (combs_fp_t, line_buf);
|
line_len = (u32) fgetl (combs_fp, line_buf);
|
||||||
|
|
||||||
// post-process rule engine
|
// post-process rule engine
|
||||||
|
|
||||||
|
43
src/stdout.c
43
src/stdout.c
@ -18,7 +18,8 @@ static void out_flush (out_t *out)
|
|||||||
{
|
{
|
||||||
if (out->len == 0) return;
|
if (out->len == 0) return;
|
||||||
|
|
||||||
hc_fwrite_direct (out->buf, 1, out->len, out->fp);
|
// hc_fwrite (out->buf, 1, out->len, out->fp);
|
||||||
|
hc_fwrite_compress (out->buf, 1, out->len, out->fp);
|
||||||
|
|
||||||
out->len = 0;
|
out->len = 0;
|
||||||
}
|
}
|
||||||
@ -61,31 +62,44 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
out_t out;
|
out_t out;
|
||||||
|
|
||||||
out.fp = stdout;
|
HCFILE fp_tmp;
|
||||||
|
fp_tmp.is_gzip = 0;
|
||||||
|
fp_tmp.f.fp = stdout;
|
||||||
|
|
||||||
|
// out.fp = stdout;
|
||||||
|
out.fp = &fp_tmp;
|
||||||
|
|
||||||
|
/// PORKODIO
|
||||||
|
|
||||||
char *filename = outfile_ctx->filename;
|
char *filename = outfile_ctx->filename;
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen (filename, "ab");
|
// FILE *fp = fopen (filename, "ab");
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
if (fp == NULL)
|
// if (fp == NULL)
|
||||||
|
if (hc_fopen (&fp, filename, "ab") == false)
|
||||||
{
|
{
|
||||||
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock_file (fp) == -1)
|
fp.is_gzip = 0;
|
||||||
|
|
||||||
|
// if (lock_file (fp) == -1)
|
||||||
|
if (lock_file (fp.f.fp) == -1)
|
||||||
{
|
{
|
||||||
fclose (fp);
|
// fclose (fp);
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.fp = fp;
|
out.fp = &fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.len = 0;
|
out.len = 0;
|
||||||
@ -108,7 +122,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
if (filename) fclose (out.fp);
|
// if (filename) fclose (out.fp);
|
||||||
|
if (filename) hc_fclose (out.fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -152,7 +167,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
if (filename) fclose (out.fp);
|
// if (filename) fclose (out.fp);
|
||||||
|
if (filename) hc_fclose (out.fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -222,7 +238,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
if (filename) fclose (out.fp);
|
// if (filename) fclose (out.fp);
|
||||||
|
if (filename) hc_fclose (out.fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -259,7 +276,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
if (filename) fclose (out.fp);
|
// if (filename) fclose (out.fp);
|
||||||
|
if (filename) hc_fclose (out.fp);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -291,7 +309,8 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
|
|
||||||
out_flush (&out);
|
out_flush (&out);
|
||||||
|
|
||||||
if (filename) fclose (out.fp);
|
// if (filename) fclose (out.fp);
|
||||||
|
if (filename) hc_fclose (out.fp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,18 +70,18 @@ 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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, straight_ctx->dict, "rb") == false)
|
if (hc_fopen (&fp, 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, &fp_t, straight_ctx->dict, &status_ctx->words_cnt);
|
const int rc = count_words (hashcat_ctx, &fp, straight_ctx->dict, &status_ctx->words_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
@ -105,18 +105,18 @@ 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)
|
||||||
{
|
{
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, combinator_ctx->dict1, "rb") == false)
|
if (hc_fopen (&fp, 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, &fp_t, combinator_ctx->dict1, &status_ctx->words_cnt);
|
const int rc = count_words (hashcat_ctx, &fp, combinator_ctx->dict1, &status_ctx->words_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
@ -127,18 +127,18 @@ 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)
|
||||||
{
|
{
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, combinator_ctx->dict2, "rb") == false)
|
if (hc_fopen (&fp, 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, &fp_t, combinator_ctx->dict2, &status_ctx->words_cnt);
|
const int rc = count_words (hashcat_ctx, &fp, combinator_ctx->dict2, &status_ctx->words_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
@ -173,18 +173,18 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, straight_ctx->dict, "rb") == false)
|
if (hc_fopen (&fp, 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, &fp_t, straight_ctx->dict, &status_ctx->words_cnt);
|
const int rc = count_words (hashcat_ctx, &fp, straight_ctx->dict, &status_ctx->words_cnt);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
{
|
{
|
||||||
|
@ -977,7 +977,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
|
|||||||
printf ("%d\t", util);
|
printf ("%d\t", util);
|
||||||
}
|
}
|
||||||
|
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (EOL, strlen (EOL), 1, stdout);
|
||||||
|
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
|
|
||||||
@ -1064,7 +1064,7 @@ 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_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (EOL, strlen (EOL), 1, stdout);
|
||||||
|
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ 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);
|
||||||
|
|
||||||
fp_tmp_t fp_t;
|
HCFILE fp;
|
||||||
|
|
||||||
if (hc_fopen (&fp_t, tuning_db_file, "rb") == false)
|
if (hc_fopen (&fp, 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 +79,7 @@ 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_t);
|
const size_t num_lines = count_lines (&fp);
|
||||||
|
|
||||||
// a bit over-allocated
|
// a bit over-allocated
|
||||||
|
|
||||||
@ -89,15 +89,15 @@ 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;
|
||||||
|
|
||||||
hc_rewind (&fp_t);
|
hc_rewind (&fp);
|
||||||
|
|
||||||
int line_num = 0;
|
int line_num = 0;
|
||||||
|
|
||||||
char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
char *buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
||||||
|
|
||||||
while (!hc_feof (&fp_t))
|
while (!hc_feof (&fp))
|
||||||
{
|
{
|
||||||
char *line_buf = hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp_t);
|
char *line_buf = hc_fgets (buf, HCBUFSIZ_LARGE - 1, &fp);
|
||||||
|
|
||||||
if (line_buf == NULL) break;
|
if (line_buf == NULL) break;
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
hcfree (buf);
|
hcfree (buf);
|
||||||
|
|
||||||
hc_fclose (&fp_t);
|
hc_fclose (&fp);
|
||||||
|
|
||||||
// todo: print loaded 'cnt' message
|
// todo: print loaded 'cnt' message
|
||||||
|
|
||||||
|
14
src/usage.c
14
src/usage.c
@ -269,7 +269,7 @@ void usage_mini_print (const char *progname)
|
|||||||
{
|
{
|
||||||
printf (USAGE_MINI[i], progname);
|
printf (USAGE_MINI[i], progname);
|
||||||
|
|
||||||
hc_fwrite_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (EOL, strlen (EOL), 1, stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,19 +315,19 @@ 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_direct (EOL, strlen (EOL), 1, stdout);
|
hc_fwrite (EOL, strlen (EOL), 1, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
//hc_fwrite (EOL, strlen (EOL), 1, stdout);
|
//hc_fwrite_compress (EOL, strlen (EOL), 1, stdout);
|
||||||
|
|
||||||
for (int i = 0; i < usage_sort_cnt; i++)
|
for (int i = 0; i < usage_sort_cnt; i++)
|
||||||
{
|
{
|
||||||
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_direct (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);
|
||||||
|
|
||||||
for (int i = 0; i < usage_sort_cnt; i++)
|
for (int i = 0; i < usage_sort_cnt; i++)
|
||||||
{
|
{
|
||||||
@ -340,8 +340,8 @@ 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_direct (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);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ 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, fp_tmp_t *fp_t)
|
int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp)
|
||||||
{
|
{
|
||||||
wl_data_t *wl_data = hashcat_ctx->wl_data;
|
wl_data_t *wl_data = hashcat_ctx->wl_data;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t)
|
|||||||
|
|
||||||
wl_data->pos = 0;
|
wl_data->pos = 0;
|
||||||
|
|
||||||
wl_data->cnt = hc_fread (wl_data->buf, 1, wl_data->incr - 1000, fp_t);
|
wl_data->cnt = hc_fread_compress (wl_data->buf, 1, wl_data->incr - 1000, fp);
|
||||||
|
|
||||||
wl_data->buf[wl_data->cnt] = 0;
|
wl_data->buf[wl_data->cnt] = 0;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t)
|
|||||||
|
|
||||||
if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0;
|
if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0;
|
||||||
|
|
||||||
while (!hc_feof (fp_t))
|
while (!hc_feof (fp))
|
||||||
{
|
{
|
||||||
if (wl_data->cnt == wl_data->avail)
|
if (wl_data->cnt == wl_data->avail)
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t)
|
|||||||
wl_data->avail += wl_data->incr;
|
wl_data->avail += wl_data->incr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int c = hc_fgetc (fp_t);
|
const int c = hc_fgetc (fp);
|
||||||
|
|
||||||
if (c == EOF) break;
|
if (c == EOF) break;
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ 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, fp_tmp_t *fp_t, char **out_buf, u32 *out_len)
|
void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, 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 +225,16 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, char **out_buf,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hc_feof (fp_t))
|
if (hc_feof (fp))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "BUG feof()!!\n");
|
fprintf (stderr, "BUG feof()!!\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_segment (hashcat_ctx, fp_t);
|
load_segment (hashcat_ctx, fp);
|
||||||
|
|
||||||
get_next_word (hashcat_ctx, fp_t, out_buf, out_len);
|
get_next_word (hashcat_ctx, fp, 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 +317,7 @@ 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, fp_tmp_t *fp_t, const char *dictfile, u64 *result)
|
int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, 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 +333,7 @@ int count_words (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, const char *dictfil
|
|||||||
|
|
||||||
d.cnt = 0;
|
d.cnt = 0;
|
||||||
|
|
||||||
if (fstat (hc_fileno (fp_t), &d.stat))
|
if (fstat (hc_fileno (fp), &d.stat))
|
||||||
{
|
{
|
||||||
*result = 0;
|
*result = 0;
|
||||||
|
|
||||||
@ -425,9 +425,9 @@ int count_words (hashcat_ctx_t *hashcat_ctx, fp_tmp_t *fp_t, const char *dictfil
|
|||||||
u64 cnt = 0;
|
u64 cnt = 0;
|
||||||
u64 cnt2 = 0;
|
u64 cnt2 = 0;
|
||||||
|
|
||||||
while (!hc_feof (fp_t))
|
while (!hc_feof (fp))
|
||||||
{
|
{
|
||||||
load_segment (hashcat_ctx, fp_t);
|
load_segment (hashcat_ctx, fp);
|
||||||
|
|
||||||
comp += wl_data->cnt;
|
comp += wl_data->cnt;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user