mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-23 00:28:11 +00:00
Backport -m 500 pure kernel code to -m 1600 enables using it on AMDGPU driver
This commit is contained in:
parent
d7d716f3ab
commit
cd88410781
@ -15,9 +15,6 @@
|
|||||||
#define COMPARE_S "inc_comp_single.cl"
|
#define COMPARE_S "inc_comp_single.cl"
|
||||||
#define COMPARE_M "inc_comp_multi.cl"
|
#define COMPARE_M "inc_comp_multi.cl"
|
||||||
|
|
||||||
#define PUTCHAR_LE(a,p,c) ((u8 *)(a))[(p)] = (u8) (c)
|
|
||||||
#define GETCHAR_LE(a,p) ((u8 *)(a))[(p)]
|
|
||||||
|
|
||||||
typedef struct md5crypt_tmp
|
typedef struct md5crypt_tmp
|
||||||
{
|
{
|
||||||
u32 digest_buf[4];
|
u32 digest_buf[4];
|
||||||
@ -170,152 +167,50 @@ KERNEL_FQ void m01600_loop (KERN_ATTR_TMPS (md5crypt_tmp_t))
|
|||||||
* digest
|
* digest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
u32 digest[4];
|
u32 digest[16] = { 0 };
|
||||||
|
|
||||||
digest[0] = tmps[gid].digest_buf[0];
|
digest[0] = tmps[gid].digest_buf[0];
|
||||||
digest[1] = tmps[gid].digest_buf[1];
|
digest[1] = tmps[gid].digest_buf[1];
|
||||||
digest[2] = tmps[gid].digest_buf[2];
|
digest[2] = tmps[gid].digest_buf[2];
|
||||||
digest[3] = tmps[gid].digest_buf[3];
|
digest[3] = tmps[gid].digest_buf[3];
|
||||||
|
|
||||||
u32 wpc_len[8];
|
|
||||||
|
|
||||||
wpc_len[0] = 16 + 0 + 0 + pw_len;
|
|
||||||
wpc_len[1] = pw_len + 0 + 0 + 16;
|
|
||||||
wpc_len[2] = 16 + salt_len + 0 + pw_len;
|
|
||||||
wpc_len[3] = pw_len + salt_len + 0 + 16;
|
|
||||||
wpc_len[4] = 16 + 0 + pw_len + pw_len;
|
|
||||||
wpc_len[5] = pw_len + 0 + pw_len + 16;
|
|
||||||
wpc_len[6] = 16 + salt_len + pw_len + pw_len;
|
|
||||||
wpc_len[7] = pw_len + salt_len + pw_len + 16;
|
|
||||||
|
|
||||||
// largest possible wpc_len[7] is not enough because of zero buffer loop
|
|
||||||
|
|
||||||
u32 wpc[8][64 + 64 + 64 + 64];
|
|
||||||
|
|
||||||
#ifdef _unroll
|
|
||||||
#pragma unroll
|
|
||||||
#endif
|
|
||||||
for (u32 i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
u32 block_len = 0;
|
|
||||||
|
|
||||||
if (i & 1)
|
|
||||||
{
|
|
||||||
for (u32 j = 0; j < pw_len; j++)
|
|
||||||
{
|
|
||||||
PUTCHAR_LE (wpc[i], block_len++, GETCHAR_LE (w, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
block_len += 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i & 2)
|
|
||||||
{
|
|
||||||
for (u32 j = 0; j < salt_len; j++)
|
|
||||||
{
|
|
||||||
PUTCHAR_LE (wpc[i], block_len++, GETCHAR_LE (s, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i & 4)
|
|
||||||
{
|
|
||||||
for (u32 j = 0; j < pw_len; j++)
|
|
||||||
{
|
|
||||||
PUTCHAR_LE (wpc[i], block_len++, GETCHAR_LE (w, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i & 1)
|
|
||||||
{
|
|
||||||
block_len += 16;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (u32 j = 0; j < pw_len; j++)
|
|
||||||
{
|
|
||||||
PUTCHAR_LE (wpc[i], block_len++, GETCHAR_LE (w, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _unroll
|
|
||||||
#pragma unroll
|
|
||||||
#endif
|
|
||||||
for (u32 i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
u32 *z = wpc[i] + ((wpc_len[i] / 64) * 16);
|
|
||||||
|
|
||||||
truncate_block_16x4_le_S (z + 0, z + 4, z + 8, z + 12, wpc_len[i] & 63);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loop
|
* loop
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (u32 i = 0, j = loop_pos; i < loop_cnt; i++, j++)
|
for (u32 i = 0, j = loop_pos; i < loop_cnt; i++, j++)
|
||||||
{
|
{
|
||||||
const u32 j1 = (j & 1) ? 1 : 0;
|
|
||||||
const u32 j3 = (j % 3) ? 2 : 0;
|
|
||||||
const u32 j7 = (j % 7) ? 4 : 0;
|
|
||||||
|
|
||||||
const u32 pc = j1 + j3 + j7;
|
|
||||||
|
|
||||||
if (j1)
|
|
||||||
{
|
|
||||||
const u32 off = wpc_len[pc] / 4;
|
|
||||||
const u32 mod = wpc_len[pc] % 4;
|
|
||||||
|
|
||||||
u32 *ptr = wpc[pc] + off - 4;
|
|
||||||
|
|
||||||
switch (mod)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
ptr[0] = digest[0];
|
|
||||||
ptr[1] = digest[1];
|
|
||||||
ptr[2] = digest[2];
|
|
||||||
ptr[3] = digest[3];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
ptr[0] = (ptr[0] & 0xff) | (digest[0] << 8);
|
|
||||||
ptr[1] = (digest[0] >> 24) | (digest[1] << 8);
|
|
||||||
ptr[2] = (digest[1] >> 24) | (digest[2] << 8);
|
|
||||||
ptr[3] = (digest[2] >> 24) | (digest[3] << 8);
|
|
||||||
ptr[4] = (digest[3] >> 24);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
ptr[0] = (ptr[0] & 0xffff) | (digest[0] << 16);
|
|
||||||
ptr[1] = (digest[0] >> 16) | (digest[1] << 16);
|
|
||||||
ptr[2] = (digest[1] >> 16) | (digest[2] << 16);
|
|
||||||
ptr[3] = (digest[2] >> 16) | (digest[3] << 16);
|
|
||||||
ptr[4] = (digest[3] >> 16);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
ptr[0] = (ptr[0] & 0xffffff) | (digest[0] << 24);
|
|
||||||
ptr[1] = (digest[0] >> 8) | (digest[1] << 24);
|
|
||||||
ptr[2] = (digest[1] >> 8) | (digest[2] << 24);
|
|
||||||
ptr[3] = (digest[2] >> 8) | (digest[3] << 24);
|
|
||||||
ptr[4] = (digest[3] >> 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wpc[pc][0] = digest[0];
|
|
||||||
wpc[pc][1] = digest[1];
|
|
||||||
wpc[pc][2] = digest[2];
|
|
||||||
wpc[pc][3] = digest[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
md5_ctx_t md5_ctx;
|
md5_ctx_t md5_ctx;
|
||||||
|
|
||||||
md5_init (&md5_ctx);
|
md5_init (&md5_ctx);
|
||||||
|
|
||||||
md5_update (&md5_ctx, wpc[pc], wpc_len[pc]);
|
if (j & 1)
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, w, pw_len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, digest, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j % 3)
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, s, salt_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j % 7)
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, w, pw_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j & 1)
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, digest, 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
md5_update (&md5_ctx, w, pw_len);
|
||||||
|
}
|
||||||
|
|
||||||
md5_final (&md5_ctx);
|
md5_final (&md5_ctx);
|
||||||
|
|
||||||
|
@ -166,17 +166,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con
|
|||||||
return pw_max;
|
return pw_max;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
|
|
||||||
{
|
|
||||||
// amdgpu-pro-18.50-708488-ubuntu-18.04: Segmentation fault
|
|
||||||
if ((device_param->device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == false))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
|
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
|
||||||
{
|
{
|
||||||
u32 *digest = (u32 *) digest_buf;
|
u32 *digest = (u32 *) digest_buf;
|
||||||
@ -320,6 +309,6 @@ void module_init (module_ctx_t *module_ctx)
|
|||||||
module_ctx->module_st_hash = module_st_hash;
|
module_ctx->module_st_hash = module_st_hash;
|
||||||
module_ctx->module_st_pass = module_st_pass;
|
module_ctx->module_st_pass = module_st_pass;
|
||||||
module_ctx->module_tmp_size = module_tmp_size;
|
module_ctx->module_tmp_size = module_tmp_size;
|
||||||
module_ctx->module_unstable_warning = module_unstable_warning;
|
module_ctx->module_unstable_warning = MODULE_DEFAULT;
|
||||||
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user