1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Prepare move potfile specific functions into their own source file

This commit is contained in:
jsteube 2016-09-09 23:17:43 +02:00
parent 75f2d39a93
commit 63b47eebc9
20 changed files with 290 additions and 206 deletions

View File

@ -178,6 +178,8 @@ typedef struct
hashconfig_t *hashconfig;
potfile_ctx_t *potfile_ctx;
#if defined (HAVE_HWMON)
uint gpu_temp_disable;
uint gpu_temp_abort;
@ -189,8 +191,6 @@ typedef struct
uint rp_gen;
uint rp_gen_seed;
FILE *pot_fp;
/**
* used for restore
*/

View File

@ -8,6 +8,21 @@
#include <stdio.h>
typedef enum hlfmt_name
{
HLFMT_HASHCAT = 0,
HLFMT_PWDUMP = 1,
HLFMT_PASSWD = 2,
HLFMT_SHADOW = 3,
HLFMT_DCC = 4,
HLFMT_DCC2 = 5,
HLFMT_NETNTLM1 = 7,
HLFMT_NETNTLM2 = 8,
HLFMT_NSLDAP = 9,
HLFMT_NSLDAPS = 10
} hlfmt_name_t;
char *strhlfmt (const uint hashfile_format);
void hlfmt_hash (uint hashfile_format, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len, hashconfig_t *hashconfig);

View File

