1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-23 07:08:19 +00:00

Move outfile specific functions into their own source file

This commit is contained in:
jsteube 2016-09-10 17:35:58 +02:00
parent a61d1faaad
commit b7906f6b93
21 changed files with 440 additions and 252 deletions

View File

@ -43,7 +43,6 @@
#define MAX_CUT_TRIES 4
#define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
#if defined (__APPLE__)

View File

@ -135,9 +135,7 @@ typedef struct
char *profile_dir;
char *session_dir;
char *shared_dir;
char *outfile;
uint outfile_format;
uint outfile_autohex;
uint outfile_check_timer;
char *eff_restore_file;
char *new_restore_file;
@ -178,6 +176,8 @@ typedef struct
hashconfig_t *hashconfig;
outfile_ctx_t *outfile_ctx;
potfile_ctx_t *potfile_ctx;
#if defined (HAVE_HWMON)

View File

@ -8,6 +8,8 @@
#include <stdio.h>
#define HLFMTS_CNT 11
typedef enum hlfmt_name
{
HLFMT_HASHCAT = 0,

43
include/outfile.h Normal file
View File

@ -0,0 +1,43 @@
/**
* Authors.....: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#ifndef _OUTFILE_H
#define _OUTFILE_H
#include <stdio.h>
#include <time.h>
#include <inttypes.h>
#define OUTFILE_FORMAT 3
#define OUTFILE_AUTOHEX 1
typedef enum outfile_fmt
{
OUTFILE_FMT_HASH = (1 << 0),
OUTFILE_FMT_PLAIN = (1 << 1),
OUTFILE_FMT_HEXPLAIN = (1 << 2),
OUTFILE_FMT_CRACKPOS = (1 << 3)
} outfile_fmt_t;
typedef struct
{
char *filename;
FILE *fp;
uint outfile_format;
uint outfile_autohex;
} outfile_ctx_t;
void outfile_init (outfile_ctx_t *outfile_ctx, char *outfile, const uint outfile_format, const uint outfile_autohex);
void outfile_destroy (outfile_ctx_t *outfile_ctx);
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const uint plain_len);
void outfile_write_open (outfile_ctx_t *outfile_ctx);
void outfile_write_close (outfile_ctx_t *outfile_ctx);
void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, const unsigned char *username, const uint user_len, const hashconfig_t *hashconfig);
#endif // _OUTFILE_H

View File

@ -42,6 +42,7 @@ int sort_by_hash_t_salt (const void *v1, const void *v2);
int sort_by_hash_t_salt_hccap (const void *v1, const void *v2);
void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path);
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len);
int potfile_read_open (potfile_ctx_t *potfile_ctx);
void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig);
void potfile_read_close (potfile_ctx_t *potfile_ctx);
@ -50,10 +51,10 @@ void potfile_write_close (potfile_ctx_t *potfile_ctx);
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const uint num);
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig);
void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *));
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *));
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *));
void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *));
int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hash_t *hashes_buf, const uint hashes_cnt);
void potfile_destroy (potfile_ctx_t *potfile_ctx);

View File

@ -13,11 +13,7 @@
#include <sys/stat.h>
#include <string.h>
/**
* Outfile formats
*/
#define OUTFILES_DIR "outfiles"
typedef enum wl_mode
{
@ -34,8 +30,14 @@ typedef enum hl_mode
} hl_mode_t;
#define HLFMTS_CNT 11
typedef struct
{
char *file_name;
long seek;
time_t ctime;
} outfile_data_t;
typedef enum attack_mode
@ -86,14 +88,7 @@ typedef enum kern_run_mp
} kern_run_mp_t;
typedef enum outfile_fmt
{
OUTFILE_FMT_HASH = (1 << 0),
OUTFILE_FMT_PLAIN = (1 << 1),
OUTFILE_FMT_HEXPLAIN = (1 << 2),
OUTFILE_FMT_CRACKPOS = (1 << 3)
} outfile_fmt_t;
/**
* status
@ -186,13 +181,7 @@ typedef struct
typedef struct
{
char *file_name;
long seek;
time_t ctime;
} outfile_data_t;
@ -205,15 +194,6 @@ typedef struct
} cpt_t;
/*
typedef struct
{
uint plain_buf[16];
uint plain_len;
} plain_t;
*/
typedef struct
{
uint salt_pos;

View File

@ -166,7 +166,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
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
NATIVE_OBJS := obj/outfile.NATIVE.o 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/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
LINUX_32_OBJS := obj/outfile.LINUX.32.o 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/outfile.LINUX.64.o 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/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)
WIN_32_OBJS := obj/outfile.WIN.32.o 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/outfile.WIN.64.o 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 "outfile.h"
#include "potfile.h"
#include "data.h"

