1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Get rid of more log_info() in hashcat()

This commit is contained in:
jsteube 2016-10-07 21:47:11 +02:00
parent 81650dcc46
commit 27887bf9ce
5 changed files with 337 additions and 251 deletions

View File

@ -33,7 +33,7 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int
void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _POTFILE_H

View File

@ -91,16 +91,24 @@ typedef enum event_identifier
EVENT_LOGFILE_SUB_FINALIZE = 0x00000024,
EVENT_OUTERLOOP_STARTING = 0x00000031,
EVENT_OUTERLOOP_FINISHED = 0x00000032,
EVENT_OUTERLOOP_MAINSCREEN = 0x00000033,
EVENT_OUTERLOOP_WEAK_HASH = 0x00000034,
EVENT_INNERLOOP1_STARTING = 0x00000041,
EVENT_INNERLOOP1_FINISHED = 0x00000042,
EVENT_INNERLOOP2_STARTING = 0x00000051,
EVENT_INNERLOOP2_FINISHED = 0x00000052,
EVENT_CALCULATED_WORDS_BASE = 0x00000059,
EVENT_AUTOTUNE_STARTING = 0x00000053,
EVENT_AUTOTUNE_FINISHED = 0x00000054,
EVENT_CRACKER_STARTING = 0x00000055,
EVENT_CRACKER_FINISHED = 0x00000056,
EVENT_CRACKER_FINAL_STATS = 0x00000057,
EVENT_CRACKER_HASH_CRACKED = 0x00000058,
EVENT_POTFILE_REMOVE_PARSE = 0x00000061,
EVENT_POTFILE_NUM_CRACKED = 0x00000062,
EVENT_POTFILE_ALL_CRACKED = 0x00000063,
EVENT_OPENCL_SESSION_PRE = 0x00000071,
EVENT_OPENCL_SESSION_POST = 0x00000072,
// there will be much more event types soon
@ -499,6 +507,7 @@ typedef struct hashes
void *esalts_buf;
u32 hashes_cnt_orig;
u32 hashes_cnt;
hash_t *hashes_buf;

View File