@ -40,6 +40,103 @@ struct _hashconfig
typedef struct _hashconfig hashconfig_t;
/**
* option types
*/
typedef enum salt_type
{
SALT_TYPE_NONE = 1,
SALT_TYPE_EMBEDDED = 2,
SALT_TYPE_INTERN = 3,
SALT_TYPE_EXTERN = 4,
SALT_TYPE_VIRTUAL = 5
} salt_type_t;
typedef enum opti_type
{
OPTI_TYPE_ZERO_BYTE = (1 << 1),
OPTI_TYPE_PRECOMPUTE_INIT = (1 << 2),
OPTI_TYPE_PRECOMPUTE_MERKLE = (1 << 3),
OPTI_TYPE_PRECOMPUTE_PERMUT = (1 << 4),
OPTI_TYPE_MEET_IN_MIDDLE = (1 << 5),
OPTI_TYPE_EARLY_SKIP = (1 << 6),
OPTI_TYPE_NOT_SALTED = (1 << 7),
OPTI_TYPE_NOT_ITERATED = (1 << 8),
OPTI_TYPE_PREPENDED_SALT = (1 << 9),
OPTI_TYPE_APPENDED_SALT = (1 << 10),
OPTI_TYPE_SINGLE_HASH = (1 << 11),
OPTI_TYPE_SINGLE_SALT = (1 << 12),
OPTI_TYPE_BRUTE_FORCE = (1 << 13),
OPTI_TYPE_RAW_HASH = (1 << 14),
OPTI_TYPE_SLOW_HASH_SIMD = (1 << 15),
OPTI_TYPE_USES_BITS_8 = (1 << 16),
OPTI_TYPE_USES_BITS_16 = (1 << 17),
OPTI_TYPE_USES_BITS_32 = (1 << 18),
OPTI_TYPE_USES_BITS_64 = (1 << 19)
} opti_type_t;
typedef enum opts_type
{
OPTS_TYPE_PT_UNICODE = (1 << 0),
OPTS_TYPE_PT_UPPER = (1 << 1),
OPTS_TYPE_PT_LOWER = (1 << 2),
OPTS_TYPE_PT_ADD01 = (1 << 3),
OPTS_TYPE_PT_ADD02 = (1 << 4),
OPTS_TYPE_PT_ADD80 = (1 << 5),
OPTS_TYPE_PT_ADDBITS14 = (1 << 6),
OPTS_TYPE_PT_ADDBITS15 = (1 << 7),
OPTS_TYPE_PT_GENERATE_LE = (1 << 8),
OPTS_TYPE_PT_GENERATE_BE = (1 << 9),
OPTS_TYPE_PT_NEVERCRACK = (1 << 10), // if we want all possible results
OPTS_TYPE_PT_BITSLICE = (1 << 11),
OPTS_TYPE_ST_UNICODE = (1 << 12),
OPTS_TYPE_ST_UPPER = (1 << 13),
OPTS_TYPE_ST_LOWER = (1 << 14),
OPTS_TYPE_ST_ADD01 = (1 << 15),
OPTS_TYPE_ST_ADD02 = (1 << 16),
OPTS_TYPE_ST_ADD80 = (1 << 17),
OPTS_TYPE_ST_ADDBITS14 = (1 << 18),
OPTS_TYPE_ST_ADDBITS15 = (1 << 19),
OPTS_TYPE_ST_GENERATE_LE = (1 << 20),
OPTS_TYPE_ST_GENERATE_BE = (1 << 21),
OPTS_TYPE_ST_HEX = (1 << 22),
OPTS_TYPE_ST_BASE64 = (1 << 23),
OPTS_TYPE_HASH_COPY = (1 << 24),
OPTS_TYPE_HOOK12 = (1 << 25),
OPTS_TYPE_HOOK23 = (1 << 26)
} opts_type_t;
typedef enum dgst_size
{
DGST_SIZE_4_2 = (2 * sizeof (uint)), // 8
DGST_SIZE_4_4 = (4 * sizeof (uint)), // 16
DGST_SIZE_4_5 = (5 * sizeof (uint)), // 20
DGST_SIZE_4_6 = (6 * sizeof (uint)), // 24
DGST_SIZE_4_8 = (8 * sizeof (uint)), // 32
DGST_SIZE_4_16 = (16 * sizeof (uint)), // 64 !!!
DGST_SIZE_4_32 = (32 * sizeof (uint)), // 128 !!!
DGST_SIZE_4_64 = (64 * sizeof (uint)), // 256
DGST_SIZE_8_8 = (8 * sizeof (u64)), // 64 !!!
DGST_SIZE_8_16 = (16 * sizeof (u64)), // 128 !!!
DGST_SIZE_8_25 = (25 * sizeof (u64)) // 200
} dgst_size_t;
typedef enum attack_exec
{
ATTACK_EXEC_OUTSIDE_KERNEL = 10,
ATTACK_EXEC_INSIDE_KERNEL = 11
} attack_exec_t;
/**
* algo specific
*/
typedef struct
{
uint iv[4];

36
include/potfile.h Normal file
View File

@ -0,0 +1,36 @@
/**
* Authors.....: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#ifndef _POTFILE_H
#define _POTFILE_H
#include <stdio.h>
#include <errno.h>
typedef struct
{
char plain_buf[HCBUFSIZ_TINY];
int plain_len;
hash_t hash;
} pot_t;
typedef struct
{
FILE *fp;
char *filename;
} potfile_ctx_t;
void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path);
int potfile_read_open (potfile_ctx_t *potfile_ctx);
void potfile_read_close (potfile_ctx_t *potfile_ctx);
int potfile_write_open (potfile_ctx_t *potfile_ctx);
void potfile_write_close (potfile_ctx_t *potfile_ctx);
void potfile_destroy (potfile_ctx_t *potfile_ctx);
#endif // _POTFILE_H

View File

@ -36,20 +36,7 @@ typedef enum hl_mode
#define HLFMTS_CNT 11
typedef enum hlfmt_name
{
HLFMT_HASHCAT = 0,
HLFMT_PWDUMP = 1,
HLFMT_PASSWD = 2,
HLFMT_SHADOW = 3,
HLFMT_DCC = 4,
HLFMT_DCC2 = 5,
HLFMT_NETNTLM1 = 7,
HLFMT_NETNTLM2 = 8,
HLFMT_NSLDAP = 9,
HLFMT_NSLDAPS = 10
} hlfmt_name_t;
typedef enum attack_mode
{
@ -74,13 +61,6 @@ typedef enum attack_kern
} attack_kern_t;
typedef enum attack_exec
{
ATTACK_EXEC_OUTSIDE_KERNEL = 10,
ATTACK_EXEC_INSIDE_KERNEL = 11
} attack_exec_t;
typedef enum combinator_mode
{
COMBINATOR_MODE_BASE_LEFT = 10001,
@ -115,104 +95,6 @@ typedef enum outfile_fmt
} outfile_fmt_t;
/**
* salt types
*/
typedef enum salt_type
{
SALT_TYPE_NONE = 1,
SALT_TYPE_EMBEDDED = 2,
SALT_TYPE_INTERN = 3,
SALT_TYPE_EXTERN = 4,
SALT_TYPE_VIRTUAL = 5
} salt_type_t;
/**
* optimizer options
*/
typedef enum opti_type
{
OPTI_TYPE_ZERO_BYTE = (1 << 1),
OPTI_TYPE_PRECOMPUTE_INIT = (1 << 2),
OPTI_TYPE_PRECOMPUTE_MERKLE = (1 << 3),
OPTI_TYPE_PRECOMPUTE_PERMUT = (1 << 4),
OPTI_TYPE_MEET_IN_MIDDLE = (1 << 5),
OPTI_TYPE_EARLY_SKIP = (1 << 6),
OPTI_TYPE_NOT_SALTED = (1 << 7),
OPTI_TYPE_NOT_ITERATED = (1 << 8),
OPTI_TYPE_PREPENDED_SALT = (1 << 9),
OPTI_TYPE_APPENDED_SALT = (1 << 10),
OPTI_TYPE_SINGLE_HASH = (1 << 11),
OPTI_TYPE_SINGLE_SALT = (1 << 12),
OPTI_TYPE_BRUTE_FORCE = (1 << 13),
OPTI_TYPE_RAW_HASH = (1 << 14),
OPTI_TYPE_SLOW_HASH_SIMD = (1 << 15),
OPTI_TYPE_USES_BITS_8 = (1 << 16),
OPTI_TYPE_USES_BITS_16 = (1 << 17),
OPTI_TYPE_USES_BITS_32 = (1 << 18),
OPTI_TYPE_USES_BITS_64 = (1 << 19)
} opti_type_t;
/**
* hash options
*/
typedef enum opts_type
{
OPTS_TYPE_PT_UNICODE = (1 << 0),
OPTS_TYPE_PT_UPPER = (1 << 1),
OPTS_TYPE_PT_LOWER = (1 << 2),
OPTS_TYPE_PT_ADD01 = (1 << 3),
OPTS_TYPE_PT_ADD02 = (1 << 4),
OPTS_TYPE_PT_ADD80 = (1 << 5),
OPTS_TYPE_PT_ADDBITS14 = (1 << 6),
OPTS_TYPE_PT_ADDBITS15 = (1 << 7),
OPTS_TYPE_PT_GENERATE_LE = (1 << 8),
OPTS_TYPE_PT_GENERATE_BE = (1 << 9),
OPTS_TYPE_PT_NEVERCRACK = (1 << 10), // if we want all possible results
OPTS_TYPE_PT_BITSLICE = (1 << 11),
OPTS_TYPE_ST_UNICODE = (1 << 12),
OPTS_TYPE_ST_UPPER = (1 << 13),
OPTS_TYPE_ST_LOWER = (1 << 14),
OPTS_TYPE_ST_ADD01 = (1 << 15),
OPTS_TYPE_ST_ADD02 = (1 << 16),
OPTS_TYPE_ST_ADD80 = (1 << 17),
OPTS_TYPE_ST_ADDBITS14 = (1 << 18),
OPTS_TYPE_ST_ADDBITS15 = (1 << 19),
OPTS_TYPE_ST_GENERATE_LE = (1 << 20),
OPTS_TYPE_ST_GENERATE_BE = (1 << 21),
OPTS_TYPE_ST_HEX = (1 << 22),
OPTS_TYPE_ST_BASE64 = (1 << 23),
OPTS_TYPE_HASH_COPY = (1 << 24),
OPTS_TYPE_HOOK12 = (1 << 25),
OPTS_TYPE_HOOK23 = (1 << 26)
} opts_type_t;
/**
* digests
*/
typedef enum dgst_size
{
DGST_SIZE_4_2 = (2 * sizeof (uint)), // 8
DGST_SIZE_4_4 = (4 * sizeof (uint)), // 16
DGST_SIZE_4_5 = (5 * sizeof (uint)), // 20
DGST_SIZE_4_6 = (6 * sizeof (uint)), // 24
DGST_SIZE_4_8 = (8 * sizeof (uint)), // 32
DGST_SIZE_4_16 = (16 * sizeof (uint)), // 64 !!!
DGST_SIZE_4_32 = (32 * sizeof (uint)), // 128 !!!
DGST_SIZE_4_64 = (64 * sizeof (uint)), // 256
DGST_SIZE_8_8 = (8 * sizeof (u64)), // 64 !!!
DGST_SIZE_8_16 = (16 * sizeof (u64)), // 128 !!!
DGST_SIZE_8_25 = (25 * sizeof (u64)) // 200
} dgst_size_t;
/**
* status
*/
@ -266,14 +148,7 @@ typedef struct
} hash_t;
typedef struct
{
char plain_buf[256];
int plain_len;
hash_t hash;
} pot_t;