View File

@ -60,6 +60,7 @@
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "data.h"
#include "affinity.h"
@ -99,6 +100,7 @@ const int comptime = COMPTIME;
#define MARKOV_CLASSIC 0
#define BENCHMARK 0
#define OUTFILE_CHECK_TIMER 5
#define MACHINE_READABLE 0
#define LOOPBACK 0
#define WEAK_HASH_THRESHOLD 100
@ -122,9 +124,6 @@ const int comptime = COMPTIME;
#define HEX_CHARSET 0
#define HEX_SALT 0
#define HEX_WORDLIST 0
#define OUTFILE_FORMAT 3
#define OUTFILE_AUTOHEX 1
#define OUTFILE_CHECK_TIMER 5
#define ATTACK_MODE 0
#define HASH_MODE 0
#define SEGMENT_SIZE 32
@ -181,7 +180,7 @@ static const char OPTI_STR_USES_BITS_64[] = "Uses-64-Bit";
#define INDUCT_DIR "induct"
#define OUTFILES_DIR "outfiles"
#define LOOPBACK_FILE "hashcat.loopback"
@ -488,160 +487,135 @@ int sort_by_stringptr (const void *p1, const void *p2)
return strcmp (*s1, *s2);
}
typedef struct
{
FILE *fp;
} loopback_ctx_t;
void format_plain (FILE *fp, unsigned char *plain_ptr, uint plain_len, uint outfile_autohex)
void loopback_format_plain (loopback_ctx_t *loopback_ctx, const unsigned char *plain_ptr, const uint plain_len)
{
int needs_hexify = 0;
if (outfile_autohex == 1)
for (uint i = 0; i < plain_len; i++)
{
for (uint i = 0; i < plain_len; i++)
if (plain_ptr[i] < 0x20)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = 1;
needs_hexify = 1;
break;
}
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = 1;
if (plain_ptr[i] > 0x7f)
{
needs_hexify = 1;
break;
}
break;
}
}
if (needs_hexify == 1)
{
fprintf (fp, "$HEX[");
fprintf (loopback_ctx->fp, "$HEX[");
for (uint i = 0; i < plain_len; i++)
{
fprintf (fp, "%02x", plain_ptr[i]);
fprintf (loopback_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (fp, "]");
fprintf (loopback_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, fp);
fwrite (plain_ptr, plain_len, 1, loopback_ctx->fp);
}
}
typedef struct
{
FILE *fp;
} debug_ctx_t;
void debug_format_plain (debug_ctx_t *debug_ctx, const unsigned char *plain_ptr, const uint plain_len)
{
int needs_hexify = 0;
for (uint i = 0; i < plain_len; i++)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = 1;
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = 1;
break;
}
}
if (needs_hexify == 1)
{
fprintf (debug_ctx->fp, "$HEX[");
for (uint i = 0; i < plain_len; i++)
{
fprintf (debug_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (debug_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, debug_ctx->fp);
}
}
void format_debug (char *debug_file, uint debug_mode, unsigned char *orig_plain_ptr, uint orig_plain_len, unsigned char *mod_plain_ptr, uint mod_plain_len, char *rule_buf, int rule_len)
{
uint outfile_autohex = data.outfile_autohex;
unsigned char *rule_ptr = (unsigned char *) rule_buf;
FILE *debug_fp = NULL;
debug_ctx_t debug_ctx;
if (debug_file != NULL)
{
debug_fp = fopen (debug_file, "ab");
debug_ctx.fp = fopen (debug_file, "ab");
lock_file (debug_fp);
}
else
if (debug_ctx.fp == NULL)
{
debug_fp = stderr;
log_error ("ERROR: Could not open debug-file for writing");
return;
}
if (debug_fp == NULL)
if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
{
log_info ("WARNING: Could not open debug-file for writing");
debug_format_plain (&debug_ctx, orig_plain_ptr, orig_plain_len);
if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debug_ctx.fp);
}
else
fwrite (rule_ptr, rule_len, 1, debug_ctx.fp);
if (debug_mode == 4)
{
if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
{
format_plain (debug_fp, orig_plain_ptr, orig_plain_len, outfile_autohex);
fputc (':', debug_ctx.fp);
if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debug_fp);
}
fwrite (rule_ptr, rule_len, 1, debug_fp);
if (debug_mode == 4)
{
fputc (':', debug_fp);
format_plain (debug_fp, mod_plain_ptr, mod_plain_len, outfile_autohex);
}
fputc ('\n', debug_fp);
if (debug_file != NULL) fclose (debug_fp);
debug_format_plain (&debug_ctx, mod_plain_ptr, mod_plain_len);
}
fputc ('\n', debug_ctx.fp);
fclose (debug_ctx.fp);
}
void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, unsigned char *username, const uint user_len, const hashconfig_t *hashconfig)
{
uint outfile_format = data.outfile_format;
char separator = hashconfig->separator;
if (outfile_format & OUTFILE_FMT_HASH)
{
fprintf (out_fp, "%s", out_buf);
if (outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (separator, out_fp);
}
}
else if (data.username)
{
if (username != NULL)
{
for (uint i = 0; i < user_len; i++)
{
fprintf (out_fp, "%c", username[i]);
}
if (outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (separator, out_fp);
}
}
}
if (outfile_format & OUTFILE_FMT_PLAIN)
{
format_plain (out_fp, plain_ptr, plain_len, data.outfile_autohex);
if (outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (separator, out_fp);
}
}
if (outfile_format & OUTFILE_FMT_HEXPLAIN)
{
for (uint i = 0; i < plain_len; i++)
{
fprintf (out_fp, "%02x", plain_ptr[i]);
}
if (outfile_format & (OUTFILE_FMT_CRACKPOS))
{
fputc (separator, out_fp);
}
}
if (outfile_format & OUTFILE_FMT_CRACKPOS)
{
fprintf (out_fp, "%" PRIu64, crackpos);
}
fputs (EOL, out_fp);
}
static char *stroptitype (const uint opti_type)
{
@ -804,6 +778,13 @@ static void hc_signal (void (callback) (int))
*/
static void send_prompt ()
{
fprintf (stdout, "%s", PROMPT);
fflush (stdout);
}
static void clear_prompt ()
{
fputc ('\r', stdout);
@ -820,7 +801,6 @@ static void clear_prompt ()
static void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
char *outfile = data.outfile;
uint quiet = data.quiet;
uint loopback = data.loopback;
uint debug_mode = data.debug_mode;
@ -1063,46 +1043,25 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
potfile_write_append (potfile_ctx, out_buf, plain_ptr, plain_len);
}
// outfile
// outfile, can be either to file or stdout
// if an error occurs opening the file, send to stdout as fallback
// the fp gets opened for each cracked hash so that the user can modify (move) the outfile while hashcat runs
FILE *out_fp = NULL;
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
if (outfile != NULL)
outfile_write_open (outfile_ctx);
if (outfile_ctx->filename == NULL) if (quiet == 0) clear_prompt ();
outfile_write (outfile_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, hashconfig);
outfile_write_close (outfile_ctx);
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{
if ((out_fp = fopen (outfile, "ab")) == NULL)
if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
{
log_error ("ERROR: %s: %s", outfile, strerror (errno));
out_fp = stdout;
}
lock_file (out_fp);
}
else
{
out_fp = stdout;
if (quiet == 0) clear_prompt ();
}
format_output (out_fp, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, hashconfig);
if (outfile != NULL)
{
if (out_fp != stdout)
{
fclose (out_fp);
}
}
else
{
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{
if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
{
if (quiet == 0) fprintf (stdout, "%s", PROMPT);
if (quiet == 0) fflush (stdout);
}
if (outfile_ctx->filename == NULL) if (quiet == 0) send_prompt ();
}
}
@ -1112,17 +1071,17 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
char *loopback_file = data.loopback_file;
FILE *fb_fp = NULL;
loopback_ctx_t loopback_ctx;
if ((fb_fp = fopen (loopback_file, "ab")) != NULL)
loopback_ctx.fp = fopen (loopback_file, "ab");
if (loopback_ctx.fp != NULL)
{
lock_file (fb_fp);
loopback_format_plain (&loopback_ctx, plain_ptr, plain_len);
format_plain (fb_fp, plain_ptr, plain_len, 1);
fputc ('\n', loopback_ctx.fp);
fputc ('\n', fb_fp);
fclose (fb_fp);
fclose (loopback_ctx.fp);
}
}
@ -5727,9 +5686,7 @@ int main (int argc, char **argv)
data.debug_file = debug_file;
data.username = username;
data.quiet = quiet;
data.outfile = outfile;
data.outfile_format = outfile_format;
data.outfile_autohex = outfile_autohex;
data.hex_charset = hex_charset;
data.hex_salt = hex_salt;
data.hex_wordlist = hex_wordlist;
@ -6079,23 +6036,15 @@ int main (int argc, char **argv)
* outfile
*/
FILE *out_fp = NULL;
outfile_ctx_t *outfile_ctx = mymalloc (sizeof (outfile_ctx_t));
data.outfile_ctx = outfile_ctx;
outfile_init (outfile_ctx, outfile, outfile_format, outfile_autohex);
if (show == 1 || left == 1)
{
if (outfile != NULL)
{
if ((out_fp = fopen (outfile, "ab")) == NULL)
{
log_error ("ERROR: %s: %s", outfile, strerror (errno));
return -1;
}
}
else
{
out_fp = stdout;
}
outfile_write_open (outfile_ctx);
}
/**
@ -6556,8 +6505,8 @@ int main (int argc, char **argv)
tmp_salt->salt_len += 1 + 12 + 1 + 12;
}
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf, out_fp);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf, out_fp);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
hashes_cnt++;
}
@ -6604,8 +6553,8 @@ int main (int argc, char **argv)
if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
{
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
}
else
@ -6614,8 +6563,8 @@ int main (int argc, char **argv)
if (parser_status == PARSER_OK)
{
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
@ -6634,8 +6583,8 @@ int main (int argc, char **argv)
if (parser_status == PARSER_OK)
{
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
@ -6765,8 +6714,8 @@ int main (int argc, char **argv)
// show / left
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
else
{
@ -6781,8 +6730,8 @@ int main (int argc, char **argv)
if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
@ -6800,8 +6749,8 @@ int main (int argc, char **argv)
if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
@ -6812,8 +6761,6 @@ int main (int argc, char **argv)
fclose (fp);
if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
}
}
else
@ -7212,6 +7159,8 @@ int main (int argc, char **argv)
if (show == 1 || left == 1)
{
outfile_write_close (outfile_ctx);
potfile_hash_free (potfile_ctx, hashconfig);
if (data.quiet == 0) log_info_nn ("");
@ -7233,9 +7182,11 @@ int main (int argc, char **argv)
* Sanity check for hashfile vs outfile (should not point to the same physical file)
*/
if (data.outfile != NULL)
if (outfile != NULL)
{
if (data.hashfile != NULL)
char *hashfile = data.hashfile;
if (hashfile != NULL)
{
#if defined (_POSIX)
struct stat tmpstat_outfile;
@ -7247,7 +7198,7 @@ int main (int argc, char **argv)
struct stat64 tmpstat_hashfile;
#endif
FILE *tmp_outfile_fp = fopen (data.outfile, "r");
FILE *tmp_outfile_fp = fopen (outfile, "r");
if (tmp_outfile_fp)
{
@ -7262,7 +7213,7 @@ int main (int argc, char **argv)
fclose (tmp_outfile_fp);
}
FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
FILE *tmp_hashfile_fp = fopen (hashfile, "r");
if (tmp_hashfile_fp)
{
@ -13879,6 +13830,8 @@ int main (int argc, char **argv)
local_free (masks);
outfile_destroy (outfile_ctx);
potfile_write_close (potfile_ctx);
potfile_destroy (potfile_ctx);

View File

@ -28,6 +28,7 @@
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.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 "outfile.h"
#include "potfile.h"
#include "data.h"

View File

@ -26,6 +26,7 @@
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"
#include "outfile.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 "outfile.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 "outfile.h"
#include "potfile.h"
#include "data.h"

157
src/outfile.c Normal file
View File

@ -0,0 +1,157 @@
/**
* Authors.....: Jens Steube <jens.steube@gmail.com>
* License.....: MIT
*/
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "logging.h"
#include "interface.h"
#include "outfile.h"
void outfile_init (outfile_ctx_t *outfile_ctx, char *outfile, const uint outfile_format, const uint outfile_autohex)
{
if (outfile == NULL)
{
outfile_ctx->fp = stdout;
outfile_ctx->filename = NULL;
}
else
{
outfile_ctx->fp = NULL;
outfile_ctx->filename = outfile;
}
outfile_ctx->outfile_format = outfile_format;
outfile_ctx->outfile_autohex = outfile_autohex;
}
void outfile_destroy (outfile_ctx_t *outfile_ctx)
{
outfile_ctx->fp = NULL;
outfile_ctx->filename = NULL;
outfile_ctx->outfile_format = 0;
outfile_ctx->outfile_autohex = 0;
}
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const uint plain_len)
{
int needs_hexify = 0;
if (outfile_ctx->outfile_autohex == 1)
{
for (uint i = 0; i < plain_len; i++)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = 1;
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = 1;
break;
}
}
}
if (needs_hexify == 1)
{
fprintf (outfile_ctx->fp, "$HEX[");
for (uint i = 0; i < plain_len; i++)
{
fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (outfile_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, outfile_ctx->fp);
}
}
void outfile_write_open (outfile_ctx_t *outfile_ctx)
{
if (outfile_ctx->filename == NULL) return;
outfile_ctx->fp = fopen (outfile_ctx->filename, "ab");
if (outfile_ctx->fp == NULL)
{
log_error ("ERROR: %s: %s", outfile_ctx->filename, strerror (errno));
outfile_ctx->fp = stdout;
outfile_ctx->filename = NULL;
}
}
void outfile_write_close (outfile_ctx_t *outfile_ctx)
{
if (outfile_ctx->fp == stdout) return;
fclose (outfile_ctx->fp);
}
void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, const unsigned char *username, const uint user_len, const hashconfig_t *hashconfig)
{
if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH)
{
fprintf (outfile_ctx->fp, "%s", out_buf);
if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
}
}
else if (user_len)
{
if (username != NULL)
{
for (uint i = 0; i < user_len; i++)
{
fprintf (outfile_ctx->fp, "%c", username[i]);
}
if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
}
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN)
{
outfile_format_plain (outfile_ctx, plain_ptr, plain_len);
if (outfile_ctx->outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_HEXPLAIN)
{
for (uint i = 0; i < plain_len; i++)
{
fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]);
}
if (outfile_ctx->outfile_format & (OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_CRACKPOS)
{
fprintf (outfile_ctx->fp, "%" PRIu64, crackpos);
}
fputs (EOL, outfile_ctx->fp);
}

