Brain: Add brain_ctx_t to hashcat_ctx_t to enable runtime check if hashcat was compiled with brain support
This commit is contained in:
+35
@@ -3352,3 +3352,38 @@ int brain_server (const char *listen_host, const int listen_port, const char *br
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int brain_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
brain_ctx_t *brain_ctx = hashcat_ctx->brain_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
#ifdef WITH_BRAIN
|
||||
brain_ctx->support = true;
|
||||
#else
|
||||
brain_ctx->support = false;
|
||||
#endif
|
||||
|
||||
if (brain_ctx->support == false) return 0;
|
||||
|
||||
if (user_options->brain_client == true)
|
||||
{
|
||||
brain_ctx->enabled = true;
|
||||
}
|
||||
|
||||
if (user_options->brain_server == true)
|
||||
{
|
||||
brain_ctx->enabled = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void brain_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
brain_ctx_t *brain_ctx = hashcat_ctx->brain_ctx;
|
||||
|
||||
if (brain_ctx->support == false) return;
|
||||
|
||||
memset (brain_ctx, 0, sizeof (brain_ctx_t));
|
||||
}
|
||||
|
||||
@@ -868,6 +868,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
// clean up
|
||||
|
||||
brain_ctx_destroy (hashcat_ctx);
|
||||
bitmap_ctx_destroy (hashcat_ctx);
|
||||
combinator_ctx_destroy (hashcat_ctx);
|
||||
cpt_ctx_destroy (hashcat_ctx);
|
||||
@@ -897,6 +898,7 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct h
|
||||
hashcat_ctx->event = event;
|
||||
}
|
||||
|
||||
hashcat_ctx->brain_ctx = (brain_ctx_t *) hcmalloc (sizeof (brain_ctx_t));
|
||||
hashcat_ctx->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (sizeof (bitmap_ctx_t));
|
||||
hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (sizeof (combinator_ctx_t));
|
||||
hashcat_ctx->cpt_ctx = (cpt_ctx_t *) hcmalloc (sizeof (cpt_ctx_t));
|
||||
@@ -931,6 +933,7 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct h
|
||||
|
||||
void hashcat_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
hcfree (hashcat_ctx->brain_ctx);
|
||||
hcfree (hashcat_ctx->bitmap_ctx);
|
||||
hcfree (hashcat_ctx->combinator_ctx);
|
||||
hcfree (hashcat_ctx->cpt_ctx);
|
||||
@@ -1035,6 +1038,12 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* brain
|
||||
*/
|
||||
|
||||
if (brain_ctx_init (hashcat_ctx) == -1) return -1;
|
||||
|
||||
/**
|
||||
* logfile
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user