@ -188,12 +188,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx);
if (user_options->keyspace == true)
{
log_info ("%" PRIu64 "", status_ctx->words_base);
EVENT_SEND (EVENT_CALCULATED_WORDS_BASE);
return 0;
}
if (user_options->keyspace == true) return 0;
// restore stuff
@ -427,10 +424,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
static int outer_loop (hashcat_ctx_t *hashcat_ctx)
{
bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
@ -506,23 +500,21 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
}
/**
* Potfile removes
* potfile removes
*/
int potfile_remove_cracks = 0;
if (user_options->potfile_disable == 0)
{
if (user_options->quiet == false) log_info_nn ("Comparing hashes with potfile entries...");
EVENT_SEND (EVENT_POTFILE_REMOVE_PARSE);
potfile_remove_cracks = potfile_remove_parse (hashcat_ctx);
potfile_remove_parse (hashcat_ctx);
}
/**
* load hashes, stage 2, remove duplicates, build base structure
*/
const u32 hashes_cnt_orig = hashes->hashes_cnt;
hashes->hashes_cnt_orig = hashes->hashes_cnt;
const int rc_hashes_init_stage2 = hashes_init_stage2 (hashcat_ctx);
@ -534,13 +526,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (status_ctx->devices_status == STATUS_CRACKED)
{
if (user_options->quiet == false)
{
log_info ("INFO: All hashes found in potfile! You can use --show to display them.");
log_info ("");
log_info ("INFO: No more hashes left to crack, exiting...");
log_info ("");
}
EVENT_SEND (EVENT_POTFILE_ALL_CRACKED);
hashes_destroy (hashcat_ctx);
@ -640,107 +626,20 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_status_init == -1) return -1;
/**
* enable custom signal handler(s)
* currently disabled, because man page says:
* The effects of signal() in a multithreaded process are unspecified.
* main screen
*/
/*
if (user_options->benchmark == false)
{
hc_signal (sigHandler_default);
}
else
{
hc_signal (sigHandler_benchmark);
}
*/
EVENT_SEND (EVENT_OUTERLOOP_MAINSCREEN);
/**
* inform the user
*/
if (user_options->quiet == false)
{
log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
log_info ("Rules: %u", straight_ctx->kernel_rules_cnt);
}
if (user_options->quiet == false) log_info ("");
if (hashconfig->opti_type)
{
log_info ("Applicable Optimizers:");
for (u32 i = 0; i < 32; i++)
{
const u32 opti_bit = 1u << i;
if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
}
}
if (user_options->quiet == false) log_info ("");
/**
* Watchdog and Temperature balance
*/
if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false)
{
log_info ("Watchdog: Hardware Monitoring Interface not found on your system");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0)
{
log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort);
}
else
{
log_info ("Watchdog: Temperature abort trigger disabled");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0)
{
log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain);
}
else
{
log_info ("Watchdog: Temperature retain trigger disabled");
}
if (user_options->quiet == false) log_info ("");
}
#if defined (DEBUG)
if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode);
#endif
if (user_options->quiet == false) log_info_nn ("Initializing device kernels and memory...");
EVENT_SEND (EVENT_OPENCL_SESSION_PRE);
opencl_session_begin (hashcat_ctx);
if (user_options->quiet == false) log_info_nn ("");
/**
* In benchmark-mode, inform user which algorithm is checked
*/
if (user_options->benchmark == true)
{
if (user_options->machine_readable == false)
{
char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug
log_info ("Hashtype: %s", hash_type);
log_info ("");
}
}
EVENT_SEND (EVENT_OPENCL_SESSION_POST);
/**
* weak hash check is the first to write to potfile, so open it for writing from here
@ -767,7 +666,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
break;
}
if (user_options->quiet == false) log_info_nn ("Checking for weak hashes...");
EVENT_SEND (EVENT_OUTERLOOP_WEAK_HASH);
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
@ -807,25 +706,12 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* Tell user about cracked hashes by potfile
*/
if (user_options->quiet == false)
{
if (potfile_remove_cracks > 0)
{
if (potfile_remove_cracks == 1)
{
log_info ("INFO: Removed 1 hash found in potfile");
log_info ("");
}
else
{
log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks);
log_info ("");
}
}
}
EVENT_SEND (EVENT_POTFILE_NUM_CRACKED);
// main call
EVENT_SEND (EVENT_INNERLOOP1_STARTING);
if (mask_ctx->masks_cnt)
{
restore_data_t *rd = restore_ctx->rd;
@ -866,6 +752,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
myfree (inner_threads);
EVENT_SEND (EVENT_INNERLOOP1_FINISHED);
// finalize potfile
potfile_write_close (hashcat_ctx);

View File

@ -10,18 +10,20 @@
#include "common.h"
#include "types.h"
#include "user_options.h"
#include "usage.h"
#include "hashcat.h"
#include "memory.h" // commandline only
#include "terminal.h" // commandline only
#include "usage.h" // commandline only
#include "logging.h" // commandline only
#include "logfile.h" // commandline only
#include "thread.h" // commandline only
#include "status.h" // commandline only
#define RUN_AS_COMMANDLINE true
#define RUN_AS_COMMANDLINE
#if (RUN_AS_COMMANDLINE == true)
#if defined (RUN_AS_COMMANDLINE)
#include "memory.h"
#include "terminal.h"
#include "logging.h"
#include "logfile.h"
#include "thread.h"
#include "status.h"
#include "interface.h"
static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx)
{
@ -103,10 +105,11 @@ static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx)
static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx)
{
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
/**
* keypress thread
@ -156,8 +159,10 @@ static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx)
static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return 0;
// Tell the user we're about to start
@ -165,13 +170,13 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx)
{
if ((user_options->quiet == false) && (user_options->status == false) && (user_options->benchmark == false))
{
if (user_options->quiet == false) send_prompt ();
send_prompt ();
}
}
else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
{
if (user_options->quiet == false) log_info ("Starting attack in stdin mode...");
if (user_options->quiet == false) log_info ("");
log_info ("Starting attack in stdin mode...");
log_info ("");
}
return 0;
@ -179,8 +184,8 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx)
static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx)
{
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
logfile_sub_var_uint ("status-after-work", status_ctx->devices_status);
@ -189,8 +194,8 @@ static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx)
static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
user_options_t *user_options = hashcat_ctx->user_options;
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
// print final status
@ -231,8 +236,8 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
user_options_t *user_options = hashcat_ctx->user_options;
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
if (hashes == NULL) hashes = NULL;
if (user_options == NULL) user_options = NULL;
@ -240,6 +245,190 @@ static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx)
return 0;
}
static int event_calculated_words_base (hashcat_ctx_t *hashcat_ctx)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->keyspace == true)
{
log_info ("%" PRIu64 "", status_ctx->words_base);
}
return 0;
}
static int event_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
log_info_nn ("Comparing hashes with potfile entries...");
return 0;
}
static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashes_t *hashes = hashcat_ctx->hashes;
if (user_options->quiet == true) return 0;
const int potfile_remove_cracks = hashes->digests_done;
if (potfile_remove_cracks > 0)
{
if (potfile_remove_cracks == 1)
{
log_info ("INFO: Removed 1 hash found in potfile");
log_info ("");
}
else
{
log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks);
log_info ("");
}
}
return 0;
}
static int event_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
log_info ("INFO: All hashes found in potfile! You can use --show to display them.");
log_info ("");
log_info ("INFO: No more hashes left to crack, exiting...");
log_info ("");
return 0;
}
static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx)
{
const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const hashes_t *hashes = hashcat_ctx->hashes;
const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
/**
* In benchmark-mode, inform user which algorithm is checked
*/
if (user_options->benchmark == true)
{
if (user_options->machine_readable == false)
{
char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug
log_info ("Hashtype: %s", hash_type);
log_info ("");
}
}
if (user_options->quiet == true) return 0;
log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
log_info ("Rules: %u", straight_ctx->kernel_rules_cnt);
}
if (user_options->quiet == false) log_info ("");
if (hashconfig->opti_type)
{
log_info ("Applicable Optimizers:");
for (u32 i = 0; i < 32; i++)
{
const u32 opti_bit = 1u << i;
if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
}
}
log_info ("");
/**
* Watchdog and Temperature balance
*/
if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false)
{
log_info ("Watchdog: Hardware Monitoring Interface not found on your system");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0)
{
log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort);
}
else
{
log_info ("Watchdog: Temperature abort trigger disabled");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0)
{
log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain);
}
else
{
log_info ("Watchdog: Temperature retain trigger disabled");
}
log_info ("");
#if defined (DEBUG)
if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode);
#endif
return 0;
}
static int event_opencl_session_pre (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
log_info_nn ("Initializing device kernels and memory...");
return 0;
}
static int event_opencl_session_post (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
log_info_nn ("");
return 0;
}
static int event_outerloop_weak_hash (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
log_info_nn ("Checking for weak hashes...");
return 0;
}
int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
{
int rc = 0;
@ -254,10 +443,18 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
case EVENT_LOGFILE_SUB_FINALIZE: rc = event_logfile_sub_finalize (hashcat_ctx); break;
case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break;
case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break;
case EVENT_OUTERLOOP_MAINSCREEN: rc = event_outerloop_mainscreen (hashcat_ctx); break;
case EVENT_OUTERLOOP_WEAK_HASH: rc = event_outerloop_weak_hash (hashcat_ctx); break;
case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break;
case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break;
case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break;
case EVENT_CRACKER_HASH_CRACKED: rc = event_cracker_hash_cracked (hashcat_ctx); break;
case EVENT_CALCULATED_WORDS_BASE: rc = event_calculated_words_base (hashcat_ctx); break;
case EVENT_POTFILE_REMOVE_PARSE: rc = event_potfile_remove_parse (hashcat_ctx); break;
case EVENT_POTFILE_NUM_CRACKED: rc = event_potfile_num_cracked (hashcat_ctx); break;
case EVENT_POTFILE_ALL_CRACKED: rc = event_potfile_all_cracked (hashcat_ctx); break;
case EVENT_OPENCL_SESSION_PRE: rc = event_opencl_session_pre (hashcat_ctx); break;
case EVENT_OPENCL_SESSION_POST: rc = event_opencl_session_post (hashcat_ctx); break;
}
return rc;
@ -267,9 +464,15 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL;
int rc = 0;
switch (event)
{
}
return rc;
}
#endif
@ -285,91 +488,88 @@ int main (int argc, char **argv)
// initialize the session via getops for commandline use or
// alternatively you can set the user_options directly
int rc_hashcat = 0;
#if defined (RUN_AS_COMMANDLINE)
bool run_as_commandline = RUN_AS_COMMANDLINE;
// install and shared folder need to be set to recognize "make install" use
if (run_as_commandline == true)
char *install_folder = NULL;
char *shared_folder = NULL;
#if defined (INSTALL_FOLDER)
install_folder = INSTALL_FOLDER;
#endif
#if defined (SHARED_FOLDER)
shared_folder = SHARED_FOLDER;
#endif
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// parse commandline parameters and check them
const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv);
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (hashcat_ctx);
if (rc_options_sanity == -1) return -1;
// some early exits
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->version == true)
{
// install and shared folder need to be set to recognize "make install" use
printf ("%s\n", VERSION_TAG);
char *install_folder = NULL;
char *shared_folder = NULL;
#if defined (INSTALL_FOLDER)
install_folder = INSTALL_FOLDER;
#endif
#if defined (SHARED_FOLDER)
shared_folder = SHARED_FOLDER;
#endif
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// parse commandline parameters and check them
const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv);
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (hashcat_ctx);
if (rc_options_sanity == -1) return -1;
// some early exits
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->version == true)
{
printf ("%s\n", VERSION_TAG);
return 0;
}
if (user_options->usage == true)
{
usage_big_print (PROGNAME);
return 0;
}
// now run hashcat
rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
return 0;
}
else
if (user_options->usage == true)
{
// this is a bit ugly, but it's the example you're looking for
usage_big_print (PROGNAME);
char *hash = "8743b52063cd84097a65d1633f5c74f5";
char *mask = "?l?l?l?l?l?l?l";
char *hc_argv[] = { hash, mask, NULL };
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// your own stuff
user_options_t *user_options = hashcat_ctx->user_options;
user_options->hc_argv = hc_argv;
user_options->hc_argc = 2;
user_options->quiet = true;
user_options->potfile_disable = true;
user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3
user_options->hash_mode = 0; // MD5
user_options->workload_profile = 3;
// now run hashcat
rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0);
return 0;
}
// now run hashcat
const int rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
#else
// this is a bit ugly, but it's the example you're looking for
char *hash = "8743b52063cd84097a65d1633f5c74f5";
char *mask = "?l?l?l?l?l?l?l";
char *hc_argv[] = { hash, mask, NULL };
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// your own stuff
user_options_t *user_options = hashcat_ctx->user_options;
user_options->hc_argv = hc_argv;
user_options->hc_argc = 2;
user_options->quiet = true;
user_options->potfile_disable = true;
user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3
user_options->hash_mode = 0; // MD5
user_options->workload_profile = 3;
// now run hashcat
const int rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0);
#endif
// finished with hashcat, clean up
hashcat_ctx_destroy (hashcat_ctx);

