2016-09-06 11:52:26 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-06 11:52:26 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
2016-09-06 17:44:27 +00:00
|
|
|
#include "types.h"
|
2016-09-24 12:43:18 +00:00
|
|
|
#include "memory.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
2017-06-23 10:13:51 +00:00
|
|
|
#include "bitops.h"
|
2016-10-06 20:00:02 +00:00
|
|
|
#include "logfile.h"
|
2016-09-24 12:43:18 +00:00
|
|
|
#include "convert.h"
|
|
|
|
#include "filehandling.h"
|
2016-09-25 23:18:00 +00:00
|
|
|
#include "interface.h"
|
2016-10-06 20:00:02 +00:00
|
|
|
#include "opencl.h"
|
2016-10-31 10:28:06 +00:00
|
|
|
#include "shared.h"
|
2017-06-23 12:43:43 +00:00
|
|
|
#include "ext_lzma.h"
|
2016-09-06 11:52:26 +00:00
|
|
|
#include "mpsp.h"
|
|
|
|
|
2017-11-13 20:05:40 +00:00
|
|
|
static const char *DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d";
|
2016-10-02 21:30:31 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
#define MAX_MFS 5 // 4*charset, 1*mask
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
static int sp_comp_val (const void *p1, const void *p2)
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2017-11-14 04:46:26 +00:00
|
|
|
const hcstat_table_t *b1 = (const hcstat_table_t *) p1;
|
|
|
|
const hcstat_table_t *b2 = (const hcstat_table_t *) p2;
|
2016-10-10 09:03:11 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
const u64 v1 = b1->val;
|
|
|
|
const u64 v2 = b2->val;
|
|
|
|
|
|
|
|
if (v1 < v2) return 1;
|
|
|
|
if (v1 > v2) return -1;
|
|
|
|
|
|
|
|
return 0;
|
2016-10-10 09:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig, u32 css_cnt_lr[2])
|
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
2016-10-10 09:03:11 +00:00
|
|
|
|
2016-10-04 06:52:56 +00:00
|
|
|
u32 css_cnt_l = mask_ctx->css_cnt;
|
|
|
|
u32 css_cnt_r;
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (user_options->slow_candidates == true)
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
css_cnt_r = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (css_cnt_orig < 6)
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
css_cnt_r = 1;
|
|
|
|
}
|
|
|
|
else if (css_cnt_orig == 6)
|
|
|
|
{
|
|
|
|
css_cnt_r = 2;
|
2016-10-04 06:52:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if ((hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE))
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (css_cnt_orig == 8 || css_cnt_orig == 10)
|
|
|
|
{
|
|
|
|
css_cnt_r = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
css_cnt_r = 4;
|
|
|
|
}
|
2016-10-04 06:52:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if ((mask_ctx->css_buf[0].cs_len * mask_ctx->css_buf[1].cs_len * mask_ctx->css_buf[2].cs_len) > 256)
|
|
|
|
{
|
|
|
|
css_cnt_r = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
css_cnt_r = 4;
|
|
|
|
}
|
2016-10-04 06:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
css_cnt_r = 1;
|
2016-10-04 06:52:56 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
/* unfinished code?
|
|
|
|
int sum = css_buf[css_cnt_r - 1].cs_len;
|
2016-10-04 06:52:56 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
for (u32 i = 1; i < 4 && i < css_cnt; i++)
|
|
|
|
{
|
|
|
|
if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
|
2016-10-04 06:52:56 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
css_cnt_r++;
|
2016-10-04 06:52:56 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
sum *= css_buf[css_cnt_r - 1].cs_len;
|
|
|
|
}
|
|
|
|
*/
|
2016-10-04 06:52:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
css_cnt_l -= css_cnt_r;
|
|
|
|
|
|
|
|
css_cnt_lr[0] = css_cnt_l;
|
|
|
|
css_cnt_lr[1] = css_cnt_r;
|
|
|
|
}
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
static int mp_css_append_salt (hashcat_ctx_t *hashcat_ctx, salt_t *salt_buf)
|
2016-10-04 06:52:56 +00:00
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
|
2017-11-05 08:52:29 +00:00
|
|
|
u32 salt_len = salt_buf->salt_len;
|
2016-10-04 06:52:56 +00:00
|
|
|
u8 *salt_buf_ptr = (u8 *) salt_buf->salt_buf;
|
|
|
|
|
|
|
|
u32 css_cnt_salt = mask_ctx->css_cnt + salt_len;
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
cs_t *css_buf_salt = (cs_t *) hccalloc (css_cnt_salt, sizeof (cs_t));
|
2016-10-04 06:52:56 +00:00
|
|
|
|
|
|
|
memcpy (css_buf_salt, mask_ctx->css_buf, mask_ctx->css_cnt * sizeof (cs_t));
|
|
|
|
|
|
|
|
for (u32 i = 0, j = mask_ctx->css_cnt; i < salt_len; i++, j++)
|
|
|
|
{
|
|
|
|
css_buf_salt[j].cs_buf[0] = salt_buf_ptr[i];
|
|
|
|
css_buf_salt[j].cs_len = 1;
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->css_buf);
|
2016-10-04 06:52:56 +00:00
|
|
|
|
|
|
|
mask_ctx->css_buf = css_buf_salt;
|
|
|
|
mask_ctx->css_cnt = css_cnt_salt;
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-10-04 06:52:56 +00:00
|
|
|
}
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
static int mp_css_utf16le_expand (hashcat_ctx_t *hashcat_ctx)
|
2016-10-04 06:21:03 +00:00
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
u32 css_cnt_utf16le = mask_ctx->css_cnt * 2;
|
2016-10-04 06:21:03 +00:00
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
cs_t *css_buf_utf16le = (cs_t *) hccalloc (css_cnt_utf16le, sizeof (cs_t));
|
2016-10-04 06:21:03 +00:00
|
|
|
|
|
|
|
for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2)
|
|
|
|
{
|
2017-06-05 10:15:28 +00:00
|
|
|
memcpy (&css_buf_utf16le[j + 0], &mask_ctx->css_buf[i], sizeof (cs_t));
|
2016-10-04 06:21:03 +00:00
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
css_buf_utf16le[j + 1].cs_buf[0] = 0;
|
|
|
|
css_buf_utf16le[j + 1].cs_len = 1;
|
2016-10-04 06:21:03 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->css_buf);
|
2016-10-04 06:21:03 +00:00
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
mask_ctx->css_buf = css_buf_utf16le;
|
|
|
|
mask_ctx->css_cnt = css_cnt_utf16le;
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-10-04 06:21:03 +00:00
|
|
|
}
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
static int mp_css_utf16be_expand (hashcat_ctx_t *hashcat_ctx)
|
2017-06-04 20:46:05 +00:00
|
|
|
{
|
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
u32 css_cnt_utf16be = mask_ctx->css_cnt * 2;
|
2017-06-04 20:46:05 +00:00
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
cs_t *css_buf_utf16be = (cs_t *) hccalloc (css_cnt_utf16be, sizeof (cs_t));
|
2017-06-04 20:46:05 +00:00
|
|
|
|
|
|
|
for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2)
|
|
|
|
{
|
2017-06-05 10:15:28 +00:00
|
|
|
css_buf_utf16be[j + 0].cs_buf[0] = 0;
|
|
|
|
css_buf_utf16be[j + 0].cs_len = 1;
|
2017-06-04 20:46:05 +00:00
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
memcpy (&css_buf_utf16be[j + 1], &mask_ctx->css_buf[i], sizeof (cs_t));
|
2017-06-04 20:46:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hcfree (mask_ctx->css_buf);
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
mask_ctx->css_buf = css_buf_utf16be;
|
|
|
|
mask_ctx->css_cnt = css_cnt_utf16be;
|
2017-06-04 20:46:05 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
static int mp_css_to_uniq_tbl (hashcat_ctx_t *hashcat_ctx, u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ])
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
/* generates a lookup table where key is the char itself for fastest possible lookup performance */
|
|
|
|
|
|
|
|
if (css_cnt > SP_PW_MAX)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Mask length is too long.");
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 css_pos = 0; css_pos < css_cnt; css_pos++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 *uniq_tbl = uniq_tbls[css_pos];
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 *cs_buf = css[css_pos].cs_buf;
|
|
|
|
u32 cs_len = css[css_pos].cs_len;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 cs_pos = 0; cs_pos < cs_len; cs_pos++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 c = cs_buf[cs_pos] & 0xff;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
uniq_tbl[c] = 1;
|
|
|
|
}
|
|
|
|
}
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 08:52:29 +00:00
|
|
|
static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, const u32 *in_buf, size_t in_len, cs_t *css, u32 css_cnt)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
cs_t *cs = &css[css_cnt];
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
size_t css_uniq_sz = CHARSIZ * sizeof (u32);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
u32 *css_uniq = (u32 *) hcmalloc (css_uniq_sz);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < cs->cs_len; i++)
|
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
const u32 u = cs->cs_buf[i];
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
css_uniq[u] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < in_len; i++)
|
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 u = in_buf[i] & 0xff;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) u = (u32) toupper (u);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
if (css_uniq[u] == 1) continue;
|
|
|
|
|
|
|
|
css_uniq[u] = 1;
|
|
|
|
|
|
|
|
cs->cs_buf[cs->cs_len] = u;
|
|
|
|
|
|
|
|
cs->cs_len++;
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (css_uniq);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-11-13 20:05:40 +00:00
|
|
|
static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
size_t in_pos;
|
|
|
|
|
|
|
|
for (in_pos = 0; in_pos < in_len; in_pos++)
|
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 p0 = in_buf[in_pos] & 0xff;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
if (interpret == 1 && p0 == '?')
|
|
|
|
{
|
|
|
|
in_pos++;
|
|
|
|
|
2018-10-16 13:59:20 +00:00
|
|
|
if (in_pos == in_len)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Syntax error in mask: %s", in_buf);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 p1 = in_buf[in_pos] & 0xff;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
switch (p1)
|
|
|
|
{
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-11-10 04:37:55 +00:00
|
|
|
case 'h': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[6].cs_buf, mp_sys[6].cs_len, mp_usr, mp_usr_offset);
|
|
|
|
break;
|
2016-11-10 18:25:04 +00:00
|
|
|
case 'H': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[7].cs_buf, mp_sys[7].cs_len, mp_usr, mp_usr_offset);
|
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2018-10-16 13:59:20 +00:00
|
|
|
default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", in_buf);
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-22 13:26:51 +00:00
|
|
|
if (user_options->hex_charset == true)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
in_pos++;
|
|
|
|
|
|
|
|
if (in_pos == in_len)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "The hex-charset option expects exactly 2 hexadecimal chars. Failed mask: %s", in_buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 p1 = in_buf[in_pos] & 0xff;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-09-30 16:39:31 +00:00
|
|
|
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-11 08:55:02 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", in_buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 chr = 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
chr = (u32) hex_convert ((u8) p1) << 0;
|
|
|
|
chr |= (u32) hex_convert ((u8) p0) << 4;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 chr = p0;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, mp_usr, mp_usr_offset);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, cs_t *css_buf, u32 *css_cnt)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 mask_pos;
|
|
|
|
u32 css_pos;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
for (mask_pos = 0, css_pos = 0; mask_pos < mask_len; mask_pos++, css_pos++)
|
|
|
|
{
|
|
|
|
char p0 = mask_buf[mask_pos];
|
|
|
|
|
|
|
|
if (p0 == '?')
|
|
|
|
{
|
|
|
|
mask_pos++;
|
|
|
|
|
2018-10-16 13:59:20 +00:00
|
|
|
if (mask_pos == mask_len)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Syntax error in mask: %s", mask_buf);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
char p1 = mask_buf[mask_pos];
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 chr = (u32) p1;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
switch (p1)
|
|
|
|
{
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'l': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[0].cs_buf, mp_sys[0].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'u': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[1].cs_buf, mp_sys[1].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'd': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[2].cs_buf, mp_sys[2].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 's': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[3].cs_buf, mp_sys[3].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'a': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[4].cs_buf, mp_sys[4].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case 'b': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[5].cs_buf, mp_sys[5].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-11-10 04:37:55 +00:00
|
|
|
case 'h': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[6].cs_buf, mp_sys[6].cs_len, css_buf, css_pos);
|
|
|
|
break;
|
2016-11-10 18:25:04 +00:00
|
|
|
case 'H': rc = mp_add_cs_buf (hashcat_ctx, mp_sys[7].cs_buf, mp_sys[7].cs_len, css_buf, css_pos);
|
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '1': if (mp_usr[0].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 1 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[0].cs_buf, mp_usr[0].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '2': if (mp_usr[1].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 2 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[1].cs_buf, mp_usr[1].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '3': if (mp_usr[2].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 3 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[2].cs_buf, mp_usr[2].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2017-04-02 07:50:06 +00:00
|
|
|
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; }
|
2016-10-13 08:07:04 +00:00
|
|
|
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2016-10-13 08:07:04 +00:00
|
|
|
case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
|
2016-09-06 11:52:26 +00:00
|
|
|
break;
|
2018-10-16 13:59:20 +00:00
|
|
|
default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", mask_buf);
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-22 13:26:51 +00:00
|
|
|
if (user_options->hex_charset == true)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
mask_pos++;
|
|
|
|
|
|
|
|
// if there is no 2nd hex character, show an error:
|
|
|
|
|
|
|
|
if (mask_pos == mask_len)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "The hex-charset option expects exactly 2 hexadecimal chars. Failed mask: %s", mask_buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char p1 = mask_buf[mask_pos];
|
|
|
|
|
|
|
|
// if they are not valid hex character, show an error:
|
|
|
|
|
2016-09-30 16:39:31 +00:00
|
|
|
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-11 08:55:02 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid hex character detected in mask %s", mask_buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 chr = 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
chr |= (u32) hex_convert ((u8) p1) << 0;
|
|
|
|
chr |= (u32) hex_convert ((u8) p0) << 4;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 chr = (u32) p0;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (css_pos == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid mask length (0).");
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*css_cnt = css_pos;
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len, char *new_mask_buf)
|
2016-10-09 20:41:55 +00:00
|
|
|
{
|
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
|
|
|
u32 mask_pos;
|
|
|
|
|
|
|
|
u32 css_pos;
|
|
|
|
|
|
|
|
for (mask_pos = 0, css_pos = 0; mask_pos < mask_len; mask_pos++, css_pos++)
|
|
|
|
{
|
|
|
|
if (css_pos == len) break;
|
|
|
|
|
|
|
|
char p0 = mask_buf[mask_pos];
|
|
|
|
|
|
|
|
new_mask_buf[mask_pos] = p0;
|
|
|
|
|
|
|
|
if (p0 == '?')
|
|
|
|
{
|
|
|
|
mask_pos++;
|
|
|
|
|
|
|
|
if (mask_pos == mask_len) break;
|
|
|
|
|
|
|
|
new_mask_buf[mask_pos] = mask_buf[mask_pos];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (user_options->hex_charset == true)
|
|
|
|
{
|
|
|
|
mask_pos++;
|
|
|
|
|
|
|
|
if (mask_pos == mask_len)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "The hex-charset option expects exactly 2 hexadecimal chars. Failed mask: %s", mask_buf);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-10-09 20:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char p1 = mask_buf[mask_pos];
|
|
|
|
|
|
|
|
// if they are not valid hex character, show an error:
|
|
|
|
|
|
|
|
if ((is_valid_hex_char ((u8) p0) == false) || (is_valid_hex_char ((u8) p1) == false))
|
|
|
|
{
|
2016-10-11 08:55:02 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid hex character detected in mask: %s", mask_buf);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return -1;
|
2016-10-09 20:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
new_mask_buf[mask_pos] = p1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
return 0;
|
2016-10-09 20:41:55 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
static void mp_setup_sys (cs_t *mp_sys)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 pos;
|
|
|
|
u32 chr;
|
|
|
|
u32 donec[CHARSIZ] = { 0 };
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (pos = 0, chr = 'a'; chr <= 'z'; chr++) { donec[chr] = 1;
|
|
|
|
mp_sys[0].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[0].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 'A'; chr <= 'Z'; chr++) { donec[chr] = 1;
|
|
|
|
mp_sys[1].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[1].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = '0'; chr <= '9'; chr++) { donec[chr] = 1;
|
|
|
|
mp_sys[2].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[2].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 0x20; chr <= 0x7e; chr++) { if (donec[chr]) continue;
|
|
|
|
mp_sys[3].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[3].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 0x20; chr <= 0x7e; chr++) { mp_sys[4].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[4].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 0x00; chr <= 0xff; chr++) { mp_sys[5].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[5].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 0x30; chr <= 0x39; chr++) { mp_sys[6].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[6].cs_len = pos; }
|
|
|
|
for (pos = 10, chr = 0x61; chr <= 0x66; chr++) { mp_sys[6].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[6].cs_len = pos; }
|
|
|
|
|
|
|
|
for (pos = 0, chr = 0x30; chr <= 0x39; chr++) { mp_sys[7].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[7].cs_len = pos; }
|
|
|
|
for (pos = 10, chr = 0x41; chr <= 0x46; chr++) { mp_sys[7].cs_buf[pos++] = chr;
|
|
|
|
mp_sys[7].cs_len = pos; }
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-11-13 20:05:40 +00:00
|
|
|
static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr, const char *buf, const u32 userindex)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
FILE *fp = fopen (buf, "rb");
|
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
if (fp == NULL) // feof() in case if file is empty
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2017-02-11 11:19:34 +00:00
|
|
|
const int rc = mp_expand (hashcat_ctx, buf, strlen (buf), mp_sys, mp_usr, userindex, 1);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-11-05 08:52:29 +00:00
|
|
|
char mp_file[1024];
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-07-06 08:35:25 +00:00
|
|
|
const size_t nread = hc_fread (mp_file, 1, sizeof (mp_file) - 1, fp);
|
2016-11-12 11:16:41 +00:00
|
|
|
|
|
|
|
if (!feof (fp))
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Custom charset file is too large.", buf);
|
2016-11-12 11:16:41 +00:00
|
|
|
|
2016-11-30 22:45:21 +00:00
|
|
|
fclose (fp);
|
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-11-05 08:52:29 +00:00
|
|
|
|
|
|
|
fclose (fp);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
if (nread == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Custom charset file is empty.", buf);
|
2016-10-30 15:08:41 +00:00
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-02-14 10:14:32 +00:00
|
|
|
mp_file[nread] = 0;
|
|
|
|
|
|
|
|
const size_t len = superchop_with_length (mp_file, nread);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Custom charset file is corrupted.", buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-11-12 11:28:47 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-11 11:19:34 +00:00
|
|
|
const int rc = mp_expand (hashcat_ctx, mp_file, len, mp_sys, mp_usr, userindex, 0);
|
2016-11-12 11:21:02 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-11 11:19:34 +00:00
|
|
|
static void mp_reset_usr (cs_t *mp_usr, const u32 userindex)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2017-02-11 11:19:34 +00:00
|
|
|
mp_usr[userindex].cs_len = 0;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-02-11 11:19:34 +00:00
|
|
|
memset (mp_usr[userindex].cs_buf, 0, sizeof (mp_usr[userindex].cs_buf));
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int sp_setup_tbl (hashcat_ctx_t *hashcat_ctx)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
char *shared_dir = folder_config->shared_dir;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2018-08-23 07:10:54 +00:00
|
|
|
char *hcstat = user_options->markov_hcstat2;
|
2016-10-31 10:28:06 +00:00
|
|
|
u32 disable = user_options->markov_disable;
|
|
|
|
u32 classic = user_options->markov_classic;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
hcstat_table_t *root_table_buf = mask_ctx->root_table_buf;
|
|
|
|
hcstat_table_t *markov_table_buf = mask_ctx->markov_table_buf;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize hcstats
|
|
|
|
*/
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
u64 *root_stats_buf = (u64 *) hccalloc (SP_ROOT_CNT, sizeof (u64));
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
u64 *root_stats_ptr = root_stats_buf;
|
|
|
|
|
|
|
|
u64 *root_stats_buf_by_pos[SP_PW_MAX];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
root_stats_buf_by_pos[i] = root_stats_ptr;
|
|
|
|
|
|
|
|
root_stats_ptr += CHARSIZ;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
u64 *markov_stats_buf = (u64 *) hccalloc (SP_MARKOV_CNT, sizeof (u64));
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
u64 *markov_stats_ptr = markov_stats_buf;
|
|
|
|
|
|
|
|
u64 *markov_stats_buf_by_key[SP_PW_MAX][CHARSIZ];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int j = 0; j < CHARSIZ; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
markov_stats_buf_by_key[i][j] = markov_stats_ptr;
|
|
|
|
|
|
|
|
markov_stats_ptr += CHARSIZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load hcstats File
|
|
|
|
*/
|
|
|
|
|
2017-02-14 14:19:05 +00:00
|
|
|
char hcstat_tmp[256];
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
if (hcstat == NULL)
|
|
|
|
{
|
2017-02-14 14:19:05 +00:00
|
|
|
snprintf (hcstat_tmp, sizeof (hcstat_tmp), "%s/%s", shared_dir, SP_HCSTAT);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
hcstat = hcstat_tmp;
|
|
|
|
}
|
|
|
|
|
2017-12-10 00:40:45 +00:00
|
|
|
struct stat s;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-12-10 00:40:45 +00:00
|
|
|
if (stat (hcstat, &s) == -1)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno));
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
FILE *fd = fopen (hcstat, "rb");
|
2017-06-23 10:13:51 +00:00
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
if (fd == NULL)
|
2017-06-23 10:13:51 +00:00
|
|
|
{
|
2017-06-23 12:43:43 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", hcstat, strerror (errno));
|
2017-06-23 10:13:51 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
u8 *inbuf = (u8 *) hcmalloc (s.st_size);
|
|
|
|
|
2017-07-06 08:35:25 +00:00
|
|
|
SizeT inlen = (SizeT) hc_fread (inbuf, 1, s.st_size, fd);
|
2017-06-23 12:43:43 +00:00
|
|
|
|
2017-06-23 12:50:44 +00:00
|
|
|
if (inlen != (SizeT) s.st_size)
|
2017-06-23 10:13:51 +00:00
|
|
|
{
|
2017-06-23 12:43:43 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Could not read data.", hcstat);
|
2017-06-23 10:13:51 +00:00
|
|
|
|
|
|
|
fclose (fd);
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
hcfree (inbuf);
|
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
fclose (fd);
|
|
|
|
|
|
|
|
u8 *outbuf = (u8 *) hcmalloc (SP_FILESZ);
|
|
|
|
|
2017-06-23 12:50:44 +00:00
|
|
|
SizeT outlen = SP_FILESZ;
|
2017-06-23 12:43:43 +00:00
|
|
|
|
2017-06-23 12:50:44 +00:00
|
|
|
const char props = 0x1c; // lzma properties constant, retrieved with 7z2hashcat
|
2017-06-23 12:43:43 +00:00
|
|
|
|
2017-06-23 12:50:44 +00:00
|
|
|
const SRes res = hc_lzma2_decompress (inbuf, &inlen, outbuf, &outlen, &props);
|
2017-06-23 12:43:43 +00:00
|
|
|
|
|
|
|
if (res != SZ_OK)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2017-06-23 12:43:43 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Could not uncompress data.", hcstat);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
hcfree (inbuf);
|
|
|
|
hcfree (outbuf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
if (outlen != SP_FILESZ)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2017-06-23 12:43:43 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: Could not uncompress data.", hcstat);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
hcfree (inbuf);
|
|
|
|
hcfree (outbuf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return -1;
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
|
2017-06-23 12:43:43 +00:00
|
|
|
u64 *ptr = (u64 *) outbuf;
|
|
|
|
|
|
|
|
u64 v = *ptr++;
|
|
|
|
u64 z = *ptr++;
|
|
|
|
|
|
|
|
memcpy (root_stats_buf, ptr, sizeof (u64) * SP_ROOT_CNT); ptr += SP_ROOT_CNT;
|
2017-11-05 08:52:29 +00:00
|
|
|
memcpy (markov_stats_buf, ptr, sizeof (u64) * SP_MARKOV_CNT); // ptr += SP_MARKOV_CNT;
|
2017-06-23 12:43:43 +00:00
|
|
|
|
|
|
|
hcfree (inbuf);
|
|
|
|
hcfree (outbuf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2017-06-23 10:13:51 +00:00
|
|
|
/**
|
|
|
|
* switch endianess
|
|
|
|
*/
|
|
|
|
|
|
|
|
v = byte_swap_64 (v);
|
|
|
|
z = byte_swap_64 (z);
|
|
|
|
|
|
|
|
for (int i = 0; i < SP_ROOT_CNT; i++) root_stats_buf[i] = byte_swap_64 (root_stats_buf[i]);
|
|
|
|
for (int i = 0; i < SP_MARKOV_CNT; i++) markov_stats_buf[i] = byte_swap_64 (markov_stats_buf[i]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* verify header
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (v != SP_VERSION)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "%s: Invalid header", hcstat);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (z != 0)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "%s: Invalid header", hcstat);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
/**
|
|
|
|
* Markov modifier of hcstat_table on user request
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (disable)
|
|
|
|
{
|
|
|
|
memset (root_stats_buf, 0, SP_ROOT_CNT * sizeof (u64));
|
|
|
|
memset (markov_stats_buf, 0, SP_MARKOV_CNT * sizeof (u64));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (classic)
|
|
|
|
{
|
|
|
|
/* Add all stats to first position */
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 1; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
u64 *out = root_stats_buf_by_pos[0];
|
|
|
|
u64 *in = root_stats_buf_by_pos[i];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int j = 0; j < CHARSIZ; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
*out++ += *in++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 1; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
u64 *out = markov_stats_buf_by_key[0][0];
|
|
|
|
u64 *in = markov_stats_buf_by_key[i][0];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int j = 0; j < CHARSIZ; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int k = 0; k < CHARSIZ; k++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
*out++ += *in++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy them to all pw_positions */
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 1; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
memcpy (root_stats_buf_by_pos[i], root_stats_buf_by_pos[0], CHARSIZ * sizeof (u64));
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 1; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
memcpy (markov_stats_buf_by_key[i][0], markov_stats_buf_by_key[0][0], CHARSIZ * CHARSIZ * sizeof (u64));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize tables
|
|
|
|
*/
|
|
|
|
|
|
|
|
hcstat_table_t *root_table_ptr = root_table_buf;
|
|
|
|
|
|
|
|
hcstat_table_t *root_table_buf_by_pos[SP_PW_MAX];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
root_table_buf_by_pos[i] = root_table_ptr;
|
|
|
|
|
|
|
|
root_table_ptr += CHARSIZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
hcstat_table_t *markov_table_ptr = markov_table_buf;
|
|
|
|
|
|
|
|
hcstat_table_t *markov_table_buf_by_key[SP_PW_MAX][CHARSIZ];
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int j = 0; j < CHARSIZ; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
markov_table_buf_by_key[i][j] = markov_table_ptr;
|
|
|
|
|
|
|
|
markov_table_ptr += CHARSIZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert hcstat to tables
|
|
|
|
*/
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_ROOT_CNT; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 key = i % CHARSIZ;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
root_table_buf[i].key = key;
|
|
|
|
root_table_buf[i].val = root_stats_buf[i];
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_MARKOV_CNT; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 key = i % CHARSIZ;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
markov_table_buf[i].key = key;
|
|
|
|
markov_table_buf[i].val = markov_stats_buf[i];
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (root_stats_buf);
|
|
|
|
hcfree (markov_stats_buf);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finally sort them
|
|
|
|
*/
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
qsort (root_table_buf_by_pos[i], CHARSIZ, sizeof (hcstat_table_t), sp_comp_val);
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int i = 0; i < SP_PW_MAX; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-11-16 14:16:53 +00:00
|
|
|
for (int j = 0; j < CHARSIZ; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
qsort (markov_table_buf_by_key[i][j], CHARSIZ, sizeof (hcstat_table_t), sp_comp_val);
|
|
|
|
}
|
|
|
|
}
|
2016-10-09 20:41:55 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-22 11:28:23 +00:00
|
|
|
static int sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf, u64 *result)
|
2016-10-09 20:41:55 +00:00
|
|
|
{
|
|
|
|
u64 sum = 1;
|
|
|
|
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = start; i < stop; i++)
|
|
|
|
{
|
2017-02-23 09:39:17 +00:00
|
|
|
if (overflow_check_u64_mul (sum, root_css_buf[i].cs_len) == false) return -1;
|
2017-02-22 11:28:23 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
sum *= root_css_buf[i].cs_len;
|
|
|
|
}
|
|
|
|
|
2017-02-22 11:28:23 +00:00
|
|
|
*result = sum;
|
|
|
|
|
|
|
|
return 0;
|
2016-10-09 20:41:55 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
static void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ])
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-09-26 15:50:47 +00:00
|
|
|
memset (root_css_buf, 0, SP_PW_MAX * sizeof (cs_t));
|
|
|
|
memset (markov_css_buf, 0, SP_PW_MAX * CHARSIZ * sizeof (cs_t));
|
|
|
|
|
2016-09-06 11:52:26 +00:00
|
|
|
/**
|
|
|
|
* Convert tables to css
|
|
|
|
*/
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 i = 0; i < SP_ROOT_CNT; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 pw_pos = i / CHARSIZ;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
cs_t *cs = &root_css_buf[pw_pos];
|
|
|
|
|
|
|
|
if (cs->cs_len == threshold) continue;
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 key = root_table_buf[i].key;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
if (uniq_tbls[pw_pos][key] == 0) continue;
|
|
|
|
|
|
|
|
cs->cs_buf[cs->cs_len] = key;
|
|
|
|
|
|
|
|
cs->cs_len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert table to css
|
|
|
|
*/
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 i = 0; i < SP_MARKOV_CNT; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 c = i / CHARSIZ;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
cs_t *cs = &markov_css_buf[c];
|
|
|
|
|
|
|
|
if (cs->cs_len == threshold) continue;
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 pw_pos = c / CHARSIZ;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 key = markov_table_buf[i].key;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
|
|
|
if ((pw_pos + 1) < SP_PW_MAX) if (uniq_tbls[pw_pos + 1][key] == 0) continue;
|
|
|
|
|
|
|
|
cs->cs_buf[cs->cs_len] = key;
|
|
|
|
|
|
|
|
cs->cs_len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 i = 0; i < 8; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 j = 0x20; j < 0x80; j++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
|
|
|
cs_t *ptr = &markov_css_buf[(i * CHARSIZ) + j];
|
|
|
|
|
2016-10-25 10:40:47 +00:00
|
|
|
printf ("pos:%u key:%u len:%u" EOL, i, j, ptr->cs_len);
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 k = 0; k < 10; k++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-25 10:40:47 +00:00
|
|
|
printf (" %u" EOL, ptr->cs_buf[k]);
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
u64 v = ctx;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
cs_t *cs = &root_css_buf[start];
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
u32 i;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
for (i = start; i < stop; i++)
|
2016-09-06 11:52:26 +00:00
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
const u64 m = v % cs->cs_len;
|
|
|
|
const u64 d = v / cs->cs_len;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
v = d;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
const u32 k = cs->cs_buf[m];
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
pw_buf[i - start] = (char) k;
|
2016-09-06 11:52:26 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
cs = &markov_css_buf[(i * CHARSIZ) + k];
|
2016-09-06 11:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
static int mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
|
2016-09-25 23:18:00 +00:00
|
|
|
if (mask_ctx->masks_avail == mask_ctx->masks_cnt)
|
|
|
|
{
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->masks = (char **) hcrealloc (mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
mask_ctx->masks_avail += INCR_MASKS;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->masks[mask_ctx->masks_cnt] = hcstrdup (mask);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
mask_ctx->masks_cnt++;
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask, const char *prepend)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-11-07 10:17:05 +00:00
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
2016-10-09 20:41:55 +00:00
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-25 23:18:00 +00:00
|
|
|
if (user_options->increment == true)
|
|
|
|
{
|
2016-11-07 10:17:05 +00:00
|
|
|
const u32 mask_length = mp_get_length (mask);
|
|
|
|
|
|
|
|
u32 increment_min = user_options->increment_min;
|
|
|
|
u32 increment_max = user_options->increment_max;
|
|
|
|
|
|
|
|
increment_max = MIN (increment_max, mask_length);
|
|
|
|
|
2016-12-18 15:01:23 +00:00
|
|
|
if (user_options->attack_mode == ATTACK_MODE_BF)
|
|
|
|
{
|
|
|
|
const u32 pw_min = hashconfig->pw_min;
|
|
|
|
const u32 pw_max = hashconfig->pw_max;
|
|
|
|
|
|
|
|
increment_min = MAX (increment_min, pw_min);
|
|
|
|
increment_max = MIN (increment_max, pw_max);
|
|
|
|
}
|
|
|
|
|
2016-11-07 10:17:05 +00:00
|
|
|
for (u32 increment_len = increment_min; increment_len <= increment_max; increment_len++)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-11-20 21:54:52 +00:00
|
|
|
char *mask_truncated = (char *) hcmalloc (256);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
char *mask_truncated_next = mask_truncated;
|
|
|
|
|
|
|
|
if (prepend)
|
|
|
|
{
|
|
|
|
// this happens with maskfiles only
|
|
|
|
|
|
|
|
mask_truncated_next += snprintf (mask_truncated, 256, "%s,", prepend);
|
|
|
|
}
|
|
|
|
|
|
|
|
const int rc_truncated_mask = mp_get_truncated_mask (hashcat_ctx, mask, strlen (mask), increment_len, mask_truncated_next);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2017-02-14 14:38:57 +00:00
|
|
|
if (rc_truncated_mask == -1)
|
|
|
|
{
|
|
|
|
hcfree (mask_truncated);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mask_append_final (hashcat_ctx, mask_truncated);
|
|
|
|
|
2017-02-14 15:46:41 +00:00
|
|
|
hcfree (mask_truncated);
|
2017-02-14 14:38:57 +00:00
|
|
|
|
2017-02-14 15:46:41 +00:00
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-28 21:11:35 +00:00
|
|
|
if (prepend)
|
|
|
|
{
|
|
|
|
// this happens with maskfiles only
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2016-12-28 21:11:35 +00:00
|
|
|
char *prepend_mask;
|
|
|
|
|
|
|
|
hc_asprintf (&prepend_mask, "%s,%s", prepend, mask);
|
|
|
|
|
|
|
|
const int rc = mask_append_final (hashcat_ctx, prepend_mask);
|
|
|
|
|
|
|
|
hcfree (prepend_mask);
|
2017-02-14 15:46:41 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-12-28 21:11:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const int rc = mask_append_final (hashcat_ctx, mask);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-11-07 10:17:05 +00:00
|
|
|
u32 mp_get_length (const char *mask)
|
2016-10-29 20:44:01 +00:00
|
|
|
{
|
|
|
|
u32 len = 0;
|
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
const size_t mask_len = strlen (mask);
|
2016-10-29 20:44:01 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
for (size_t i = 0; i < mask_len; i++)
|
2016-10-29 20:44:01 +00:00
|
|
|
{
|
|
|
|
if (mask[i] == '?') i++;
|
|
|
|
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
static char *mask_ctx_parse_maskfile_find_mask (char *line_buf, const size_t line_len)
|
2016-12-17 13:09:58 +00:00
|
|
|
{
|
|
|
|
char *mask_buf = line_buf;
|
|
|
|
|
|
|
|
bool escaped = false;
|
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
for (size_t i = 0; i < line_len; i++)
|
2016-12-17 13:09:58 +00:00
|
|
|
{
|
|
|
|
if (escaped == true)
|
|
|
|
{
|
|
|
|
escaped = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (line_buf[i] == '\\')
|
|
|
|
{
|
|
|
|
escaped = true;
|
|
|
|
}
|
|
|
|
else if (line_buf[i] == ',')
|
|
|
|
{
|
|
|
|
mask_buf = line_buf + i + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask_buf;
|
|
|
|
}
|
|
|
|
|
2016-10-06 20:00:02 +00:00
|
|
|
int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
|
|
|
|
{
|
|
|
|
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
hashes_t *hashes = hashcat_ctx->hashes;
|
|
|
|
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
|
|
|
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
|
|
|
if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
|
|
|
{
|
|
|
|
if (user_options->attack_mode == ATTACK_MODE_COMBI)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
|
|
|
|
{
|
2017-07-18 12:45:15 +00:00
|
|
|
if (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))
|
2017-06-30 14:51:57 +00:00
|
|
|
{
|
|
|
|
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
if (rc_mask_file == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
if (rc_gen_css == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
const int rc_get_sum = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &mask_ctx->bfs_cnt);
|
2017-02-22 11:28:23 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
if (rc_get_sum == -1)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2017-02-22 11:28:23 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
const int rc_update_mp = opencl_session_update_mp (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc_update_mp == -1) return -1;
|
2017-02-22 11:28:23 +00:00
|
|
|
}
|
2017-06-30 14:51:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
|
|
|
|
|
|
|
|
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc_mask_file == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-06-30 14:51:57 +00:00
|
|
|
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
|
|
|
|
|
|
|
|
if (rc_gen_css == -1) return -1;
|
|
|
|
|
|
|
|
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
|
|
|
|
|
|
|
|
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
|
|
|
|
|
|
|
|
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
|
|
|
|
|
|
|
|
const int rc_get_sum = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &combinator_ctx->combs_cnt);
|
|
|
|
|
|
|
|
if (rc_get_sum == -1)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int rc_update_mp = opencl_session_update_mp (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc_update_mp == -1) return -1;
|
|
|
|
}
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const int rc_update_combinator = opencl_session_update_combinator (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc_update_combinator == -1) return -1;
|
|
|
|
}
|
|
|
|
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
|
|
|
{
|
|
|
|
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
|
|
|
|
|
|
|
|
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc_mask_file == -1) return -1;
|
|
|
|
|
|
|
|
if (user_options->attack_mode == ATTACK_MODE_BF) // always true
|
|
|
|
{
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
|
2016-10-09 20:41:55 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
|
|
|
|
|
|
|
|
if (rc_gen_css == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2016-10-06 20:18:20 +00:00
|
|
|
// special case for benchmark
|
|
|
|
|
|
|
|
u32 pw_min = hashconfig->pw_min;
|
|
|
|
u32 pw_max = hashconfig->pw_max;
|
|
|
|
|
|
|
|
if (user_options->benchmark == true)
|
|
|
|
{
|
|
|
|
pw_min = mp_get_length (mask_ctx->mask);
|
|
|
|
pw_max = pw_min;
|
|
|
|
}
|
|
|
|
|
|
|
|
hashconfig->pw_min = pw_min;
|
|
|
|
hashconfig->pw_max = pw_max;
|
|
|
|
|
2016-11-12 14:46:42 +00:00
|
|
|
// check if mask is not too large or too small for pw_min/pw_max
|
2016-10-06 20:00:02 +00:00
|
|
|
|
|
|
|
u32 mask_min = hashconfig->pw_min;
|
|
|
|
u32 mask_max = hashconfig->pw_max;
|
|
|
|
|
|
|
|
if ((mask_ctx->css_cnt < mask_min) || (mask_ctx->css_cnt > mask_max))
|
|
|
|
{
|
|
|
|
if (mask_ctx->css_cnt < mask_min)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Skipping mask '%s' because it is smaller than the minimum password length.", mask_ctx->mask);
|
2018-01-03 13:46:49 +00:00
|
|
|
event_log_warning (hashcat_ctx, NULL);
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mask_ctx->css_cnt > mask_max)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Skipping mask '%s' because it is larger than the maximum password length.", mask_ctx->mask);
|
2018-01-03 13:46:49 +00:00
|
|
|
event_log_warning (hashcat_ctx, NULL);
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// skip to next mask
|
|
|
|
|
|
|
|
logfile_sub_msg ("STOP");
|
|
|
|
|
2018-01-03 13:46:49 +00:00
|
|
|
return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
|
2017-06-05 10:15:28 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE)
|
2017-06-04 20:46:05 +00:00
|
|
|
{
|
2017-06-05 10:15:28 +00:00
|
|
|
const int rc = mp_css_utf16le_expand (hashcat_ctx);
|
2017-06-04 20:46:05 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
|
|
|
}
|
2017-06-05 10:15:28 +00:00
|
|
|
else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)
|
2016-10-06 20:00:02 +00:00
|
|
|
{
|
2017-06-05 10:15:28 +00:00
|
|
|
const int rc = mp_css_utf16be_expand (hashcat_ctx);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 css_cnt_orig = mask_ctx->css_cnt;
|
|
|
|
|
|
|
|
if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH)
|
|
|
|
{
|
|
|
|
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
|
|
|
|
{
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = mp_css_append_salt (hashcat_ctx, &hashes->salts_buf[0]);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-10-06 20:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
|
2016-10-06 20:00:02 +00:00
|
|
|
|
|
|
|
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
|
|
|
|
|
2017-02-22 11:28:23 +00:00
|
|
|
const int rc_get_sum1 = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &status_ctx->words_cnt);
|
|
|
|
|
|
|
|
if (rc_get_sum1 == -1)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-10-06 20:00:02 +00:00
|
|
|
|
|
|
|
// copy + args
|
|
|
|
|
|
|
|
u32 css_cnt_lr[2];
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
mp_css_split_cnt (hashcat_ctx, css_cnt_orig, css_cnt_lr);
|
2016-10-06 20:00:02 +00:00
|
|
|
|
2017-02-22 11:28:23 +00:00
|
|
|
const int rc_get_sum2 = sp_get_sum (0, css_cnt_lr[1], mask_ctx->root_css_buf, &mask_ctx->bfs_cnt);
|
|
|
|
|
|
|
|
if (rc_get_sum2 == -1)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-10-06 20:00:02 +00:00
|
|
|
|
|
|
|
const int rc_update_mp_rl = opencl_session_update_mp_rl (hashcat_ctx, css_cnt_lr[0], css_cnt_lr[1]);
|
|
|
|
|
|
|
|
if (rc_update_mp_rl == -1) return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 08:14:19 +00:00
|
|
|
int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2018-12-15 15:24:37 +00:00
|
|
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
2016-10-06 08:14:19 +00:00
|
|
|
|
2016-09-26 13:11:46 +00:00
|
|
|
mask_ctx->enabled = false;
|
|
|
|
|
2017-08-22 09:09:46 +00:00
|
|
|
if (user_options->example_hashes == 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->usage == true) return 0;
|
|
|
|
if (user_options->version == true) return 0;
|
2016-09-30 10:13:52 +00:00
|
|
|
|
|
|
|
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) return 0;
|
|
|
|
if (user_options->attack_mode == ATTACK_MODE_COMBI) return 0;
|
2016-09-26 13:11:46 +00:00
|
|
|
|
|
|
|
mask_ctx->enabled = true;
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->root_table_buf = (hcstat_table_t *) hccalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
|
|
|
|
mask_ctx->markov_table_buf = (hcstat_table_t *) hccalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2018-02-07 21:32:01 +00:00
|
|
|
const int rc_setup_tbl = sp_setup_tbl (hashcat_ctx);
|
2018-02-07 17:47:55 +00:00
|
|
|
|
2018-02-07 21:32:01 +00:00
|
|
|
if (rc_setup_tbl == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->root_css_buf = (cs_t *) hccalloc (SP_PW_MAX, sizeof (cs_t));
|
|
|
|
mask_ctx->markov_css_buf = (cs_t *) hccalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
mask_ctx->css_cnt = 0;
|
|
|
|
mask_ctx->css_buf = NULL;
|
|
|
|
|
|
|
|
mask_ctx->mask_from_file = false;
|
|
|
|
|
|
|
|
mask_ctx->masks = NULL;
|
|
|
|
mask_ctx->masks_pos = 0;
|
|
|
|
mask_ctx->masks_cnt = 0;
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
mask_ctx->mfs = (mf_t *) hccalloc (MAX_MFS, sizeof (mf_t));
|
2016-09-27 18:02:12 +00:00
|
|
|
|
2016-09-25 23:18:00 +00:00
|
|
|
mp_setup_sys (mask_ctx->mp_sys);
|
|
|
|
|
2016-11-12 11:16:41 +00:00
|
|
|
if (user_options->custom_charset_1) { const int rc = mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0); if (rc == -1) return -1; }
|
|
|
|
if (user_options->custom_charset_2) { const int rc = mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1); if (rc == -1) return -1; }
|
|
|
|
if (user_options->custom_charset_3) { const int rc = mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2); if (rc == -1) return -1; }
|
|
|
|
if (user_options->custom_charset_4) { const int rc = mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3); if (rc == -1) return -1; }
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
if (user_options->attack_mode == ATTACK_MODE_BF)
|
|
|
|
{
|
|
|
|
if (user_options->benchmark == false)
|
|
|
|
{
|
2016-10-02 21:30:31 +00:00
|
|
|
if (user_options_extra->hc_workc)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-10-02 21:30:31 +00:00
|
|
|
char *arg = user_options_extra->hc_workv[0];
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_exist (arg) == false)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-12-17 13:09:58 +00:00
|
|
|
const int rc = mask_append (hashcat_ctx, arg, NULL);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mask_ctx->mask_from_file = true;
|
|
|
|
|
2016-10-02 21:30:31 +00:00
|
|
|
for (int i = 0; i < user_options_extra->hc_workc; i++)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-10-02 21:30:31 +00:00
|
|
|
arg = user_options_extra->hc_workv[i];
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_is_file (arg) == true)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
|
|
|
FILE *mask_fp = fopen (arg, "r");
|
|
|
|
|
|
|
|
if (mask_fp == NULL)
|
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
while (!feof (mask_fp))
|
|
|
|
{
|
2018-02-08 18:13:29 +00:00
|
|
|
const size_t line_len = fgetl (mask_fp, line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
if (line_len == 0) continue;
|
|
|
|
|
|
|
|
if (line_buf[0] == '#') continue;
|
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
char *mask_buf = mask_ctx_parse_maskfile_find_mask (line_buf, line_len);
|
|
|
|
|
|
|
|
char *prepend_buf = NULL;
|
|
|
|
|
|
|
|
if (line_buf != mask_buf)
|
|
|
|
{
|
|
|
|
// if we have custom charsets
|
|
|
|
|
|
|
|
prepend_buf = line_buf;
|
|
|
|
|
|
|
|
mask_buf[-1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int rc = mask_append (hashcat_ctx, mask_buf, prepend_buf);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2016-11-20 22:15:54 +00:00
|
|
|
if (rc == -1)
|
|
|
|
{
|
|
|
|
fclose (mask_fp);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
fclose (mask_fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: unsupported file type.", arg);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-02 21:30:31 +00:00
|
|
|
const char *mask = DEF_MASK;
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
const int rc = mask_append (hashcat_ctx, mask, NULL);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-15 15:24:37 +00:00
|
|
|
const char *mask = hashconfig->benchmark_mask;
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
const int rc = mask_append (hashcat_ctx, mask, NULL);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
|
|
|
|
{
|
|
|
|
// display
|
|
|
|
|
2016-10-02 21:30:31 +00:00
|
|
|
char *arg = user_options_extra->hc_workv[user_options_extra->hc_workc - 1];
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
// mod
|
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_exist (arg) == false)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-12-17 13:09:58 +00:00
|
|
|
const int rc = mask_append (hashcat_ctx, arg, NULL);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_is_file (arg) == true)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
|
|
|
mask_ctx->mask_from_file = true;
|
|
|
|
|
|
|
|
FILE *mask_fp = fopen (arg, "r");
|
|
|
|
|
|
|
|
if (mask_fp == NULL)
|
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
while (!feof (mask_fp))
|
|
|
|
{
|
2018-02-08 18:13:29 +00:00
|
|
|
const size_t line_len = fgetl (mask_fp, line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
if (line_len == 0) continue;
|
|
|
|
|
|
|
|
if (line_buf[0] == '#') continue;
|
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
char *mask_buf = mask_ctx_parse_maskfile_find_mask (line_buf, line_len);
|
|
|
|
|
|
|
|
char *prepend_buf = NULL;
|
|
|
|
|
|
|
|
if (line_buf != mask_buf)
|
|
|
|
{
|
|
|
|
// if we have custom charsets
|
|
|
|
|
|
|
|
prepend_buf = line_buf;
|
|
|
|
|
|
|
|
mask_buf[-1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int rc = mask_append (hashcat_ctx, mask_buf, prepend_buf);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2016-11-20 22:15:54 +00:00
|
|
|
if (rc == -1)
|
|
|
|
{
|
|
|
|
fclose (mask_fp);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
fclose (mask_fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: unsupported file type.", arg);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
|
|
|
|
{
|
|
|
|
// display
|
|
|
|
|
2016-10-02 21:30:31 +00:00
|
|
|
char *arg = user_options_extra->hc_workv[0];
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
// mod
|
|
|
|
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_exist (arg) == false)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-12-17 13:09:58 +00:00
|
|
|
const int rc = mask_append (hashcat_ctx, arg, NULL);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-27 10:46:45 +00:00
|
|
|
if (hc_path_is_file (arg) == true)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
|
|
|
mask_ctx->mask_from_file = true;
|
|
|
|
|
|
|
|
FILE *mask_fp = fopen (arg, "r");
|
|
|
|
|
|
|
|
if (mask_fp == NULL)
|
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", arg, strerror (errno));
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
while (!feof (mask_fp))
|
|
|
|
{
|
2018-02-08 18:13:29 +00:00
|
|
|
const size_t line_len = fgetl (mask_fp, line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
if (line_len == 0) continue;
|
|
|
|
|
|
|
|
if (line_buf[0] == '#') continue;
|
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
char *mask_buf = mask_ctx_parse_maskfile_find_mask (line_buf, line_len);
|
|
|
|
|
|
|
|
char *prepend_buf = NULL;
|
|
|
|
|
|
|
|
if (line_buf != mask_buf)
|
|
|
|
{
|
|
|
|
// if we have custom charsets
|
|
|
|
|
|
|
|
prepend_buf = line_buf;
|
|
|
|
|
|
|
|
mask_buf[-1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int rc = mask_append (hashcat_ctx, mask_buf, prepend_buf);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
2016-11-20 22:15:54 +00:00
|
|
|
if (rc == -1)
|
|
|
|
{
|
|
|
|
fclose (mask_fp);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (line_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
fclose (mask_fp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: unsupported file type.", arg);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mask_ctx->masks_cnt == 0)
|
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid mask.");
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask_ctx->mask = mask_ctx->masks[0];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 08:14:19 +00:00
|
|
|
void mask_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
2016-09-25 23:18:00 +00:00
|
|
|
{
|
2016-10-06 08:14:19 +00:00
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
|
2016-09-26 13:11:46 +00:00
|
|
|
if (mask_ctx->enabled == false) return;
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->css_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->root_css_buf);
|
|
|
|
hcfree (mask_ctx->markov_css_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->root_table_buf);
|
|
|
|
hcfree (mask_ctx->markov_table_buf);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
|
|
|
for (u32 mask_pos = 0; mask_pos < mask_ctx->masks_cnt; mask_pos++)
|
|
|
|
{
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->masks[mask_pos]);
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->masks);
|
2016-09-25 23:18:00 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (mask_ctx->mfs);
|
2016-09-27 18:02:12 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
memset (mask_ctx, 0, sizeof (mask_ctx_t));
|
2016-09-25 23:18:00 +00:00
|
|
|
}
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-10-06 08:14:19 +00:00
|
|
|
int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
|
2016-09-27 16:32:09 +00:00
|
|
|
{
|
2016-10-06 08:14:19 +00:00
|
|
|
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
if (mask_ctx->enabled == false) return 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
if (mask_ctx->mask_from_file == false) return 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
mf_t *mfs_buf = mask_ctx->mfs;
|
|
|
|
|
|
|
|
mfs_buf[0].mf_len = 0;
|
|
|
|
mfs_buf[1].mf_len = 0;
|
|
|
|
mfs_buf[2].mf_len = 0;
|
|
|
|
mfs_buf[3].mf_len = 0;
|
|
|
|
mfs_buf[4].mf_len = 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
size_t mfs_cnt = 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
char *mask_buf = mask_ctx->mask;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
const size_t mask_len = strlen (mask_buf);
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
bool escaped = false;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
for (size_t i = 0; i < mask_len; i++)
|
2016-09-27 18:02:12 +00:00
|
|
|
{
|
2016-12-17 13:09:58 +00:00
|
|
|
mf_t *mf = mfs_buf + mfs_cnt;
|
2016-09-27 18:02:12 +00:00
|
|
|
|
|
|
|
if (escaped == true)
|
|
|
|
{
|
|
|
|
escaped = false;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
mf->mf_buf[mf->mf_len] = mask_buf[i];
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
mf->mf_len++;
|
|
|
|
}
|
|
|
|
else
|
2016-09-27 16:32:09 +00:00
|
|
|
{
|
2016-09-27 18:02:12 +00:00
|
|
|
if (mask_buf[i] == '\\')
|
2016-09-27 16:32:09 +00:00
|
|
|
{
|
2016-09-27 18:02:12 +00:00
|
|
|
escaped = true;
|
|
|
|
}
|
|
|
|
else if (mask_buf[i] == ',')
|
|
|
|
{
|
|
|
|
mf->mf_buf[mf->mf_len] = 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
mfs_cnt++;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
if (mfs_cnt == MAX_MFS)
|
2016-09-27 18:02:12 +00:00
|
|
|
{
|
2017-04-02 07:50:06 +00:00
|
|
|
event_log_error (hashcat_ctx, "Invalid line '%s' in maskfile.", mask_buf);
|
2016-09-27 18:02:12 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-27 16:32:09 +00:00
|
|
|
}
|
2016-09-27 18:02:12 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
mf->mf_buf[mf->mf_len] = mask_buf[i];
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
mf->mf_len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
mf_t *mf = mfs_buf + mfs_cnt;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
mf->mf_buf[mf->mf_len] = 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-12-28 21:11:35 +00:00
|
|
|
user_options->custom_charset_1 = NULL;
|
|
|
|
user_options->custom_charset_2 = NULL;
|
|
|
|
user_options->custom_charset_3 = NULL;
|
|
|
|
user_options->custom_charset_4 = NULL;
|
|
|
|
|
|
|
|
mp_reset_usr (mask_ctx->mp_usr, 0);
|
|
|
|
mp_reset_usr (mask_ctx->mp_usr, 1);
|
|
|
|
mp_reset_usr (mask_ctx->mp_usr, 2);
|
|
|
|
mp_reset_usr (mask_ctx->mp_usr, 3);
|
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
for (size_t i = 0; i < mfs_cnt; i++)
|
2016-09-27 18:02:12 +00:00
|
|
|
{
|
|
|
|
switch (i)
|
2016-09-27 16:32:09 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2016-12-17 13:09:58 +00:00
|
|
|
user_options->custom_charset_1 = mfs_buf[0].mf_buf;
|
2016-10-09 20:41:55 +00:00
|
|
|
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0);
|
2016-09-27 16:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2016-12-17 13:09:58 +00:00
|
|
|
user_options->custom_charset_2 = mfs_buf[1].mf_buf;
|
2016-10-09 20:41:55 +00:00
|
|
|
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1);
|
2016-09-27 16:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2016-12-17 13:09:58 +00:00
|
|
|
user_options->custom_charset_3 = mfs_buf[2].mf_buf;
|
2016-10-09 20:41:55 +00:00
|
|
|
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2);
|
2016-09-27 16:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2016-12-17 13:09:58 +00:00
|
|
|
user_options->custom_charset_4 = mfs_buf[3].mf_buf;
|
2016-10-09 20:41:55 +00:00
|
|
|
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3);
|
2016-09-27 16:32:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 13:09:58 +00:00
|
|
|
mask_ctx->mask = mfs_buf[mfs_cnt].mf_buf;
|
2016-09-27 16:32:09 +00:00
|
|
|
|
2016-09-27 18:02:12 +00:00
|
|
|
return 0;
|
2016-09-27 16:32:09 +00:00
|
|
|
}
|