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

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:
Jens Steube 2021-06-26 20:24:45 +02:00
parent 909d5e64a5
commit dcaba1f473
5 changed files with 57 additions and 0 deletions

View File

@ -11,6 +11,7 @@
- Added hash-mode: AES-192-ECB NOKDF (PT = $salt, key = $pass) - Added hash-mode: AES-192-ECB NOKDF (PT = $salt, key = $pass)
- Added hash-mode: AES-256-ECB NOKDF (PT = $salt, key = $pass) - Added hash-mode: AES-256-ECB NOKDF (PT = $salt, key = $pass)
## ##
## Bugs ## Bugs
## ##
@ -40,6 +41,7 @@
## Technical ## Technical
## ##
- Brain: Add brain_ctx_t to hashcat_ctx_t to enable runtime check if hashcat was compiled with brain support
- Autodetect: Limit the number of errors per hash-mode try to 100 to avoid long startup time - Autodetect: Limit the number of errors per hash-mode try to 100 to avoid long startup time
- Folders: Do not escape the variable cpath_real to prevent certain OpenCL runtimes from running into an error which do not support escape characters - Folders: Do not escape the variable cpath_real to prevent certain OpenCL runtimes from running into an error which do not support escape characters
- LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes - LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes

View File

@ -249,4 +249,7 @@ void brain_server_db_attack_init (brain_server_db_attack_t *brain_server_
bool brain_server_db_attack_realloc (brain_server_db_attack_t *brain_server_db_attack, const i64 new_long_cnt, const i64 new_short_cnt); bool brain_server_db_attack_realloc (brain_server_db_attack_t *brain_server_db_attack, const i64 new_long_cnt, const i64 new_short_cnt);
void brain_server_db_attack_free (brain_server_db_attack_t *brain_server_db_attack); void brain_server_db_attack_free (brain_server_db_attack_t *brain_server_db_attack);
int brain_ctx_init (hashcat_ctx_t *hashcat_ctx);
void brain_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _BRAIN_H #endif // _BRAIN_H

View File

@ -2120,6 +2120,13 @@ typedef struct user_options_extra
} user_options_extra_t; } user_options_extra_t;
typedef struct brain_ctx
{
bool support; // general brain support compiled in (server or client)
bool enabled; // brain support required by user request on command line
} brain_ctx_t;
typedef struct bitmap_ctx typedef struct bitmap_ctx
{ {
bool enabled; bool enabled;
@ -2585,6 +2592,7 @@ typedef struct module_ctx
typedef struct hashcat_ctx typedef struct hashcat_ctx
{ {
brain_ctx_t *brain_ctx;
bitmap_ctx_t *bitmap_ctx; bitmap_ctx_t *bitmap_ctx;
combinator_ctx_t *combinator_ctx; combinator_ctx_t *combinator_ctx;
cpt_ctx_t *cpt_ctx; cpt_ctx_t *cpt_ctx;

View File

@ -3352,3 +3352,38 @@ int brain_server (const char *listen_host, const int listen_port, const char *br
return 0; 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));
}

View File

@ -868,6 +868,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
// clean up // clean up
brain_ctx_destroy (hashcat_ctx);
bitmap_ctx_destroy (hashcat_ctx); bitmap_ctx_destroy (hashcat_ctx);
combinator_ctx_destroy (hashcat_ctx); combinator_ctx_destroy (hashcat_ctx);
cpt_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->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->bitmap_ctx = (bitmap_ctx_t *) hcmalloc (sizeof (bitmap_ctx_t));
hashcat_ctx->combinator_ctx = (combinator_ctx_t *) hcmalloc (sizeof (combinator_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)); 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) void hashcat_destroy (hashcat_ctx_t *hashcat_ctx)
{ {
hcfree (hashcat_ctx->brain_ctx);
hcfree (hashcat_ctx->bitmap_ctx); hcfree (hashcat_ctx->bitmap_ctx);
hcfree (hashcat_ctx->combinator_ctx); hcfree (hashcat_ctx->combinator_ctx);
hcfree (hashcat_ctx->cpt_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
#endif #endif
/**
* brain
*/
if (brain_ctx_init (hashcat_ctx) == -1) return -1;
/** /**
* logfile * logfile
*/ */