Merge pull request #2075 from matrix/zlib_support_2

Add zlib support for loading hashlist/wordlist (v2)
This commit is contained in:
Jens Steube
2019-07-10 10:56:06 +02:00
committed by GitHub
79 changed files with 1104 additions and 750 deletions
+2 -2
View File
@@ -10,9 +10,9 @@
#include <string.h>
#include <errno.h>
u64 count_lines (FILE *fd);
u64 count_lines (HCFILE *fp);
size_t fgetl (FILE *fp, char *line_buf);
size_t fgetl (HCFILE *fp, char *line_buf);
size_t superchop_with_length (char *buf, const size_t len);
+1 -1
View File
@@ -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_user (hashcat_ctx_t *hashcat_ctx, u32 hashfile_format, char *line_buf, const int line_len, char **userbuf_pos, int *userbuf_len);
u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check);
u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, u32 max_check);
#endif // _HLFMT_H
+2 -2
View File
@@ -13,7 +13,7 @@
#include <errno.h>
#include <fcntl.h>
int lock_file (FILE *fp);
int unlock_file (FILE *fp);
int hc_lockfile (HCFILE *fp);
int hc_unlockfile (HCFILE *fp);
#endif // _LOCKING_H
+21 -2
View File
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <ctype.h>
#include <math.h>
#include "zlib.h"
#if defined (_WIN)
#include <winsock2.h> // needed for select()
@@ -61,8 +62,26 @@ bool hc_string_is_digit (const char *s);
void hc_string_trim_trailing (char *s);
void hc_string_trim_leading (char *s);
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
#if defined (__CYGWIN__)
int _wopen(const char *path, int oflag, ...);
#endif
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);
int hc_fseek (HCFILE *fp, off_t offset, int whence);
void hc_rewind (HCFILE *fp);
off_t hc_ftell (HCFILE *fp);
int hc_fgetc (HCFILE *fp);
int hc_fileno (HCFILE *fp);
int hc_feof (HCFILE *fp);
void hc_fflush (HCFILE *fp);
void hc_fclose (HCFILE *fp);
int hc_fputc (int c, HCFILE *fp);
char *hc_fgets (char *buf, int len, HCFILE *fp);
size_t hc_fwrite (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp);
bool hc_same_files (char *file1, char *file2);
+3 -3
View File
@@ -10,7 +10,7 @@ typedef struct extra_info_straight
{
u64 pos;
FILE *fp;
HCFILE fp;
u64 rule_pos_prev;
u64 rule_pos;
@@ -27,8 +27,8 @@ typedef struct extra_info_combi
{
u64 pos;
FILE *base_fp;
FILE *combs_fp;
HCFILE base_fp;
HCFILE combs_fp;
u64 comb_pos_prev;
u64 comb_pos;
+37 -20
View File
@@ -17,6 +17,7 @@
#include <sys/time.h>
#include <unistd.h>
#include <math.h>
#include "zlib.h"
#if defined (_WIN)
#define WINICONV_CONST
@@ -988,6 +989,19 @@ typedef struct link_speed
} link_speed_t;
// handling gzip files
typedef struct hc_fp
{
int fd;
FILE *pfp;
gzFile gfp;
bool is_gzip;
char *mode;
const char *path;
} HCFILE;
#include "ext_nvrtc.h"
#include "ext_cuda.h"
#include "ext_OpenCL.h"
@@ -1147,12 +1161,12 @@ typedef struct hc_device_param
u32 *brain_link_out_buf;
#endif
char *scratch_buf;
char *scratch_buf;
FILE *combs_fp;
pw_t *combs_buf;
HCFILE combs_fp;
pw_t *combs_buf;
void *hooks_buf;
void *hooks_buf;
pw_idx_t *pws_idx;
u32 *pws_comp;
@@ -1541,11 +1555,12 @@ typedef aes_context_t aes_ctx;
typedef struct debugfile_ctx
{
bool enabled;
HCFILE fp;
FILE *fp;
char *filename;
u32 mode;
bool enabled;
char *filename;
u32 mode;
} debugfile_ctx_t;
@@ -1586,11 +1601,12 @@ typedef struct dictstat_ctx
typedef struct loopback_ctx
{
bool enabled;
bool unused;
HCFILE fp;
FILE *fp;
char *filename;
bool enabled;
bool unused;
char *filename;
} loopback_ctx_t;
@@ -1603,12 +1619,12 @@ typedef struct mf
typedef struct outfile_ctx
{
char *filename;
HCFILE fp;
FILE *fp;
u32 outfile_format;
bool outfile_autohex;
u32 outfile_format;
bool outfile_autohex;
char *filename;
} outfile_ctx_t;
@@ -1623,9 +1639,10 @@ typedef struct pot
typedef struct potfile_ctx
{
HCFILE fp;
bool enabled;
FILE *fp;
char *filename;
u8 *out_buf; // allocates [HCBUFSIZ_LARGE];
@@ -1707,10 +1724,10 @@ typedef struct pidfile_ctx
typedef struct out
{
FILE *fp;
HCFILE fp;
char buf[HCBUFSIZ_SMALL];
int len;
char buf[HCBUFSIZ_SMALL];
int len;
} out_t;
+4 -3
View File
@@ -19,9 +19,10 @@ void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len);
int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 *result);
void get_next_word (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, char **out_buf, u32 *out_len);
int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp);
int count_words (hashcat_ctx_t *hashcat_ctx, HCFILE *fp, const char *dictfile, u64 *result);
int wl_data_init (hashcat_ctx_t *hashcat_ctx);
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx);