|
|
|
@ -9,59 +9,10 @@
|
|
|
|
|
#include "logging.h"
|
|
|
|
|
#include "debugfile.h"
|
|
|
|
|
|
|
|
|
|
int debugfile_init (debugfile_ctx_t *debugfile_ctx, const user_options_t *user_options)
|
|
|
|
|
static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx->enabled = false;
|
|
|
|
|
|
|
|
|
|
if (user_options->benchmark == true) return 0;
|
|
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
|
if (user_options->left == true) return 0;
|
|
|
|
|
if (user_options->opencl_info == true) return 0;
|
|
|
|
|
if (user_options->show == true) return 0;
|
|
|
|
|
if (user_options->stdout_flag == true) return 0;
|
|
|
|
|
if (user_options->usage == true) return 0;
|
|
|
|
|
if (user_options->version == true) return 0;
|
|
|
|
|
if (user_options->debug_mode == 0) return 0;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->enabled = true;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->mode = user_options->debug_mode;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->filename)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx->filename = user_options->debug_file;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->fp = fopen (debugfile_ctx->filename, "ab");
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error ("ERROR: Could not open debug-file for writing");
|
|
|
|
|
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx->fp = stdout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void debugfile_destroy (debugfile_ctx_t *debugfile_ctx)
|
|
|
|
|
{
|
|
|
|
|
if (debugfile_ctx->enabled == false) return;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->filename)
|
|
|
|
|
{
|
|
|
|
|
fclose (debugfile_ctx->fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (debugfile_ctx, 0, sizeof (debugfile_ctx_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void debugfile_format_plain (debugfile_ctx_t *debugfile_ctx, const u8 *plain_ptr, const u32 plain_len)
|
|
|
|
|
{
|
|
|
|
|
if (debugfile_ctx->enabled == false) return;
|
|
|
|
|
|
|
|
|
|
int needs_hexify = 0;
|
|
|
|
@ -100,15 +51,17 @@ void debugfile_format_plain (debugfile_ctx_t *debugfile_ctx, const u8 *plain_ptr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void debugfile_write_append (debugfile_ctx_t *debugfile_ctx, const u8 *rule_buf, const u32 rule_len, const u8 *mod_plain_ptr, const u32 mod_plain_len, const u8 *orig_plain_ptr, const u32 orig_plain_len)
|
|
|
|
|
void debugfile_write_append (hashcat_ctx_t *hashcat_ctx, const u8 *rule_buf, const u32 rule_len, const u8 *mod_plain_ptr, const u32 mod_plain_len, const u8 *orig_plain_ptr, const u32 orig_plain_len)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->enabled == false) return;
|
|
|
|
|
|
|
|
|
|
const u32 debug_mode = debugfile_ctx->mode;
|
|
|
|
|
|
|
|
|
|
if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
|
|
|
|
|
{
|
|
|
|
|
debugfile_format_plain (debugfile_ctx, orig_plain_ptr, orig_plain_len);
|
|
|
|
|
debugfile_format_plain (hashcat_ctx, orig_plain_ptr, orig_plain_len);
|
|
|
|
|
|
|
|
|
|
if ((debug_mode == 3) || (debug_mode == 4)) fputc (':', debugfile_ctx->fp);
|
|
|
|
|
}
|
|
|
|
@ -119,8 +72,64 @@ void debugfile_write_append (debugfile_ctx_t *debugfile_ctx, const u8 *rule_buf,
|
|
|
|
|
{
|
|
|
|
|
fputc (':', debugfile_ctx->fp);
|
|
|
|
|
|
|
|
|
|
debugfile_format_plain (debugfile_ctx, mod_plain_ptr, mod_plain_len);
|
|
|
|
|
debugfile_format_plain (hashcat_ctx, mod_plain_ptr, mod_plain_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fputc ('\n', debugfile_ctx->fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int debugfile_init (hashcat_ctx_t *hashcat_ctx)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->enabled = false;
|
|
|
|
|
|
|
|
|
|
if (user_options->benchmark == true) return 0;
|
|
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
|
if (user_options->left == true) return 0;
|
|
|
|
|
if (user_options->opencl_info == true) return 0;
|
|
|
|
|
if (user_options->show == true) return 0;
|
|
|
|
|
if (user_options->stdout_flag == true) return 0;
|
|
|
|
|
if (user_options->usage == true) return 0;
|
|
|
|
|
if (user_options->version == true) return 0;
|
|
|
|
|
if (user_options->debug_mode == 0) return 0;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->enabled = true;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->mode = user_options->debug_mode;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->filename)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx->filename = user_options->debug_file;
|
|
|
|
|
|
|
|
|
|
debugfile_ctx->fp = fopen (debugfile_ctx->filename, "ab");
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error ("ERROR: Could not open debug-file for writing");
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx->fp = stdout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void debugfile_destroy (hashcat_ctx_t *hashcat_ctx)
|
|
|
|
|
{
|
|
|
|
|
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->enabled == false) return;
|
|
|
|
|
|
|
|
|
|
if (debugfile_ctx->filename)
|
|
|
|
|
{
|
|
|
|
|
fclose (debugfile_ctx->fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset (debugfile_ctx, 0, sizeof (debugfile_ctx_t));
|
|
|
|
|
}
|
|
|
|
|