mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-28 00:21:18 +00:00
Added hash-mode: Windows Hello PIN/Password
This commit is contained in:
parent
93ba57f183
commit
d2ccd96da6
461
OpenCL/m28100-pure.cl
Normal file
461
OpenCL/m28100-pure.cl
Normal file
@ -0,0 +1,461 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#define NEW_SIMD_CODE
|
||||
|
||||
#ifdef KERNEL_STATIC
|
||||
#include "inc_vendor.h"
|
||||
#include "inc_types.h"
|
||||
#include "inc_platform.cl"
|
||||
#include "inc_common.cl"
|
||||
#include "inc_simd.cl"
|
||||
#include "inc_hash_md4.cl"
|
||||
#include "inc_hash_sha256.cl"
|
||||
#include "inc_hash_sha512.cl"
|
||||
#endif
|
||||
|
||||
#define COMPARE_S "inc_comp_single.cl"
|
||||
#define COMPARE_M "inc_comp_multi.cl"
|
||||
|
||||
typedef struct winhello
|
||||
{
|
||||
// we need a lot of padding here because sha512_update expects them to be multiple of 128
|
||||
|
||||
u32 mk_buf[16];
|
||||
u32 mk_buf_pc[8];
|
||||
u32 hmac_buf[32];
|
||||
u32 blob_buf[256];
|
||||
u32 magicv_buf[32];
|
||||
|
||||
int mk_len;
|
||||
int hmac_len;
|
||||
int blob_len;
|
||||
int magicv_len;
|
||||
|
||||
} winhello_t;
|
||||
|
||||
typedef struct winhello_tmp
|
||||
{
|
||||
u32 ipad[8];
|
||||
u32 opad[8];
|
||||
|
||||
u32 dgst[8];
|
||||
u32 out[8];
|
||||
|
||||
} winhello_tmp_t;
|
||||
|
||||
DECLSPEC void hmac_sha256_run_V (u32x *w0, u32x *w1, u32x *w2, u32x *w3, u32x *ipad, u32x *opad, u32x *digest)
|
||||
{
|
||||
digest[0] = ipad[0];
|
||||
digest[1] = ipad[1];
|
||||
digest[2] = ipad[2];
|
||||
digest[3] = ipad[3];
|
||||
digest[4] = ipad[4];
|
||||
digest[5] = ipad[5];
|
||||
digest[6] = ipad[6];
|
||||
digest[7] = ipad[7];
|
||||
|
||||
sha256_transform_vector (w0, w1, w2, w3, digest);
|
||||
|
||||
w0[0] = digest[0];
|
||||
w0[1] = digest[1];
|
||||
w0[2] = digest[2];
|
||||
w0[3] = digest[3];
|
||||
w1[0] = digest[4];
|
||||
w1[1] = digest[5];
|
||||
w1[2] = digest[6];
|
||||
w1[3] = digest[7];
|
||||
w2[0] = 0x80000000;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = (64 + 32) * 8;
|
||||
|
||||
digest[0] = opad[0];
|
||||
digest[1] = opad[1];
|
||||
digest[2] = opad[2];
|
||||
digest[3] = opad[3];
|
||||
digest[4] = opad[4];
|
||||
digest[5] = opad[5];
|
||||
digest[6] = opad[6];
|
||||
digest[7] = opad[7];
|
||||
|
||||
sha256_transform_vector (w0, w1, w2, w3, digest);
|
||||
}
|
||||
|
||||
KERNEL_FQ void m28100_init (KERN_ATTR_TMPS_ESALT (winhello_tmp_t, winhello_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= gid_max) return;
|
||||
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const int pw_len = pws[gid].pw_len & 127;
|
||||
|
||||
u32 w[128] = { 0 };
|
||||
|
||||
for (int i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
|
||||
{
|
||||
w[idx] = pws[gid].i[idx];
|
||||
}
|
||||
|
||||
u8 *w_ptr = (u8 *) w;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (int i = pw_len - 1; i >= 0; i--)
|
||||
{
|
||||
const u8 c = w_ptr[i];
|
||||
|
||||
const u8 c0 = (c >> 0) & 15;
|
||||
const u8 c1 = (c >> 4) & 15;
|
||||
|
||||
w_ptr[(i * 4) + 0] = (c1 < 10) ? '0' + c1 : 'A' - 10 + c1;
|
||||
w_ptr[(i * 4) + 1] = 0;
|
||||
w_ptr[(i * 4) + 2] = (c0 < 10) ? '0' + c0 : 'A' - 10 + c0;
|
||||
w_ptr[(i * 4) + 3] = 0;
|
||||
}
|
||||
|
||||
sha256_hmac_ctx_t sha256_hmac_ctx;
|
||||
|
||||
sha256_hmac_init_swap (&sha256_hmac_ctx, w, pw_len * 4);
|
||||
|
||||
tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0];
|
||||
tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1];
|
||||
tmps[gid].ipad[2] = sha256_hmac_ctx.ipad.h[2];
|
||||
tmps[gid].ipad[3] = sha256_hmac_ctx.ipad.h[3];
|
||||
tmps[gid].ipad[4] = sha256_hmac_ctx.ipad.h[4];
|
||||
tmps[gid].ipad[5] = sha256_hmac_ctx.ipad.h[5];
|
||||
tmps[gid].ipad[6] = sha256_hmac_ctx.ipad.h[6];
|
||||
tmps[gid].ipad[7] = sha256_hmac_ctx.ipad.h[7];
|
||||
|
||||
tmps[gid].opad[0] = sha256_hmac_ctx.opad.h[0];
|
||||
tmps[gid].opad[1] = sha256_hmac_ctx.opad.h[1];
|
||||
tmps[gid].opad[2] = sha256_hmac_ctx.opad.h[2];
|
||||
tmps[gid].opad[3] = sha256_hmac_ctx.opad.h[3];
|
||||
tmps[gid].opad[4] = sha256_hmac_ctx.opad.h[4];
|
||||
tmps[gid].opad[5] = sha256_hmac_ctx.opad.h[5];
|
||||
tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7];
|
||||
|
||||
sha256_hmac_update_global (&sha256_hmac_ctx, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
|
||||
{
|
||||
sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx;
|
||||
|
||||
u32 w0[4];
|
||||
u32 w1[4];
|
||||
u32 w2[4];
|
||||
u32 w3[4];
|
||||
|
||||
w0[0] = j;
|
||||
w0[1] = 0;
|
||||
w0[2] = 0;
|
||||
w0[3] = 0;
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4);
|
||||
|
||||
sha256_hmac_final (&sha256_hmac_ctx2);
|
||||
|
||||
tmps[gid].dgst[i + 0] = sha256_hmac_ctx2.opad.h[0];
|
||||
tmps[gid].dgst[i + 1] = sha256_hmac_ctx2.opad.h[1];
|
||||
tmps[gid].dgst[i + 2] = sha256_hmac_ctx2.opad.h[2];
|
||||
tmps[gid].dgst[i + 3] = sha256_hmac_ctx2.opad.h[3];
|
||||
tmps[gid].dgst[i + 4] = sha256_hmac_ctx2.opad.h[4];
|
||||
tmps[gid].dgst[i + 5] = sha256_hmac_ctx2.opad.h[5];
|
||||
tmps[gid].dgst[i + 6] = sha256_hmac_ctx2.opad.h[6];
|
||||
tmps[gid].dgst[i + 7] = sha256_hmac_ctx2.opad.h[7];
|
||||
|
||||
tmps[gid].out[i + 0] = tmps[gid].dgst[i + 0];
|
||||
tmps[gid].out[i + 1] = tmps[gid].dgst[i + 1];
|
||||
tmps[gid].out[i + 2] = tmps[gid].dgst[i + 2];
|
||||
tmps[gid].out[i + 3] = tmps[gid].dgst[i + 3];
|
||||
tmps[gid].out[i + 4] = tmps[gid].dgst[i + 4];
|
||||
tmps[gid].out[i + 5] = tmps[gid].dgst[i + 5];
|
||||
tmps[gid].out[i + 6] = tmps[gid].dgst[i + 6];
|
||||
tmps[gid].out[i + 7] = tmps[gid].dgst[i + 7];
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m28100_loop (KERN_ATTR_TMPS_ESALT (winhello_tmp_t, winhello_t))
|
||||
{
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if ((gid * VECT_SIZE) >= gid_max) return;
|
||||
|
||||
u32x ipad[8];
|
||||
u32x opad[8];
|
||||
|
||||
ipad[0] = packv (tmps, ipad, gid, 0);
|
||||
ipad[1] = packv (tmps, ipad, gid, 1);
|
||||
ipad[2] = packv (tmps, ipad, gid, 2);
|
||||
ipad[3] = packv (tmps, ipad, gid, 3);
|
||||
ipad[4] = packv (tmps, ipad, gid, 4);
|
||||
ipad[5] = packv (tmps, ipad, gid, 5);
|
||||
ipad[6] = packv (tmps, ipad, gid, 6);
|
||||
ipad[7] = packv (tmps, ipad, gid, 7);
|
||||
|
||||
opad[0] = packv (tmps, opad, gid, 0);
|
||||
opad[1] = packv (tmps, opad, gid, 1);
|
||||
opad[2] = packv (tmps, opad, gid, 2);
|
||||
opad[3] = packv (tmps, opad, gid, 3);
|
||||
opad[4] = packv (tmps, opad, gid, 4);
|
||||
opad[5] = packv (tmps, opad, gid, 5);
|
||||
opad[6] = packv (tmps, opad, gid, 6);
|
||||
opad[7] = packv (tmps, opad, gid, 7);
|
||||
|
||||
for (u32 i = 0; i < 8; i += 8)
|
||||
{
|
||||
u32x dgst[8];
|
||||
u32x out[8];
|
||||
|
||||
dgst[0] = packv (tmps, dgst, gid, i + 0);
|
||||
dgst[1] = packv (tmps, dgst, gid, i + 1);
|
||||
dgst[2] = packv (tmps, dgst, gid, i + 2);
|
||||
dgst[3] = packv (tmps, dgst, gid, i + 3);
|
||||
dgst[4] = packv (tmps, dgst, gid, i + 4);
|
||||
dgst[5] = packv (tmps, dgst, gid, i + 5);
|
||||
dgst[6] = packv (tmps, dgst, gid, i + 6);
|
||||
dgst[7] = packv (tmps, dgst, gid, i + 7);
|
||||
|
||||
out[0] = packv (tmps, out, gid, i + 0);
|
||||
out[1] = packv (tmps, out, gid, i + 1);
|
||||
out[2] = packv (tmps, out, gid, i + 2);
|
||||
out[3] = packv (tmps, out, gid, i + 3);
|
||||
out[4] = packv (tmps, out, gid, i + 4);
|
||||
out[5] = packv (tmps, out, gid, i + 5);
|
||||
out[6] = packv (tmps, out, gid, i + 6);
|
||||
out[7] = packv (tmps, out, gid, i + 7);
|
||||
|
||||
for (u32 j = 0; j < loop_cnt; j++)
|
||||
{
|
||||
u32x w0[4];
|
||||
u32x w1[4];
|
||||
u32x w2[4];
|
||||
u32x w3[4];
|
||||
|
||||
w0[0] = dgst[0];
|
||||
w0[1] = dgst[1];
|
||||
w0[2] = dgst[2];
|
||||
w0[3] = dgst[3];
|
||||
w1[0] = dgst[4];
|
||||
w1[1] = dgst[5];
|
||||
w1[2] = dgst[6];
|
||||
w1[3] = dgst[7];
|
||||
w2[0] = 0x80000000;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = (64 + 32) * 8;
|
||||
|
||||
hmac_sha256_run_V (w0, w1, w2, w3, ipad, opad, dgst);
|
||||
|
||||
out[0] ^= dgst[0];
|
||||
out[1] ^= dgst[1];
|
||||
out[2] ^= dgst[2];
|
||||
out[3] ^= dgst[3];
|
||||
out[4] ^= dgst[4];
|
||||
out[5] ^= dgst[5];
|
||||
out[6] ^= dgst[6];
|
||||
out[7] ^= dgst[7];
|
||||
}
|
||||
|
||||
unpackv (tmps, dgst, gid, i + 0, dgst[0]);
|
||||
unpackv (tmps, dgst, gid, i + 1, dgst[1]);
|
||||
unpackv (tmps, dgst, gid, i + 2, dgst[2]);
|
||||
unpackv (tmps, dgst, gid, i + 3, dgst[3]);
|
||||
unpackv (tmps, dgst, gid, i + 4, dgst[4]);
|
||||
unpackv (tmps, dgst, gid, i + 5, dgst[5]);
|
||||
unpackv (tmps, dgst, gid, i + 6, dgst[6]);
|
||||
unpackv (tmps, dgst, gid, i + 7, dgst[7]);
|
||||
|
||||
unpackv (tmps, out, gid, i + 0, out[0]);
|
||||
unpackv (tmps, out, gid, i + 1, out[1]);
|
||||
unpackv (tmps, out, gid, i + 2, out[2]);
|
||||
unpackv (tmps, out, gid, i + 3, out[3]);
|
||||
unpackv (tmps, out, gid, i + 4, out[4]);
|
||||
unpackv (tmps, out, gid, i + 5, out[5]);
|
||||
unpackv (tmps, out, gid, i + 6, out[6]);
|
||||
unpackv (tmps, out, gid, i + 7, out[7]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m28100_comp (KERN_ATTR_TMPS_ESALT (winhello_tmp_t, winhello_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= gid_max) return;
|
||||
|
||||
const u64 lid = get_local_id (0);
|
||||
|
||||
u32 w[32];
|
||||
|
||||
w[0] = hc_swap32_S (tmps[gid].out[0]);
|
||||
w[1] = hc_swap32_S (tmps[gid].out[1]);
|
||||
w[2] = hc_swap32_S (tmps[gid].out[2]);
|
||||
w[3] = hc_swap32_S (tmps[gid].out[3]);
|
||||
w[4] = hc_swap32_S (tmps[gid].out[4]);
|
||||
w[5] = hc_swap32_S (tmps[gid].out[5]);
|
||||
w[6] = hc_swap32_S (tmps[gid].out[6]);
|
||||
w[7] = hc_swap32_S (tmps[gid].out[7]);
|
||||
|
||||
u8 *w_ptr = (u8 *) w;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (int i = 31; i >= 0; i--)
|
||||
{
|
||||
const u8 c = w_ptr[i];
|
||||
|
||||
const u8 c0 = (c >> 0) & 15;
|
||||
const u8 c1 = (c >> 4) & 15;
|
||||
|
||||
w_ptr[(i * 4) + 0] = (c1 < 10) ? '0' + c1 : 'A' - 10 + c1;
|
||||
w_ptr[(i * 4) + 1] = 0;
|
||||
w_ptr[(i * 4) + 2] = (c0 < 10) ? '0' + c0 : 'A' - 10 + c0;
|
||||
w_ptr[(i * 4) + 3] = 0;
|
||||
}
|
||||
|
||||
sha512_ctx_t ctx1;
|
||||
|
||||
sha512_init (&ctx1);
|
||||
|
||||
sha512_update_swap (&ctx1, w, 128);
|
||||
|
||||
sha512_final (&ctx1);
|
||||
|
||||
u32 stage4_sha512[32] = { 0 };
|
||||
|
||||
stage4_sha512[ 0] = h32_from_64_S (ctx1.h[0]);
|
||||
stage4_sha512[ 1] = l32_from_64_S (ctx1.h[0]);
|
||||
stage4_sha512[ 2] = h32_from_64_S (ctx1.h[1]);
|
||||
stage4_sha512[ 3] = l32_from_64_S (ctx1.h[1]);
|
||||
stage4_sha512[ 4] = h32_from_64_S (ctx1.h[2]);
|
||||
stage4_sha512[ 5] = l32_from_64_S (ctx1.h[2]);
|
||||
stage4_sha512[ 6] = h32_from_64_S (ctx1.h[3]);
|
||||
stage4_sha512[ 7] = l32_from_64_S (ctx1.h[3]);
|
||||
stage4_sha512[ 8] = h32_from_64_S (ctx1.h[4]);
|
||||
stage4_sha512[ 9] = l32_from_64_S (ctx1.h[4]);
|
||||
stage4_sha512[10] = h32_from_64_S (ctx1.h[5]);
|
||||
stage4_sha512[11] = l32_from_64_S (ctx1.h[5]);
|
||||
stage4_sha512[12] = h32_from_64_S (ctx1.h[6]);
|
||||
stage4_sha512[13] = l32_from_64_S (ctx1.h[6]);
|
||||
stage4_sha512[14] = h32_from_64_S (ctx1.h[7]);
|
||||
stage4_sha512[15] = l32_from_64_S (ctx1.h[7]);
|
||||
|
||||
// stage4_sha512 ready in ctx.h[]
|
||||
|
||||
u32 sub_digest_seed[32];
|
||||
|
||||
for (int i = 0; i < 32; i++) sub_digest_seed[i] = 0x36363636;
|
||||
|
||||
sub_digest_seed[0] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[0];
|
||||
sub_digest_seed[1] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[1];
|
||||
sub_digest_seed[2] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[2];
|
||||
sub_digest_seed[3] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[3];
|
||||
sub_digest_seed[4] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[4];
|
||||
|
||||
// sub_digest
|
||||
|
||||
sha512_ctx_t ctx2;
|
||||
|
||||
sha512_init (&ctx2);
|
||||
|
||||
sha512_update (&ctx2, sub_digest_seed, 128);
|
||||
sha512_update_global (&ctx2, esalt_bufs[DIGESTS_OFFSET].hmac_buf,
|
||||
esalt_bufs[DIGESTS_OFFSET].hmac_len);
|
||||
sha512_update_global (&ctx2, esalt_bufs[DIGESTS_OFFSET].magicv_buf,
|
||||
esalt_bufs[DIGESTS_OFFSET].magicv_len);
|
||||
sha512_update (&ctx2, stage4_sha512, 64);
|
||||
sha512_update_global (&ctx2, esalt_bufs[DIGESTS_OFFSET].blob_buf,
|
||||
esalt_bufs[DIGESTS_OFFSET].blob_len);
|
||||
|
||||
sha512_final (&ctx2);
|
||||
|
||||
u32 sub_digest[32] = { 0 };
|
||||
|
||||
sub_digest[ 0] = h32_from_64_S (ctx2.h[0]);
|
||||
sub_digest[ 1] = l32_from_64_S (ctx2.h[0]);
|
||||
sub_digest[ 2] = h32_from_64_S (ctx2.h[1]);
|
||||
sub_digest[ 3] = l32_from_64_S (ctx2.h[1]);
|
||||
sub_digest[ 4] = h32_from_64_S (ctx2.h[2]);
|
||||
sub_digest[ 5] = l32_from_64_S (ctx2.h[2]);
|
||||
sub_digest[ 6] = h32_from_64_S (ctx2.h[3]);
|
||||
sub_digest[ 7] = l32_from_64_S (ctx2.h[3]);
|
||||
sub_digest[ 8] = h32_from_64_S (ctx2.h[4]);
|
||||
sub_digest[ 9] = l32_from_64_S (ctx2.h[4]);
|
||||
sub_digest[10] = h32_from_64_S (ctx2.h[5]);
|
||||
sub_digest[11] = l32_from_64_S (ctx2.h[5]);
|
||||
sub_digest[12] = h32_from_64_S (ctx2.h[6]);
|
||||
sub_digest[13] = l32_from_64_S (ctx2.h[6]);
|
||||
sub_digest[14] = h32_from_64_S (ctx2.h[7]);
|
||||
sub_digest[15] = l32_from_64_S (ctx2.h[7]);
|
||||
|
||||
// main_digest_seed
|
||||
|
||||
u32 main_digest_seed[32];
|
||||
|
||||
for (int i = 0; i < 32; i++) main_digest_seed[i] = 0x5c5c5c5c;
|
||||
|
||||
main_digest_seed[0] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[0];
|
||||
main_digest_seed[1] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[1];
|
||||
main_digest_seed[2] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[2];
|
||||
main_digest_seed[3] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[3];
|
||||
main_digest_seed[4] ^= esalt_bufs[DIGESTS_OFFSET].mk_buf_pc[4];
|
||||
|
||||
// main_digest
|
||||
|
||||
sha512_ctx_t ctx3;
|
||||
|
||||
sha512_init (&ctx3);
|
||||
|
||||
sha512_update (&ctx3, main_digest_seed, 128);
|
||||
sha512_update (&ctx3, sub_digest, 64);
|
||||
|
||||
sha512_final (&ctx3);
|
||||
|
||||
const u32 r0 = l32_from_64_S (ctx3.h[0]);
|
||||
const u32 r1 = h32_from_64_S (ctx3.h[0]);
|
||||
const u32 r2 = l32_from_64_S (ctx3.h[1]);
|
||||
const u32 r3 = h32_from_64_S (ctx3.h[1]);
|
||||
|
||||
#define il_pos 0
|
||||
|
||||
#ifdef KERNEL_STATIC
|
||||
#include COMPARE_M
|
||||
#endif
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
- Added hash-mode: CRC64Jones
|
||||
- Added hash-mode: MultiBit Classic .wallet (scrypt)
|
||||
- Added hash-mode: MurmurHash3
|
||||
- Added hash-mode: Windows Hello PIN/Password
|
||||
|
||||
##
|
||||
## Performance
|
||||
|
@ -203,6 +203,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or
|
||||
- NTLM
|
||||
- Radmin2
|
||||
- Samsung Android Password/PIN
|
||||
- Windows Hello PIN/Password
|
||||
- Windows Phone 8+ PIN/password
|
||||
- Cisco-ASA MD5
|
||||
- Cisco-IOS $8$ (PBKDF2-SHA256)
|
||||
|
460
src/modules/module_28100.c
Normal file
460
src/modules/module_28100.c
Normal file
@ -0,0 +1,460 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "modules.h"
|
||||
#include "bitops.h"
|
||||
#include "convert.h"
|
||||
#include "shared.h"
|
||||
#include "emu_inc_hash_sha1.h"
|
||||
|
||||
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
|
||||
static const u32 DGST_POS0 = 0;
|
||||
static const u32 DGST_POS1 = 1;
|
||||
static const u32 DGST_POS2 = 2;
|
||||
static const u32 DGST_POS3 = 3;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_8_8;
|
||||
static const u32 HASH_CATEGORY = HASH_CATEGORY_OS;
|
||||
static const char *HASH_NAME = "Windows Hello PIN/Password";
|
||||
static const u64 KERN_TYPE = 28100;
|
||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "$WINHELLO$*SHA512*10000*00761655*3b3d3197efb2839a6072e922cc03be910be55d1e60389689c05b520d2d57c06258dc5a48798ba65424004cbe2e003d0509036f3394bcae108eb6b77c7eb306d7*c0772a3aca949db60f274f315b3a5f63fea552fc0d1f2032db5293ca9690735217d918d4cf697aa45b2fe598168804040e18fe00758be94aac971985ea7a5521*bff47e398df761733b5aeda7035cdf289547db3afb94b70cbad2aaea21a5cd58*8a4d5b88832e10bad57303324e6c9021733733df4acbf91366f51cebdc755e00fe1d01b3202469ee6ad5e667975b4f50e3110b00ef60414cd2cf96cc47df532e36b997727ffec2924d979d3fb6e677cb5827f4313131a46be8712926c42158339b55183e2fd7f2f0761980b1413897825c3759c566ff8a438189a6c8fb2d630dc33c6330de45c784d11957c686b40b6fe31fd8f2b1b664f542392326af5d334fdf92155343335e1b964955ac0b0e6f7254a599f0f0dc99becc2216515ba9e9472a54e60a14507fc353ebc47b9f0a8249a2a1bfa5d2cf526bd15ee68bd52e944ece9de6bbda913bc5083e26229673340fcc5285df0d38cbc7bb14584ced2fe9e9b3c283fa3c5ad4dd2034b7a67c8e7a1632fae8979a0abdd19be91c6bc371966121e04d433923e44df0b60c156bd90bc61c9fed01a7a76353f79dd4da3e07e12810ec3765128ec44b44b0789d6aa9e9702211a22ab8055ea32e9513fb1bd9d24ca04b33282632f63ab1b213e9644f97bc31dc4d2e7050c1fa23c0000facbf7c76fd7be4b112586f73f0c27abcf7cbe8c9d9fb83af70f60c490936fef84ed5301f73917b4e4170674a5d5e4bfbebdfeda9584221a0f190545efea7245dd2517ade393bedc255c4e016d9919e6e3f3711bca677fc099bf4e1730a752ea2a90a20ff3d09c909771849d3b009ba8d95d2b84fff889e38b079f1325aa42daa067a52abb5c064de3a5040e4a64e76b397b5c9ee6d045f3b5150cf428a92c141735908bb278077d52beefdc87efa156b8ebda071cb425fad0372a8a7cb6eb29926e8f6411ff1b818750c5b6888302fee9b1591b1c23db131538db2aa3de61dcd76fb7067be7ab71ee372bac18be0f446c974e92e79e27e7e3b2aa5ffc3f5f923f2df8ac2edcbb9392d1ac35e4cd52037d9dceedec6391e713e78770307bfde6a31b4e115904d285ac35db055ae8253b9968b7ed7b948da5f*785435725a573571565662727670754100";
|
||||
|
||||
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
||||
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
||||
u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; }
|
||||
u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; }
|
||||
u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; }
|
||||
u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; }
|
||||
u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; }
|
||||
const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; }
|
||||
u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; }
|
||||
u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; }
|
||||
u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; }
|
||||
u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; }
|
||||
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
|
||||
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
|
||||
|
||||
typedef struct winhello
|
||||
{
|
||||
// we need a lot of padding here because sha512_update expects them to be multiple of 128
|
||||
|
||||
u32 mk_buf[16];
|
||||
u32 mk_buf_pc[8];
|
||||
u32 hmac_buf[32];
|
||||
u32 blob_buf[256];
|
||||
u32 magicv_buf[32];
|
||||
|
||||
int mk_len;
|
||||
int hmac_len;
|
||||
int blob_len;
|
||||
int magicv_len;
|
||||
|
||||
} winhello_t;
|
||||
|
||||
typedef struct winhello_tmp
|
||||
{
|
||||
u32 ipad[8];
|
||||
u32 opad[8];
|
||||
|
||||
u32 dgst[8];
|
||||
u32 out[8];
|
||||
|
||||
} winhello_tmp_t;
|
||||
|
||||
static const char *SIGNATURE_WINHELLO = "$WINHELLO$";
|
||||
|
||||
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (winhello_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u64 tmp_size = (const u64) sizeof (winhello_tmp_t);
|
||||
|
||||
return tmp_size;
|
||||
}
|
||||
|
||||
u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_min = 4; // https://docs.microsoft.com/en-us/windows/security/information-protection/tpm/tpm-fundamentals#anti-hammering
|
||||
|
||||
return pw_min;
|
||||
}
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_max = 127; // https://docs.microsoft.com/en-us/windows/security/information-protection/tpm/tpm-fundamentals#anti-hammering
|
||||
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
u64 *digest = (u64 *) digest_buf;
|
||||
|
||||
winhello_t *winhello = (winhello_t *) esalt_buf;
|
||||
|
||||
token_t token;
|
||||
|
||||
token.token_cnt = 9;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_WINHELLO;
|
||||
|
||||
token.len_min[0] = 10;
|
||||
token.len_max[0] = 10;
|
||||
token.sep[0] = '*';
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
|
||||
token.len_min[1] = 6; // fixed SHA512
|
||||
token.len_max[1] = 6;
|
||||
token.sep[1] = '*';
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
// pbkdf2 iter
|
||||
token.len_min[2] = 5; // fixed 10000
|
||||
token.len_max[2] = 5;
|
||||
token.sep[2] = '*';
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// pbdfk2 salt
|
||||
token.len_min[3] = 8;
|
||||
token.len_max[3] = 8;
|
||||
token.sep[3] = '*';
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// sign (hash)
|
||||
token.len_min[4] = 128;
|
||||
token.len_max[4] = 128;
|
||||
token.sep[4] = '*';
|
||||
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// mk
|
||||
token.len_min[5] = 128;
|
||||
token.len_max[5] = 128;
|
||||
token.sep[5] = '*';
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// hmac
|
||||
token.len_min[6] = 64;
|
||||
token.len_max[6] = 64;
|
||||
token.sep[6] = '*';
|
||||
token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// verify blob
|
||||
token.len_min[7] = 1384;
|
||||
token.len_max[7] = 1384;
|
||||
token.sep[7] = '*';
|
||||
token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// magicv
|
||||
token.len_min[8] = 34; // fixed 785435725a573571565662727670754100
|
||||
token.len_max[8] = 34;
|
||||
token.sep[8] = '*';
|
||||
token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
|
||||
const u8 *sha512_pos = token.buf[1];
|
||||
const u8 *iter_pos = token.buf[2];
|
||||
const u8 *salt_pos = token.buf[3];
|
||||
const u8 *sign_pos = token.buf[4];
|
||||
const u8 *mk_pos = token.buf[5];
|
||||
const u8 *hmac_pos = token.buf[6];
|
||||
const u8 *blob_pos = token.buf[7];
|
||||
const u8 *magicv_pos = token.buf[8];
|
||||
|
||||
const int salt_len = token.len[3];
|
||||
const int mk_len = token.len[5];
|
||||
const int hmac_len = token.len[6];
|
||||
const int blob_len = token.len[7];
|
||||
const int magicv_len = token.len[8];
|
||||
|
||||
// verify
|
||||
|
||||
if (memcmp (sha512_pos, "SHA512", 6) != 0) return (PARSER_SALT_VALUE);
|
||||
|
||||
// pbkdf2 iter
|
||||
|
||||
const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10);
|
||||
|
||||
salt->salt_iter = iter - 1;
|
||||
|
||||
// pbkdf2 salt
|
||||
|
||||
salt->salt_len = hex_decode (salt_pos, salt_len, (u8 *) salt->salt_buf);
|
||||
|
||||
for (u32 i = 0, j = 0; i < salt->salt_len; i += 4, j += 1)
|
||||
{
|
||||
salt->salt_buf[j] = byte_swap_32 (salt->salt_buf[j]);
|
||||
}
|
||||
|
||||
// mk
|
||||
|
||||
winhello->mk_len = hex_decode (mk_pos, mk_len, (u8 *) winhello->mk_buf);
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->mk_len; i += 4, j += 1)
|
||||
{
|
||||
winhello->mk_buf[j] = byte_swap_32 (winhello->mk_buf[j]);
|
||||
}
|
||||
|
||||
// hmac
|
||||
|
||||
winhello->hmac_len = hex_decode (hmac_pos, hmac_len, (u8 *) winhello->hmac_buf);
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->hmac_len; i += 4, j += 1)
|
||||
{
|
||||
winhello->hmac_buf[j] = byte_swap_32 (winhello->hmac_buf[j]);
|
||||
}
|
||||
|
||||
// blob
|
||||
|
||||
winhello->blob_len = hex_decode (blob_pos, blob_len, (u8 *) winhello->blob_buf);
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->blob_len; i += 4, j += 1)
|
||||
{
|
||||
winhello->blob_buf[j] = byte_swap_32 (winhello->blob_buf[j]);
|
||||
}
|
||||
|
||||
// magicv
|
||||
|
||||
winhello->magicv_len = hex_decode (magicv_pos, magicv_len, (u8 *) winhello->magicv_buf);
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->magicv_len; i += 4, j += 1)
|
||||
{
|
||||
winhello->magicv_buf[j] = byte_swap_32 (winhello->magicv_buf[j]);
|
||||
}
|
||||
|
||||
// sign (hash)
|
||||
|
||||
digest[0] = hex_to_u64 (sign_pos + 0);
|
||||
digest[1] = hex_to_u64 (sign_pos + 16);
|
||||
digest[2] = hex_to_u64 (sign_pos + 32);
|
||||
digest[3] = hex_to_u64 (sign_pos + 48);
|
||||
digest[4] = hex_to_u64 (sign_pos + 64);
|
||||
digest[5] = hex_to_u64 (sign_pos + 80);
|
||||
digest[6] = hex_to_u64 (sign_pos + 96);
|
||||
digest[7] = hex_to_u64 (sign_pos + 112);
|
||||
|
||||
digest[0] = byte_swap_64 (digest[0]);
|
||||
digest[1] = byte_swap_64 (digest[1]);
|
||||
digest[2] = byte_swap_64 (digest[2]);
|
||||
digest[3] = byte_swap_64 (digest[3]);
|
||||
digest[4] = byte_swap_64 (digest[4]);
|
||||
digest[5] = byte_swap_64 (digest[5]);
|
||||
digest[6] = byte_swap_64 (digest[6]);
|
||||
digest[7] = byte_swap_64 (digest[7]);
|
||||
|
||||
// precompute mk
|
||||
|
||||
sha1_ctx_t sha1_ctx;
|
||||
|
||||
sha1_init (&sha1_ctx);
|
||||
sha1_update (&sha1_ctx, winhello->mk_buf, winhello->mk_len);
|
||||
sha1_final (&sha1_ctx);
|
||||
|
||||
winhello->mk_buf_pc[0] = sha1_ctx.h[0];
|
||||
winhello->mk_buf_pc[1] = sha1_ctx.h[1];
|
||||
winhello->mk_buf_pc[2] = sha1_ctx.h[2];
|
||||
winhello->mk_buf_pc[3] = sha1_ctx.h[3];
|
||||
winhello->mk_buf_pc[4] = sha1_ctx.h[4];
|
||||
winhello->mk_buf_pc[5] = 0;
|
||||
winhello->mk_buf_pc[6] = 0;
|
||||
winhello->mk_buf_pc[7] = 0;
|
||||
|
||||
// yes we can precompute the first block of both sha512 here, because length is 128 + hmac lenght + magic length, but
|
||||
// speed improvement is negligible, but readability would drop a lot
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
|
||||
{
|
||||
const u64 *digest = (const u64 *) digest_buf;
|
||||
|
||||
const winhello_t *winhello = (const winhello_t *) esalt_buf;
|
||||
|
||||
u8 *out_buf = (u8 *) line_buf;
|
||||
|
||||
int out_len = snprintf (line_buf, line_size, "%s*SHA512*%u*", SIGNATURE_WINHELLO, salt->salt_iter + 1);
|
||||
|
||||
u32 tmp32[256];
|
||||
|
||||
for (u32 i = 0, j = 0; i < salt->salt_len; i += 4, j += 1)
|
||||
{
|
||||
tmp32[j] = byte_swap_32 (salt->salt_buf[j]);
|
||||
}
|
||||
|
||||
out_len += hex_encode ((u8 *) tmp32, salt->salt_len, out_buf + out_len);
|
||||
|
||||
out_buf[out_len] = '*';
|
||||
|
||||
out_len++;
|
||||
|
||||
u64 tmp[8];
|
||||
|
||||
tmp[0] = byte_swap_64 (digest[0]);
|
||||
tmp[1] = byte_swap_64 (digest[1]);
|
||||
tmp[2] = byte_swap_64 (digest[2]);
|
||||
tmp[3] = byte_swap_64 (digest[3]);
|
||||
tmp[4] = byte_swap_64 (digest[4]);
|
||||
tmp[5] = byte_swap_64 (digest[5]);
|
||||
tmp[6] = byte_swap_64 (digest[6]);
|
||||
tmp[7] = byte_swap_64 (digest[7]);
|
||||
|
||||
u64_to_hex (tmp[0], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[1], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[2], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[3], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[4], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[5], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[6], out_buf + out_len); out_len += 16;
|
||||
u64_to_hex (tmp[7], out_buf + out_len); out_len += 16;
|
||||
|
||||
out_buf[out_len] = '*';
|
||||
|
||||
out_len++;
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->mk_len; i += 4, j += 1)
|
||||
{
|
||||
tmp32[j] = byte_swap_32 (winhello->mk_buf[j]);
|
||||
}
|
||||
|
||||
out_len += hex_encode ((u8 *) tmp32, winhello->mk_len, out_buf + out_len);
|
||||
|
||||
out_buf[out_len] = '*';
|
||||
|
||||
out_len++;
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->hmac_len; i += 4, j += 1)
|
||||
{
|
||||
tmp32[j] = byte_swap_32 (winhello->hmac_buf[j]);
|
||||
}
|
||||
|
||||
out_len += hex_encode ((u8 *) tmp32, winhello->hmac_len, out_buf + out_len);
|
||||
|
||||
out_buf[out_len] = '*';
|
||||
|
||||
out_len++;
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->blob_len; i += 4, j += 1)
|
||||
{
|
||||
tmp32[j] = byte_swap_32 (winhello->blob_buf[j]);
|
||||
}
|
||||
|
||||
out_len += hex_encode ((u8 *) tmp32, winhello->blob_len, out_buf + out_len);
|
||||
|
||||
out_buf[out_len] = '*';
|
||||
|
||||
out_len++;
|
||||
|
||||
for (int i = 0, j = 0; i < winhello->magicv_len; i += 4, j += 1)
|
||||
{
|
||||
tmp32[j] = byte_swap_32 (winhello->magicv_buf[j]);
|
||||
}
|
||||
|
||||
out_len += hex_encode ((u8 *) tmp32, winhello->magicv_len, out_buf + out_len);
|
||||
|
||||
out_buf[out_len] = 0;
|
||||
|
||||
return out_len;
|
||||
}
|
||||
|
||||
void module_init (module_ctx_t *module_ctx)
|
||||
{
|
||||
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
|
||||
module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT;
|
||||
|
||||
module_ctx->module_attack_exec = module_attack_exec;
|
||||
module_ctx->module_benchmark_esalt = MODULE_DEFAULT;
|
||||
module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT;
|
||||
module_ctx->module_benchmark_mask = MODULE_DEFAULT;
|
||||
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
|
||||
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
|
||||
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
|
||||
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
|
||||
module_ctx->module_dgst_pos0 = module_dgst_pos0;
|
||||
module_ctx->module_dgst_pos1 = module_dgst_pos1;
|
||||
module_ctx->module_dgst_pos2 = module_dgst_pos2;
|
||||
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
||||
module_ctx->module_dgst_size = module_dgst_size;
|
||||
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_esalt_size = module_esalt_size;
|
||||
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
||||
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_binary_save = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_decode = module_hash_decode;
|
||||
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_encode = module_hash_encode;
|
||||
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_mode = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_category = module_hash_category;
|
||||
module_ctx->module_hash_name = module_hash_name;
|
||||
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
|
||||
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
|
||||
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_hook_extra_param_size = MODULE_DEFAULT;
|
||||
module_ctx->module_hook_extra_param_init = MODULE_DEFAULT;
|
||||
module_ctx->module_hook_extra_param_term = MODULE_DEFAULT;
|
||||
module_ctx->module_hook12 = MODULE_DEFAULT;
|
||||
module_ctx->module_hook23 = MODULE_DEFAULT;
|
||||
module_ctx->module_hook_salt_size = MODULE_DEFAULT;
|
||||
module_ctx->module_hook_size = MODULE_DEFAULT;
|
||||
module_ctx->module_jit_build_options = MODULE_DEFAULT;
|
||||
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
|
||||
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
|
||||
module_ctx->module_kern_type = module_kern_type;
|
||||
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
|
||||
module_ctx->module_opti_type = module_opti_type;
|
||||
module_ctx->module_opts_type = module_opts_type;
|
||||
module_ctx->module_outfile_check_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT;
|
||||
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
|
||||
module_ctx->module_potfile_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT;
|
||||
module_ctx->module_pwdump_column = MODULE_DEFAULT;
|
||||
module_ctx->module_pw_max = module_pw_max;
|
||||
module_ctx->module_pw_min = module_pw_min;
|
||||
module_ctx->module_salt_max = MODULE_DEFAULT;
|
||||
module_ctx->module_salt_min = MODULE_DEFAULT;
|
||||
module_ctx->module_salt_type = module_salt_type;
|
||||
module_ctx->module_separator = MODULE_DEFAULT;
|
||||
module_ctx->module_st_hash = module_st_hash;
|
||||
module_ctx->module_st_pass = module_st_pass;
|
||||
module_ctx->module_tmp_size = module_tmp_size;
|
||||
module_ctx->module_unstable_warning = MODULE_DEFAULT;
|
||||
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
||||
}
|
134
tools/test_modules/m28100.pm
Normal file
134
tools/test_modules/m28100.pm
Normal file
@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Digest::MD4 qw (md4 md4_hex);
|
||||
use Digest::SHA qw (sha1 sha1_hex);
|
||||
use Digest::SHA qw (sha512 sha512_hex);
|
||||
use Crypt::PBKDF2;
|
||||
use Encode;
|
||||
|
||||
sub module_constraints { [[4, 127], [8, 8], [-1, -1], [-1, -1], [-1, -1]] }
|
||||
|
||||
#
|
||||
# Helper functions:
|
||||
#
|
||||
|
||||
sub exclusive_or
|
||||
{
|
||||
my $in1 = shift;
|
||||
my $in2 = shift;
|
||||
|
||||
# MIN () function (should always be 16 for us):
|
||||
# my $len = (length ($in1) <= length ($in2)) ? length ($in2) : length ($in1);
|
||||
|
||||
# padding if input not multiple of block size:
|
||||
# $in1 .= "\x00" x ($AES256_IGE_BLOCK_SIZE - $len);
|
||||
# $in2 .= "\x00" x ($AES256_IGE_BLOCK_SIZE - $len);
|
||||
|
||||
my $out = "";
|
||||
|
||||
for (my $i = 0; $i < length $in1; $i++) # $i < $len
|
||||
{
|
||||
$out .= chr (ord (substr ($in1, $i, 1)) ^ ord (substr ($in2, $i, 1)));
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $salt = shift;
|
||||
my $iter = shift // 10000;
|
||||
my $mk = shift // random_hex_string (128);
|
||||
my $hmac = shift // random_hex_string (64);
|
||||
my $blob = shift // random_hex_string (1384);
|
||||
my $magicv = shift // "785435725a573571565662727670754100";
|
||||
|
||||
my $salt_bin = pack ("H*", $salt);
|
||||
my $mk_bin = pack ("H*", $mk);
|
||||
my $hmac_bin = pack ("H*", $hmac);
|
||||
my $blob_bin = pack ("H*", $blob);
|
||||
my $magicv_bin = pack ("H*", $magicv);
|
||||
|
||||
## convert_userpin_to_secretpin()
|
||||
## this looks strange. what if the user password is outside 0x20 - 0x7f?
|
||||
## from some testing, it seems MS prevents the user to use any non-ascii charcters
|
||||
|
||||
my $stage1_hexpin = uc (encode ("UTF-16LE", unpack ("H*", $word)));
|
||||
|
||||
my $pbkdf2 = Crypt::PBKDF2->new
|
||||
(
|
||||
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
|
||||
iterations => $iter,
|
||||
output_len => 32
|
||||
);
|
||||
|
||||
my $stage2_pbkdf2 = $pbkdf2->PBKDF2 ($salt_bin, $stage1_hexpin);
|
||||
|
||||
my $stage3_hexconvert = uc (encode ("UTF-16LE", unpack ("H*", $stage2_pbkdf2)));
|
||||
|
||||
my $stage4_sha512 = sha512 ($stage3_hexconvert);
|
||||
|
||||
## is_signature_matching()
|
||||
|
||||
my $masterkey = sha1 ($mk_bin) . "\x00" x 108;
|
||||
|
||||
my $sub_digest_seed = exclusive_or ($masterkey, "\x36" x 128);
|
||||
my $main_digest_seed = exclusive_or ($masterkey, "\x5c" x 128);
|
||||
|
||||
my $sub_digest = sha512 ($sub_digest_seed . $hmac_bin . $magicv_bin . $stage4_sha512 . $blob_bin);
|
||||
|
||||
my $main_digest = sha512 ($main_digest_seed . $sub_digest);
|
||||
|
||||
my $hash = sprintf ("\$WINHELLO\$*SHA512*%i*%s*%s*%s*%s*%s*%s", $iter, unpack ("H*", $salt_bin), unpack ("H*", $main_digest), unpack ("H*", $mk_bin), unpack ("H*", $hmac_bin), unpack ("H*", $blob_bin), unpack ("H*", $magicv_bin));
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my $idx = index ($line, ':');
|
||||
|
||||
return unless $idx >= 0;
|
||||
|
||||
my $hash = substr ($line, 0, $idx);
|
||||
my $word = substr ($line, $idx + 1);
|
||||
|
||||
my ($signature, $algo, $iter, $pin_salt, $sign, $mk, $hmac, $verify_blob, $magicv) = split '\*', $hash;
|
||||
|
||||
return unless defined $signature;
|
||||
return unless defined $algo;
|
||||
return unless defined $iter;
|
||||
return unless defined $pin_salt;
|
||||
return unless defined $sign;
|
||||
return unless defined $mk;
|
||||
return unless defined $hmac;
|
||||
return unless defined $verify_blob;
|
||||
return unless defined $magicv;
|
||||
|
||||
return unless ($signature eq '$WINHELLO$');
|
||||
return unless ($algo eq 'SHA512');
|
||||
return unless (length $pin_salt eq 8);
|
||||
return unless (length $sign eq 128);
|
||||
return unless (length $mk eq 128);
|
||||
return unless (length $hmac eq 64);
|
||||
return unless (length $verify_blob eq 1384);
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word, $pin_salt, $iter, $mk, $hmac, $verify_blob, $magicv);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user