View File

@ -762,30 +762,25 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
if (weak_hash_found == 1) myfree (pot_right_ptr);
}
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
void potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return 0;
if (potfile_ctx->enabled == false) return;
hash_t *hashes_buf = hashes->hashes_buf;
u32 hashes_cnt = hashes->hashes_cnt;
u32 hashes_cnt = hashes->hashes_cnt;
// no solution for these special hash types (for instane because they use hashfile in output etc)
if (hashconfig->hash_mode == 5200)
return 0;
if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299))
return 0;
if (hashconfig->hash_mode == 9000)
return 0;
if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799))
return 0;
if (hashconfig->hash_mode == 5200) return;
if ((hashconfig->hash_mode >= 6200)
&& (hashconfig->hash_mode <= 6299)) return;
if (hashconfig->hash_mode == 9000) return;
if ((hashconfig->hash_mode >= 13700)
&& (hashconfig->hash_mode <= 13799)) return;
hash_t hash_buf;
@ -807,9 +802,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
const int rc = potfile_read_open (hashcat_ctx);
if (rc == -1) return 0;
int potfile_remove_cracks = 0;
if (rc == -1) return;
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -946,8 +939,6 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (found == NULL) continue;
if (!found->cracked) potfile_remove_cracks++;
found->cracked = 1;
if (found) break;
@ -973,6 +964,4 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
}
myfree (hash_buf.digest);
return potfile_remove_cracks;
}