mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-14 18:48:21 +00:00
Do not write potfile if --potfile-disable is in use
This commit is contained in:
parent
e9d6d06300
commit
bd9e092ea3
@ -26,8 +26,9 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
FILE *fp;
|
int disable;
|
||||||
|
|
||||||
|
FILE *fp;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
pot_t *pot;
|
pot_t *pot;
|
||||||
@ -43,7 +44,7 @@ int sort_by_salt_buf (const void *v1, const void *v2);
|
|||||||
int sort_by_hash_t_salt (const void *v1, const void *v2);
|
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);
|
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_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path, const uint potfile_disable);
|
||||||
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len);
|
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);
|
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_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig);
|
||||||
|
@ -374,14 +374,9 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if enabled, update also the potfile
|
|
||||||
// no need for locking, we're in a mutex protected function
|
// no need for locking, we're in a mutex protected function
|
||||||
|
|
||||||
|
|
||||||
if (potfile_ctx->fp != NULL)
|
|
||||||
{
|
|
||||||
potfile_write_append (potfile_ctx, out_buf, plain_ptr, plain_len);
|
potfile_write_append (potfile_ctx, out_buf, plain_ptr, plain_len);
|
||||||
}
|
|
||||||
|
|
||||||
// outfile, can be either to file or stdout
|
// outfile, can be either to file or stdout
|
||||||
// if an error occurs opening the file, send to stdout as fallback
|
// if an error occurs opening the file, send to stdout as fallback
|
||||||
|
@ -3639,13 +3639,13 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.potfile_ctx = potfile_ctx;
|
data.potfile_ctx = potfile_ctx;
|
||||||
|
|
||||||
potfile_init (potfile_ctx, profile_dir, potfile_path);
|
potfile_init (potfile_ctx, profile_dir, potfile_path, potfile_disable);
|
||||||
|
|
||||||
if (show == 1 || left == 1)
|
if (show == 1 || left == 1)
|
||||||
{
|
{
|
||||||
SUPPRESS_OUTPUT = 1;
|
SUPPRESS_OUTPUT = 1;
|
||||||
|
|
||||||
int rc = potfile_read_open (potfile_ctx);
|
const int rc = potfile_read_open (potfile_ctx);
|
||||||
|
|
||||||
if (rc == -1) return -1;
|
if (rc == -1) return -1;
|
||||||
|
|
||||||
|
@ -107,8 +107,12 @@ int sort_by_hash_t_salt_hccap (const void *v1, const void *v2)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path)
|
void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const char *potfile_path, const uint potfile_disable)
|
||||||
{
|
{
|
||||||
|
potfile_ctx->disable = potfile_disable;
|
||||||
|
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
potfile_ctx->fp = NULL;
|
potfile_ctx->fp = NULL;
|
||||||
|
|
||||||
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
|
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||||
@ -130,6 +134,8 @@ void potfile_init (potfile_ctx_t *potfile_ctx, const char *profile_dir, const ch
|
|||||||
|
|
||||||
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len)
|
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
int needs_hexify = 0;
|
int needs_hexify = 0;
|
||||||
|
|
||||||
for (uint i = 0; i < plain_len; i++)
|
for (uint i = 0; i < plain_len; i++)
|
||||||
@ -168,6 +174,8 @@ void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plai
|
|||||||
|
|
||||||
int potfile_read_open (potfile_ctx_t *potfile_ctx)
|
int potfile_read_open (potfile_ctx_t *potfile_ctx)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return 0;
|
||||||
|
|
||||||
potfile_ctx->fp = fopen (potfile_ctx->filename, "rb");
|
potfile_ctx->fp = fopen (potfile_ctx->filename, "rb");
|
||||||
|
|
||||||
if (potfile_ctx->fp == NULL)
|
if (potfile_ctx->fp == NULL)
|
||||||
@ -182,6 +190,8 @@ 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_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
potfile_ctx->pot_avail = count_lines (potfile_ctx->fp);
|
potfile_ctx->pot_avail = count_lines (potfile_ctx->fp);
|
||||||
|
|
||||||
potfile_ctx->pot = (pot_t *) mycalloc (potfile_ctx->pot_avail, sizeof (pot_t));
|
potfile_ctx->pot = (pot_t *) mycalloc (potfile_ctx->pot_avail, sizeof (pot_t));
|
||||||
@ -285,11 +295,15 @@ void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
|
|||||||
|
|
||||||
void potfile_read_close (potfile_ctx_t *potfile_ctx)
|
void potfile_read_close (potfile_ctx_t *potfile_ctx)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
fclose (potfile_ctx->fp);
|
fclose (potfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int potfile_write_open (potfile_ctx_t *potfile_ctx)
|
int potfile_write_open (potfile_ctx_t *potfile_ctx)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return 0;
|
||||||
|
|
||||||
potfile_ctx->fp = fopen (potfile_ctx->filename, "ab");
|
potfile_ctx->fp = fopen (potfile_ctx->filename, "ab");
|
||||||
|
|
||||||
if (potfile_ctx->fp == NULL)
|
if (potfile_ctx->fp == NULL)
|
||||||
@ -304,11 +318,15 @@ int potfile_write_open (potfile_ctx_t *potfile_ctx)
|
|||||||
|
|
||||||
void potfile_write_close (potfile_ctx_t *potfile_ctx)
|
void potfile_write_close (potfile_ctx_t *potfile_ctx)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
fclose (potfile_ctx->fp);
|
fclose (potfile_ctx->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len)
|
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
FILE *fp = potfile_ctx->fp;
|
FILE *fp = potfile_ctx->fp;
|
||||||
|
|
||||||
fprintf (fp, "%s:", out_buf);
|
fprintf (fp, "%s:", out_buf);
|
||||||
@ -322,6 +340,8 @@ void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *
|
|||||||
|
|
||||||
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const uint num)
|
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const uint num)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
uint pos = 0;
|
uint pos = 0;
|
||||||
|
|
||||||
for (pos = 0; pos < num; pos++)
|
for (pos = 0; pos < num; pos++)
|
||||||
@ -350,6 +370,8 @@ void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
|
|||||||
|
|
||||||
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig)
|
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
for (uint i = 0; i < potfile_ctx->pot_cnt; i++)
|
for (uint i = 0; i < potfile_ctx->pot_cnt; i++)
|
||||||
{
|
{
|
||||||
pot_t *pot_ptr = &potfile_ctx->pot[i];
|
pot_t *pot_ptr = &potfile_ctx->pot[i];
|
||||||
@ -372,6 +394,8 @@ 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, 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 (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 *))
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
pot_t pot_key;
|
pot_t pot_key;
|
||||||
|
|
||||||
pot_key.hash.salt = hashes_buf->salt;
|
pot_key.hash.salt = hashes_buf->salt;
|
||||||
@ -409,6 +433,8 @@ void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
|||||||
|
|
||||||
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_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 *))
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
pot_t pot_key;
|
pot_t pot_key;
|
||||||
|
|
||||||
memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t));
|
memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t));
|
||||||
@ -427,6 +453,8 @@ void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
|||||||
|
|
||||||
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_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 *))
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
// left
|
// left
|
||||||
|
|
||||||
pot_t pot_left_key;
|
pot_t pot_left_key;
|
||||||
@ -547,6 +575,8 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
|||||||
|
|
||||||
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 *))
|
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 *))
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
// left
|
// left
|
||||||
|
|
||||||
pot_t pot_left_key;
|
pot_t pot_left_key;
|
||||||
@ -627,6 +657,8 @@ void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
|||||||
|
|
||||||
int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hash_t *hashes_buf, const uint hashes_cnt)
|
int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hash_t *hashes_buf, const uint hashes_cnt)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return 0;
|
||||||
|
|
||||||
// no solution for these special hash types (for instane because they use hashfile in output etc)
|
// no solution for these special hash types (for instane because they use hashfile in output etc)
|
||||||
|
|
||||||
if (hashconfig->hash_mode == 5200)
|
if (hashconfig->hash_mode == 5200)
|
||||||
@ -833,5 +865,7 @@ int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashco
|
|||||||
|
|
||||||
void potfile_destroy (potfile_ctx_t *potfile_ctx)
|
void potfile_destroy (potfile_ctx_t *potfile_ctx)
|
||||||
{
|
{
|
||||||
|
if (potfile_ctx->disable == 1) return;
|
||||||
|
|
||||||
myfree (potfile_ctx->filename);
|
myfree (potfile_ctx->filename);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user