1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 22:58:30 +00:00

Merge pull request #2884 from matrix/vbox

Added hash-modes: VirtualBox (PBKDF2-HMAC-SHA256 & AES-128-XTS/AES-256-XTS)
This commit is contained in:
Jens Steube 2021-08-14 08:48:20 +02:00 committed by GitHub
commit 2ca13fb450
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 2646 additions and 0 deletions

663
OpenCL/m27500-pure.cl Normal file
View File

@ -0,0 +1,663 @@
/**
* 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_sha256.cl"
#include "inc_cipher_aes.cl"
#endif
#define COMPARE_M "inc_comp_multi.cl"
typedef struct vbox
{
u32 salt1_buf[64];
u32 salt1_len;
u32 aes_key_len;
u32 enc_pass_buf[64];
u32 salt2_buf[64];
u32 salt2_len;
} vbox_t;
typedef struct pbkdf2_sha256_tmp
{
u32 ipad[8];
u32 opad[8];
u32 dgst[64];
u32 out[64];
} pbkdf2_sha256_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);
}
DECLSPEC void xts_mul2 (u32 *in, u32 *out)
{
const u32 c = in[3] >> 31;
out[3] = (in[3] << 1) | (in[2] >> 31);
out[2] = (in[2] << 1) | (in[1] >> 31);
out[1] = (in[1] << 1) | (in[0] >> 31);
out[0] = (in[0] << 1);
out[0] ^= c * 0x87;
}
KERNEL_FQ void m27500_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
sha256_hmac_ctx_t sha256_hmac_ctx;
sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
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_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET].salt1_buf, esalt_bufs[DIGESTS_OFFSET].salt1_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 m27500_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_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 m27500_init2 (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* aes
*/
u32 ukey1[4];
u32 ukey2[4];
ukey1[0] = tmps[gid].out[0];
ukey1[1] = tmps[gid].out[1];
ukey1[2] = tmps[gid].out[2];
ukey1[3] = tmps[gid].out[3];
ukey2[0] = tmps[gid].out[4];
ukey2[1] = tmps[gid].out[5];
ukey2[2] = tmps[gid].out[6];
ukey2[3] = tmps[gid].out[7];
ukey1[0] = hc_swap32_S (ukey1[0]);
ukey1[1] = hc_swap32_S (ukey1[1]);
ukey1[2] = hc_swap32_S (ukey1[2]);
ukey1[3] = hc_swap32_S (ukey1[3]);
ukey2[0] = hc_swap32_S (ukey2[0]);
ukey2[1] = hc_swap32_S (ukey2[1]);
ukey2[2] = hc_swap32_S (ukey2[2]);
ukey2[3] = hc_swap32_S (ukey2[3]);
u32 ks[44];
u32 aes_decrypt[8];
// first block
u32 in[4];
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[0];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[1];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[2];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[3];
u32 out[4];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
u32 S[4] = { 0 }; // tweak, 16 x 0x00
u32 T[4] = { 0 };
aes128_set_encrypt_key (ks, ukey2, s_te0, s_te1, s_te2, s_te3);
aes128_encrypt (ks, S, T, s_te0, s_te1, s_te2, s_te3, s_te4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes128_set_decrypt_key (ks, ukey1, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
aes128_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[0] = out[0];
aes_decrypt[1] = out[1];
aes_decrypt[2] = out[2];
aes_decrypt[3] = out[3];
// next
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[4];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[5];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[6];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[7];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
xts_mul2 (T, T);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes128_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[4] = out[0];
aes_decrypt[5] = out[1];
aes_decrypt[6] = out[2];
aes_decrypt[7] = out[3];
// pbkdf2-hmac-sha256
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = hc_swap32_S (aes_decrypt[ 0]);
w0[1] = hc_swap32_S (aes_decrypt[ 1]);
w0[2] = hc_swap32_S (aes_decrypt[ 2]);
w0[3] = hc_swap32_S (aes_decrypt[ 3]);
w1[0] = hc_swap32_S (aes_decrypt[ 4]);
w1[1] = hc_swap32_S (aes_decrypt[ 5]);
w1[2] = hc_swap32_S (aes_decrypt[ 6]);
w1[3] = hc_swap32_S (aes_decrypt[ 7]);
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
// init2
sha256_hmac_ctx_t sha256_hmac_ctx;
sha256_hmac_init_64 (&sha256_hmac_ctx, w0, w1, w2, w3);
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_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET].salt2_buf, esalt_bufs[DIGESTS_OFFSET].salt2_len);
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
{
sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx;
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 m27500_loop2 (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_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 m27500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
const u32 r0 = tmps[gid].out[0];
const u32 r1 = tmps[gid].out[1];
const u32 r2 = tmps[gid].out[2];
const u32 r3 = tmps[gid].out[3];
#define il_pos 0
#ifdef KERNEL_STATIC
#include COMPARE_M
#endif
}

741
OpenCL/m27600-pure.cl Normal file
View File

@ -0,0 +1,741 @@
/**
* 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_sha256.cl"
#include "inc_cipher_aes.cl"
#endif
#define COMPARE_M "inc_comp_multi.cl"
typedef struct vbox
{
u32 salt1_buf[64];
u32 salt1_len;
u32 aes_key_len;
u32 enc_pass_buf[128];
u32 salt2_buf[64];
u32 salt2_len;
} vbox_t;
typedef struct pbkdf2_sha256_tmp
{
u32 ipad[8];
u32 opad[8];
u32 dgst[64];
u32 out[64];
} pbkdf2_sha256_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);
}
DECLSPEC void xts_mul2 (u32 *in, u32 *out)
{
const u32 c = in[3] >> 31;
out[3] = (in[3] << 1) | (in[2] >> 31);
out[2] = (in[2] << 1) | (in[1] >> 31);
out[1] = (in[1] << 1) | (in[0] >> 31);
out[0] = (in[0] << 1);
out[0] ^= c * 0x87;
}
KERNEL_FQ void m27600_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
sha256_hmac_ctx_t sha256_hmac_ctx;
sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
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_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET].salt1_buf, esalt_bufs[DIGESTS_OFFSET].salt1_len);
for (u32 i = 0, j = 1; i < 16; 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 m27600_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_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 < 16; 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 m27600_init2 (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
const u64 lsz = get_local_size (0);
/**
* aes shared
*/
#ifdef REAL_SHM
LOCAL_VK u32 s_td0[256];
LOCAL_VK u32 s_td1[256];
LOCAL_VK u32 s_td2[256];
LOCAL_VK u32 s_td3[256];
LOCAL_VK u32 s_td4[256];
LOCAL_VK u32 s_te0[256];
LOCAL_VK u32 s_te1[256];
LOCAL_VK u32 s_te2[256];
LOCAL_VK u32 s_te3[256];
LOCAL_VK u32 s_te4[256];
for (u32 i = lid; i < 256; i += lsz)
{
s_td0[i] = td0[i];
s_td1[i] = td1[i];
s_td2[i] = td2[i];
s_td3[i] = td3[i];
s_td4[i] = td4[i];
s_te0[i] = te0[i];
s_te1[i] = te1[i];
s_te2[i] = te2[i];
s_te3[i] = te3[i];
s_te4[i] = te4[i];
}
SYNC_THREADS ();
#else
CONSTANT_AS u32a *s_td0 = td0;
CONSTANT_AS u32a *s_td1 = td1;
CONSTANT_AS u32a *s_td2 = td2;
CONSTANT_AS u32a *s_td3 = td3;
CONSTANT_AS u32a *s_td4 = td4;
CONSTANT_AS u32a *s_te0 = te0;
CONSTANT_AS u32a *s_te1 = te1;
CONSTANT_AS u32a *s_te2 = te2;
CONSTANT_AS u32a *s_te3 = te3;
CONSTANT_AS u32a *s_te4 = te4;
#endif
if (gid >= gid_max) return;
/**
* aes
*/
u32 ukey1[8];
u32 ukey2[8];
ukey1[0] = tmps[gid].out[ 0];
ukey1[1] = tmps[gid].out[ 1];
ukey1[2] = tmps[gid].out[ 2];
ukey1[3] = tmps[gid].out[ 3];
ukey1[4] = tmps[gid].out[ 4];
ukey1[5] = tmps[gid].out[ 5];
ukey1[6] = tmps[gid].out[ 6];
ukey1[7] = tmps[gid].out[ 7];
ukey2[0] = tmps[gid].out[ 8];
ukey2[1] = tmps[gid].out[ 9];
ukey2[2] = tmps[gid].out[10];
ukey2[3] = tmps[gid].out[11];
ukey2[4] = tmps[gid].out[12];
ukey2[5] = tmps[gid].out[13];
ukey2[6] = tmps[gid].out[14];
ukey2[7] = tmps[gid].out[15];
ukey1[0] = hc_swap32_S (ukey1[0]);
ukey1[1] = hc_swap32_S (ukey1[1]);
ukey1[2] = hc_swap32_S (ukey1[2]);
ukey1[3] = hc_swap32_S (ukey1[3]);
ukey1[4] = hc_swap32_S (ukey1[4]);
ukey1[5] = hc_swap32_S (ukey1[5]);
ukey1[6] = hc_swap32_S (ukey1[6]);
ukey1[7] = hc_swap32_S (ukey1[7]);
ukey2[0] = hc_swap32_S (ukey2[0]);
ukey2[1] = hc_swap32_S (ukey2[1]);
ukey2[2] = hc_swap32_S (ukey2[2]);
ukey2[3] = hc_swap32_S (ukey2[3]);
ukey2[4] = hc_swap32_S (ukey2[4]);
ukey2[5] = hc_swap32_S (ukey2[5]);
ukey2[6] = hc_swap32_S (ukey2[6]);
ukey2[7] = hc_swap32_S (ukey2[7]);
u32 ks[60];
u32 aes_decrypt[16];
// first block
u32 in[4];
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[0];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[1];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[2];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[3];
u32 out[4];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
u32 S[4] = { 0 }; // tweak, 16 x 0x00
u32 T[4] = { 0 };
aes256_set_encrypt_key (ks, ukey2, s_te0, s_te1, s_te2, s_te3);
aes256_encrypt (ks, S, T, s_te0, s_te1, s_te2, s_te3, s_te4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes256_set_decrypt_key (ks, ukey1, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
aes256_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[0] = out[0];
aes_decrypt[1] = out[1];
aes_decrypt[2] = out[2];
aes_decrypt[3] = out[3];
// next
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[4];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[5];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[6];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[7];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
xts_mul2 (T, T);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes256_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[4] = out[0];
aes_decrypt[5] = out[1];
aes_decrypt[6] = out[2];
aes_decrypt[7] = out[3];
// next
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[8];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[9];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[10];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[11];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
xts_mul2 (T, T);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes256_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[8] = out[0];
aes_decrypt[9] = out[1];
aes_decrypt[10] = out[2];
aes_decrypt[11] = out[3];
// next
in[0] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[12];
in[1] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[13];
in[2] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[14];
in[3] = esalt_bufs[DIGESTS_OFFSET].enc_pass_buf[15];
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
out[3] = in[3];
xts_mul2 (T, T);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes256_decrypt (ks, out, out, s_td0, s_td1, s_td2, s_td3, s_td4);
out[0] ^= T[0];
out[1] ^= T[1];
out[2] ^= T[2];
out[3] ^= T[3];
aes_decrypt[12] = out[0];
aes_decrypt[13] = out[1];
aes_decrypt[14] = out[2];
aes_decrypt[15] = out[3];
// pbkdf2-hmac-sha256
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = hc_swap32_S (aes_decrypt[ 0]);
w0[1] = hc_swap32_S (aes_decrypt[ 1]);
w0[2] = hc_swap32_S (aes_decrypt[ 2]);
w0[3] = hc_swap32_S (aes_decrypt[ 3]);
w1[0] = hc_swap32_S (aes_decrypt[ 4]);
w1[1] = hc_swap32_S (aes_decrypt[ 5]);
w1[2] = hc_swap32_S (aes_decrypt[ 6]);
w1[3] = hc_swap32_S (aes_decrypt[ 7]);
w2[0] = hc_swap32_S (aes_decrypt[ 8]);
w2[1] = hc_swap32_S (aes_decrypt[ 9]);
w2[2] = hc_swap32_S (aes_decrypt[10]);
w2[3] = hc_swap32_S (aes_decrypt[11]);
w3[0] = hc_swap32_S (aes_decrypt[12]);
w3[1] = hc_swap32_S (aes_decrypt[13]);
w3[2] = hc_swap32_S (aes_decrypt[14]);
w3[3] = hc_swap32_S (aes_decrypt[15]);
// init2
sha256_hmac_ctx_t sha256_hmac_ctx;
sha256_hmac_init_64 (&sha256_hmac_ctx, w0, w1, w2, w3);
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_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET].salt2_buf, esalt_bufs[DIGESTS_OFFSET].salt2_len);
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
{
sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx;
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 m27600_loop2 (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_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 m27600_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, vbox_t))
{
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
const u32 r0 = tmps[gid].out[0];
const u32 r1 = tmps[gid].out[1];
const u32 r2 = tmps[gid].out[2];
const u32 r3 = tmps[gid].out[3];
#define il_pos 0
#ifdef KERNEL_STATIC
#include COMPARE_M
#endif
}

View File

@ -79,6 +79,8 @@
- Added hash-mode: SNMPv3 HMAC-SHA256-192
- Added hash-mode: SNMPv3 HMAC-SHA384-256
- Added hash-mode: SNMPv3 HMAC-SHA512-384
- Added hash-mode: VirtualBox (PBKDF2-HMAC-SHA256 & AES-128-XTS)
- Added hash-mode: VirtualBox (PBKDF2-HMAC-SHA256 & AES-256-XTS)
* changes v6.2.2 -> v6.2.3

View File

@ -277,6 +277,8 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or
- VeraCrypt
- BestCrypt v3 Volume Encryption
- FileVault 2
- VirtualBox (PBKDF2-HMAC-SHA256 & AES-128-XTS)
- VirtualBox (PBKDF2-HMAC-SHA256 & AES-256-XTS)
- DiskCryptor
- BitLocker
- Android FDE (Samsung DEK)

434
src/modules/module_27500.c Normal file
View File

@ -0,0 +1,434 @@
/**
* 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 "memory.h"
#include "emu_inc_hash_md5.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_4_8;
static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE;
static const char *HASH_NAME = "VirtualBox (PBKDF2-HMAC-SHA256 & AES-128-XTS)";
static const u64 KERN_TYPE = 27500;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP2;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_ST_HEX
| OPTS_TYPE_INIT2
| OPTS_TYPE_LOOP2;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$vbox$0$260000$fcc37189521686699a43e49514b91f159306be108b98895666583cd15c3e206b$8$288c3957db47e7c3dff2f7932121eb3395d21ab76b9cf3de2dc660310a25e7ad$20000$8847cd90f8acef74bae41155392908780eebb1d16452aa09b2f7b6cd7d8a4096$9f4d615b484f95c73944a98f392a3ce04f93403e8bb6257e6b6c854273d3a08a";
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 vbox
{
u32 salt1_buf[64];
u32 salt1_len;
u32 aes_key_len;
u32 enc_pass_buf[64];
u32 salt2_buf[64];
u32 salt2_len;
} vbox_t;
typedef struct pbkdf2_sha256_tmp
{
u32 ipad[8];
u32 opad[8];
u32 dgst[64];
u32 out[64];
} pbkdf2_sha256_tmp_t;
static const char *SIGNATURE_VBOX = "$vbox$0$";
salt_t *module_benchmark_salt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
salt_t *salt = (salt_t *) hcmalloc (sizeof (salt_t));
salt->salt_iter = 260000 - 1;
salt->salt_iter2 = 20000 - 1;
salt->salt_len = 32;
return salt;
}
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 (vbox_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 (pbkdf2_sha256_tmp_t);
return tmp_size;
}
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)
{
// this overrides the reductions of PW_MAX in case optimized kernel is selected
// IOW, even in optimized kernel mode it support length 256
const u32 pw_max = PW_MAX;
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)
{
u32 *digest = (u32 *) digest_buf;
vbox_t *vbox = (vbox_t *) esalt_buf;
token_t token;
token.token_cnt = 8;
token.signatures_cnt = 1;
token.signatures_buf[0] = SIGNATURE_VBOX;
token.sep[0] = '$';
token.len[0] = 8;
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
| TOKEN_ATTR_VERIFY_SIGNATURE;
token.sep[1] = '$';
token.len_min[1] = 1;
token.len_max[1] = 9;
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[2] = '$';
token.len_min[2] = 64;
token.len_max[2] = 64;
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[3] = '$';
token.len_min[3] = 1;
token.len_max[3] = 2;
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[4] = '$';
token.len_min[4] = 64;
token.len_max[4] = 64;
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[5] = '$';
token.len_min[5] = 1;
token.len_max[5] = 9;
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[6] = '$';
token.len_min[6] = 64;
token.len_max[6] = 64;
token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[7] = '$';
token.len_min[7] = 64;
token.len_max[7] = 64;
token.attr[7] = 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);
// iter 1
const u8 *iter1_pos = token.buf[1];
u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10);
if (iter1 < 1) return (PARSER_SALT_ITERATION);
salt->salt_iter = iter1 - 1;
// salt 1
const u8 *salt1_pos = token.buf[2];
const u32 salt1_len = token.len[2];
u32 *salt1_buf_ptr = (u32 *) vbox->salt1_buf;
salt1_buf_ptr[0] = hex_to_u32 ((const u8 *) &salt1_pos[ 0]);
salt1_buf_ptr[1] = hex_to_u32 ((const u8 *) &salt1_pos[ 8]);
salt1_buf_ptr[2] = hex_to_u32 ((const u8 *) &salt1_pos[16]);
salt1_buf_ptr[3] = hex_to_u32 ((const u8 *) &salt1_pos[24]);
salt1_buf_ptr[4] = hex_to_u32 ((const u8 *) &salt1_pos[32]);
salt1_buf_ptr[5] = hex_to_u32 ((const u8 *) &salt1_pos[40]);
salt1_buf_ptr[6] = hex_to_u32 ((const u8 *) &salt1_pos[48]);
salt1_buf_ptr[7] = hex_to_u32 ((const u8 *) &salt1_pos[56]);
vbox->salt1_len = salt1_len / 2;
// handle unique salts detection
md5_ctx_t md5_ctx;
md5_init (&md5_ctx);
md5_update (&md5_ctx, vbox->salt1_buf, vbox->salt1_len);
md5_final (&md5_ctx);
// store md5(vbox->salt1_buf) in salt_buf
salt->salt_len = 16;
memcpy (salt->salt_buf, md5_ctx.h, salt->salt_len);
// aes xts key len (128 or 256)
const u8 *aes_key_len_pos = token.buf[3];
u32 aes_key_len = hc_strtoul ((const char *) aes_key_len_pos, NULL, 10);
if (aes_key_len != 8) return (PARSER_SALT_ITERATION); // todo: change return
vbox->aes_key_len = aes_key_len;
// enc pass
const u8 *enc_pass_pos = token.buf[4];
const u32 enc_pass_len = token.len[4];
if (enc_pass_len != 64) return (PARSER_SALT_ITERATION); // todo: change return
u32 *enc_pass_buf_ptr = (u32 *) vbox->enc_pass_buf;
enc_pass_buf_ptr[ 0] = hex_to_u32 ((const u8 *) &enc_pass_pos[ 0]);
enc_pass_buf_ptr[ 1] = hex_to_u32 ((const u8 *) &enc_pass_pos[ 8]);
enc_pass_buf_ptr[ 2] = hex_to_u32 ((const u8 *) &enc_pass_pos[16]);
enc_pass_buf_ptr[ 3] = hex_to_u32 ((const u8 *) &enc_pass_pos[24]);
enc_pass_buf_ptr[ 4] = hex_to_u32 ((const u8 *) &enc_pass_pos[32]);
enc_pass_buf_ptr[ 5] = hex_to_u32 ((const u8 *) &enc_pass_pos[40]);
enc_pass_buf_ptr[ 6] = hex_to_u32 ((const u8 *) &enc_pass_pos[48]);
enc_pass_buf_ptr[ 7] = hex_to_u32 ((const u8 *) &enc_pass_pos[56]);
// iter 2
const u8 *iter2_pos = token.buf[5];
u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10);
if (iter2 < 1) return (PARSER_SALT_ITERATION);
salt->salt_iter2 = iter2 - 1;
// salt 2
const u8 *salt2_pos = token.buf[6];
const u32 salt2_len = token.len[6];
u32 *salt2_buf_ptr = (u32 *) vbox->salt2_buf;
salt2_buf_ptr[0] = hex_to_u32 ((const u8 *) &salt2_pos[ 0]);
salt2_buf_ptr[1] = hex_to_u32 ((const u8 *) &salt2_pos[ 8]);
salt2_buf_ptr[2] = hex_to_u32 ((const u8 *) &salt2_pos[16]);
salt2_buf_ptr[3] = hex_to_u32 ((const u8 *) &salt2_pos[24]);
salt2_buf_ptr[4] = hex_to_u32 ((const u8 *) &salt2_pos[32]);
salt2_buf_ptr[5] = hex_to_u32 ((const u8 *) &salt2_pos[40]);
salt2_buf_ptr[6] = hex_to_u32 ((const u8 *) &salt2_pos[48]);
salt2_buf_ptr[7] = hex_to_u32 ((const u8 *) &salt2_pos[56]);
vbox->salt2_len = salt2_len / 2;
// hash
const u8 *hash_pos = token.buf[7];
digest[0] = hex_to_u32 ((const u8 *) &hash_pos[ 0]);
digest[1] = hex_to_u32 ((const u8 *) &hash_pos[ 8]);
digest[2] = hex_to_u32 ((const u8 *) &hash_pos[16]);
digest[3] = hex_to_u32 ((const u8 *) &hash_pos[24]);
digest[4] = hex_to_u32 ((const u8 *) &hash_pos[32]);
digest[5] = hex_to_u32 ((const u8 *) &hash_pos[40]);
digest[6] = hex_to_u32 ((const u8 *) &hash_pos[48]);
digest[7] = hex_to_u32 ((const u8 *) &hash_pos[56]);
digest[0] = byte_swap_32 (digest[0]);
digest[1] = byte_swap_32 (digest[1]);
digest[2] = byte_swap_32 (digest[2]);
digest[3] = byte_swap_32 (digest[3]);
digest[4] = byte_swap_32 (digest[4]);
digest[5] = byte_swap_32 (digest[5]);
digest[6] = byte_swap_32 (digest[6]);
digest[7] = byte_swap_32 (digest[7]);
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 u32 *digest = (const u32 *) digest_buf;
const vbox_t *vbox = (const vbox_t *) esalt_buf;
u8 salt1_buf[64+1] = { 0 };
u32_to_hex (vbox->salt1_buf[0], salt1_buf + 0);
u32_to_hex (vbox->salt1_buf[1], salt1_buf + 8);
u32_to_hex (vbox->salt1_buf[2], salt1_buf + 16);
u32_to_hex (vbox->salt1_buf[3], salt1_buf + 24);
u32_to_hex (vbox->salt1_buf[4], salt1_buf + 32);
u32_to_hex (vbox->salt1_buf[5], salt1_buf + 40);
u32_to_hex (vbox->salt1_buf[6], salt1_buf + 48);
u32_to_hex (vbox->salt1_buf[7], salt1_buf + 56);
u8 enc_pass_buf[64+1] = { 0 };
u32_to_hex (vbox->enc_pass_buf[0], enc_pass_buf + 0);
u32_to_hex (vbox->enc_pass_buf[1], enc_pass_buf + 8);
u32_to_hex (vbox->enc_pass_buf[2], enc_pass_buf + 16);
u32_to_hex (vbox->enc_pass_buf[3], enc_pass_buf + 24);
u32_to_hex (vbox->enc_pass_buf[4], enc_pass_buf + 32);
u32_to_hex (vbox->enc_pass_buf[5], enc_pass_buf + 40);
u32_to_hex (vbox->enc_pass_buf[6], enc_pass_buf + 48);
u32_to_hex (vbox->enc_pass_buf[7], enc_pass_buf + 56);
u8 salt2_buf[64+1] = { 0 };
u32_to_hex (vbox->salt2_buf[0], salt2_buf + 0);
u32_to_hex (vbox->salt2_buf[1], salt2_buf + 8);
u32_to_hex (vbox->salt2_buf[2], salt2_buf + 16);
u32_to_hex (vbox->salt2_buf[3], salt2_buf + 24);
u32_to_hex (vbox->salt2_buf[4], salt2_buf + 32);
u32_to_hex (vbox->salt2_buf[5], salt2_buf + 40);
u32_to_hex (vbox->salt2_buf[6], salt2_buf + 48);
u32_to_hex (vbox->salt2_buf[7], salt2_buf + 56);
u8 hash[64+1] = { 0 };
u32_to_hex (byte_swap_32 (digest[0]), hash + 0);
u32_to_hex (byte_swap_32 (digest[1]), hash + 8);
u32_to_hex (byte_swap_32 (digest[2]), hash + 16);
u32_to_hex (byte_swap_32 (digest[3]), hash + 24);
u32_to_hex (byte_swap_32 (digest[4]), hash + 32);
u32_to_hex (byte_swap_32 (digest[5]), hash + 40);
u32_to_hex (byte_swap_32 (digest[6]), hash + 48);
u32_to_hex (byte_swap_32 (digest[7]), hash + 56);
const int line_len = snprintf (line_buf, line_size, "%s%u$%s$%u$%s$%u$%s$%s",
SIGNATURE_VBOX,
salt->salt_iter + 1,
salt1_buf,
vbox->aes_key_len,
enc_pass_buf,
salt->salt_iter2 + 1,
salt2_buf,
hash);
return line_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_benchmark_salt;
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_DEFAULT;
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;
}

450
src/modules/module_27600.c Normal file
View File

@ -0,0 +1,450 @@
/**
* 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 "memory.h"
#include "emu_inc_hash_md5.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_4_8;
static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE;
static const char *HASH_NAME = "VirtualBox (PBKDF2-HMAC-SHA256 & AES-256-XTS)";
static const u64 KERN_TYPE = 27600;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP2;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_ST_HEX
| OPTS_TYPE_INIT2
| OPTS_TYPE_LOOP2;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$vbox$0$160000$54aff69fca91c20b3b15618c6732c4a2f953dd88690cd4cc731569b6b80b5572$16$cfb003087e0c618afa9ad7e44adcd97517f039e0424dedb46db8affbb73cd064019abae19ee5e4f5b05b626e6bc5d7da65c61a5f94d7bcac521c388276e5358b$20000$2e5729055136168eea79cb3f1765450a35ab7540125f2ca2a46924a99fd0524d$b28d1db1cabe99ca989a405c33a27beeb9c0683b8b4b54b0e0d85f712f64d89c";
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 vbox
{
u32 salt1_buf[64];
u32 salt1_len;
u32 aes_key_len;
u32 enc_pass_buf[128];
u32 salt2_buf[64];
u32 salt2_len;
} vbox_t;
typedef struct pbkdf2_sha256_tmp
{
u32 ipad[8];
u32 opad[8];
u32 dgst[64];
u32 out[64];
} pbkdf2_sha256_tmp_t;
static const char *SIGNATURE_VBOX = "$vbox$0$";
salt_t *module_benchmark_salt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
salt_t *salt = (salt_t *) hcmalloc (sizeof (salt_t));
salt->salt_iter = 160000 - 1;
salt->salt_iter2 = 20000 - 1;
salt->salt_len = 32;
return salt;
}
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 (vbox_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 (pbkdf2_sha256_tmp_t);
return tmp_size;
}
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)
{
// this overrides the reductions of PW_MAX in case optimized kernel is selected
// IOW, even in optimized kernel mode it support length 256
const u32 pw_max = PW_MAX;
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)
{
u32 *digest = (u32 *) digest_buf;
vbox_t *vbox = (vbox_t *) esalt_buf;
token_t token;
token.token_cnt = 8;
token.signatures_cnt = 1;
token.signatures_buf[0] = SIGNATURE_VBOX;
token.sep[0] = '$';
token.len[0] = 8;
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
| TOKEN_ATTR_VERIFY_SIGNATURE;
token.sep[1] = '$';
token.len_min[1] = 1;
token.len_max[1] = 9;
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[2] = '$';
token.len_min[2] = 64;
token.len_max[2] = 64;
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[3] = '$';
token.len_min[3] = 1;
token.len_max[3] = 2;
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[4] = '$';
token.len_min[4] = 128;
token.len_max[4] = 128;
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[5] = '$';
token.len_min[5] = 1;
token.len_max[5] = 9;
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
token.sep[6] = '$';
token.len_min[6] = 64;
token.len_max[6] = 64;
token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
token.sep[7] = '$';
token.len_min[7] = 64;
token.len_max[7] = 64;
token.attr[7] = 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);
// iter 1
const u8 *iter1_pos = token.buf[1];
u32 iter1 = hc_strtoul ((const char *) iter1_pos, NULL, 10);
if (iter1 < 1) return (PARSER_SALT_ITERATION);
salt->salt_iter = iter1 - 1;
// salt 1
const u8 *salt1_pos = token.buf[2];
const u32 salt1_len = token.len[2];
u32 *salt1_buf_ptr = (u32 *) vbox->salt1_buf;
salt1_buf_ptr[0] = hex_to_u32 ((const u8 *) &salt1_pos[ 0]);
salt1_buf_ptr[1] = hex_to_u32 ((const u8 *) &salt1_pos[ 8]);
salt1_buf_ptr[2] = hex_to_u32 ((const u8 *) &salt1_pos[16]);
salt1_buf_ptr[3] = hex_to_u32 ((const u8 *) &salt1_pos[24]);
salt1_buf_ptr[4] = hex_to_u32 ((const u8 *) &salt1_pos[32]);
salt1_buf_ptr[5] = hex_to_u32 ((const u8 *) &salt1_pos[40]);
salt1_buf_ptr[6] = hex_to_u32 ((const u8 *) &salt1_pos[48]);
salt1_buf_ptr[7] = hex_to_u32 ((const u8 *) &salt1_pos[56]);
vbox->salt1_len = salt1_len / 2;
// handle unique salts detection
md5_ctx_t md5_ctx;
md5_init (&md5_ctx);
md5_update (&md5_ctx, vbox->salt1_buf, vbox->salt1_len);
md5_final (&md5_ctx);
// store md5(vbox->salt1_buf) in salt_buf
salt->salt_len = 16;
memcpy (salt->salt_buf, md5_ctx.h, salt->salt_len);
// aes xts key len (128 or 256)
const u8 *aes_key_len_pos = token.buf[3];
u32 aes_key_len = hc_strtoul ((const char *) aes_key_len_pos, NULL, 10);
if (aes_key_len != 16) return (PARSER_SALT_ITERATION); // todo: change return
vbox->aes_key_len = aes_key_len;
// enc pass
const u8 *enc_pass_pos = token.buf[4];
const u32 enc_pass_len = token.len[4];
if (enc_pass_len != 128) return (PARSER_SALT_ITERATION); // todo: change return
u32 *enc_pass_buf_ptr = (u32 *) vbox->enc_pass_buf;
enc_pass_buf_ptr[ 0] = hex_to_u32 ((const u8 *) &enc_pass_pos[ 0]);
enc_pass_buf_ptr[ 1] = hex_to_u32 ((const u8 *) &enc_pass_pos[ 8]);
enc_pass_buf_ptr[ 2] = hex_to_u32 ((const u8 *) &enc_pass_pos[16]);
enc_pass_buf_ptr[ 3] = hex_to_u32 ((const u8 *) &enc_pass_pos[24]);
enc_pass_buf_ptr[ 4] = hex_to_u32 ((const u8 *) &enc_pass_pos[32]);
enc_pass_buf_ptr[ 5] = hex_to_u32 ((const u8 *) &enc_pass_pos[40]);
enc_pass_buf_ptr[ 6] = hex_to_u32 ((const u8 *) &enc_pass_pos[48]);
enc_pass_buf_ptr[ 7] = hex_to_u32 ((const u8 *) &enc_pass_pos[56]);
enc_pass_buf_ptr[ 8] = hex_to_u32 ((const u8 *) &enc_pass_pos[64]);
enc_pass_buf_ptr[ 9] = hex_to_u32 ((const u8 *) &enc_pass_pos[72]);
enc_pass_buf_ptr[10] = hex_to_u32 ((const u8 *) &enc_pass_pos[80]);
enc_pass_buf_ptr[11] = hex_to_u32 ((const u8 *) &enc_pass_pos[88]);
enc_pass_buf_ptr[12] = hex_to_u32 ((const u8 *) &enc_pass_pos[96]);
enc_pass_buf_ptr[13] = hex_to_u32 ((const u8 *) &enc_pass_pos[104]);
enc_pass_buf_ptr[14] = hex_to_u32 ((const u8 *) &enc_pass_pos[112]);
enc_pass_buf_ptr[15] = hex_to_u32 ((const u8 *) &enc_pass_pos[120]);
// iter 2
const u8 *iter2_pos = token.buf[5];
u32 iter2 = hc_strtoul ((const char *) iter2_pos, NULL, 10);
if (iter2 < 1) return (PARSER_SALT_ITERATION);
salt->salt_iter2 = iter2 - 1;
// salt 2
const u8 *salt2_pos = token.buf[6];
const u32 salt2_len = token.len[6];
u32 *salt2_buf_ptr = (u32 *) vbox->salt2_buf;
salt2_buf_ptr[0] = hex_to_u32 ((const u8 *) &salt2_pos[ 0]);
salt2_buf_ptr[1] = hex_to_u32 ((const u8 *) &salt2_pos[ 8]);
salt2_buf_ptr[2] = hex_to_u32 ((const u8 *) &salt2_pos[16]);
salt2_buf_ptr[3] = hex_to_u32 ((const u8 *) &salt2_pos[24]);
salt2_buf_ptr[4] = hex_to_u32 ((const u8 *) &salt2_pos[32]);
salt2_buf_ptr[5] = hex_to_u32 ((const u8 *) &salt2_pos[40]);
salt2_buf_ptr[6] = hex_to_u32 ((const u8 *) &salt2_pos[48]);
salt2_buf_ptr[7] = hex_to_u32 ((const u8 *) &salt2_pos[56]);
vbox->salt2_len = salt2_len / 2;
// hash
const u8 *hash_pos = token.buf[7];
digest[0] = hex_to_u32 ((const u8 *) &hash_pos[ 0]);
digest[1] = hex_to_u32 ((const u8 *) &hash_pos[ 8]);
digest[2] = hex_to_u32 ((const u8 *) &hash_pos[16]);
digest[3] = hex_to_u32 ((const u8 *) &hash_pos[24]);
digest[4] = hex_to_u32 ((const u8 *) &hash_pos[32]);
digest[5] = hex_to_u32 ((const u8 *) &hash_pos[40]);
digest[6] = hex_to_u32 ((const u8 *) &hash_pos[48]);
digest[7] = hex_to_u32 ((const u8 *) &hash_pos[56]);
digest[0] = byte_swap_32 (digest[0]);
digest[1] = byte_swap_32 (digest[1]);
digest[2] = byte_swap_32 (digest[2]);
digest[3] = byte_swap_32 (digest[3]);
digest[4] = byte_swap_32 (digest[4]);
digest[5] = byte_swap_32 (digest[5]);
digest[6] = byte_swap_32 (digest[6]);
digest[7] = byte_swap_32 (digest[7]);
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 u32 *digest = (const u32 *) digest_buf;
const vbox_t *vbox = (const vbox_t *) esalt_buf;
u8 salt1_buf[64+1] = { 0 };
u32_to_hex (vbox->salt1_buf[0], salt1_buf + 0);
u32_to_hex (vbox->salt1_buf[1], salt1_buf + 8);
u32_to_hex (vbox->salt1_buf[2], salt1_buf + 16);
u32_to_hex (vbox->salt1_buf[3], salt1_buf + 24);
u32_to_hex (vbox->salt1_buf[4], salt1_buf + 32);
u32_to_hex (vbox->salt1_buf[5], salt1_buf + 40);
u32_to_hex (vbox->salt1_buf[6], salt1_buf + 48);
u32_to_hex (vbox->salt1_buf[7], salt1_buf + 56);
u8 enc_pass_buf[128+1] = { 0 };
u32_to_hex (vbox->enc_pass_buf[ 0], enc_pass_buf + 0);
u32_to_hex (vbox->enc_pass_buf[ 1], enc_pass_buf + 8);
u32_to_hex (vbox->enc_pass_buf[ 2], enc_pass_buf + 16);
u32_to_hex (vbox->enc_pass_buf[ 3], enc_pass_buf + 24);
u32_to_hex (vbox->enc_pass_buf[ 4], enc_pass_buf + 32);
u32_to_hex (vbox->enc_pass_buf[ 5], enc_pass_buf + 40);
u32_to_hex (vbox->enc_pass_buf[ 6], enc_pass_buf + 48);
u32_to_hex (vbox->enc_pass_buf[ 7], enc_pass_buf + 56);
u32_to_hex (vbox->enc_pass_buf[ 8], enc_pass_buf + 64);
u32_to_hex (vbox->enc_pass_buf[ 9], enc_pass_buf + 72);
u32_to_hex (vbox->enc_pass_buf[10], enc_pass_buf + 80);
u32_to_hex (vbox->enc_pass_buf[11], enc_pass_buf + 88);
u32_to_hex (vbox->enc_pass_buf[12], enc_pass_buf + 96);
u32_to_hex (vbox->enc_pass_buf[13], enc_pass_buf + 104);
u32_to_hex (vbox->enc_pass_buf[14], enc_pass_buf + 112);
u32_to_hex (vbox->enc_pass_buf[15], enc_pass_buf + 120);
u8 salt2_buf[64+1] = { 0 };
u32_to_hex (vbox->salt2_buf[0], salt2_buf + 0);
u32_to_hex (vbox->salt2_buf[1], salt2_buf + 8);
u32_to_hex (vbox->salt2_buf[2], salt2_buf + 16);
u32_to_hex (vbox->salt2_buf[3], salt2_buf + 24);
u32_to_hex (vbox->salt2_buf[4], salt2_buf + 32);
u32_to_hex (vbox->salt2_buf[5], salt2_buf + 40);
u32_to_hex (vbox->salt2_buf[6], salt2_buf + 48);
u32_to_hex (vbox->salt2_buf[7], salt2_buf + 56);
u8 hash[64+1] = { 0 };
u32_to_hex (byte_swap_32 (digest[0]), hash + 0);
u32_to_hex (byte_swap_32 (digest[1]), hash + 8);
u32_to_hex (byte_swap_32 (digest[2]), hash + 16);
u32_to_hex (byte_swap_32 (digest[3]), hash + 24);
u32_to_hex (byte_swap_32 (digest[4]), hash + 32);
u32_to_hex (byte_swap_32 (digest[5]), hash + 40);
u32_to_hex (byte_swap_32 (digest[6]), hash + 48);
u32_to_hex (byte_swap_32 (digest[7]), hash + 56);
const int line_len = snprintf (line_buf, line_size, "%s%u$%s$%u$%s$%u$%s$%s",
SIGNATURE_VBOX,
salt->salt_iter + 1,
salt1_buf,
vbox->aes_key_len,
enc_pass_buf,
salt->salt_iter2 + 1,
salt2_buf,
hash);
return line_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_benchmark_salt;
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_DEFAULT;
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;
}

View File

@ -0,0 +1,137 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Crypt::PBKDF2;
use MIME::Base64 qw (encode_base64 decode_base64);
use Encode;
sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] }
sub aes_decrypt
{
my $key_main = shift;
my $key_tweak = shift;
my $data = shift;
my $python_code = <<'END_CODE';
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
import base64
key = base64.b64decode (key_main)
tweak = base64.b64decode (key_tweak)
cipher = Cipher(algorithms.AES(key), modes.XTS(tweak), backend=default_backend())
decryptor = cipher.decryptor()
decrypted = decryptor.update(base64.b64decode (data)[0:32])
print (decrypted.hex ())
END_CODE
# replace code with these values
$python_code =~ s/key_main/"$key_main"/;
$python_code =~ s/key_tweak/"$key_tweak"/;
$python_code =~ s/data/"$data"/;
my $output_buf = `python3 -c '$python_code'`;
$output_buf =~ s/[\r\n]//g;
$output_buf = pack ("H*", $output_buf);
return $output_buf;
}
sub module_generate_hash
{
my $word = shift;
my $salt1 = shift;
my $iter1 = shift // 260000;
my $enc_pass = shift // random_hex_string (64);
my $salt2 = shift // random_hex_string (64);
my $iter2 = shift // 20000;
my $pbkdf2 = Crypt::PBKDF2->new
(
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
iterations => $iter1,
output_len => 32
);
my $salt1_bin = pack ("H*", $salt1);
my $key = $pbkdf2->PBKDF2 ($salt1_bin, $word);
my $tweak = "\x00" x 16;
my $key_b64 = encode_base64 ($key, "");
my $tweak_b64 = encode_base64 ($tweak, "");
my $enc_pass_b64 = encode_base64 (pack ("H*", $enc_pass), "");
my $dec_pass = aes_decrypt ($key_b64, $tweak_b64, $enc_pass_b64);
$pbkdf2 = Crypt::PBKDF2->new
(
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
iterations => $iter2,
output_len => 32
);
my $salt2_bin = pack ("H*", $salt2);
my $hash_buf = $pbkdf2->PBKDF2 ($salt2_bin, $dec_pass);
my $hash = sprintf ("\$vbox\$0\$%s\$%s\$8\$%s\$%s\$%s\$%s", $iter1, $salt1, $enc_pass, $iter2, $salt2, unpack ("H*", $hash_buf));
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);
return unless substr ($hash, 0, 6) eq '$vbox$';
my (undef, $signature, $version, $iter1, $salt1, $klen, $enc_pass, $iter2, $salt2) = split '\$', $hash;
return unless defined $signature;
return unless defined $version;
return unless defined $iter1;
return unless defined $salt1;
return unless defined $klen;
return unless defined $enc_pass;
return unless defined $iter2;
return unless defined $salt2;
return unless ($version eq "0");
return unless (length $salt1 eq 64);
return unless ($klen eq "8");
return unless (length $enc_pass eq 64);
return unless (length $salt2 eq 64);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word, $salt1, $iter1, $enc_pass, $salt2, $iter2);
return ($new_hash, $word);
}
1;

View File

@ -0,0 +1,137 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use Crypt::PBKDF2;
use MIME::Base64 qw (encode_base64 decode_base64);
use Encode;
sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] }
sub aes_decrypt
{
my $key_main = shift;
my $key_tweak = shift;
my $data = shift;
my $python_code = <<'END_CODE';
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
import base64
key = base64.b64decode (key_main)
tweak = base64.b64decode (key_tweak)
cipher = Cipher(algorithms.AES(key), modes.XTS(tweak), backend=default_backend())
decryptor = cipher.decryptor()
decrypted = decryptor.update(base64.b64decode (data)[0:64])
print (decrypted.hex ())
END_CODE
# replace code with these values
$python_code =~ s/key_main/"$key_main"/;
$python_code =~ s/key_tweak/"$key_tweak"/;
$python_code =~ s/data/"$data"/;
my $output_buf = `python3 -c '$python_code'`;
$output_buf =~ s/[\r\n]//g;
$output_buf = pack ("H*", $output_buf);
return $output_buf;
}
sub module_generate_hash
{
my $word = shift;
my $salt1 = shift;
my $iter1 = shift // 160000;
my $enc_pass = shift // random_hex_string (128);
my $salt2 = shift // random_hex_string (64);
my $iter2 = shift // 20000;
my $pbkdf2 = Crypt::PBKDF2->new
(
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
iterations => $iter1,
output_len => 64
);
my $salt1_bin = pack ("H*", $salt1);
my $key = $pbkdf2->PBKDF2 ($salt1_bin, $word);
my $tweak = "\x00" x 16;
my $key_b64 = encode_base64 ($key, "");
my $tweak_b64 = encode_base64 ($tweak, "");
my $enc_pass_b64 = encode_base64 (pack ("H*", $enc_pass), "");
my $dec_pass = aes_decrypt ($key_b64, $tweak_b64, $enc_pass_b64);
$pbkdf2 = Crypt::PBKDF2->new
(
hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256),
iterations => $iter2,
output_len => 32
);
my $salt2_bin = pack ("H*", $salt2);
my $hash_buf = $pbkdf2->PBKDF2 ($salt2_bin, $dec_pass);
my $hash = sprintf ("\$vbox\$0\$%s\$%s\$16\$%s\$%s\$%s\$%s", $iter1, $salt1, $enc_pass, $iter2, $salt2, unpack ("H*", $hash_buf));
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);
return unless substr ($hash, 0, 6) eq '$vbox$';
my (undef, $signature, $version, $iter1, $salt1, $klen, $enc_pass, $iter2, $salt2) = split '\$', $hash;
return unless defined $signature;
return unless defined $version;
return unless defined $iter1;
return unless defined $salt1;
return unless defined $klen;
return unless defined $enc_pass;
return unless defined $iter2;
return unless defined $salt2;
return unless ($version eq "0");
return unless (length $salt1 eq 64);
return unless ($klen eq "16");
return unless (length $enc_pass eq 128);
return unless (length $salt2 eq 64);
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word, $salt1, $iter1, $enc_pass, $salt2, $iter2);
return ($new_hash, $word);
}
1;

View File

@ -0,0 +1,80 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Based on "pyvboxdie-cracker" (https://github.com/axcheron/pyvboxdie-cracker) (MIT license)
# Author: Gabriele 'matrix' Gristina
# Version: 1.0
# Date: Sat 17 Jul 2021 05:36:37 PM CEST
# License: MIT
import argparse
import xml.dom.minidom
import base64
from struct import *
from binascii import hexlify
keystore_struct = {
'FileHeader': None,
'Version': None,
'EVP_Algorithm': None,
'PBKDF2_Hash': None,
'Key_Length': None,
'Final_Hash': None,
'KL2_PBKDF2': None,
'Salt2_PBKDF2' : None,
'Iteration2_PBKDF2': None,
'Salt1_PBKDF2': None,
'Iteration1_PBKDF2': None,
'EVP_Length': None,
'Enc_Password': None
}
def parse_keystore(file):
keystore = None
try:
fh_vbox = xml.dom.minidom.parse(file)
except IOError:
print('[-] Cannot open:', file)
exit(1)
hds = fh_vbox.getElementsByTagName("HardDisk")
# TODO - Clean up & exceptions
if len(hds) == 0:
print('[-] No hard drive found')
exit(1)
else:
for disk in hds:
is_enc = disk.getElementsByTagName("Property")
if is_enc:
data = disk.getElementsByTagName("Property")[1]
keystore = data.getAttribute("value")
raw_ks = base64.decodebytes(keystore.encode())
unpkt_ks = unpack('<4sxb32s32sI32sI32sI32sII64s', raw_ks)
idx = 0
ks = keystore_struct
for key in ks.keys():
ks[key] = unpkt_ks[idx]
idx += 1
return ks
def pyvboxdie(vbox):
keystore = parse_keystore(vbox)
print("$vbox$0$" + str(keystore['Iteration1_PBKDF2']) + "$" + hexlify(keystore['Salt1_PBKDF2']).decode() + "$" + str(int(keystore['Key_Length'] / 4)) + "$" + hexlify(keystore['Enc_Password'][0:keystore['Key_Length']]).decode() + "$" + str(keystore['Iteration2_PBKDF2']) + "$" + hexlify(keystore['Salt2_PBKDF2']).decode() + "$" + hexlify(keystore['Final_Hash'].rstrip(b'\x00')).decode())
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="virtualbox2hashcat extraction tool")
parser.add_argument('--vbox', required=True, help='set virtualbox vbox file from path', type=str)
args = parser.parse_args()
if args.vbox:
pyvboxdie(args.vbox)
else:
parser.print_help()
exit(1)