View File

@ -166,7 +166,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
NATIVE_OBJS := obj/dictstat.NATIVE.o obj/wordlist.NATIVE.o obj/stdout.NATIVE.o obj/filenames.NATIVE.o obj/hlfmt.NATIVE.o obj/status.NATIVE.o obj/restore.NATIVE.o obj/bitmap.NATIVE.o obj/opencl.NATIVE.o obj/affinity.NATIVE.o obj/filehandling.NATIVE.o obj/tuningdb.NATIVE.o obj/locking.NATIVE.o obj/folder.NATIVE.o obj/bitops.NATIVE.o obj/convert.NATIVE.o obj/cpu_aes.NATIVE.o obj/cpu_crc32.NATIVE.o obj/cpu_des.NATIVE.o obj/cpu_md5.NATIVE.o obj/cpu_sha1.NATIVE.o obj/cpu_sha256.NATIVE.o obj/data.NATIVE.o obj/ext_OpenCL.NATIVE.o obj/hwmon.NATIVE.o obj/interface.NATIVE.o obj/logfile.NATIVE.o obj/logging.NATIVE.o obj/memory.NATIVE.o obj/mpsp.NATIVE.o obj/rp_cpu.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o obj/shared.NATIVE.o obj/terminal.NATIVE.o obj/usage.NATIVE.o
NATIVE_OBJS := obj/potfile.NATIVE.o obj/dictstat.NATIVE.o obj/wordlist.NATIVE.o obj/stdout.NATIVE.o obj/filenames.NATIVE.o obj/hlfmt.NATIVE.o obj/status.NATIVE.o obj/restore.NATIVE.o obj/bitmap.NATIVE.o obj/opencl.NATIVE.o obj/affinity.NATIVE.o obj/filehandling.NATIVE.o obj/tuningdb.NATIVE.o obj/locking.NATIVE.o obj/folder.NATIVE.o obj/bitops.NATIVE.o obj/convert.NATIVE.o obj/cpu_aes.NATIVE.o obj/cpu_crc32.NATIVE.o obj/cpu_des.NATIVE.o obj/cpu_md5.NATIVE.o obj/cpu_sha1.NATIVE.o obj/cpu_sha256.NATIVE.o obj/data.NATIVE.o obj/ext_OpenCL.NATIVE.o obj/hwmon.NATIVE.o obj/interface.NATIVE.o obj/logfile.NATIVE.o obj/logging.NATIVE.o obj/memory.NATIVE.o obj/mpsp.NATIVE.o obj/rp_cpu.NATIVE.o obj/rp_kernel_on_cpu.NATIVE.o obj/shared.NATIVE.o obj/terminal.NATIVE.o obj/usage.NATIVE.o
ifeq ($(UNAME),Linux)
NATIVE_OBJS += obj/ext_ADL.NATIVE.o
@ -175,8 +175,8 @@ NATIVE_OBJS += obj/ext_nvml.NATIVE.o
NATIVE_OBJS += obj/ext_xnvctrl.NATIVE.o
endif
LINUX_32_OBJS := obj/dictstat.LINUX.32.o obj/wordlist.LINUX.32.o obj/stdout.LINUX.32.o obj/filenames.LINUX.32.o obj/hlfmt.LINUX.32.o obj/status.LINUX.32.o obj/restore.LINUX.32.o obj/bitmap.LINUX.32.o obj/opencl.LINUX.32.o obj/affinity.LINUX.32.o obj/filehandling.LINUX.32.o obj/tuningdb.LINUX.32.o obj/locking.LINUX.32.o obj/folder.LINUX.32.o obj/bitops.LINUX.32.o obj/convert.LINUX.32.o obj/cpu_aes.LINUX.32.o obj/cpu_crc32.LINUX.32.o obj/cpu_des.LINUX.32.o obj/cpu_md5.LINUX.32.o obj/cpu_sha1.LINUX.32.o obj/cpu_sha256.LINUX.32.o obj/data.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_OpenCL.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o obj/hwmon.LINUX.32.o obj/interface.LINUX.32.o obj/logfile.LINUX.32.o obj/logging.LINUX.32.o obj/memory.LINUX.32.o obj/mpsp.LINUX.32.o obj/rp_cpu.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/shared.LINUX.32.o obj/terminal.LINUX.32.o obj/usage.LINUX.32.o
LINUX_64_OBJS := obj/dictstat.LINUX.64.o obj/wordlist.LINUX.64.o obj/stdout.LINUX.64.o obj/filenames.LINUX.64.o obj/hlfmt.LINUX.64.o obj/status.LINUX.64.o obj/restore.LINUX.64.o obj/bitmap.LINUX.64.o obj/opencl.LINUX.64.o obj/affinity.LINUX.64.o obj/filehandling.LINUX.64.o obj/tuningdb.LINUX.64.o obj/locking.LINUX.64.o obj/folder.LINUX.64.o obj/bitops.LINUX.64.o obj/convert.LINUX.64.o obj/cpu_aes.LINUX.64.o obj/cpu_crc32.LINUX.64.o obj/cpu_des.LINUX.64.o obj/cpu_md5.LINUX.64.o obj/cpu_sha1.LINUX.64.o obj/cpu_sha256.LINUX.64.o obj/data.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_OpenCL.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o obj/hwmon.LINUX.64.o obj/interface.LINUX.64.o obj/logfile.LINUX.64.o obj/logging.LINUX.64.o obj/memory.LINUX.64.o obj/mpsp.LINUX.64.o obj/rp_cpu.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/shared.LINUX.64.o obj/terminal.LINUX.64.o obj/usage.LINUX.64.o
LINUX_32_OBJS := obj/potfile.LINUX.32.o obj/dictstat.LINUX.32.o obj/wordlist.LINUX.32.o obj/stdout.LINUX.32.o obj/filenames.LINUX.32.o obj/hlfmt.LINUX.32.o obj/status.LINUX.32.o obj/restore.LINUX.32.o obj/bitmap.LINUX.32.o obj/opencl.LINUX.32.o obj/affinity.LINUX.32.o obj/filehandling.LINUX.32.o obj/tuningdb.LINUX.32.o obj/locking.LINUX.32.o obj/folder.LINUX.32.o obj/bitops.LINUX.32.o obj/convert.LINUX.32.o obj/cpu_aes.LINUX.32.o obj/cpu_crc32.LINUX.32.o obj/cpu_des.LINUX.32.o obj/cpu_md5.LINUX.32.o obj/cpu_sha1.LINUX.32.o obj/cpu_sha256.LINUX.32.o obj/data.LINUX.32.o obj/ext_ADL.LINUX.32.o obj/ext_nvapi.LINUX.32.o obj/ext_nvml.LINUX.32.o obj/ext_OpenCL.LINUX.32.o obj/ext_xnvctrl.LINUX.32.o obj/hwmon.LINUX.32.o obj/interface.LINUX.32.o obj/logfile.LINUX.32.o obj/logging.LINUX.32.o obj/memory.LINUX.32.o obj/mpsp.LINUX.32.o obj/rp_cpu.LINUX.32.o obj/rp_kernel_on_cpu.LINUX.32.o obj/shared.LINUX.32.o obj/terminal.LINUX.32.o obj/usage.LINUX.32.o
LINUX_64_OBJS := obj/potfile.LINUX.64.o obj/dictstat.LINUX.64.o obj/wordlist.LINUX.64.o obj/stdout.LINUX.64.o obj/filenames.LINUX.64.o obj/hlfmt.LINUX.64.o obj/status.LINUX.64.o obj/restore.LINUX.64.o obj/bitmap.LINUX.64.o obj/opencl.LINUX.64.o obj/affinity.LINUX.64.o obj/filehandling.LINUX.64.o obj/tuningdb.LINUX.64.o obj/locking.LINUX.64.o obj/folder.LINUX.64.o obj/bitops.LINUX.64.o obj/convert.LINUX.64.o obj/cpu_aes.LINUX.64.o obj/cpu_crc32.LINUX.64.o obj/cpu_des.LINUX.64.o obj/cpu_md5.LINUX.64.o obj/cpu_sha1.LINUX.64.o obj/cpu_sha256.LINUX.64.o obj/data.LINUX.64.o obj/ext_ADL.LINUX.64.o obj/ext_nvapi.LINUX.64.o obj/ext_nvml.LINUX.64.o obj/ext_OpenCL.LINUX.64.o obj/ext_xnvctrl.LINUX.64.o obj/hwmon.LINUX.64.o obj/interface.LINUX.64.o obj/logfile.LINUX.64.o obj/logging.LINUX.64.o obj/memory.LINUX.64.o obj/mpsp.LINUX.64.o obj/rp_cpu.LINUX.64.o obj/rp_kernel_on_cpu.LINUX.64.o obj/shared.LINUX.64.o obj/terminal.LINUX.64.o obj/usage.LINUX.64.o
# Windows CRT file globbing:
@ -186,8 +186,8 @@ CRT_GLOB_INCLUDE_FOLDER := $(dir $(lastword $(MAKEFILE_LIST)))
include $(CRT_GLOB_INCLUDE_FOLDER)/win_file_globbing.mk
WIN_32_OBJS := obj/dictstat.WIN.32.o obj/wordlist.WIN.32.o obj/stdout.WIN.32.o obj/filenames.WIN.32.o obj/hlfmt.WIN.32.o obj/status.WIN.32.o obj/restore.WIN.32.o obj/bitmap.WIN.32.o obj/opencl.WIN.32.o obj/affinity.WIN.32.o obj/filehandling.WIN.32.o obj/tuningdb.WIN.32.o obj/locking.WIN.32.o obj/folder.WIN.32.o obj/bitops.WIN.32.o obj/convert.WIN.32.o obj/cpu_aes.WIN.32.o obj/cpu_crc32.WIN.32.o obj/cpu_des.WIN.32.o obj/cpu_md5.WIN.32.o obj/cpu_sha1.WIN.32.o obj/cpu_sha256.WIN.32.o obj/data.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_OpenCL.WIN.32.o obj/ext_xnvctrl.WIN.32.o obj/hwmon.WIN.32.o obj/interface.WIN.32.o obj/logfile.WIN.32.o obj/logging.WIN.32.o obj/memory.WIN.32.o obj/mpsp.WIN.32.o obj/rp_cpu.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/shared.WIN.32.o obj/terminal.WIN.32.o obj/usage.WIN.32.o $(CRT_GLOB_32)
WIN_64_OBJS := obj/dictstat.WIN.64.o obj/wordlist.WIN.64.o obj/stdout.WIN.64.o obj/filenames.WIN.64.o obj/hlfmt.WIN.64.o obj/status.WIN.64.o obj/restore.WIN.64.o obj/bitmap.WIN.64.o obj/opencl.WIN.64.o obj/affinity.WIN.64.o obj/filehandling.WIN.64.o obj/tuningdb.WIN.64.o obj/locking.WIN.64.o obj/folder.WIN.64.o obj/bitops.WIN.64.o obj/convert.WIN.64.o obj/cpu_aes.WIN.64.o obj/cpu_crc32.WIN.64.o obj/cpu_des.WIN.64.o obj/cpu_md5.WIN.64.o obj/cpu_sha1.WIN.64.o obj/cpu_sha256.WIN.64.o obj/data.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_OpenCL.WIN.64.o obj/ext_xnvctrl.WIN.64.o obj/hwmon.WIN.64.o obj/interface.WIN.64.o obj/logfile.WIN.64.o obj/logging.WIN.64.o obj/memory.WIN.64.o obj/mpsp.WIN.64.o obj/rp_cpu.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/shared.WIN.64.o obj/terminal.WIN.64.o obj/usage.WIN.64.o $(CRT_GLOB_64)
WIN_32_OBJS := obj/potfile.WIN.32.o obj/dictstat.WIN.32.o obj/wordlist.WIN.32.o obj/stdout.WIN.32.o obj/filenames.WIN.32.o obj/hlfmt.WIN.32.o obj/status.WIN.32.o obj/restore.WIN.32.o obj/bitmap.WIN.32.o obj/opencl.WIN.32.o obj/affinity.WIN.32.o obj/filehandling.WIN.32.o obj/tuningdb.WIN.32.o obj/locking.WIN.32.o obj/folder.WIN.32.o obj/bitops.WIN.32.o obj/convert.WIN.32.o obj/cpu_aes.WIN.32.o obj/cpu_crc32.WIN.32.o obj/cpu_des.WIN.32.o obj/cpu_md5.WIN.32.o obj/cpu_sha1.WIN.32.o obj/cpu_sha256.WIN.32.o obj/data.WIN.32.o obj/ext_ADL.WIN.32.o obj/ext_nvapi.WIN.32.o obj/ext_nvml.WIN.32.o obj/ext_OpenCL.WIN.32.o obj/ext_xnvctrl.WIN.32.o obj/hwmon.WIN.32.o obj/interface.WIN.32.o obj/logfile.WIN.32.o obj/logging.WIN.32.o obj/memory.WIN.32.o obj/mpsp.WIN.32.o obj/rp_cpu.WIN.32.o obj/rp_kernel_on_cpu.WIN.32.o obj/shared.WIN.32.o obj/terminal.WIN.32.o obj/usage.WIN.32.o $(CRT_GLOB_32)
WIN_64_OBJS := obj/potfile.WIN.64.o obj/dictstat.WIN.64.o obj/wordlist.WIN.64.o obj/stdout.WIN.64.o obj/filenames.WIN.64.o obj/hlfmt.WIN.64.o obj/status.WIN.64.o obj/restore.WIN.64.o obj/bitmap.WIN.64.o obj/opencl.WIN.64.o obj/affinity.WIN.64.o obj/filehandling.WIN.64.o obj/tuningdb.WIN.64.o obj/locking.WIN.64.o obj/folder.WIN.64.o obj/bitops.WIN.64.o obj/convert.WIN.64.o obj/cpu_aes.WIN.64.o obj/cpu_crc32.WIN.64.o obj/cpu_des.WIN.64.o obj/cpu_md5.WIN.64.o obj/cpu_sha1.WIN.64.o obj/cpu_sha256.WIN.64.o obj/data.WIN.64.o obj/ext_ADL.WIN.64.o obj/ext_nvapi.WIN.64.o obj/ext_nvml.WIN.64.o obj/ext_OpenCL.WIN.64.o obj/ext_xnvctrl.WIN.64.o obj/hwmon.WIN.64.o obj/interface.WIN.64.o obj/logfile.WIN.64.o obj/logging.WIN.64.o obj/memory.WIN.64.o obj/mpsp.WIN.64.o obj/rp_cpu.WIN.64.o obj/rp_kernel_on_cpu.WIN.64.o obj/shared.WIN.64.o obj/terminal.WIN.64.o obj/usage.WIN.64.o $(CRT_GLOB_64)
##
## Targets: Global

