diff --git a/include/shared.h b/include/shared.h index 34d919838..e9cfd95ca 100644 --- a/include/shared.h +++ b/include/shared.h @@ -66,7 +66,7 @@ void hc_string_trim_leading (char *s); int _wopen(const char *path, int oflag, ...); #endif -bool hc_fopen (HCFILE *fp, const char *path, char *mode, int file_format); +bool hc_fopen (HCFILE *fp, const char *path, char *mode); int hc_fscanf (HCFILE *fp, const char *format, void *ptr); int hc_fprintf (HCFILE *fp, const char *format, ...); int hc_vfprintf (HCFILE *fp, const char *format, va_list ap); diff --git a/include/types.h b/include/types.h index b918fd7bb..a9e562d2f 100644 --- a/include/types.h +++ b/include/types.h @@ -1002,13 +1002,6 @@ typedef struct hc_fp const char *path; } HCFILE; -typedef enum hcfile_format -{ - HCFILE_FORMAT_PLAIN = 0, - HCFILE_FORMAT_GZIP = 1, - -} hcfile_format_t; - #include "ext_nvrtc.h" #include "ext_cuda.h" #include "ext_OpenCL.h" diff --git a/src/backend.c b/src/backend.c index c69bd3aec..30d0532cd 100644 --- a/src/backend.c +++ b/src/backend.c @@ -441,9 +441,8 @@ 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) { HCFILE fp; - bool is_gzip = false; - if (hc_fopen (&fp, kernel_file, "rb", false) != false) + if (hc_fopen (&fp, kernel_file, "rb") != false) { struct stat st; @@ -454,22 +453,16 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f return false; } - is_gzip = fp.is_gzip; - #define EXTRASZ 100 size_t klen = st.st_size; - if (is_gzip) klen *= 10; // must be >= of uncompress len - char *buf = (char *) hcmalloc (klen + 1 + EXTRASZ); size_t num_read = hc_fread (buf, sizeof (char), klen, &fp); hc_fclose (&fp); - if (is_gzip && klen > num_read) klen = num_read; - if (num_read != (size_t) klen) { event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); @@ -514,8 +507,7 @@ static bool write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, { HCFILE fp; - // change HCFILE_FORMAT_GZIP to HCFILE_FORMAT_PLAIN to write kernel binary uncompressed - if (hc_fopen (&fp, kernel_file, "wb", HCFILE_FORMAT_GZIP) == false) + if (hc_fopen (&fp, kernel_file, "wb") == false) { event_log_error (hashcat_ctx, "%s: %s", kernel_file, strerror (errno)); diff --git a/src/brain.c b/src/brain.c index 5a1fe9fed..4412bb796 100644 --- a/src/brain.c +++ b/src/brain.c @@ -541,7 +541,7 @@ u64 brain_compute_attack_wordlist (const char *filename) HCFILE fp; - hc_fopen (&fp, filename, "rb", false); + hc_fopen (&fp, filename, "rb"); while (!hc_feof (&fp)) { @@ -613,7 +613,7 @@ u32 brain_auth_challenge (void) HCFILE fp; - if (hc_fopen (&fp, urandom, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, urandom, "rb") == false) { brain_logging (stderr, 0, "%s: %s\n", urandom, strerror (errno)); @@ -1599,7 +1599,7 @@ bool brain_server_read_hash_dump (brain_server_db_hash_t *brain_server_db_hash, HCFILE fp; - if (hc_fopen (&fp, file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, file, "rb") == false) { brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno)); @@ -1655,7 +1655,7 @@ bool brain_server_write_hash_dump (brain_server_db_hash_t *brain_server_db_hash, HCFILE fp; - if (hc_fopen (&fp, file, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, file, "wb") == false) { brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno)); @@ -1798,7 +1798,7 @@ bool brain_server_read_attack_dump (brain_server_db_attack_t *brain_server_db_at HCFILE fp; - if (hc_fopen (&fp, file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, file, "rb") == false) { brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno)); @@ -1854,7 +1854,7 @@ bool brain_server_write_attack_dump (brain_server_db_attack_t *brain_server_db_a HCFILE fp; - if (hc_fopen (&fp, file, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, file, "wb") == false) { brain_logging (stderr, 0, "%s: %s\n", file, strerror (errno)); diff --git a/src/combinator.c b/src/combinator.c index f147b8d48..bb4efb322 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -63,14 +63,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE fp1; HCFILE fp2; - if (hc_fopen (&fp1, dictfile1, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp1, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if (hc_fopen (&fp2, dictfile2, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp2, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); @@ -166,14 +166,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE fp1; HCFILE fp2; - if (hc_fopen (&fp1, dictfile1, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp1, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if (hc_fopen (&fp2, dictfile2, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp2, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); @@ -297,14 +297,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE fp1; HCFILE fp2; - if (hc_fopen (&fp1, dictfile1, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp1, dictfile1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); return -1; } - if (hc_fopen (&fp2, dictfile2, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp2, dictfile2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); @@ -389,7 +389,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, dictfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 72b72e36f..e2d0d75d4 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -94,7 +94,7 @@ int cpu_crc32 (const char *filename, u8 keytab[64]) HCFILE fp; - hc_fopen (&fp, filename, "rb", HCFILE_FORMAT_PLAIN); + hc_fopen (&fp, filename, "rb"); #define MAX_KEY_SIZE (1024 * 1024) diff --git a/src/debugfile.c b/src/debugfile.c index e81669fca..7449ffd9c 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -109,7 +109,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (debugfile_ctx->filename) { - if (hc_fopen (&fp, debugfile_ctx->filename, "ab", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, debugfile_ctx->filename, "ab") == false) { event_log_error (hashcat_ctx, "Could not open --debug-file file for writing."); diff --git a/src/dictstat.c b/src/dictstat.c index 798f0cb99..caab3deea 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -98,7 +98,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, dictstat_ctx->filename, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, dictstat_ctx->filename, "rb") == false) { // first run, file does not exist, do not error out @@ -186,7 +186,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, dictstat_ctx->filename, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, dictstat_ctx->filename, "wb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno)); diff --git a/src/dispatch.c b/src/dispatch.c index 87bad7a77..418a3b049 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -429,7 +429,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE fp; - if (hc_fopen (&fp, dictfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); @@ -749,7 +749,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE base_fp; - if (hc_fopen (&base_fp, base_file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&base_fp, base_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", base_file, strerror (errno)); @@ -758,7 +758,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE combs_fp; - if (hc_fopen (&combs_fp, combs_file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&combs_fp, combs_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combs_file, strerror (errno)); @@ -1324,7 +1324,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE combs_fp; - if (hc_fopen (&combs_fp, dictfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&combs_fp, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); @@ -1390,7 +1390,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE combs_fp; - if (hc_fopen (&combs_fp, dictfilec, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&combs_fp, dictfilec, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); @@ -1405,7 +1405,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE combs_fp; - if (hc_fopen (&combs_fp, dictfilec, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&combs_fp, dictfilec, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno)); @@ -1418,7 +1418,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) HCFILE fp; - if (hc_fopen (&fp, dictfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, dictfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); diff --git a/src/hashes.c b/src/hashes.c index ad363ee13..188b3969f 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -186,7 +186,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, new_hashfile, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, new_hashfile, "wb") == false) { event_log_error (hashcat_ctx, "%s: %s", new_hashfile, strerror (errno)); @@ -676,7 +676,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; - if (hc_fopen (&fp, hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, hashfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); @@ -996,7 +996,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; - if (hc_fopen (&fp, hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, hashfile, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", hashfile, strerror (errno)); @@ -1792,7 +1792,7 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - hc_fopen (&fp, tmpfile_bin, "wb", false); + hc_fopen (&fp, tmpfile_bin, "wb"); const size_t st_hash_len = strlen (hashconfig->st_hash); diff --git a/src/hwmon.c b/src/hwmon.c index a3e018cfc..512f60b61 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -112,7 +112,7 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int HCFILE fp_cur; - if (hc_fopen (&fp_cur, path_cur, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp_cur, path_cur, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno)); @@ -140,7 +140,7 @@ static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int HCFILE fp_max; - if (hc_fopen (&fp_max, path_max, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp_max, path_max, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno)); @@ -202,7 +202,7 @@ static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const i HCFILE fp; - if (hc_fopen (&fp, path, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, path, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); @@ -247,7 +247,7 @@ static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backe HCFILE fp; - if (hc_fopen (&fp, path, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, path, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); @@ -302,7 +302,7 @@ static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backe HCFILE fp; - if (hc_fopen (&fp, path, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, path, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); @@ -357,7 +357,7 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe HCFILE fp; - if (hc_fopen (&fp, path, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, path, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); @@ -462,7 +462,7 @@ static int nvml_init (hashcat_ctx_t *hashcat_ctx) { HCFILE nvml_lib; - if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb") == false) { //if (user_options->quiet == false) // event_log_error (hashcat_ctx, "NVML library load failed: %m. Proceeding without NVML HWMon enabled."); diff --git a/src/keyboard_layout.c b/src/keyboard_layout.c index 841c51309..2e6927557 100644 --- a/src/keyboard_layout.c +++ b/src/keyboard_layout.c @@ -24,7 +24,7 @@ bool initialize_keyboard_layout_mapping (const char *filename, keyboard_layout_m HCFILE fp; - if (hc_fopen (&fp, filename, "r", HCFILE_FORMAT_PLAIN) == false) return false; + if (hc_fopen (&fp, filename, "r") == false) return false; int maps_cnt = 0; diff --git a/src/locking.c b/src/locking.c index 5c89d23c8..411a02178 100644 --- a/src/locking.c +++ b/src/locking.c @@ -12,7 +12,7 @@ int hc_lockfile (HCFILE *fp) { - if (!fp) return -1; + if (fp == NULL) return -1; struct flock lock; @@ -31,7 +31,7 @@ int hc_lockfile (HCFILE *fp) int hc_unlockfile (HCFILE *fp) { - if (!fp) return -1; + if (fp == NULL) return -1; struct flock lock; @@ -39,10 +39,7 @@ int hc_unlockfile (HCFILE *fp) lock.l_type = F_UNLCK; - if (fcntl (hc_fileno (fp), F_SETLK, &lock)) - { - return -1; - } + if (fcntl (hc_fileno (fp), F_SETLK, &lock)) return -1; return 0; } diff --git a/src/logfile.c b/src/logfile.c index bef206fa2..29f342a4b 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -45,7 +45,7 @@ void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) HCFILE fp; - if (hc_fopen (&fp, logfile_ctx->logfile, "ab", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, logfile_ctx->logfile, "ab") == false) { event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno)); diff --git a/src/loopback.c b/src/loopback.c index 0fc9297f2..7b1ac84f9 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -107,7 +107,7 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, loopback_ctx->filename, "ab", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, loopback_ctx->filename, "ab") == false) { event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno)); diff --git a/src/main.c b/src/main.c index f481b60f4..b0fa61d38 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,14 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel) if (prev_len) main_log_clear_line (prev_len, fp); - event_ctx->prev_len = (msg_newline == true) ? 0 : msg_len; + if (msg_newline == true) + { + event_ctx->prev_len = 0; + } + else + { + event_ctx->prev_len = msg_len; + } // color stuff pre diff --git a/src/modules/module_02500.c b/src/modules/module_02500.c index e7fefb931..8907f8677 100644 --- a/src/modules/module_02500.c +++ b/src/modules/module_02500.c @@ -376,7 +376,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return -1; + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; char *in = (char *) hcmalloc (sizeof (hccapx_t)); diff --git a/src/modules/module_02501.c b/src/modules/module_02501.c index 750a47bfa..a7ce17b04 100644 --- a/src/modules/module_02501.c +++ b/src/modules/module_02501.c @@ -351,7 +351,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return -1; + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return -1; char *in = (char *) hcmalloc (sizeof (hccapx_t)); diff --git a/src/modules/module_05200.c b/src/modules/module_05200.c index c5682cb14..7c50b5d47 100644 --- a/src/modules/module_05200.c +++ b/src/modules/module_05200.c @@ -95,7 +95,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE HCFILE fp; - if (hc_fopen (&fp, (const char *) line_buf, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); psafe3_t in; diff --git a/src/modules/module_06211.c b/src/modules/module_06211.c index 39ef928fd..8f2be8897 100644 --- a/src/modules/module_06211.c +++ b/src/modules/module_06211.c @@ -148,7 +148,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06212.c b/src/modules/module_06212.c index a5a02cb28..bfc9d05d8 100644 --- a/src/modules/module_06212.c +++ b/src/modules/module_06212.c @@ -148,7 +148,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06213.c b/src/modules/module_06213.c index ea292f65e..1b09d8607 100644 --- a/src/modules/module_06213.c +++ b/src/modules/module_06213.c @@ -146,7 +146,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06221.c b/src/modules/module_06221.c index fcc0ebb7a..6d43ffe3c 100644 --- a/src/modules/module_06221.c +++ b/src/modules/module_06221.c @@ -146,7 +146,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06222.c b/src/modules/module_06222.c index 3e6c15e8d..b0ae40989 100644 --- a/src/modules/module_06222.c +++ b/src/modules/module_06222.c @@ -146,7 +146,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06223.c b/src/modules/module_06223.c index 61d7f7930..ee3c1f5ed 100644 --- a/src/modules/module_06223.c +++ b/src/modules/module_06223.c @@ -146,7 +146,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06231.c b/src/modules/module_06231.c index d08688405..e01fd7300 100644 --- a/src/modules/module_06231.c +++ b/src/modules/module_06231.c @@ -148,7 +148,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06232.c b/src/modules/module_06232.c index ee648e993..b8a404670 100644 --- a/src/modules/module_06232.c +++ b/src/modules/module_06232.c @@ -148,7 +148,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06233.c b/src/modules/module_06233.c index ca017e24e..499f0714a 100644 --- a/src/modules/module_06233.c +++ b/src/modules/module_06233.c @@ -148,7 +148,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index 093a43fd0..09c3e8ec7 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -160,7 +160,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index 27635a09b..20a239fd0 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -160,7 +160,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index 608a9c48b..baa540b0c 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -160,7 +160,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define TC_HEADER_SIZE 512 diff --git a/src/modules/module_09000.c b/src/modules/module_09000.c index 5a4751a0b..b69166668 100644 --- a/src/modules/module_09000.c +++ b/src/modules/module_09000.c @@ -158,7 +158,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE HCFILE fp; - if (hc_fopen (&fp, (const char *) line_buf, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); psafe2_hdr buf; diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index b801781ce..87852ec44 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index 76992723e..c8179fb71 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index b0415cfb3..062378441 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index f0e899047..fba2cc96d 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -172,7 +172,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index 605612293..7e8257b77 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -172,7 +172,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index 345aae7b6..5b9c5cb94 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -172,7 +172,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index ed3c1ab3d..3afff8644 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index a5f1bbe74..965776e9e 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index 9e825d0e1..3a7d0bbbb 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index dd47faa6e..45fa7d48c 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index 3c65d12df..eda71240c 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index b36a3f8bf..fb3b75f0f 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index c640d1aff..dae3c2d94 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index bff6adc63..9f847766b 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index c03c67c8e..8113f044c 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -174,7 +174,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index e5b80c5a4..5fc1a1376 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index 1807fc803..b0da01aa7 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index a09cf950e..09fb93505 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -175,7 +175,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index a0a8882d5..f788981ef 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -178,7 +178,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index ed9f3f060..e52ee2725 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -178,7 +178,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index eecec3320..20634ebe4 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -178,7 +178,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE HCFILE fp; - if (hc_fopen (&fp, hashes->hashfile, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HASH_FILE); #define VC_HEADER_SIZE 512 diff --git a/src/modules/module_14600.c b/src/modules/module_14600.c index 5532f0d1b..9b8fcc357 100644 --- a/src/modules/module_14600.c +++ b/src/modules/module_14600.c @@ -353,7 +353,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE HCFILE fp; - if (hc_fopen (&fp, (const char *) line_buf, "rb", HCFILE_FORMAT_PLAIN) == false) return (PARSER_HASH_FILE); + if (hc_fopen (&fp, (const char *) line_buf, "rb") == false) return (PARSER_HASH_FILE); struct luks_phdr hdr; diff --git a/src/mpsp.c b/src/mpsp.c index e2527653f..f6d81a6aa 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -584,7 +584,7 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, { HCFILE fp; - if (hc_fopen (&fp, buf, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, buf, "rb") == false) { const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1); @@ -712,7 +712,7 @@ static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, hcstat, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, hcstat, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno)); @@ -1462,7 +1462,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) { HCFILE mask_fp; - if (hc_fopen (&mask_fp, arg, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&mask_fp, arg, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); @@ -1555,7 +1555,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE mask_fp; - if (hc_fopen (&mask_fp, arg, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&mask_fp, arg, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); @@ -1629,7 +1629,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) HCFILE mask_fp; - if (hc_fopen (&mask_fp, arg, "r", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&mask_fp, arg, "r") == false) { event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno)); diff --git a/src/outfile.c b/src/outfile.c index c3e1d3b24..2c3b5934d 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -392,7 +392,7 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, outfile_ctx->filename, "ab", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, outfile_ctx->filename, "ab") == false) { event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno)); diff --git a/src/outfile_check.c b/src/outfile_check.c index 4879cdc98..c67b9429c 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -157,7 +157,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; - if (hc_fopen (&fp, out_info[j].file_name, "rb", HCFILE_FORMAT_PLAIN) == false) continue; + if (hc_fopen (&fp, out_info[j].file_name, "rb") == false) continue; //hc_thread_mutex_lock (status_ctx->mux_display); diff --git a/src/pidfile.c b/src/pidfile.c index 866f5cfd4..7da26fa70 100644 --- a/src/pidfile.c +++ b/src/pidfile.c @@ -18,7 +18,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, pidfile_filename, "rb", HCFILE_FORMAT_PLAIN) == false) return 0; + if (hc_fopen (&fp, pidfile_filename, "rb") == false) return 0; pidfile_data_t *pd = (pidfile_data_t *) hcmalloc (sizeof (pidfile_data_t)); @@ -155,7 +155,7 @@ static int write_pidfile (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, pidfile_filename, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, pidfile_filename, "wb") == false) { event_log_error (hashcat_ctx, "%s: %s", pidfile_filename, strerror (errno)); diff --git a/src/restore.c b/src/restore.c index e261d2b26..3800a361b 100644 --- a/src/restore.c +++ b/src/restore.c @@ -56,7 +56,7 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, eff_restore_file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, eff_restore_file, "rb") == false) { event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno)); @@ -205,7 +205,7 @@ static int write_restore (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, new_restore_file, "wb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, new_restore_file, "wb") == false) { event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno)); diff --git a/src/rp.c b/src/rp.c index 74709878c..716e451bf 100644 --- a/src/rp.c +++ b/src/rp.c @@ -737,7 +737,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32 u32 rule_line = 0; - if (hc_fopen (&fp, rp_file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, rp_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno)); diff --git a/src/shared.c b/src/shared.c index 01da83cf7..7ff8718e5 100644 --- a/src/shared.c +++ b/src/shared.c @@ -352,7 +352,7 @@ bool hc_path_has_bom (const char *path) HCFILE fp; - if (hc_fopen (&fp, path, "rb", HCFILE_FORMAT_PLAIN) == false) return false; + if (hc_fopen (&fp, path, "rb") == false) return false; const size_t nread = hc_fread (buf, 1, sizeof (buf), &fp); @@ -615,7 +615,7 @@ int _wopen(const char *path, int oflag, ...) } #endif -bool hc_fopen (HCFILE *fp, const char *path, char *mode, int file_format) +bool hc_fopen (HCFILE *fp, const char *path, char *mode) { if (!path || !mode) return false; @@ -654,37 +654,42 @@ bool hc_fopen (HCFILE *fp, const char *path, char *mode, int file_format) return false; } - if (file_format == HCFILE_FORMAT_PLAIN) - { - unsigned char check[3] = { 0 }; + fp->pfp = NULL; + fp->is_gzip = false; + + unsigned char check[3] = { 0 }; - int fd_tmp = open (path, O_RDONLY); + int fd_tmp = open (path, O_RDONLY); + if (fd_tmp != -1) + { lseek (fd_tmp, 0, SEEK_SET); - size_t s = read (fd_tmp, check, sizeof(check)); + read (fd_tmp, check, sizeof(check)); - if (s == 3 && (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08)) file_format = HCFILE_FORMAT_GZIP; + if (check[0] == 0x1f && check[1] == 0x8b && check[2] == 0x08) fp->is_gzip = true; close (fd_tmp); } - fp->fd = (fmode == -1) ? open (path, oflag) : open (path, oflag, fmode); + if (fmode == -1) + { + fp->fd = open (path, oflag); + } + else + { + fp->fd = open (path, oflag, fmode); + } if (fp->fd == -1) return false; - if (file_format == HCFILE_FORMAT_PLAIN) + if (fp->is_gzip) { - if (!(fp->pfp = fdopen (fp->fd, mode))) return false; - - fp->is_gzip = false; + if (!(fp->gfp = gzdopen (fp->fd, mode))) return false; } - else // HCFILE_FORMAT_GZIP + else { - if (!(fp->gfp = gzdopen (fp->fd, mode))) return false; - - fp->is_gzip = true; - fp->pfp = NULL; + if (!(fp->pfp = fdopen (fp->fd, mode))) return false; } fp->path = path; @@ -700,9 +705,13 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) if (fp == NULL) return n; if (fp->is_gzip) + { n = gzfread (ptr, size, nmemb, fp->gfp); + } else + { n = fread (ptr, size, nmemb, fp->pfp); + } return n; } @@ -714,9 +723,13 @@ size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp) if (fp == NULL) return n; if (fp->is_gzip) + { n = gzfwrite (ptr, size, nmemb, fp->gfp); + } else + { n = fwrite (ptr, size, nmemb, fp->pfp); + } if (n != nmemb) return -1; @@ -730,9 +743,13 @@ int hc_fseek (HCFILE *fp, off_t offset, int whence) if (fp == NULL) return r; if (fp->is_gzip) + { r = gzseek (fp->gfp, (z_off_t) offset, whence); + } else + { r = fseeko (fp->pfp, offset, whence); + } return r; } @@ -742,9 +759,13 @@ void hc_rewind (HCFILE *fp) if (fp == NULL) return; if (fp->is_gzip) + { gzrewind (fp->gfp); + } else + { rewind (fp->pfp); + } } off_t hc_ftell (HCFILE *fp) @@ -754,9 +775,13 @@ off_t hc_ftell (HCFILE *fp) if (fp == NULL) return -1; if (fp->is_gzip) + { n = (off_t) gztell (fp->gfp); + } else + { n = ftello (fp->pfp); + } return n; } @@ -768,9 +793,13 @@ int hc_fputc (int c, HCFILE *fp) if (fp == NULL) return r; if (fp->is_gzip) + { r = gzputc (fp->gfp, c); + } else + { r = fputc (c, fp->pfp); + } return r; } @@ -782,9 +811,13 @@ int hc_fgetc (HCFILE *fp) if (fp == NULL) return r; if (fp->is_gzip) + { r = gzgetc (fp->gfp); + } else + { r = fgetc (fp->pfp); + } return r; } @@ -793,12 +826,16 @@ char *hc_fgets (char *buf, int len, HCFILE *fp) { char *r = NULL; - if (fp == NULL) return NULL; + if (fp == NULL) return r; if (fp->is_gzip) + { r = gzgets (fp->gfp, buf, len); + } else + { r = fgets (buf, len, fp->pfp); + } return r; } @@ -810,9 +847,13 @@ int hc_vfprintf (HCFILE *fp, const char *format, va_list ap) if (fp == NULL) return r; if (fp->is_gzip) + { r = gzvprintf (fp->gfp, format, ap); + } else + { r = vfprintf (fp->pfp, format, ap); + } return r; } @@ -828,9 +869,13 @@ int hc_fprintf (HCFILE *fp, const char *format, ...) va_start (ap, format); if (fp->is_gzip) + { r = gzvprintf (fp->gfp, format, ap); + } else + { r = vfprintf (fp->pfp, format, ap); + } va_end (ap); @@ -843,11 +888,11 @@ int hc_fscanf (HCFILE *fp, const char *format, void *ptr) char *buf = (char *) hcmalloc (HCBUFSIZ_TINY); - if (!buf) return -1; + if (buf == NULL) return -1; char *b = hc_fgets (buf, HCBUFSIZ_TINY - 1, fp); - if (!b) + if (b == NULL) { hcfree (buf); @@ -875,9 +920,13 @@ int hc_feof (HCFILE *fp) if (fp == NULL) return r; if (fp->is_gzip) + { r = gzeof (fp->gfp); + } else + { r = feof (fp->pfp); + } return r; } @@ -887,9 +936,13 @@ void hc_fflush (HCFILE *fp) if (fp == NULL) return; if (fp->is_gzip) + { gzflush (fp->gfp, Z_SYNC_FLUSH); - else + } + else + { fflush (fp->pfp); + } } void hc_fclose (HCFILE *fp) @@ -897,13 +950,18 @@ void hc_fclose (HCFILE *fp) if (fp == NULL) return; if (fp->is_gzip) + { gzclose (fp->gfp); + } else + { fclose (fp->pfp); + } close (fp->fd); fp->fd = -1; + fp->pfp = NULL; fp->is_gzip = false; fp->path = NULL; @@ -921,7 +979,7 @@ bool hc_same_files (char *file1, char *file2) HCFILE fp; - if (hc_fopen (&fp, file1, "r", HCFILE_FORMAT_PLAIN) == true) + if (hc_fopen (&fp, file1, "r") == true) { if (fstat (hc_fileno (&fp), &tmpstat_file1)) { @@ -935,7 +993,7 @@ bool hc_same_files (char *file1, char *file2) do_check++; } - if (hc_fopen (&fp, file2, "r", HCFILE_FORMAT_PLAIN) == true) + if (hc_fopen (&fp, file2, "r") == true) { if (fstat (hc_fileno (&fp), &tmpstat_file2)) { diff --git a/src/stdout.c b/src/stdout.c index 7ce8e186e..1e4357cac 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -73,7 +73,7 @@ int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { HCFILE fp; - if (hc_fopen (&fp, filename, "ab", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, filename, "ab") == false) { event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno)); diff --git a/src/straight.c b/src/straight.c index e86f92aa8..21d1e0ee7 100644 --- a/src/straight.c +++ b/src/straight.c @@ -72,7 +72,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, straight_ctx->dict, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, straight_ctx->dict, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); @@ -107,7 +107,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; - if (hc_fopen (&fp, combinator_ctx->dict1, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, combinator_ctx->dict1, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict1, strerror (errno)); @@ -129,7 +129,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; - if (hc_fopen (&fp, combinator_ctx->dict2, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, combinator_ctx->dict2, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); @@ -175,7 +175,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, straight_ctx->dict, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, straight_ctx->dict, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno)); diff --git a/src/tuningdb.c b/src/tuningdb.c index 94354fad2..248f8d30a 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -70,7 +70,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) HCFILE fp; - if (hc_fopen (&fp, tuning_db_file, "rb", HCFILE_FORMAT_PLAIN) == false) + if (hc_fopen (&fp, tuning_db_file, "rb") == false) { event_log_error (hashcat_ctx, "%s: %s", tuning_db_file, strerror (errno));