View File

@ -11,13 +11,12 @@
#include "logging.h"
#include "interface.h"
#include "filehandling.h"
#include "outfile.h"
#include "potfile.h"
// get rid of this later
int sort_by_hash (const void *v1, const void *v2);
int sort_by_hash_no_salt (const void *v1, const void *v2);
void format_plain (FILE *fp, unsigned char *plain_ptr, uint plain_len, uint outfile_autohex);
void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, unsigned char *username, const uint user_len, const hashconfig_t *hashconfig);
// get rid of this later
int sort_by_pot (const void *v1, const void *v2)
@ -129,6 +128,44 @@ void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const ch
potfile_ctx->pot_hashes_avail = 0;
}
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len)
{
int needs_hexify = 0;
for (uint i = 0; i < plain_len; i++)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = 1;
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = 1;
break;
}
}
if (needs_hexify == 1)
{
fprintf (potfile_ctx->fp, "$HEX[");
for (uint i = 0; i < plain_len; i++)
{
fprintf (potfile_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (potfile_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, potfile_ctx->fp);
}
}
int potfile_read_open (potfile_ctx_t *potfile_ctx)
{
potfile_ctx->fp = fopen (potfile_ctx->filename, "rb");
@ -276,7 +313,7 @@ void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *
fprintf (fp, "%s:", out_buf);
format_plain (fp, plain_ptr, plain_len, 1);
potfile_format_plain (potfile_ctx, plain_ptr, plain_len);
fputc ('\n', fp);
@ -333,7 +370,7 @@ void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconf
}
}
void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)
void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *))
{
pot_t pot_key;
@ -365,11 +402,12 @@ void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
}
// do output the line
format_output (out_fp, input_buf, (unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, hashconfig);
outfile_write (outfile_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, hashconfig);
}
}
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *))
{
pot_t pot_key;
@ -383,11 +421,11 @@ void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
input_buf[input_len] = 0;
format_output (out_fp, input_buf, NULL, 0, 0, NULL, 0, hashconfig);
outfile_write (outfile_ctx, input_buf, NULL, 0, 0, NULL, 0, hashconfig);
}
}
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *))
{
// left
@ -499,7 +537,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
// do output the line
format_output (out_fp, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, hashconfig);
outfile_write (outfile_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, hashconfig);
if (weak_hash_found == 1) myfree (pot_right_ptr);
@ -507,7 +545,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
if (right_part_masked == 1) myfree (pot_right_ptr);
}
void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)
void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *))
{
// left
@ -580,7 +618,7 @@ void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
hash_output[user_len + 16] = 0;
}
format_output (out_fp, hash_output, NULL, 0, 0, NULL, 0, hashconfig);
outfile_write (outfile_ctx, hash_output, NULL, 0, 0, NULL, 0, hashconfig);
myfree (hash_output);

View File

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

View File

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

View File

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

View File

@ -27,6 +27,7 @@
#include "interface.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "data.h"
#include "stdout.h"
@ -62,15 +63,19 @@ void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
out.fp = stdout;
if (data.outfile != NULL)
// i think this section can be optimized now that we have outfile_ctx
char *filename = data.outfile_ctx->filename;
if (filename != NULL)
{
if ((out.fp = fopen (data.outfile, "ab")) != NULL)
if ((out.fp = fopen (filename, "ab")) != NULL)
{
lock_file (out.fp);
}
else
{
log_error ("ERROR: %s: %s", data.outfile, strerror (errno));
log_error ("ERROR: %s: %s", filename, strerror (errno));
out.fp = stdout;
}

View File

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