View File

@ -18,6 +18,7 @@
#include "rp_cpu.h"
#include "restore.h"
#include "opencl.h"
#include "potfile.h"
#include "data.h"
hc_global_data_t data;

View File

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "filenames.h"
void generate_dictstat_filename (char *profile_dir, char *dictstat_filename)

View File

@ -60,6 +60,7 @@
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "affinity.h"
#include "bitmap.h"
@ -186,8 +187,6 @@ static const char OPTI_STR_USES_BITS_64[] = "Uses-64-Bit";
#define LOOPBACK_FILE "hashcat.loopback"
#define POTFILE_FILENAME "hashcat.pot"
#define MAX_CUT_TRIES 4
@ -1177,7 +1176,6 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
char *outfile = data.outfile;
uint quiet = data.quiet;
FILE *pot_fp = data.pot_fp;
uint loopback = data.loopback;
uint debug_mode = data.debug_mode;
char *debug_file = data.debug_file;
@ -1411,19 +1409,21 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
// if enabled, update also the potfile
if (pot_fp)
potfile_ctx_t *potfile_ctx = data.potfile_ctx;
if (potfile_ctx->fp)
{
lock_file (pot_fp);
//lock_file (potfile_ctx->fp);
fprintf (pot_fp, "%s:", out_buf);
fprintf (potfile_ctx->fp, "%s:", out_buf);
format_plain (pot_fp, plain_ptr, plain_len, 1);
format_plain (potfile_ctx->fp, plain_ptr, plain_len, 1);
fputc ('\n', pot_fp);
fputc ('\n', potfile_ctx->fp);
fflush (pot_fp);
fflush (potfile_ctx->fp);
unlock_file (pot_fp);
//unlock_file (potfile_ctx->fp);
}
// outfile
@ -6422,54 +6422,29 @@ int main (int argc, char **argv)
* dictstat
*/
dictstat_ctx_t dictstat_ctx;
dictstat_ctx_t *dictstat_ctx = mymalloc (sizeof (dictstat_ctx_t));
dictstat_init (&dictstat_ctx, profile_dir);
dictstat_init (dictstat_ctx, profile_dir);
if (keyspace == 0)
{
dictstat_read (&dictstat_ctx);
dictstat_read (dictstat_ctx);
}
/**
* potfile
* outfile
*/
char potfile[256] = { 0 };
if (potfile_path == NULL)
{
snprintf (potfile, sizeof (potfile) - 1, "%s/%s", profile_dir, POTFILE_FILENAME);
}
else
{
strncpy (potfile, potfile_path, sizeof (potfile) - 1);
}
data.pot_fp = NULL;
FILE *out_fp = NULL;
FILE *pot_fp = NULL;
if (show == 1 || left == 1)
{
pot_fp = fopen (potfile, "rb");
if (pot_fp == NULL)
{
log_error ("ERROR: %s: %s", potfile, strerror (errno));
return -1;
}
if (outfile != NULL)
{
if ((out_fp = fopen (outfile, "ab")) == NULL)
{
log_error ("ERROR: %s: %s", outfile, strerror (errno));
fclose (pot_fp);
return -1;
}
}
@ -6478,22 +6453,16 @@ int main (int argc, char **argv)
out_fp = stdout;
}
}
else
{
if (potfile_disable == 0)
{
pot_fp = fopen (potfile, "ab");
if (pot_fp == NULL)
{
log_error ("ERROR: %s: %s", potfile, strerror (errno));
/**
* potfile
*/
return -1;
}
potfile_ctx_t *potfile_ctx = mymalloc (sizeof (potfile_ctx_t));
data.pot_fp = pot_fp;
}
}
data.potfile_ctx = potfile_ctx;
potfile_init (potfile_ctx, profile_dir, potfile_path);
pot_t *pot = NULL;
@ -6504,9 +6473,13 @@ int main (int argc, char **argv)
{
SUPPRESS_OUTPUT = 1;
pot_avail = count_lines (pot_fp);
int rc = potfile_read_open (potfile_ctx);
rewind (pot_fp);
if (rc == -1) return -1;
pot_avail = count_lines (potfile_ctx->fp);
rewind (potfile_ctx->fp);
pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
@ -6516,11 +6489,11 @@ int main (int argc, char **argv)
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
while (!feof (pot_fp))
while (!feof (potfile_ctx->fp))
{
line_num++;
int line_len = fgetl (pot_fp, line_buf);
int line_len = fgetl (potfile_ctx->fp, line_buf);
if (line_len == 0) continue;
@ -6629,9 +6602,9 @@ int main (int argc, char **argv)
pot_cnt++;
}
myfree (line_buf);
potfile_read_close (potfile_ctx);
fclose (pot_fp);
myfree (line_buf);
SUPPRESS_OUTPUT = 0;
@ -7926,9 +7899,9 @@ int main (int argc, char **argv)
!((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) &&
(hashconfig->hash_mode != 9000))
{
FILE *fp = fopen (potfile, "rb");
potfile_read_open (potfile_ctx);
if (fp != NULL)
if (potfile_ctx->fp != NULL)
{
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -7938,9 +7911,9 @@ int main (int argc, char **argv)
char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ_LARGE);
while (!feof (fp))
while (!feof (potfile_ctx->fp))
{
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, fp);
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, potfile_ctx->fp);
if (ptr == NULL) break;
@ -8074,7 +8047,7 @@ int main (int argc, char **argv)
myfree (line_buf);
fclose (fp);
potfile_read_close (potfile_ctx);
}
}
@ -12471,7 +12444,7 @@ int main (int argc, char **argv)
data.quiet = 1;
const u64 words1_cnt = count_words (wl_data, fp1, dictfile1, &dictstat_ctx);
const u64 words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_ctx);
data.quiet = quiet;
@ -12489,7 +12462,7 @@ int main (int argc, char **argv)
data.quiet = 1;
const u64 words2_cnt = count_words (wl_data, fp2, dictfile2, &dictstat_ctx);
const u64 words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_ctx);
data.quiet = quiet;
@ -13155,6 +13128,8 @@ int main (int argc, char **argv)
data.outfile_check_timer = outfile_check_timer;
potfile_write_open (potfile_ctx);
/**
* main loop
*/
@ -13585,7 +13560,7 @@ int main (int argc, char **argv)
return -1;
}
data.words_cnt = count_words (wl_data, fd2, dictfile, &dictstat_ctx);
data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -13616,7 +13591,7 @@ int main (int argc, char **argv)
return -1;
}
data.words_cnt = count_words (wl_data, fd2, dictfile, &dictstat_ctx);
data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_ctx);
fclose (fd2);
}
@ -13631,7 +13606,7 @@ int main (int argc, char **argv)
return -1;
}
data.words_cnt = count_words (wl_data, fd2, dictfile2, &dictstat_ctx);
data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_ctx);
fclose (fd2);
}
@ -13672,7 +13647,7 @@ int main (int argc, char **argv)
return -1;
}
data.words_cnt = count_words (wl_data, fd2, dictfile, &dictstat_ctx);
data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -14017,7 +13992,7 @@ int main (int argc, char **argv)
if (keyspace == 0)
{
dictstat_write (&dictstat_ctx);
dictstat_write (dictstat_ctx);
}
/**
@ -14594,8 +14569,6 @@ int main (int argc, char **argv)
// free memory
dictstat_destroy (&dictstat_ctx);
local_free (masks);
for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
@ -14614,6 +14587,12 @@ int main (int argc, char **argv)
local_free (pot);
potfile_write_close (potfile_ctx);
potfile_destroy (potfile_ctx);
dictstat_destroy (dictstat_ctx);
local_free (all_kernel_rules_cnt);
local_free (all_kernel_rules_buf);
@ -14655,8 +14634,6 @@ int main (int argc, char **argv)
global_free (words_progress_rejected);
global_free (words_progress_restored);
if (pot_fp) fclose (pot_fp);
if (data.devices_status == STATUS_QUIT) break;
}

View File

@ -28,6 +28,7 @@
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "hlfmt.h"

View File

@ -23,6 +23,7 @@
#include "restore.h"
#include "opencl.h"
#include "thread.h"
#include "potfile.h"
#include "data.h"
hc_thread_mutex_t mux_hwmon;

View File

@ -26,6 +26,7 @@
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "logfile.h"

View File

@ -29,6 +29,7 @@
#include "rp_cpu.h"
#include "opencl.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
//#include "shared.h"

View File

@ -24,6 +24,7 @@
#include "interface.h"
#include "mpsp.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
extern hc_global_data_t data;

72
src/potfile.c Normal file
View File

@ -0,0 +1,72 @@
/**
* Authors.....: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "potfile.h"
void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path)
{
potfile_ctx->fp = NULL;
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
if (potfile_path == NULL)
{
snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", profile_dir);
}
else
{
strncpy (potfile_ctx->filename, potfile_path, HCBUFSIZ_TINY - 1);
}
}
int potfile_read_open (potfile_ctx_t *potfile_ctx)
{
potfile_ctx->fp = fopen (potfile_ctx->filename, "rb");
if (potfile_ctx->fp == NULL)
{
//log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno));
return -1;
}
return 0;
}
void potfile_read_close (potfile_ctx_t *potfile_ctx)
{
fclose (potfile_ctx->fp);
}
int potfile_write_open (potfile_ctx_t *potfile_ctx)
{
potfile_ctx->fp = fopen (potfile_ctx->filename, "ab");
if (potfile_ctx->fp == NULL)
{
log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno));
return -1;
}
return 0;
}
void potfile_write_close (potfile_ctx_t *potfile_ctx)
{
fclose (potfile_ctx->fp);
}
void potfile_destroy (potfile_ctx_t *potfile_ctx)
{
myfree (potfile_ctx->filename);
}

View File

@ -21,6 +21,7 @@
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
extern hc_global_data_t data;

View File

@ -28,6 +28,7 @@
#include "rp_cpu.h"
#include "opencl.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "shared.h"
#include "rp_cpu.h"

View File

@ -23,6 +23,7 @@
#include "opencl.h"
#include "restore.h"
#include "interface.h"
#include "potfile.h"
#include "data.h"
//#include "shared.h"
#include "status.h"

View File

@ -27,6 +27,7 @@
#include "interface.h"
#include "mpsp.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "stdout.h"

View File

@ -26,6 +26,7 @@
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "potfile.h"
#include "data.h"
#include "wordlist.h"