From 8b7e83b72f08f9a57945bb11528dab914c8db6ba Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 22 Dec 2020 20:30:17 +0100 Subject: [PATCH 01/56] Added hash-mode 26000 - OpenEdge Progress Encode --- OpenCL/m26000_a0-pure.cl | 234 +++++++++++++++++++++++ OpenCL/m26000_a1-pure.cl | 367 +++++++++++++++++++++++++++++++++++++ OpenCL/m26000_a3-pure.cl | 254 +++++++++++++++++++++++++ docs/changes.txt | 1 + docs/readme.txt | 1 + src/modules/module_26000.c | 184 +++++++++++++++++++ 6 files changed, 1041 insertions(+) create mode 100644 OpenCL/m26000_a0-pure.cl create mode 100644 OpenCL/m26000_a1-pure.cl create mode 100644 OpenCL/m26000_a3-pure.cl create mode 100644 src/modules/module_26000.c diff --git a/OpenCL/m26000_a0-pure.cl b/OpenCL/m26000_a0-pure.cl new file mode 100644 index 000000000..48a8b9e9c --- /dev/null +++ b/OpenCL/m26000_a0-pure.cl @@ -0,0 +1,234 @@ +/** + * 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_rp.h" +#include "inc_rp.cl" +#include "inc_scalar.cl" +#endif + +CONSTANT_VK u32a PE_CONST[256] = +{ + 0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088, + 52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265, + 55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385, + 5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160, + 61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529, + 15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400, + 10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328, + 58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409, + 40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049, + 27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688, + 30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808, + 46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121, + 20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568, + 39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977, + 34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905, + 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 +}; + +KERNEL_FQ void m26000_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) tmp.i; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < tmp.pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m26000_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) tmp.i; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < tmp.pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m26000_a1-pure.cl b/OpenCL/m26000_a1-pure.cl new file mode 100644 index 000000000..a776b16ac --- /dev/null +++ b/OpenCL/m26000_a1-pure.cl @@ -0,0 +1,367 @@ +/** + * 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" +#endif + +CONSTANT_VK u32a PE_CONST[256] = +{ + 0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088, + 52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265, + 55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385, + 5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160, + 61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529, + 15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400, + 10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328, + 58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409, + 40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049, + 27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688, + 30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808, + 46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121, + 20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568, + 39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977, + 34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905, + 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 +}; + +KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + u32 pw_buf0[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + const u32 pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32 pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32 wordl0[4] = { 0 }; + u32 wordl1[4] = { 0 }; + u32 wordl2[4] = { 0 }; + u32 wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + + u32 wordr0[4] = { 0 }; + u32 wordr1[4] = { 0 }; + u32 wordr2[4] = { 0 }; + u32 wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32 w0[4]; + u32 w1[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + + u32 w[8] = { 0 }; + + w[ 0] = w0[0]; + w[ 1] = w0[1]; + w[ 2] = w0[2]; + w[ 3] = w0[3]; + w[ 4] = w1[0]; + w[ 5] = w1[1]; + w[ 6] = w1[2]; + w[ 7] = w1[3]; + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) w; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m26000_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + u32 pw_buf0[4]; + + pw_buf0[0] = pws[gid].i[0]; + pw_buf0[1] = pws[gid].i[1]; + pw_buf0[2] = pws[gid].i[2]; + pw_buf0[3] = pws[gid].i[3]; + + const u32 pw_l_len = pws[gid].pw_len & 63; + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + + const u32 pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63; + + const u32 pw_len = (pw_l_len + pw_r_len) & 63; + + /** + * concat password candidate + */ + + u32 wordl0[4] = { 0 }; + u32 wordl1[4] = { 0 }; + u32 wordl2[4] = { 0 }; + u32 wordl3[4] = { 0 }; + + wordl0[0] = pw_buf0[0]; + wordl0[1] = pw_buf0[1]; + wordl0[2] = pw_buf0[2]; + wordl0[3] = pw_buf0[3]; + + u32 wordr0[4] = { 0 }; + u32 wordr1[4] = { 0 }; + u32 wordr2[4] = { 0 }; + u32 wordr3[4] = { 0 }; + + wordr0[0] = ix_create_combt (combs_buf, il_pos, 0); + wordr0[1] = ix_create_combt (combs_buf, il_pos, 1); + wordr0[2] = ix_create_combt (combs_buf, il_pos, 2); + wordr0[3] = ix_create_combt (combs_buf, il_pos, 3); + wordr1[0] = ix_create_combt (combs_buf, il_pos, 4); + wordr1[1] = ix_create_combt (combs_buf, il_pos, 5); + wordr1[2] = ix_create_combt (combs_buf, il_pos, 6); + wordr1[3] = ix_create_combt (combs_buf, il_pos, 7); + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len); + } + else + { + switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len); + } + + u32 w0[4]; + u32 w1[4]; + + w0[0] = wordl0[0] | wordr0[0]; + w0[1] = wordl0[1] | wordr0[1]; + w0[2] = wordl0[2] | wordr0[2]; + w0[3] = wordl0[3] | wordr0[3]; + w1[0] = wordl1[0] | wordr1[0]; + w1[1] = wordl1[1] | wordr1[1]; + w1[2] = wordl1[2] | wordr1[2]; + w1[3] = wordl1[3] | wordr1[3]; + + u32 w[8] = { 0 }; + + w[ 0] = w0[0]; + w[ 1] = w0[1]; + w[ 2] = w0[2]; + w[ 3] = w0[3]; + w[ 4] = w1[0]; + w[ 5] = w1[1]; + w[ 6] = w1[2]; + w[ 7] = w1[3]; + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) w; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m26000_a3-pure.cl b/OpenCL/m26000_a3-pure.cl new file mode 100644 index 000000000..9237d24d4 --- /dev/null +++ b/OpenCL/m26000_a3-pure.cl @@ -0,0 +1,254 @@ +/** + * 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" +#endif + +CONSTANT_VK u32a PE_CONST[256] = +{ + 0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088, + 52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265, + 55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385, + 5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160, + 61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529, + 15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400, + 10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328, + 58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409, + 40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049, + 27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688, + 30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808, + 46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121, + 20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568, + 39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977, + 34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905, + 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 +}; + +KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32 w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32 w0r = ix_create_bft (bfs_buf, il_pos); + + const u32 w0 = w0l | w0r; + + w[0] = w0; + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) w; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m26000_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32 w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32 w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32 w0r = ix_create_bft (bfs_buf, il_pos); + + const u32 w0 = w0l | w0r; + + w[0] = w0; + + u32 hash = 17; + + u8 scratch[16] = { 0 }; + + u8 *input = (u8 *) w; + + for (u32 i = 0; i < 5; i++) + { + for (u32 j = 0; j < pw_len; j++) + { + int idx = 15 - (j & 15); + + scratch[idx] ^= input[j]; + } + + for (u32 j = 0; j < 16; j += 2) + { + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[15]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[14]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[13]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[12]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[11]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[10]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 9]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 8]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 7]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 6]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 5]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 4]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 3]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 2]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 1]]); + hash = (hash >> 8 ^ PE_CONST[hash & 0xff] ^ PE_CONST[scratch[ 0]]); + + scratch[j] = (unsigned char)( hash & 0xff); + scratch[j + 1] = (unsigned char)((hash >> 8) & 0xff); + } + } + + u8 target[16] = { 0 }; + + for (u32 i = 0; i < 16; i++) + { + u8 lower = (scratch[i] & 0x7f); + + if ((lower >= 'A' && lower <= 'Z') || (lower >= 'a' && lower <= 'z')) + { + target[i] = lower; + } + else + { + target[i] = (u8)((scratch[i] >> 4) + 0x61); + } + } + + u32 *digest = (u32 *) target; + + const u32 r0 = digest[DGST_R0]; + const u32 r1 = digest[DGST_R1]; + const u32 r2 = digest[DGST_R2]; + const u32 r3 = digest[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/docs/changes.txt b/docs/changes.txt index 387941f96..121deb44d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -14,6 +14,7 @@ - Added hash-mode: RAR3-p (Uncompressed) - Added hash-mode: RSA/DSA/EC/OPENSSH Private Keys - Added hash-mode: sha1(sha1($pass).$salt) +- Added hash-mode: OpenEdge Progress Encode ## ## Bugs diff --git a/docs/readme.txt b/docs/readme.txt index 21fec6f19..72ea75846 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -336,6 +336,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Django (SHA-1) - Web2py pbkdf2-sha512 - TOTP (HMAC-SHA1) +- OpenEdge Progress Encode ## ## Attack-Modes diff --git a/src/modules/module_26000.c b/src/modules/module_26000.c new file mode 100644 index 000000000..835bda64b --- /dev/null +++ b/src/modules/module_26000.c @@ -0,0 +1,184 @@ +/** + * 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" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_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_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; +static const char *HASH_NAME = "OpenEdge Progress Encode"; +static const u64 KERN_TYPE = 26000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_NOT_SALTED; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_HASH_COPY; +static const u32 SALT_TYPE = SALT_TYPE_NONE; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "lebVZteiEsdpkncc"; + +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; } + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + // Extra treatment for Apple systems + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + return jit_build_options; + } + + // ROCM + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->has_vperm == true)) + { + hc_asprintf (&jit_build_options, "-D _unroll"); + } + + return jit_build_options; +} + +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; + + token_t token; + + token.token_cnt = 1; + + token.len_min[0] = 16; + token.len_max[0] = 16; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = (u8 *) token.buf[0]; + const u32 hash_len = token.len[0]; + + memcpy ((u8 *)digest, hash_pos, hash_len); + + 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 int line_len = snprintf (line_buf, line_size, "%s", hash_info->orighash); + + 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_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = 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_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = 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_jit_build_options; + 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_DEFAULT; + 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_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} From 9b529dc34c08b758a593de02422a76126ec1899d Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 5 Jun 2021 00:10:17 +0200 Subject: [PATCH 02/56] update hash-mode to 26200 --- OpenCL/{m26000_a0-pure.cl => m26200_a0-pure.cl} | 4 ++-- OpenCL/{m26000_a1-pure.cl => m26200_a1-pure.cl} | 4 ++-- OpenCL/{m26000_a3-pure.cl => m26200_a3-pure.cl} | 4 ++-- src/modules/{module_26000.c => module_26200.c} | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename OpenCL/{m26000_a0-pure.cl => m26200_a0-pure.cl} (98%) rename OpenCL/{m26000_a1-pure.cl => m26200_a1-pure.cl} (99%) rename OpenCL/{m26000_a3-pure.cl => m26200_a3-pure.cl} (98%) rename src/modules/{module_26000.c => module_26200.c} (99%) diff --git a/OpenCL/m26000_a0-pure.cl b/OpenCL/m26200_a0-pure.cl similarity index 98% rename from OpenCL/m26000_a0-pure.cl rename to OpenCL/m26200_a0-pure.cl index 48a8b9e9c..5728a4b33 100644 --- a/OpenCL/m26000_a0-pure.cl +++ b/OpenCL/m26200_a0-pure.cl @@ -35,7 +35,7 @@ CONSTANT_VK u32a PE_CONST[256] = 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 }; -KERNEL_FQ void m26000_mxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m26200_mxx (KERN_ATTR_RULES ()) { /** * modifier @@ -128,7 +128,7 @@ KERNEL_FQ void m26000_mxx (KERN_ATTR_RULES ()) } } -KERNEL_FQ void m26000_sxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m26200_sxx (KERN_ATTR_RULES ()) { /** * modifier diff --git a/OpenCL/m26000_a1-pure.cl b/OpenCL/m26200_a1-pure.cl similarity index 99% rename from OpenCL/m26000_a1-pure.cl rename to OpenCL/m26200_a1-pure.cl index a776b16ac..8f0de7c25 100644 --- a/OpenCL/m26000_a1-pure.cl +++ b/OpenCL/m26200_a1-pure.cl @@ -33,7 +33,7 @@ CONSTANT_VK u32a PE_CONST[256] = 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 }; -KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26200_mxx (KERN_ATTR_BASIC ()) { /** * modifier @@ -193,7 +193,7 @@ KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) } } -KERNEL_FQ void m26000_sxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26200_sxx (KERN_ATTR_BASIC ()) { /** * modifier diff --git a/OpenCL/m26000_a3-pure.cl b/OpenCL/m26200_a3-pure.cl similarity index 98% rename from OpenCL/m26000_a3-pure.cl rename to OpenCL/m26200_a3-pure.cl index 9237d24d4..8b911e638 100644 --- a/OpenCL/m26000_a3-pure.cl +++ b/OpenCL/m26200_a3-pure.cl @@ -33,7 +33,7 @@ CONSTANT_VK u32a PE_CONST[256] = 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 }; -KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26200_mxx (KERN_ATTR_BASIC ()) { /** * modifier @@ -137,7 +137,7 @@ KERNEL_FQ void m26000_mxx (KERN_ATTR_BASIC ()) } } -KERNEL_FQ void m26000_sxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26200_sxx (KERN_ATTR_BASIC ()) { /** * modifier diff --git a/src/modules/module_26000.c b/src/modules/module_26200.c similarity index 99% rename from src/modules/module_26000.c rename to src/modules/module_26200.c index 835bda64b..b9445df79 100644 --- a/src/modules/module_26000.c +++ b/src/modules/module_26200.c @@ -18,7 +18,7 @@ static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; static const char *HASH_NAME = "OpenEdge Progress Encode"; -static const u64 KERN_TYPE = 26000; +static const u64 KERN_TYPE = 26200; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_NOT_ITERATED | OPTI_TYPE_NOT_SALTED; From 0719bda7c4b68badd03685ab625b0d76e8e588c3 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sun, 6 Jun 2021 14:32:14 +0200 Subject: [PATCH 03/56] Fix warning with osx build --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index 2f9f07432..77029e3f9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -189,6 +189,7 @@ endif ## because LZMA SDK ifeq ($(CC),clang) CFLAGS += -Wno-enum-conversion +CFLAGS += -Wno-typedef-redefinition endif ## because ZLIB From e8ad343153a47ad2b9318e3a6e16ee5a3180041a Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 7 Jun 2021 09:34:34 +0200 Subject: [PATCH 04/56] Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux) --- docs/changes.txt | 1 + src/hwmon.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 627e882a3..7f0b6a446 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -42,6 +42,7 @@ - AES Crypt Plugin: Reduced max password length from 256 to 128 which improved performance by 22% - CUDA Backend: Do not warn about missing CUDA SDK installation if --stdout is used - Folder Management: Add support for XDG Base Directory specification if hashcat was installed using make install +- Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux) - OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name in case OpenCL runtime supports this query - Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support diff --git a/src/hwmon.c b/src/hwmon.c index e93cd77bc..502a606b6 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -394,6 +394,57 @@ static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backe return 0; } +static int hm_SYSFS_get_gpu_busy_percent (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/gpu_busy_percent", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int util = 0; + + while (!hc_feof (&fp)) + { + char buf[HCBUFSIZ_TINY]; + + char *ptr = hc_fgets (buf, sizeof (buf), &fp); + + if (ptr == NULL) continue; + + size_t len = strlen (ptr); + + if (len < 1) continue; + + int rc = sscanf (ptr, "%d", &util); + + if (rc == 1) break; + } + + hc_fclose (&fp); + + *val = util; + + hcfree (path); + + return 0; +} + // nvml functions static int nvml_init (hashcat_ctx_t *hashcat_ctx) @@ -1896,6 +1947,20 @@ int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b return PMActivity.iActivityPercent; } + + if (hwmon_ctx->hm_sysfs) + { + int util; + + if (hm_SYSFS_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; + + return -1; + } + + return util; + } } if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_NV) @@ -2575,6 +2640,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_adapters_sysfs[device_id].fanpolicy_get_supported = true; hm_adapters_sysfs[device_id].memoryspeed_get_supported = true; hm_adapters_sysfs[device_id].temperature_get_supported = true; + hm_adapters_sysfs[device_id].utilization_get_supported = true; } } } From fdccc8287dca0f4df1b6aee7732c3769ab9d1170 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 7 Jun 2021 12:12:01 +0200 Subject: [PATCH 05/56] Fixed free memory size output for skipped GPU (both automatic and manual) of --backend-info information screen --- docs/changes.txt | 3 ++- src/backend.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 7f0b6a446..335139c9c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -32,8 +32,9 @@ ## - Fixed error message in -a 9 mode with rules in case number of words from wordlist are not in sync with number of unique salts -- Fixed false negatives with TrueCrypt/VeraCrypt in case zip or gzip compressed files were used as keyfiles - Fixed error handling logic in monitor thread to not return in case of error (disc full, permission error, ...) but to retry instead +- Fixed false negatives with TrueCrypt/VeraCrypt in case zip or gzip compressed files were used as keyfiles +- Fixed free memory size output for skipped GPU (both automatic and manual) of --backend-info information screen ## ## Improvements diff --git a/src/backend.c b/src/backend.c index 3e926a59a..760a14b3c 100644 --- a/src/backend.c +++ b/src/backend.c @@ -7059,7 +7059,12 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (device_param->is_opencl == false) continue; - if (device_param->skipped == true) continue; + if (user_options->backend_info == false) + { + // do not ignore in case -I because user expects a value also for skipped devices + + if (device_param->skipped == true) continue; + } /** * create context for each device From 1e51ca06748ff0406b536944bc5306ed0d087740 Mon Sep 17 00:00:00 2001 From: pelle Date: Mon, 7 Jun 2021 12:44:27 +0200 Subject: [PATCH 06/56] Enabled "unused" pw-max configurations. --- src/modules/module_07000.c | 2 +- src/modules/module_07400.c | 2 +- src/modules/module_07401.c | 2 +- src/modules/module_07800.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/module_07000.c b/src/modules/module_07000.c index 27238be10..aa19f0677 100644 --- a/src/modules/module_07000.c +++ b/src/modules/module_07000.c @@ -243,7 +243,7 @@ void module_init (module_ctx_t *module_ctx) 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_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; diff --git a/src/modules/module_07400.c b/src/modules/module_07400.c index 27e08fc20..f8ebca33d 100644 --- a/src/modules/module_07400.c +++ b/src/modules/module_07400.c @@ -413,7 +413,7 @@ void module_init (module_ctx_t *module_ctx) 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_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; diff --git a/src/modules/module_07401.c b/src/modules/module_07401.c index a757d1e1f..b96318d8e 100644 --- a/src/modules/module_07401.c +++ b/src/modules/module_07401.c @@ -458,7 +458,7 @@ void module_init (module_ctx_t *module_ctx) 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_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; diff --git a/src/modules/module_07800.c b/src/modules/module_07800.c index 5b55abe44..878847c7a 100644 --- a/src/modules/module_07800.c +++ b/src/modules/module_07800.c @@ -219,7 +219,7 @@ void module_init (module_ctx_t *module_ctx) 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_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; From 7a15466442d755c5c9e786bdff31fe09e6334c88 Mon Sep 17 00:00:00 2001 From: Yaakov Saxon Date: Mon, 7 Jun 2021 12:07:29 -0400 Subject: [PATCH 07/56] Update module_07000.c better? sensible change revert dgst_pos update kernel file update other 2 pure kernels updating DGST_POS* to match other SHA256 hash formats comments removing optimized that I haven't updated updated testfile renaming to 07010 restoring original 07000 files comments --- OpenCL/m07010_a0-pure.cl | 181 +++++++++++++++++++++++ OpenCL/m07010_a1-pure.cl | 171 +++++++++++++++++++++ OpenCL/m07010_a3-pure.cl | 205 ++++++++++++++++++++++++++ src/modules/module_07010.c | 277 +++++++++++++++++++++++++++++++++++ tools/test_modules/m07010.pm | 63 ++++++++ 5 files changed, 897 insertions(+) create mode 100644 OpenCL/m07010_a0-pure.cl create mode 100644 OpenCL/m07010_a1-pure.cl create mode 100644 OpenCL/m07010_a3-pure.cl create mode 100644 src/modules/module_07010.c create mode 100644 tools/test_modules/m07010.pm diff --git a/OpenCL/m07010_a0-pure.cl b/OpenCL/m07010_a0-pure.cl new file mode 100644 index 000000000..10e8c91cd --- /dev/null +++ b/OpenCL/m07010_a0-pure.cl @@ -0,0 +1,181 @@ +/** + * 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_rp.h" +#include "inc_rp.cl" +#include "inc_scalar.cl" +#include "inc_hash_sha256.cl" +#endif + +KERNEL_FQ void m07000_mxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx = ctx0; + + sha256_update_swap (&ctx, tmp.i, tmp.pw_len); + + /** + * pepper + */ + + u32 p0[4]; + u32 p1[4]; + u32 p2[4]; + u32 p3[4]; + + p0[0] = hc_swap32_S (FORTIGATE_A); + p0[1] = hc_swap32_S (FORTIGATE_B); + p0[2] = hc_swap32_S (FORTIGATE_C); + p0[3] = hc_swap32_S (FORTIGATE_D); + p1[0] = hc_swap32_S (FORTIGATE_E); + p1[1] = hc_swap32_S (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m07000_sxx (KERN_ATTR_RULES ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + COPY_PW (pws[gid]); + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha256_ctx_t ctx = ctx0; + + sha256_update_swap (&ctx, tmp.i, tmp.pw_len); + + /** + * pepper + */ + + u32 p0[4]; + u32 p1[4]; + u32 p2[4]; + u32 p3[4]; + + p0[0] = hc_swap32_S (FORTIGATE_A); + p0[1] = hc_swap32_S (FORTIGATE_B); + p0[2] = hc_swap32_S (FORTIGATE_C); + p0[3] = hc_swap32_S (FORTIGATE_D); + p1[0] = hc_swap32_S (FORTIGATE_E); + p1[1] = hc_swap32_S (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m07010_a1-pure.cl b/OpenCL/m07010_a1-pure.cl new file mode 100644 index 000000000..a10288003 --- /dev/null +++ b/OpenCL/m07010_a1-pure.cl @@ -0,0 +1,171 @@ +/** + * 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_scalar.cl" +#include "inc_hash_sha256.cl" +#endif + +KERNEL_FQ void m07000_mxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha256_ctx_t ctx = ctx0; + + sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + /** + * pepper + */ + + u32 p0[4]; + u32 p1[4]; + u32 p2[4]; + u32 p3[4]; + + p0[0] = hc_swap32_S (FORTIGATE_A); + p0[1] = hc_swap32_S (FORTIGATE_B); + p0[2] = hc_swap32_S (FORTIGATE_C); + p0[3] = hc_swap32_S (FORTIGATE_D); + p1[0] = hc_swap32_S (FORTIGATE_E); + p1[1] = hc_swap32_S (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_M_SCALAR (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m07000_sxx (KERN_ATTR_BASIC ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + sha256_update_global_swap (&ctx0, pws[gid].i, pws[gid].pw_len); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + { + sha256_ctx_t ctx = ctx0; + + sha256_update_global_swap (&ctx, combs_buf[il_pos].i, combs_buf[il_pos].pw_len); + + /** + * pepper + */ + + u32 p0[4]; + u32 p1[4]; + u32 p2[4]; + u32 p3[4]; + + p0[0] = hc_swap32_S (FORTIGATE_A); + p0[1] = hc_swap32_S (FORTIGATE_B); + p0[2] = hc_swap32_S (FORTIGATE_C); + p0[3] = hc_swap32_S (FORTIGATE_D); + p1[0] = hc_swap32_S (FORTIGATE_E); + p1[1] = hc_swap32_S (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final (&ctx); + + const u32 r0 = ctx.h[DGST_R0]; + const u32 r1 = ctx.h[DGST_R1]; + const u32 r2 = ctx.h[DGST_R2]; + const u32 r3 = ctx.h[DGST_R3]; + + COMPARE_S_SCALAR (r0, r1, r2, r3); + } +} diff --git a/OpenCL/m07010_a3-pure.cl b/OpenCL/m07010_a3-pure.cl new file mode 100644 index 000000000..3617feb14 --- /dev/null +++ b/OpenCL/m07010_a3-pure.cl @@ -0,0 +1,205 @@ +/** + * 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" +#endif + +KERNEL_FQ void m07000_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx; + + sha256_init_vector_from_scalar (&ctx, &ctx0); + + sha256_update_vector (&ctx, w, pw_len); + + /** + * pepper + */ + + u32x p0[4]; + u32x p1[4]; + u32x p2[4]; + u32x p3[4]; + + p0[0] = hc_swap32 (FORTIGATE_A); + p0[1] = hc_swap32 (FORTIGATE_B); + p0[2] = hc_swap32 (FORTIGATE_C); + p0[3] = hc_swap32 (FORTIGATE_D); + p1[0] = hc_swap32 (FORTIGATE_E); + p1[1] = hc_swap32 (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_vector_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_M_SIMD (r0, r1, r2, r3); + } +} + +KERNEL_FQ void m07000_sxx (KERN_ATTR_VECTOR ()) +{ + /** + * modifier + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + + if (gid >= gid_max) return; + + /** + * digest + */ + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + }; + + /** + * base + */ + + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + sha256_ctx_t ctx0; + + sha256_init (&ctx0); + + sha256_update_global_swap (&ctx0, salt_bufs[SALT_POS].salt_buf, salt_bufs[SALT_POS].salt_len); + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + sha256_ctx_vector_t ctx; + + sha256_init_vector_from_scalar (&ctx, &ctx0); + + sha256_update_vector (&ctx, w, pw_len); + + /** + * pepper + */ + + u32x p0[4]; + u32x p1[4]; + u32x p2[4]; + u32x p3[4]; + + p0[0] = hc_swap32 (FORTIGATE_A); + p0[1] = hc_swap32 (FORTIGATE_B); + p0[2] = hc_swap32 (FORTIGATE_C); + p0[3] = hc_swap32 (FORTIGATE_D); + p1[0] = hc_swap32 (FORTIGATE_E); + p1[1] = hc_swap32 (FORTIGATE_F); + p1[2] = 0; + p1[3] = 0; + p2[0] = 0; + p2[1] = 0; + p2[2] = 0; + p2[3] = 0; + p3[0] = 0; + p3[1] = 0; + p3[2] = 0; + p3[3] = 0; + + sha256_update_vector_64 (&ctx, p0, p1, p2, p3, 24); + + sha256_final_vector (&ctx); + + const u32x r0 = ctx.h[DGST_R0]; + const u32x r1 = ctx.h[DGST_R1]; + const u32x r2 = ctx.h[DGST_R2]; + const u32x r3 = ctx.h[DGST_R3]; + + COMPARE_S_SIMD (r0, r1, r2, r3); + } +} diff --git a/src/modules/module_07010.c b/src/modules/module_07010.c new file mode 100644 index 000000000..c55d6b923 --- /dev/null +++ b/src/modules/module_07010.c @@ -0,0 +1,277 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + * + * based on work by Nicolas B. + * + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 3; +static const u32 DGST_POS1 = 7; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 6; +static const u32 DGST_SIZE = DGST_SIZE_4_8; +static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; +static const char *HASH_NAME = "FortiGate256 (FortiOS256)"; +static const u64 KERN_TYPE = 7000; +static const u32 OPTI_TYPE = OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "backup"; +static const char *ST_HASH = "SH2MCKr6kt9rLQKbn/YTlncOnR6OtcJ1YL/h8hw2wWicjSRf3bbkSrL+q6cDpg="; + +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; } + +static const char *SIGNATURE_FORTIGATE = "SH2"; + +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) +{ + u32 pw_max = PW_MAX; + + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + if (optimized_kernel == true) + { + pw_max = 31; + } + + 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; + + token_t token; + + token.token_cnt = 2; + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_FORTIGATE; + + token.len[0] = 3; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.len[1] = 60; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64A; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + /** + * verify data + */ + + const u8 *hash_pos = token.buf[1]; + const int hash_len = token.len[1]; + + // decode salt + SHA1 hash (12 + 20 = 32) + //new 12+32=44 + + u8 tmp_buf[100] = { 0 }; + + const int decoded_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf); + + if (decoded_len != 44) return (PARSER_HASH_LENGTH); + + /** + * store data + */ + + // salt + + u32 salt_len = 12; + + memcpy (salt->salt_buf, tmp_buf, salt_len); + + salt->salt_len = salt_len; + + // digest + + memcpy (digest, tmp_buf + salt_len, 32); + + 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]); + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } + + 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; + + char tmp_buf[64]; + + // salt + + memcpy (tmp_buf, salt->salt_buf, 12); + + // digest + + u32 tmp[8]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + tmp[4] = digest[4]; + tmp[5] = digest[5]; + tmp[6] = digest[6]; + tmp[7] = digest[7]; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); + tmp[7] = byte_swap_32 (tmp[7]); + + memcpy (tmp_buf + 12, tmp, 32); + + // base64 encode (salt + SHA1) + // new would be salt+sha256 + + char ptr_plain[64]; + + base64_encode (int_to_base64, (const u8 *) tmp_buf, 12 + 32, (u8 *) ptr_plain); + + ptr_plain[60] = 0; + + const int line_len = snprintf (line_buf, line_size, "%s%s", SIGNATURE_FORTIGATE, ptr_plain); + + 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_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = 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_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = 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_DEFAULT; + 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_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/test_modules/m07010.pm b/tools/test_modules/m07010.pm new file mode 100644 index 000000000..c5f0cfb67 --- /dev/null +++ b/tools/test_modules/m07010.pm @@ -0,0 +1,63 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Digest::SHA qw (sha256); +use MIME::Base64 qw (encode_base64 decode_base64); + +sub module_constraints { [[0, 256], [24, 24], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + + my $FORTIGATE_SIGNATURE = "SH2"; + my $FORTIGATE_MAGIC = pack ("H*", "a388ba2e424cb04a537930c13107cc3fa1329029a9815b70"); + + my $salt_bin = pack ("H*", $salt); + + my $hash_buf = sha256 ($salt_bin . $word . $FORTIGATE_MAGIC); + + $hash_buf = encode_base64 ($salt_bin . $hash_buf, ""); + + my $hash = sprintf ("%s%s", $FORTIGATE_SIGNATURE, $hash_buf); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my $index1 = index ($line, ":"); + + return if $index1 != 63; + + my $hash_in = substr ($line, 0, $index1); + + my $word = substr ($line, $index1 + 1); + + my $decoded = decode_base64 (substr ($hash_in, 3)); + + my $salt = substr ($decoded, 0, 12); + + $salt = unpack ("H*", $salt); + + return unless defined $salt; + return unless defined $word; + + $word = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word, $salt); + + return ($new_hash, $word); +} + +1; From db6a079bcaeccc92c48716f979a9c57e08799d8d Mon Sep 17 00:00:00 2001 From: Yaakov Saxon Date: Mon, 7 Jun 2021 12:34:30 -0400 Subject: [PATCH 08/56] (07000->07010 in code) --- OpenCL/m07010_a0-pure.cl | 4 ++-- OpenCL/m07010_a1-pure.cl | 4 ++-- OpenCL/m07010_a3-pure.cl | 4 ++-- src/modules/module_07010.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenCL/m07010_a0-pure.cl b/OpenCL/m07010_a0-pure.cl index 10e8c91cd..10c75d352 100644 --- a/OpenCL/m07010_a0-pure.cl +++ b/OpenCL/m07010_a0-pure.cl @@ -16,7 +16,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07000_mxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m07010_mxx (KERN_ATTR_RULES ()) { /** * modifier @@ -92,7 +92,7 @@ KERNEL_FQ void m07000_mxx (KERN_ATTR_RULES ()) } } -KERNEL_FQ void m07000_sxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m07010_sxx (KERN_ATTR_RULES ()) { /** * modifier diff --git a/OpenCL/m07010_a1-pure.cl b/OpenCL/m07010_a1-pure.cl index a10288003..cadc253bc 100644 --- a/OpenCL/m07010_a1-pure.cl +++ b/OpenCL/m07010_a1-pure.cl @@ -14,7 +14,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07000_mxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m07010_mxx (KERN_ATTR_BASIC ()) { /** * modifier @@ -86,7 +86,7 @@ KERNEL_FQ void m07000_mxx (KERN_ATTR_BASIC ()) } } -KERNEL_FQ void m07000_sxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m07010_sxx (KERN_ATTR_BASIC ()) { /** * modifier diff --git a/OpenCL/m07010_a3-pure.cl b/OpenCL/m07010_a3-pure.cl index 3617feb14..fea79271d 100644 --- a/OpenCL/m07010_a3-pure.cl +++ b/OpenCL/m07010_a3-pure.cl @@ -14,7 +14,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07000_mxx (KERN_ATTR_VECTOR ()) +KERNEL_FQ void m07010_mxx (KERN_ATTR_VECTOR ()) { /** * modifier @@ -103,7 +103,7 @@ KERNEL_FQ void m07000_mxx (KERN_ATTR_VECTOR ()) } } -KERNEL_FQ void m07000_sxx (KERN_ATTR_VECTOR ()) +KERNEL_FQ void m07010_sxx (KERN_ATTR_VECTOR ()) { /** * modifier diff --git a/src/modules/module_07010.c b/src/modules/module_07010.c index c55d6b923..5a9637242 100644 --- a/src/modules/module_07010.c +++ b/src/modules/module_07010.c @@ -21,7 +21,7 @@ static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "FortiGate256 (FortiOS256)"; -static const u64 KERN_TYPE = 7000; +static const u64 KERN_TYPE = 7010; static const u32 OPTI_TYPE = OPTI_TYPE_PRECOMPUTE_INIT | OPTI_TYPE_EARLY_SKIP | OPTI_TYPE_NOT_ITERATED; From 733f5e82ec78b59a13d1105bd651a12513e37d00 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Tue, 8 Jun 2021 11:12:54 +0200 Subject: [PATCH 09/56] Renamed -m 7010 to -m 26300 --- OpenCL/{m07010_a0-pure.cl => m26300_a0-pure.cl} | 4 ++-- OpenCL/{m07010_a1-pure.cl => m26300_a1-pure.cl} | 4 ++-- OpenCL/{m07010_a3-pure.cl => m26300_a3-pure.cl} | 4 ++-- docs/changes.txt | 1 + docs/readme.txt | 1 + src/modules/{module_07010.c => module_26300.c} | 3 ++- tools/test_modules/{m07010.pm => m26300.pm} | 0 7 files changed, 10 insertions(+), 7 deletions(-) rename OpenCL/{m07010_a0-pure.cl => m26300_a0-pure.cl} (97%) rename OpenCL/{m07010_a1-pure.cl => m26300_a1-pure.cl} (97%) rename OpenCL/{m07010_a3-pure.cl => m26300_a3-pure.cl} (97%) rename src/modules/{module_07010.c => module_26300.c} (99%) rename tools/test_modules/{m07010.pm => m26300.pm} (100%) diff --git a/OpenCL/m07010_a0-pure.cl b/OpenCL/m26300_a0-pure.cl similarity index 97% rename from OpenCL/m07010_a0-pure.cl rename to OpenCL/m26300_a0-pure.cl index 10c75d352..04a2ca3be 100644 --- a/OpenCL/m07010_a0-pure.cl +++ b/OpenCL/m26300_a0-pure.cl @@ -16,7 +16,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07010_mxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m26300_mxx (KERN_ATTR_RULES ()) { /** * modifier @@ -92,7 +92,7 @@ KERNEL_FQ void m07010_mxx (KERN_ATTR_RULES ()) } } -KERNEL_FQ void m07010_sxx (KERN_ATTR_RULES ()) +KERNEL_FQ void m26300_sxx (KERN_ATTR_RULES ()) { /** * modifier diff --git a/OpenCL/m07010_a1-pure.cl b/OpenCL/m26300_a1-pure.cl similarity index 97% rename from OpenCL/m07010_a1-pure.cl rename to OpenCL/m26300_a1-pure.cl index cadc253bc..95e0f3509 100644 --- a/OpenCL/m07010_a1-pure.cl +++ b/OpenCL/m26300_a1-pure.cl @@ -14,7 +14,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07010_mxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26300_mxx (KERN_ATTR_BASIC ()) { /** * modifier @@ -86,7 +86,7 @@ KERNEL_FQ void m07010_mxx (KERN_ATTR_BASIC ()) } } -KERNEL_FQ void m07010_sxx (KERN_ATTR_BASIC ()) +KERNEL_FQ void m26300_sxx (KERN_ATTR_BASIC ()) { /** * modifier diff --git a/OpenCL/m07010_a3-pure.cl b/OpenCL/m26300_a3-pure.cl similarity index 97% rename from OpenCL/m07010_a3-pure.cl rename to OpenCL/m26300_a3-pure.cl index fea79271d..2d8f9b149 100644 --- a/OpenCL/m07010_a3-pure.cl +++ b/OpenCL/m26300_a3-pure.cl @@ -14,7 +14,7 @@ #include "inc_hash_sha256.cl" #endif -KERNEL_FQ void m07010_mxx (KERN_ATTR_VECTOR ()) +KERNEL_FQ void m26300_mxx (KERN_ATTR_VECTOR ()) { /** * modifier @@ -103,7 +103,7 @@ KERNEL_FQ void m07010_mxx (KERN_ATTR_VECTOR ()) } } -KERNEL_FQ void m07010_sxx (KERN_ATTR_VECTOR ()) +KERNEL_FQ void m26300_sxx (KERN_ATTR_VECTOR ()) { /** * modifier diff --git a/docs/changes.txt b/docs/changes.txt index 335139c9c..a80abe10f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -6,6 +6,7 @@ - Added hash-mode: bcrypt(md5($pass)) / bcryptmd5 - Added hash-mode: bcrypt(sha1($pass)) / bcryptsha1 +- Added hash-mode: FortiGate256 (FortiOS256) - Added hash-mode: Linux Kernel Crypto API (2.4) - Added hash-mode: MurmurHash - Added hash-mode: md5(utf16le($pass)) diff --git a/docs/readme.txt b/docs/readme.txt index cf493c1d2..d029c78c4 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -202,6 +202,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Domain Cached Credentials (DCC), MS Cache - Domain Cached Credentials 2 (DCC2), MS Cache 2 - FortiGate (FortiOS) +- FortiGate256 (FortiOS256) - ArubaOS - Juniper IVE - Juniper NetScreen/SSG (ScreenOS) diff --git a/src/modules/module_07010.c b/src/modules/module_26300.c similarity index 99% rename from src/modules/module_07010.c rename to src/modules/module_26300.c index 5a9637242..8fc013d55 100644 --- a/src/modules/module_07010.c +++ b/src/modules/module_26300.c @@ -21,7 +21,7 @@ static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "FortiGate256 (FortiOS256)"; -static const u64 KERN_TYPE = 7010; +static const u64 KERN_TYPE = 26300; static const u32 OPTI_TYPE = OPTI_TYPE_PRECOMPUTE_INIT | OPTI_TYPE_EARLY_SKIP | OPTI_TYPE_NOT_ITERATED; @@ -51,6 +51,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con { u32 pw_max = PW_MAX; + // There's no optimized kernel?! const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); if (optimized_kernel == true) diff --git a/tools/test_modules/m07010.pm b/tools/test_modules/m26300.pm similarity index 100% rename from tools/test_modules/m07010.pm rename to tools/test_modules/m26300.pm From 06025625749ed7b828cbba4619535c1ebf1b082a Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 9 Jun 2021 13:19:33 +0200 Subject: [PATCH 10/56] Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK --- docs/changes.txt | 1 + docs/readme.txt | 6 +++--- src/modules/module_20200.c | 2 +- src/modules/module_20300.c | 2 +- src/modules/module_20400.c | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index a80abe10f..35e79748c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -63,6 +63,7 @@ - Kernels: Add standalone true UTF8 to UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET +- Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK * changes v6.2.0 -> v6.2.1 diff --git a/docs/readme.txt b/docs/readme.txt index d029c78c4..092028b09 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -146,9 +146,6 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - PBKDF2-HMAC-SHA1 - PBKDF2-HMAC-SHA256 - PBKDF2-HMAC-SHA512 -- Python passlib pbkdf2-sha512 -- Python passlib pbkdf2-sha256 -- Python passlib pbkdf2-sha1 - scrypt - phpass - TACACS+ @@ -356,6 +353,9 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Django (SHA-1) - Atlassian (PBKDF2-HMAC-SHA1) - Ruby on Rails Restful-Authentication +- Python passlib pbkdf2-sha512 +- Python passlib pbkdf2-sha256 +- Python passlib pbkdf2-sha1 - PKCS#8 Private Keys (PBKDF2-HMAC-SHA1 + 3DES/AES) - PKCS#8 Private Keys (PBKDF2-HMAC-SHA256 + 3DES/AES) - JKS Java Key Store Private Keys (SHA1) diff --git a/src/modules/module_20200.c b/src/modules/module_20200.c index 912a33b26..9f18dc7d9 100644 --- a/src/modules/module_20200.c +++ b/src/modules/module_20200.c @@ -16,7 +16,7 @@ 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_16; -static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; static const char *HASH_NAME = "Python passlib pbkdf2-sha512"; static const u64 KERN_TYPE = 7100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE diff --git a/src/modules/module_20300.c b/src/modules/module_20300.c index 6254a00f3..0624b8dce 100644 --- a/src/modules/module_20300.c +++ b/src/modules/module_20300.c @@ -16,7 +16,7 @@ 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_64; -static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; static const char *HASH_NAME = "Python passlib pbkdf2-sha256"; static const u64 KERN_TYPE = 10900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE diff --git a/src/modules/module_20400.c b/src/modules/module_20400.c index 2a221e9ff..5df332861 100644 --- a/src/modules/module_20400.c +++ b/src/modules/module_20400.c @@ -16,7 +16,7 @@ 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_32; -static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF; +static const u32 HASH_CATEGORY = HASH_CATEGORY_FRAMEWORK; static const char *HASH_NAME = "Python passlib pbkdf2-sha1"; static const u64 KERN_TYPE = 12000; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE From 27503957aae09377d99cad78844edf98fc65dce5 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 9 Jun 2021 13:25:25 +0200 Subject: [PATCH 11/56] Fix message on startup-mode in --backend-info mode --- src/terminal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index da80ebcf9..6809ca8cd 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -68,7 +68,12 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) event_log_info (hashcat_ctx, "%s (%s) starting in progress-only mode...", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); } - else if (user_options->hash_mode == 0 && user_options->hash_mode_chgd == false) + else if (user_options->backend_info == true) + { + event_log_info (hashcat_ctx, "%s (%s) starting in backend information mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, NULL); + } + else if (user_options->hash_mode_chgd == false) { event_log_info (hashcat_ctx, "%s (%s) starting in autodetect mode...", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); From ebeb003552ef5a528370e3d3a31f5069e28059cd Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 10 Jun 2021 09:02:26 +0200 Subject: [PATCH 12/56] Unit-Tests: Added missing unit-test for Stargazer Stellar Wallet XLM --- OpenCL/m25500-optimized.cl | 455 ----------------------------------- OpenCL/m25500-pure.cl | 182 ++++++++++++++ docs/changes.txt | 1 + src/modules/module_25500.c | 8 +- tools/install_modules.sh | 1 + tools/test_modules/m25500.pm | 112 +++++++++ 6 files changed, 299 insertions(+), 460 deletions(-) delete mode 100644 OpenCL/m25500-optimized.cl create mode 100644 tools/test_modules/m25500.pm diff --git a/OpenCL/m25500-optimized.cl b/OpenCL/m25500-optimized.cl deleted file mode 100644 index dfc292a26..000000000 --- a/OpenCL/m25500-optimized.cl +++ /dev/null @@ -1,455 +0,0 @@ -/** - * 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" -#include "inc_cipher_aes-gcm.cl" -#endif - -#define COMPARE_S "inc_comp_single.cl" -#define COMPARE_M "inc_comp_multi.cl" - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; - -typedef struct pbkdf2_sha256_aes_gcm -{ - u32 salt_buf[64]; - u32 iv_buf[4]; - u32 iv_len; - u32 ct_buf[16]; - u32 ct_len; - -} pbkdf2_sha256_aes_gcm_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 m25500_init (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_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].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 m25500_loop (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_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 m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_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_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_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_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; - - // keys - - u32 ukey[8]; - - ukey[0] = tmps[gid].out[0]; - ukey[1] = tmps[gid].out[1]; - ukey[2] = tmps[gid].out[2]; - ukey[3] = tmps[gid].out[3]; - ukey[4] = tmps[gid].out[4]; - ukey[5] = tmps[gid].out[5]; - ukey[6] = tmps[gid].out[6]; - ukey[7] = tmps[gid].out[7]; - - u32 key[60] = { 0 }; - - u32 subKey[4] = { 0 }; - - AES256_set_encrypt_key (key, ukey, s_te0, s_te1, s_te2, s_te3); - - AES256_encrypt (key, subKey, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); - - // iv - - const u32 iv[4] = { - esalt_bufs[DIGESTS_OFFSET].iv_buf[0], - esalt_bufs[DIGESTS_OFFSET].iv_buf[1], - esalt_bufs[DIGESTS_OFFSET].iv_buf[2], - esalt_bufs[DIGESTS_OFFSET].iv_buf[3] - }; - - u32 J0[4] = { - iv[0], - iv[1], - iv[2], - 0x00000001 - }; - - // ct - - u32 enc[14] = { 0 }; - - enc[ 0] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 0]; - enc[ 1] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 1]; - enc[ 2] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 2]; - enc[ 3] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 3]; - enc[ 4] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 4]; - enc[ 5] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 5]; - enc[ 6] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 6]; - enc[ 7] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 7]; - enc[ 8] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 8]; - enc[ 9] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 9]; - enc[10] = esalt_bufs[DIGESTS_OFFSET].ct_buf[10]; - enc[11] = esalt_bufs[DIGESTS_OFFSET].ct_buf[11]; - enc[12] = esalt_bufs[DIGESTS_OFFSET].ct_buf[12]; - enc[13] = esalt_bufs[DIGESTS_OFFSET].ct_buf[13]; - - u32 enc_len = esalt_bufs[DIGESTS_OFFSET].ct_len; - - u32 S[4] = { 0 }; - - u32 t[4] = { 0 }; - - S[0] ^= enc[0]; - S[1] ^= enc[1]; - S[2] ^= enc[2]; - S[3] ^= enc[3]; - - AES_GCM_gf_mult (S, subKey, t); - - S[0] = t[0] ^ enc[4]; - S[1] = t[1] ^ enc[5]; - S[2] = t[2] ^ enc[6]; - S[3] = t[3] ^ enc[7]; - - AES_GCM_gf_mult (S, subKey, t); - - S[0] = t[0] ^ enc[8]; - S[1] = t[1] ^ enc[9]; - S[2] = t[2] ^ enc[10]; - S[3] = t[3] ^ enc[11]; - - AES_GCM_gf_mult (S, subKey, t); - - S[0] = t[0]; - S[1] = t[1]; - S[2] = t[2]; - S[3] = t[3]; - - t[0] = enc[12]; - t[1] = enc[13]; - t[2] = 0; - t[3] = 0; - - S[0] ^= t[0]; - S[1] ^= t[1]; - S[2] ^= t[2]; - S[3] ^= t[3]; - - AES_GCM_gf_mult (S, subKey, t); - - S[0] = t[0]; - S[1] = t[1]; - S[2] = t[2]; - S[3] = t[3]; - - u32 len_buf[4] = { 0 }; - - len_buf[0] = 0; - len_buf[3] = enc_len * 8; - - S[0] ^= len_buf[0]; - S[1] ^= len_buf[1]; - S[2] ^= len_buf[2]; - S[3] ^= len_buf[3]; - - AES_GCM_gf_mult (S, subKey, t); - - S[0] = t[0]; - S[1] = t[1]; - S[2] = t[2]; - S[3] = t[3]; - - J0[3] = 0x00000001; - - u32 T[4] = { 0 }; - - AES256_encrypt (key, J0, T, s_te0, s_te1, s_te2, s_te3, s_te4); - - /* compare tag */ - - const u32 r0 = T[0] ^ S[0]; - const u32 r1 = T[1] ^ S[1]; - const u32 r2 = T[2] ^ S[2]; - const u32 r3 = T[3] ^ S[3]; - - #define il_pos 0 - - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif -} diff --git a/OpenCL/m25500-pure.cl b/OpenCL/m25500-pure.cl index 56dddb096..81e1ba4b6 100644 --- a/OpenCL/m25500-pure.cl +++ b/OpenCL/m25500-pure.cl @@ -403,3 +403,185 @@ KERNEL_FQ void m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh #include COMPARE_M #endif } + +/* +Optimized GCM: No real speed benefit. For documentation purpose + +KERNEL_FQ void m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sha256_aes_gcm_t)) +{ + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + #ifdef REAL_SHM + + 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_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_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; + + // keys + + u32 ukey[8]; + + ukey[0] = tmps[gid].out[0]; + ukey[1] = tmps[gid].out[1]; + ukey[2] = tmps[gid].out[2]; + ukey[3] = tmps[gid].out[3]; + ukey[4] = tmps[gid].out[4]; + ukey[5] = tmps[gid].out[5]; + ukey[6] = tmps[gid].out[6]; + ukey[7] = tmps[gid].out[7]; + + u32 key[60] = { 0 }; + + u32 subKey[4] = { 0 }; + + AES256_set_encrypt_key (key, ukey, s_te0, s_te1, s_te2, s_te3); + + AES256_encrypt (key, subKey, subKey, s_te0, s_te1, s_te2, s_te3, s_te4); + + // iv + + const u32 iv[4] = { + esalt_bufs[DIGESTS_OFFSET].iv_buf[0], + esalt_bufs[DIGESTS_OFFSET].iv_buf[1], + esalt_bufs[DIGESTS_OFFSET].iv_buf[2], + esalt_bufs[DIGESTS_OFFSET].iv_buf[3] + }; + + u32 J0[4] = { + iv[0], + iv[1], + iv[2], + 0x00000001 + }; + + // ct + + u32 enc[14] = { 0 }; + + enc[ 0] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 0]; + enc[ 1] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 1]; + enc[ 2] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 2]; + enc[ 3] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 3]; + enc[ 4] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 4]; + enc[ 5] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 5]; + enc[ 6] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 6]; + enc[ 7] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 7]; + enc[ 8] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 8]; + enc[ 9] = esalt_bufs[DIGESTS_OFFSET].ct_buf[ 9]; + enc[10] = esalt_bufs[DIGESTS_OFFSET].ct_buf[10]; + enc[11] = esalt_bufs[DIGESTS_OFFSET].ct_buf[11]; + enc[12] = esalt_bufs[DIGESTS_OFFSET].ct_buf[12]; + enc[13] = esalt_bufs[DIGESTS_OFFSET].ct_buf[13]; + + u32 enc_len = esalt_bufs[DIGESTS_OFFSET].ct_len; + + u32 S[4] = { 0 }; + + u32 t[4] = { 0 }; + + S[0] ^= enc[0]; + S[1] ^= enc[1]; + S[2] ^= enc[2]; + S[3] ^= enc[3]; + + AES_GCM_gf_mult (S, subKey, t); + + S[0] = t[0] ^ enc[4]; + S[1] = t[1] ^ enc[5]; + S[2] = t[2] ^ enc[6]; + S[3] = t[3] ^ enc[7]; + + AES_GCM_gf_mult (S, subKey, t); + + S[0] = t[0] ^ enc[8]; + S[1] = t[1] ^ enc[9]; + S[2] = t[2] ^ enc[10]; + S[3] = t[3] ^ enc[11]; + + AES_GCM_gf_mult (S, subKey, t); + + S[0] = t[0]; + S[1] = t[1]; + S[2] = t[2]; + S[3] = t[3]; + + t[0] = enc[12]; + t[1] = enc[13]; + t[2] = 0; + t[3] = 0; + + S[0] ^= t[0]; + S[1] ^= t[1]; + S[2] ^= t[2]; + S[3] ^= t[3]; + + AES_GCM_gf_mult (S, subKey, t); + + S[0] = t[0]; + S[1] = t[1]; + S[2] = t[2]; + S[3] = t[3]; + + u32 len_buf[4] = { 0 }; + + len_buf[0] = 0; + len_buf[3] = enc_len * 8; + + S[0] ^= len_buf[0]; + S[1] ^= len_buf[1]; + S[2] ^= len_buf[2]; + S[3] ^= len_buf[3]; + + AES_GCM_gf_mult (S, subKey, t); + + S[0] = t[0]; + S[1] = t[1]; + S[2] = t[2]; + S[3] = t[3]; + + J0[3] = 0x00000001; + + u32 T[4] = { 0 }; + + AES256_encrypt (key, J0, T, s_te0, s_te1, s_te2, s_te3, s_te4); + + const u32 r0 = T[0] ^ S[0]; + const u32 r1 = T[1] ^ S[1]; + const u32 r2 = T[2] ^ S[2]; + const u32 r3 = T[3] ^ S[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif +} + +*/ diff --git a/docs/changes.txt b/docs/changes.txt index 35e79748c..2e64845d9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -64,6 +64,7 @@ - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET - Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK +- Unit-Tests: Added missing unit-test for Stargazer Stellar Wallet XLM * changes v6.2.0 -> v6.2.1 diff --git a/src/modules/module_25500.c b/src/modules/module_25500.c index e87b183d6..10edd7203 100644 --- a/src/modules/module_25500.c +++ b/src/modules/module_25500.c @@ -22,12 +22,10 @@ static const char *HASH_NAME = "Stargazer Stellar Wallet XLM"; static const u64 KERN_TYPE = 25500; 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 - | OPTS_TYPE_ST_BASE64 - | OPTS_TYPE_HASH_COPY; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; -static const char *ST_PASS = "lacoin"; -static const char *ST_HASH = "$stellar$ZCtl/+vWiLL358Jz+xnP5A==$GgmFU37DSX4evSMU$CoMGXWHqDmLwxRAgORqjK/MyFEMAkMbqvDEDMjn4veVwpHab9m6Egcwp70qEJsRhjkHjCMWj9zX40tu9UK5QACuB8gD1r9Cu"; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "$stellar$YAlIJziURRcBEWUwRSRDWA==$EutMmmcV5Hbf3p1I$rfSAF349RvGKG4R4Z2VCrH9WjNEKjbJa9hpOja9Yn8MwXruuFEMtw47HPn9CYj+JJ5Rb4Z87Wejj1c4fqpbMZHFOnqtQsVAr"; 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; } diff --git a/tools/install_modules.sh b/tools/install_modules.sh index 419f10f32..abec140cc 100755 --- a/tools/install_modules.sh +++ b/tools/install_modules.sh @@ -16,6 +16,7 @@ cpan install Authen::Passphrase::LANManager \ Authen::Passphrase::PHPass \ Compress::Zlib \ Convert::EBCDIC \ + Crypt::AuthEnc::GCM \ Crypt::CBC \ Crypt::DES \ Crypt::DES_EDE3 \ diff --git a/tools/test_modules/m25500.pm b/tools/test_modules/m25500.pm new file mode 100644 index 000000000..a53cf227f --- /dev/null +++ b/tools/test_modules/m25500.pm @@ -0,0 +1,112 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +use Crypt::PBKDF2; +use Crypt::AuthEnc::GCM; +use MIME::Base64 qw (decode_base64 encode_base64); + +sub module_constraints { [[0, 256], [32, 32], [-1, -1], [-1, -1], [-1, -1]] } + +sub module_generate_hash +{ + my $word = shift; + my $salt = shift; + my $iv = shift // random_hex_string (24); + my $ct = shift; + + my $kdf = Crypt::PBKDF2->new + ( + hasher => Crypt::PBKDF2->hasher_from_algorithm ('HMACSHA2', 256), + iterations => 4096, + output_len => 32 + ); + + my $salt_bin = pack ("H*", $salt); + + my $key = $kdf->PBKDF2 ($salt_bin, $word); + + my $iv_bin = pack ("H*", $iv); + + my $pt; + + if (defined $ct) + { + my $ct_bin = pack ("H*", $ct); + + my $data_bin = substr ($ct_bin, 0, -16); + my $tag_bin = substr ($ct_bin, -16); + + my $aes = Crypt::AuthEnc::GCM->new ("AES", $key, $iv_bin); + + $pt = $aes->decrypt_add ($data_bin); + + my $result_tag = $aes->decrypt_done ($tag_bin); + + if ($result_tag == 1) + { + ## correct password + } + else + { + $pt = "\xff" x 56; + } + } + else + { + $pt = "\xff" x 56; + } + + my $aes = Crypt::AuthEnc::GCM->new ("AES", $key, $iv_bin); + + my $ct_bin = $aes->encrypt_add ($pt); + + my $tag_bin = $aes->encrypt_done (); + + my $hash = sprintf ('$stellar$%s$%s$%s', encode_base64 ($salt_bin, ""), encode_base64 ($iv_bin, ""), encode_base64 ($ct_bin . $tag_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); + + return unless substr ($hash, 0, 9) eq '$stellar$'; + + my (undef, $signature, $salt, $iv, $ct) = split '\$', $hash; + + return unless defined $signature; + return unless defined $salt; + return unless defined $iv; + return unless defined $ct; + + my $salt_bin = decode_base64 ($salt); + my $iv_bin = decode_base64 ($iv); + my $ct_bin = decode_base64 ($ct); + + return unless length $salt_bin == 16; + return unless length $iv_bin == 12; + return unless length $ct_bin == 72; + + my $word_packed = pack_if_HEX_notation ($word); + + my $new_hash = module_generate_hash ($word_packed, unpack ("H*", $salt_bin), unpack ("H*", $iv_bin), unpack ("H*", $ct_bin)); + + return ($new_hash, $word); +} + +1; From d59f8c42d29b4859b3a46d072de9ee93e01224b8 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Thu, 10 Jun 2021 10:31:27 +0200 Subject: [PATCH 13/56] Prepare FBE support --- include/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/types.h b/include/types.h index 62b242e5d..192c0998b 100644 --- a/include/types.h +++ b/include/types.h @@ -2682,7 +2682,7 @@ typedef enum hash_category HASH_CATEGORY_PRIVATE_KEY = 20, HASH_CATEGORY_IMS = 21, HASH_CATEGORY_CRYPTOCURRENCY_WALLET = 22, - + HASH_CATEGORY_FBE = 23 } hash_category_t; // hash specific From 6430b7ab71e6ac0f92ef4222bbb89072e1d3a021 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Thu, 10 Jun 2021 20:09:03 +0200 Subject: [PATCH 14/56] Fix FBE description --- src/shared.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared.c b/src/shared.c index b7833b14a..46046346d 100644 --- a/src/shared.c +++ b/src/shared.c @@ -97,6 +97,7 @@ static const char *HASH_CATEGORY_OS_STR = "Operating System" static const char *HASH_CATEGORY_EAS_STR = "Enterprise Application Software (EAS)"; static const char *HASH_CATEGORY_ARCHIVE_STR = "Archives"; static const char *HASH_CATEGORY_FDE_STR = "Full-Disk Encryption (FDE)"; +static const char *HASH_CATEGORY_FBE_STR = "File-Based Encryption (FBE)"; static const char *HASH_CATEGORY_DOCUMENTS_STR = "Documents"; static const char *HASH_CATEGORY_PASSWORD_MANAGER_STR = "Password Managers"; static const char *HASH_CATEGORY_OTP_STR = "One-Time Passwords"; @@ -952,6 +953,7 @@ const char *strhashcategory (const u32 hash_category) case HASH_CATEGORY_EAS: return HASH_CATEGORY_EAS_STR; case HASH_CATEGORY_ARCHIVE: return HASH_CATEGORY_ARCHIVE_STR; case HASH_CATEGORY_FDE: return HASH_CATEGORY_FDE_STR; + case HASH_CATEGORY_FBE: return HASH_CATEGORY_FBE_STR; case HASH_CATEGORY_DOCUMENTS: return HASH_CATEGORY_DOCUMENTS_STR; case HASH_CATEGORY_PASSWORD_MANAGER: return HASH_CATEGORY_PASSWORD_MANAGER_STR; case HASH_CATEGORY_OTP: return HASH_CATEGORY_OTP_STR; From e5de44c80d55ce0a2746163e5a39f1d6634a3c96 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 10 Jun 2021 20:13:12 +0200 Subject: [PATCH 15/56] Restyling hwmon (2021)(2) --- include/ext_ADL.h | 14 + include/ext_nvapi.h | 11 + include/ext_nvml.h | 16 + include/ext_sysfs.h | 13 + src/ext_ADL.c | 276 +++++++++ src/ext_nvapi.c | 233 ++++++++ src/ext_nvml.c | 386 +++++++++++++ src/ext_sysfs.c | 436 ++++++++++++++ src/hwmon.c | 1317 ------------------------------------------- 9 files changed, 1385 insertions(+), 1317 deletions(-) diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 18a903b70..fd8438c8e 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -314,4 +314,18 @@ typedef hm_adl_lib_t ADL_PTR; void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize); +int adl_init (void *hashcat_ctx); +void adl_close (void *hashcat_ctx); +int hm_ADL_Main_Control_Destroy (void *hashcat_ctx); +int hm_ADL_Main_Control_Create (void *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); +int hm_ADL_Adapter_NumberOfAdapters_Get (void *hashcat_ctx, int *lpNumAdapters); +int hm_ADL_Adapter_AdapterInfo_Get (void *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize); +int hm_ADL_Overdrive5_Temperature_Get (void *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature); +int hm_ADL_Overdrive6_Temperature_Get (void *hashcat_ctx, int iAdapterIndex, int *iTemperature); +int hm_ADL_Overdrive_CurrentActivity_Get (void *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity); +int hm_ADL_Overdrive5_FanSpeed_Get (void *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue); +int hm_ADL_Overdrive6_FanSpeed_Get (void *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo); +int hm_ADL_Overdrive_Caps (void *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version); +int hm_ADL_Overdrive6_TargetTemperatureData_Get (void *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp); + #endif // _EXT_ADL_H diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index 5ef6bdb1c..b72cd357c 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -239,4 +239,15 @@ typedef struct hm_nvapi_lib typedef hm_nvapi_lib_t NVAPI_PTR; +int nvapi_init (void *hashcat_ctx); +void nvapi_close (void *hashcat_ctx); +void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI_rc, NvAPI_ShortString string); +int hm_NvAPI_Initialize (void *hashcat_ctx); +int hm_NvAPI_Unload (void *hashcat_ctx); +int hm_NvAPI_EnumPhysicalGPUs (void *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount); +int hm_NvAPI_GPU_GetPerfPoliciesInfo (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info); +int hm_NvAPI_GPU_GetPerfPoliciesStatus (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); +int hm_NvAPI_GPU_GetBusId (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusId); +int hm_NvAPI_GPU_GetBusSlotId (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusSlotId); + #endif // _EXT_NVAPI_H diff --git a/include/ext_nvml.h b/include/ext_nvml.h index b2b11887d..74396810d 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -217,4 +217,20 @@ typedef struct hm_nvml_lib typedef hm_nvml_lib_t NVML_PTR; +int nvml_init (void *hashcat_ctx); +void nvml_close (void *hashcat_ctx); +const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t nvml_rc); + +int hm_NVML_nvmlInit (void *hashcat_ctx); +int hm_NVML_nvmlShutdown (void *hashcat_ctx); +int hm_NVML_nvmlDeviceGetCount (void *hashcat_ctx, unsigned int *deviceCount); +int hm_NVML_nvmlDeviceGetHandleByIndex (void *hashcat_ctx, unsigned int device_index, nvmlDevice_t *device); +int hm_NVML_nvmlDeviceGetTemperature (void *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp); +int hm_NVML_nvmlDeviceGetFanSpeed (void *hashcat_ctx, nvmlDevice_t device, unsigned int *speed); +int hm_NVML_nvmlDeviceGetUtilizationRates (void *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization); +int hm_NVML_nvmlDeviceGetClockInfo (void *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clockfreq); +int hm_NVML_nvmlDeviceGetTemperatureThreshold (void *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp); +int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (void *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth); +int hm_NVML_nvmlDeviceGetPciInfo (void *hashcat_ctx, nvmlDevice_t device, nvmlPciInfo_t *pci); + #endif // _NVML_H diff --git a/include/ext_sysfs.h b/include/ext_sysfs.h index 8ce8cddd7..02dfd6177 100644 --- a/include/ext_sysfs.h +++ b/include/ext_sysfs.h @@ -6,6 +6,8 @@ #ifndef _EXT_SYSFS_H #define _EXT_SYSFS_H +#include + static const char SYS_BUS_PCI_DEVICES[] = "/sys/bus/pci/devices"; typedef int HM_ADAPTER_SYSFS; @@ -22,4 +24,15 @@ typedef struct hm_sysfs_lib typedef hm_sysfs_lib_t SYSFS_PTR; +bool sysfs_init (void *hashcat_ctx); +void sysfs_close (void *hashcat_ctx); +char *hm_SYSFS_get_syspath_device (void *hashcat_ctx, const int backend_device_idx); +char *hm_SYSFS_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx); +int hm_SYSFS_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val); + #endif // _EXT_SYSFS_H diff --git a/src/ext_ADL.c b/src/ext_ADL.c index 4d35ff9c8..e54420713 100644 --- a/src/ext_ADL.c +++ b/src/ext_ADL.c @@ -5,9 +5,285 @@ #include "common.h" #include "types.h" +#include "memory.h" +#include "event.h" #include "ext_ADL.h" +#include "dynloader.h" + void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize) { return malloc ((size_t) iSize); } + +int adl_init (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + memset (adl, 0, sizeof (ADL_PTR)); + + #if defined (_WIN) + adl->lib = hc_dlopen ("atiadlxx.dll"); + + if (!adl->lib) + { + adl->lib = hc_dlopen ("atiadlxy.dll"); + } + #elif defined (__CYGWIN__) + adl->lib = hc_dlopen ("atiadlxx.dll"); + + if (!adl->lib) + { + adl->lib = hc_dlopen ("atiadlxy.dll"); + } + #elif defined (_POSIX) + adl->lib = hc_dlopen ("libatiadlxx.so"); + #endif + + if (!adl->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "Load of ADL library failed. Proceeding without ADL HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0); + HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0); + + return 0; +} + +void adl_close (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + if (adl) + { + if (adl->lib) + hc_dlclose (adl->lib); + + hcfree (adl); + } +} + +int hm_ADL_Main_Control_Destroy (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Main_Control_Destroy (); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Main_Control_Destroy(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Main_Control_Create (void *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Main_Control_Create(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_NumberOfAdapters_Get (void *hashcat_ctx, int *lpNumAdapters) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Adapter_NumberOfAdapters_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Adapter_AdapterInfo_Get (void *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Adapter_AdapterInfo_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_Temperature_Get (void *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Overdrive5_Temperature_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_Temperature_Get (void *hashcat_ctx, int iAdapterIndex, int *iTemperature) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Overdrive6_Temperature_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_CurrentActivity_Get (void *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Overdrive5_CurrentActivity_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive5_FanSpeed_Get (void *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeed_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_FanSpeed_Get (void *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo); + + if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here + { + event_log_error (hashcat_ctx, "ADL_Overdrive6_FanSpeed_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive_Caps (void *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Overdrive_Caps(): %d", ADL_rc); + + return -1; + } + + return 0; +} + +int hm_ADL_Overdrive6_TargetTemperatureData_Get (void *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; + + const int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp); + + if (ADL_rc != ADL_OK) + { + event_log_error (hashcat_ctx, "ADL_Overdrive6_TargetTemperatureData_Get(): %d", ADL_rc); + + return -1; + } + + return 0; +} diff --git a/src/ext_nvapi.c b/src/ext_nvapi.c index 4fad053ff..d4607ad84 100644 --- a/src/ext_nvapi.c +++ b/src/ext_nvapi.c @@ -5,4 +5,237 @@ #include "common.h" #include "types.h" +#include "memory.h" +#include "event.h" #include "ext_nvapi.h" + +#include "dynloader.h" + +int nvapi_init (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + memset (nvapi, 0, sizeof (NVAPI_PTR)); + + #if defined (_WIN) + + #if defined (_WIN64) + nvapi->lib = hc_dlopen ("nvapi64.dll"); + #else + nvapi->lib = hc_dlopen ("nvapi.dll"); + #endif + + #else + + #if defined (__CYGWIN__) + + #if defined (__x86_x64__) + nvapi->lib = hc_dlopen ("nvapi64.dll"); + #else + nvapi->lib = hc_dlopen ("nvapi.dll"); + #endif + + #else + nvapi->lib = hc_dlopen ("nvapi.so"); // uhm yes, but .. yeah + #endif + + #endif + + if (!nvapi->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "Load of NVAPI library failed. Proceeding without NVAPI HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7EU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048CU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921FU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0CU, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusId, NVAPI_GPU_GETBUSID, nvapi_QueryInterface, 0x1BE0B8E5U, NVAPI, 0); + HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusSlotId, NVAPI_GPU_GETBUSSLOTID, nvapi_QueryInterface, 0x2A0A350FU, NVAPI, 0); + + return 0; +} + +void nvapi_close (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + if (nvapi) + { + if (nvapi->lib) + hc_dlclose (nvapi->lib); + + hcfree (nvapi); + } +} + +void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI_rc, NvAPI_ShortString string) +{ + nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); +} + +int hm_NvAPI_Initialize (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Initialize (); + + if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) return -1; + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_Initialize(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_Unload (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Unload (); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_Unload(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_EnumPhysicalGPUs (void *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_EnumPhysicalGPUs(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetPerfPoliciesInfo (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesInfo(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetPerfPoliciesStatus (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesStatus(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetBusId (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusId) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusId (hPhysicalGpu, pBusId); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_GPU_GetBusId(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NvAPI_GPU_GetBusSlotId (void *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusSlotId) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; + + const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusSlotId (hPhysicalGpu, pBusSlotId); + + if (NvAPI_rc != NVAPI_OK) + { + NvAPI_ShortString string = { 0 }; + + hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); + + event_log_error (hashcat_ctx, "NvAPI_GPU_GetBusSlotId(): %s", string); + + return -1; + } + + return 0; +} diff --git a/src/ext_nvml.c b/src/ext_nvml.c index 416b02bb4..25911df14 100644 --- a/src/ext_nvml.c +++ b/src/ext_nvml.c @@ -5,4 +5,390 @@ #include "common.h" #include "types.h" +#include "memory.h" +#include "shared.h" +#include "event.h" #include "ext_nvml.h" + +#include "dynloader.h" + +#if defined (__CYGWIN__) +#include +#endif + +int nvml_init (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + memset (nvml, 0, sizeof (NVML_PTR)); + + #if defined (_WIN) + + nvml->lib = hc_dlopen ("nvml.dll"); + + if (!nvml->lib) + { + DWORD BufferSize = 1024; + + DWORD Type = REG_SZ; + + char *Buffer = (char *) hcmalloc (BufferSize + 1); + + HKEY hKey = 0; + + if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS) + { + Buffer[BufferSize] = 0; + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); + + return -1; + } + + RegCloseKey (hKey); + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); + + return -1; + } + + strcat (Buffer, "\\nvml.dll"); + + nvml->lib = hc_dlopen (Buffer); + + hcfree (Buffer); + } + + #elif defined (__CYGWIN__) + + nvml->lib = hc_dlopen ("nvml.dll"); + + if (!nvml->lib) + { + HCFILE nvml_lib; + + if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb") == false) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed: %m. Proceeding without NVML HWMon enabled."); + + return -1; + } + + char *nvml_winpath, *nvml_cygpath; + + nvml_winpath = (char *) hcmalloc (100); + + hc_fread (nvml_winpath, 100, 1, &nvml_lib); + + hc_fclose (&nvml_lib); + + ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0); + + if (size > 0) + { + nvml_cygpath = (char *) hcmalloc (size + 9); + + cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, nvml_cygpath, size); + } + else + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "Could not find NVML on this system. Proceeding without NVML HWMon enabled."); + + return -1; + } + + strcat (nvml_cygpath, "/nvml.dll"); + + nvml->lib = hc_dlopen (nvml_cygpath); + } + + #elif defined (_POSIX) + + nvml->lib = hc_dlopen ("libnvidia-ml.so"); + + if (!nvml->lib) + { + nvml->lib = hc_dlopen ("libnvidia-ml.so.1"); + } + + #endif + + if (!nvml->lib) + { + //if (user_options->quiet == false) + // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); + + return -1; + } + + HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCount, NVML_DEVICE_GET_COUNT, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0); + HC_LOAD_FUNC(nvml, nvmlDeviceGetPciInfo, NVML_DEVICE_GET_PCIINFO, NVML, 0); + + return 0; +} + +void nvml_close (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + if (nvml) + { + if (nvml->lib) + hc_dlclose (nvml->lib); + + hcfree (nvml); + } +} + +const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t nvml_rc) +{ + return nvml->nvmlErrorString (nvml_rc); +} + +int hm_NVML_nvmlInit (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlInit (); + + if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlInit(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlShutdown (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlShutdown (); + + if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlShutdown(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetCount (void *hashcat_ctx, unsigned int *deviceCount) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCount (deviceCount); + + if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetCount(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetHandleByIndex (void *hashcat_ctx, unsigned int device_index, nvmlDevice_t *device) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (device_index, device); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetHandleByIndex(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetTemperature (void *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetTemperature(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetFanSpeed (void *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetFanSpeed(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetUtilizationRates (void *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetUtilizationRates(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetClockInfo (void *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clockfreq) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clockfreq); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetClockInfo(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetTemperatureThreshold (void *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetTemperatureThreshold(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (void *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetCurrPcieLinkWidth(): %s", string); + + return -1; + } + + return 0; +} + +int hm_NVML_nvmlDeviceGetPciInfo (void *hashcat_ctx, nvmlDevice_t device, nvmlPciInfo_t *pci) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; + + const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPciInfo (device, pci); + + if (nvml_rc != NVML_SUCCESS) + { + const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); + + event_log_error (hashcat_ctx, "nvmlDeviceGetPciInfo(): %s", string); + + return -1; + } + + return 0; +} diff --git a/src/ext_sysfs.c b/src/ext_sysfs.c index b4898950d..fc50ea388 100644 --- a/src/ext_sysfs.c +++ b/src/ext_sysfs.c @@ -4,4 +4,440 @@ */ #include "common.h" +#include "types.h" +#include "memory.h" +#include "shared.h" +#include "event.h" +#include "folder.h" #include "ext_sysfs.h" + +bool sysfs_init (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; + + memset (sysfs, 0, sizeof (SYSFS_PTR)); + + char *path; + + hc_asprintf (&path, "%s", SYS_BUS_PCI_DEVICES); + + const bool r = hc_path_read (path); + + hcfree (path); + + return r; +} + +void sysfs_close (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; + + if (sysfs) + { + hcfree (sysfs); + } +} + +char *hm_SYSFS_get_syspath_device (void *hashcat_ctx, const int backend_device_idx) +{ + backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; + + hc_device_param_t *device_param = &backend_ctx->devices_param[backend_device_idx]; + + char *syspath; + + hc_asprintf (&syspath, "%s/0000:%02x:%02x.%01x", SYS_BUS_PCI_DEVICES, device_param->pcie_bus, device_param->pcie_device, device_param->pcie_function); + + return syspath; +} + +char *hm_SYSFS_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) + { + event_log_error (hashcat_ctx, "hm_SYSFS_get_syspath_device() failed."); + + return NULL; + } + + char *hwmon = (char *) hcmalloc (HCBUFSIZ_TINY); + + snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon", syspath); + + char *hwmonN = first_file_in_directory (hwmon); + + if (hwmonN == NULL) + { + event_log_error (hashcat_ctx, "First_file_in_directory() failed."); + + hcfree (syspath); + + hcfree (hwmon); + hcfree (hwmonN); + + return NULL; + } + + snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon/%s", syspath, hwmonN); + + hcfree (syspath); + + hcfree (hwmonN); + + return hwmon; +} + +int hm_SYSFS_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path_cur; + char *path_max; + + hc_asprintf (&path_cur, "%s/pwm1", syspath); + hc_asprintf (&path_max, "%s/pwm1_max", syspath); + + hcfree (syspath); + + HCFILE fp_cur; + + if (hc_fopen (&fp_cur, path_cur, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno)); + + hcfree (path_cur); + hcfree (path_max); + + return -1; + } + + int pwm1_cur = 0; + + if (hc_fscanf (&fp_cur, "%d", &pwm1_cur) != 1) + { + hc_fclose (&fp_cur); + + event_log_error (hashcat_ctx, "%s: unexpected data.", path_cur); + + hcfree (path_cur); + hcfree (path_max); + + return -1; + } + + hc_fclose (&fp_cur); + + HCFILE fp_max; + + if (hc_fopen (&fp_max, path_max, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno)); + + hcfree (path_cur); + hcfree (path_max); + + return -1; + } + + int pwm1_max = 0; + + if (hc_fscanf (&fp_max, "%d", &pwm1_max) != 1) + { + hc_fclose (&fp_max); + + event_log_error (hashcat_ctx, "%s: unexpected data.", path_max); + + hcfree (path_cur); + hcfree (path_max); + + return -1; + } + + hc_fclose (&fp_max); + + if (pwm1_max == 0) + { + event_log_error (hashcat_ctx, "%s: pwm1_max cannot be 0.", path_max); + + hcfree (path_cur); + hcfree (path_max); + + return -1; + } + + const float p1 = (float) pwm1_max / 100.0F; + + const float pwm1_percent = (float) pwm1_cur / p1; + + *val = (int) pwm1_percent; + + hcfree (path_cur); + hcfree (path_max); + + return 0; +} + +int hm_SYSFS_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/temp1_input", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int temperature = 0; + + if (hc_fscanf (&fp, "%d", &temperature) != 1) + { + hc_fclose (&fp); + + event_log_error (hashcat_ctx, "%s: unexpected data.", path); + + hcfree (path); + + return -1; + } + + hc_fclose (&fp); + + *val = temperature / 1000; + + hcfree (path); + + return 0; +} + +int hm_SYSFS_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/pp_dpm_sclk", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int clockfreq = 0; + + while (!hc_feof (&fp)) + { + char buf[HCBUFSIZ_TINY] = { 0 }; + + char *ptr = hc_fgets (buf, sizeof (buf), &fp); + + if (ptr == NULL) continue; + + size_t len = strlen (ptr); + + if (len < 2) continue; + + if (ptr[len - 2] != '*') continue; + + int profile = 0; + + int rc = sscanf (ptr, "%d: %dMHz", &profile, &clockfreq); + + if (rc == 2) break; + } + + hc_fclose (&fp); + + *val = clockfreq; + + hcfree (path); + + return 0; +} + +int hm_SYSFS_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/pp_dpm_mclk", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int clockfreq = 0; + + while (!hc_feof (&fp)) + { + char buf[HCBUFSIZ_TINY]; + + char *ptr = hc_fgets (buf, sizeof (buf), &fp); + + if (ptr == NULL) continue; + + size_t len = strlen (ptr); + + if (len < 2) continue; + + if (ptr[len - 2] != '*') continue; + + int profile = 0; + + int rc = sscanf (ptr, "%d: %dMHz", &profile, &clockfreq); + + if (rc == 2) break; + } + + hc_fclose (&fp); + + *val = clockfreq; + + hcfree (path); + + return 0; +} + +int hm_SYSFS_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/current_link_width", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int lanes = 0; + + while (!hc_feof (&fp)) + { + char buf[HCBUFSIZ_TINY]; + + char *ptr = hc_fgets (buf, sizeof (buf), &fp); + + if (ptr == NULL) continue; + + size_t len = strlen (ptr); + + if (len < 2) continue; + + int rc = sscanf (ptr, "%d", &lanes); + + if (rc == 1) break; + } + + hc_fclose (&fp); + + *val = lanes; + + hcfree (path); + + return 0; +} + +int hm_SYSFS_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val) +{ + char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + + if (syspath == NULL) return -1; + + char *path; + + hc_asprintf (&path, "%s/gpu_busy_percent", syspath); + + hcfree (syspath); + + HCFILE fp; + + if (hc_fopen (&fp, path, "r") == false) + { + event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); + + hcfree (path); + + return -1; + } + + int util = 0; + + while (!hc_feof (&fp)) + { + char buf[HCBUFSIZ_TINY]; + + char *ptr = hc_fgets (buf, sizeof (buf), &fp); + + if (ptr == NULL) continue; + + size_t len = strlen (ptr); + + if (len < 1) continue; + + int rc = sscanf (ptr, "%d", &util); + + if (rc == 1) break; + } + + hc_fclose (&fp); + + *val = util; + + hcfree (path); + + return 0; +} diff --git a/src/hwmon.c b/src/hwmon.c index 502a606b6..a37faecc0 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -12,1323 +12,6 @@ #include "folder.h" #include "hwmon.h" -// sysfs functions - -static bool sysfs_init (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; - - memset (sysfs, 0, sizeof (SYSFS_PTR)); - - char *path; - - hc_asprintf (&path, "%s", SYS_BUS_PCI_DEVICES); - - const bool r = hc_path_read (path); - - hcfree (path); - - return r; -} - -static void sysfs_close (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; - - if (sysfs) - { - hcfree (sysfs); - } -} - -static char *hm_SYSFS_get_syspath_device (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx) -{ - backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; - - hc_device_param_t *device_param = &backend_ctx->devices_param[backend_device_idx]; - - char *syspath; - - hc_asprintf (&syspath, "%s/0000:%02x:%02x.%01x", SYS_BUS_PCI_DEVICES, device_param->pcie_bus, device_param->pcie_device, device_param->pcie_function); - - return syspath; -} - -static char *hm_SYSFS_get_syspath_hwmon (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx) -{ - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) - { - event_log_error (hashcat_ctx, "hm_SYSFS_get_syspath_device() failed."); - - return NULL; - } - - char *hwmon = (char *) hcmalloc (HCBUFSIZ_TINY); - - snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon", syspath); - - char *hwmonN = first_file_in_directory (hwmon); - - if (hwmonN == NULL) - { - event_log_error (hashcat_ctx, "First_file_in_directory() failed."); - - hcfree (syspath); - - hcfree (hwmon); - hcfree (hwmonN); - - return NULL; - } - - snprintf (hwmon, HCBUFSIZ_TINY, "%s/hwmon/%s", syspath, hwmonN); - - hcfree (syspath); - - hcfree (hwmonN); - - return hwmon; -} - -static int hm_SYSFS_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path_cur; - char *path_max; - - hc_asprintf (&path_cur, "%s/pwm1", syspath); - hc_asprintf (&path_max, "%s/pwm1_max", syspath); - - hcfree (syspath); - - HCFILE fp_cur; - - if (hc_fopen (&fp_cur, path_cur, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path_cur, strerror (errno)); - - hcfree (path_cur); - hcfree (path_max); - - return -1; - } - - int pwm1_cur = 0; - - if (hc_fscanf (&fp_cur, "%d", &pwm1_cur) != 1) - { - hc_fclose (&fp_cur); - - event_log_error (hashcat_ctx, "%s: unexpected data.", path_cur); - - hcfree (path_cur); - hcfree (path_max); - - return -1; - } - - hc_fclose (&fp_cur); - - HCFILE fp_max; - - if (hc_fopen (&fp_max, path_max, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path_max, strerror (errno)); - - hcfree (path_cur); - hcfree (path_max); - - return -1; - } - - int pwm1_max = 0; - - if (hc_fscanf (&fp_max, "%d", &pwm1_max) != 1) - { - hc_fclose (&fp_max); - - event_log_error (hashcat_ctx, "%s: unexpected data.", path_max); - - hcfree (path_cur); - hcfree (path_max); - - return -1; - } - - hc_fclose (&fp_max); - - if (pwm1_max == 0) - { - event_log_error (hashcat_ctx, "%s: pwm1_max cannot be 0.", path_max); - - hcfree (path_cur); - hcfree (path_max); - - return -1; - } - - const float p1 = (float) pwm1_max / 100.0F; - - const float pwm1_percent = (float) pwm1_cur / p1; - - *val = (int) pwm1_percent; - - hcfree (path_cur); - hcfree (path_max); - - return 0; -} - -static int hm_SYSFS_get_temperature_current (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path; - - hc_asprintf (&path, "%s/temp1_input", syspath); - - hcfree (syspath); - - HCFILE fp; - - if (hc_fopen (&fp, path, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); - - hcfree (path); - - return -1; - } - - int temperature = 0; - - if (hc_fscanf (&fp, "%d", &temperature) != 1) - { - hc_fclose (&fp); - - event_log_error (hashcat_ctx, "%s: unexpected data.", path); - - hcfree (path); - - return -1; - } - - hc_fclose (&fp); - - *val = temperature / 1000; - - hcfree (path); - - return 0; -} - -static int hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path; - - hc_asprintf (&path, "%s/pp_dpm_sclk", syspath); - - hcfree (syspath); - - HCFILE fp; - - if (hc_fopen (&fp, path, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); - - hcfree (path); - - return -1; - } - - int clockfreq = 0; - - while (!hc_feof (&fp)) - { - char buf[HCBUFSIZ_TINY] = { 0 }; - - char *ptr = hc_fgets (buf, sizeof (buf), &fp); - - if (ptr == NULL) continue; - - size_t len = strlen (ptr); - - if (len < 2) continue; - - if (ptr[len - 2] != '*') continue; - - int profile = 0; - - int rc = sscanf (ptr, "%d: %dMHz", &profile, &clockfreq); - - if (rc == 2) break; - } - - hc_fclose (&fp); - - *val = clockfreq; - - hcfree (path); - - return 0; -} - -static int hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path; - - hc_asprintf (&path, "%s/pp_dpm_mclk", syspath); - - hcfree (syspath); - - HCFILE fp; - - if (hc_fopen (&fp, path, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); - - hcfree (path); - - return -1; - } - - int clockfreq = 0; - - while (!hc_feof (&fp)) - { - char buf[HCBUFSIZ_TINY]; - - char *ptr = hc_fgets (buf, sizeof (buf), &fp); - - if (ptr == NULL) continue; - - size_t len = strlen (ptr); - - if (len < 2) continue; - - if (ptr[len - 2] != '*') continue; - - int profile = 0; - - int rc = sscanf (ptr, "%d: %dMHz", &profile, &clockfreq); - - if (rc == 2) break; - } - - hc_fclose (&fp); - - *val = clockfreq; - - hcfree (path); - - return 0; -} - -static int hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path; - - hc_asprintf (&path, "%s/current_link_width", syspath); - - hcfree (syspath); - - HCFILE fp; - - if (hc_fopen (&fp, path, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); - - hcfree (path); - - return -1; - } - - int lanes = 0; - - while (!hc_feof (&fp)) - { - char buf[HCBUFSIZ_TINY]; - - char *ptr = hc_fgets (buf, sizeof (buf), &fp); - - if (ptr == NULL) continue; - - size_t len = strlen (ptr); - - if (len < 2) continue; - - int rc = sscanf (ptr, "%d", &lanes); - - if (rc == 1) break; - } - - hc_fclose (&fp); - - *val = lanes; - - hcfree (path); - - return 0; -} - -static int hm_SYSFS_get_gpu_busy_percent (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx, int *val) -{ - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); - - if (syspath == NULL) return -1; - - char *path; - - hc_asprintf (&path, "%s/gpu_busy_percent", syspath); - - hcfree (syspath); - - HCFILE fp; - - if (hc_fopen (&fp, path, "r") == false) - { - event_log_error (hashcat_ctx, "%s: %s", path, strerror (errno)); - - hcfree (path); - - return -1; - } - - int util = 0; - - while (!hc_feof (&fp)) - { - char buf[HCBUFSIZ_TINY]; - - char *ptr = hc_fgets (buf, sizeof (buf), &fp); - - if (ptr == NULL) continue; - - size_t len = strlen (ptr); - - if (len < 1) continue; - - int rc = sscanf (ptr, "%d", &util); - - if (rc == 1) break; - } - - hc_fclose (&fp); - - *val = util; - - hcfree (path); - - return 0; -} - -// nvml functions - -static int nvml_init (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - memset (nvml, 0, sizeof (NVML_PTR)); - - #if defined (_WIN) - - nvml->lib = hc_dlopen ("nvml.dll"); - - if (!nvml->lib) - { - DWORD BufferSize = 1024; - - DWORD Type = REG_SZ; - - char *Buffer = (char *) hcmalloc (BufferSize + 1); - - HKEY hKey = 0; - - if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS) - { - Buffer[BufferSize] = 0; - } - else - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); - - return -1; - } - - RegCloseKey (hKey); - } - else - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); - - return -1; - } - - strcat (Buffer, "\\nvml.dll"); - - nvml->lib = hc_dlopen (Buffer); - - hcfree (Buffer); - } - - #elif defined (__CYGWIN__) - - nvml->lib = hc_dlopen ("nvml.dll"); - - if (!nvml->lib) - { - HCFILE nvml_lib; - - if (hc_fopen (&nvml_lib, "/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/NVIDIA Corporation/Global/NVSMI/NVSMIPATH", "rb") == false) - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed: %m. Proceeding without NVML HWMon enabled."); - - return -1; - } - - char *nvml_winpath, *nvml_cygpath; - - nvml_winpath = (char *) hcmalloc (100); - - hc_fread (nvml_winpath, 100, 1, &nvml_lib); - - hc_fclose (&nvml_lib); - - ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, NULL, 0); - - if (size > 0) - { - nvml_cygpath = (char *) hcmalloc (size + 9); - - cygwin_conv_path (CCP_WIN_A_TO_POSIX | CCP_PROC_CYGDRIVE, nvml_winpath, nvml_cygpath, size); - } - else - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "Could not find NVML on this system. Proceeding without NVML HWMon enabled."); - - return -1; - } - - strcat (nvml_cygpath, "/nvml.dll"); - - nvml->lib = hc_dlopen (nvml_cygpath); - } - - #elif defined (_POSIX) - - nvml->lib = hc_dlopen ("libnvidia-ml.so"); - - if (!nvml->lib) - { - nvml->lib = hc_dlopen ("libnvidia-ml.so.1"); - } - - #endif - - if (!nvml->lib) - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "NVML library load failed. Proceeding without NVML HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetCount, NVML_DEVICE_GET_COUNT, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0); - HC_LOAD_FUNC(nvml, nvmlDeviceGetPciInfo, NVML_DEVICE_GET_PCIINFO, NVML, 0); - - return 0; -} - -static void nvml_close (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - if (nvml) - { - if (nvml->lib) - hc_dlclose (nvml->lib); - - hcfree (nvml); - } -} - -static const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, const nvmlReturn_t nvml_rc) -{ - return nvml->nvmlErrorString (nvml_rc); -} - -static int hm_NVML_nvmlInit (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlInit (); - - if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlInit(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlShutdown (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = (nvmlReturn_t) nvml->nvmlShutdown (); - - if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlShutdown(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetCount (hashcat_ctx_t *hashcat_ctx, unsigned int *deviceCount) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCount (deviceCount); - - if (nvml_rc != NVML_SUCCESS && nvml_rc != NVML_ERROR_DRIVER_NOT_LOADED) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetCount(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetHandleByIndex (hashcat_ctx_t *hashcat_ctx, unsigned int device_index, nvmlDevice_t *device) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (device_index, device); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetHandleByIndex(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetTemperature (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetTemperature(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *speed) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetFanSpeed(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetUtilizationRates (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlUtilization_t *utilization) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetUtilizationRates(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetClockInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clockfreq) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clockfreq); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetClockInfo(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetTemperatureThreshold (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetTemperatureThreshold(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, unsigned int *currLinkWidth) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetCurrPcieLinkWidth(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx_t *hashcat_ctx, nvmlDevice_t device, nvmlPciInfo_t *pci) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVML_PTR *nvml = (NVML_PTR *) hwmon_ctx->hm_nvml; - - const nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPciInfo (device, pci); - - if (nvml_rc != NVML_SUCCESS) - { - const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc); - - event_log_error (hashcat_ctx, "nvmlDeviceGetPciInfo(): %s", string); - - return -1; - } - - return 0; -} - -// nvapi functions - -static int nvapi_init (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - memset (nvapi, 0, sizeof (NVAPI_PTR)); - - #if defined (_WIN) - - #if defined (_WIN64) - nvapi->lib = hc_dlopen ("nvapi64.dll"); - #else - nvapi->lib = hc_dlopen ("nvapi.dll"); - #endif - - #else - - #if defined (__CYGWIN__) - - #if defined (__x86_x64__) - nvapi->lib = hc_dlopen ("nvapi64.dll"); - #else - nvapi->lib = hc_dlopen ("nvapi.dll"); - #endif - - #else - nvapi->lib = hc_dlopen ("nvapi.so"); // uhm yes, but .. yeah - #endif - - #endif - - if (!nvapi->lib) - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "Load of NVAPI library failed. Proceeding without NVAPI HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828U, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7EU, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048CU, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921FU, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841U, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0CU, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusId, NVAPI_GPU_GETBUSID, nvapi_QueryInterface, 0x1BE0B8E5U, NVAPI, 0); - HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetBusSlotId, NVAPI_GPU_GETBUSSLOTID, nvapi_QueryInterface, 0x2A0A350FU, NVAPI, 0); - - return 0; -} - -static void nvapi_close (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - if (nvapi) - { - if (nvapi->lib) - hc_dlclose (nvapi->lib); - - hcfree (nvapi); - } -} - -static void hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, const NvAPI_Status NvAPI_rc, NvAPI_ShortString string) -{ - nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string); -} - -static int hm_NvAPI_Initialize (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Initialize (); - - if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) return -1; - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_Initialize(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_Unload (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_Unload (); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_Unload(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_EnumPhysicalGPUs (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_EnumPhysicalGPUs(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_GPU_GetPerfPoliciesInfo (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesInfo(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_GPU_GetPerfPoliciesStatus (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_GPU_GetPerfPoliciesStatus(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_GPU_GetBusId (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusId) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusId (hPhysicalGpu, pBusId); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_GPU_GetBusId(): %s", string); - - return -1; - } - - return 0; -} - -static int hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx_t *hashcat_ctx, NvPhysicalGpuHandle hPhysicalGpu, NvU32 *pBusSlotId) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - NVAPI_PTR *nvapi = (NVAPI_PTR *) hwmon_ctx->hm_nvapi; - - const NvAPI_Status NvAPI_rc = (NvAPI_Status) nvapi->NvAPI_GPU_GetBusSlotId (hPhysicalGpu, pBusSlotId); - - if (NvAPI_rc != NVAPI_OK) - { - NvAPI_ShortString string = { 0 }; - - hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string); - - event_log_error (hashcat_ctx, "NvAPI_GPU_GetBusSlotId(): %s", string); - - return -1; - } - - return 0; -} - -// ADL functions - -static int adl_init (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - memset (adl, 0, sizeof (ADL_PTR)); - - #if defined (_WIN) - adl->lib = hc_dlopen ("atiadlxx.dll"); - - if (!adl->lib) - { - adl->lib = hc_dlopen ("atiadlxy.dll"); - } - #elif defined (__CYGWIN__) - adl->lib = hc_dlopen ("atiadlxx.dll"); - - if (!adl->lib) - { - adl->lib = hc_dlopen ("atiadlxy.dll"); - } - #elif defined (_POSIX) - adl->lib = hc_dlopen ("libatiadlxx.so"); - #endif - - if (!adl->lib) - { - //if (user_options->quiet == false) - // event_log_error (hashcat_ctx, "Load of ADL library failed. Proceeding without ADL HWMon enabled."); - - return -1; - } - - HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0); - HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0); - - return 0; -} - -static void adl_close (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - if (adl) - { - if (adl->lib) - hc_dlclose (adl->lib); - - hcfree (adl); - } -} - -static int hm_ADL_Main_Control_Destroy (hashcat_ctx_t *hashcat_ctx) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Main_Control_Destroy (); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Main_Control_Destroy(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Main_Control_Create (hashcat_ctx_t *hashcat_ctx, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Main_Control_Create(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx_t *hashcat_ctx, int *lpNumAdapters) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Adapter_NumberOfAdapters_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx_t *hashcat_ctx, LPAdapterInfo lpInfo, int iInputSize) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Adapter_AdapterInfo_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive5_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Overdrive5_Temperature_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive6_Temperature_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *iTemperature) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Overdrive6_Temperature_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive_CurrentActivity_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLPMActivity *lpActivity) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Overdrive5_CurrentActivity_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive5_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - event_log_error (hashcat_ctx, "ADL_Overdrive5_FanSpeed_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive6_FanSpeed_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo); - - if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here - { - event_log_error (hashcat_ctx, "ADL_Overdrive6_FanSpeed_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive_Caps (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Overdrive_Caps(): %d", ADL_rc); - - return -1; - } - - return 0; -} - -static int hm_ADL_Overdrive6_TargetTemperatureData_Get (hashcat_ctx_t *hashcat_ctx, int iAdapterIndex, int *cur_temp, int *default_temp) -{ - hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; - - ADL_PTR *adl = (ADL_PTR *) hwmon_ctx->hm_adl; - - const int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp); - - if (ADL_rc != ADL_OK) - { - event_log_error (hashcat_ctx, "ADL_Overdrive6_TargetTemperatureData_Get(): %d", ADL_rc); - - return -1; - } - - return 0; -} - // general functions static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapters) From 2bc68f32db9613eb62a1f9851ce0070ed466a3e7 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 10 Jun 2021 20:26:24 +0200 Subject: [PATCH 16/56] remove unused rc vars --- src/hwmon.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/hwmon.c b/src/hwmon.c index a37faecc0..de6dafd5f 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -16,9 +16,7 @@ static int get_adapters_num_adl (hashcat_ctx_t *hashcat_ctx, int *iNumberAdapters) { - const int hm_rc = hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx, iNumberAdapters); - - if (hm_rc == -1) return -1; + if (hm_ADL_Adapter_NumberOfAdapters_Get (hashcat_ctx, iNumberAdapters) == -1) return -1; if (iNumberAdapters == NULL) { @@ -1074,9 +1072,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { nvmlPciInfo_t pci; - int rc = hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci); - - if (rc == -1) continue; + if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue; if ((device_param->pcie_bus == pci.bus) && (device_param->pcie_device == (pci.device >> 3)) @@ -1108,9 +1104,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { nvmlPciInfo_t pci; - int rc = hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci); - - if (rc == -1) continue; + if (hm_NVML_nvmlDeviceGetPciInfo (hashcat_ctx, nvmlGPUHandle[i], &pci) == -1) continue; if ((device_param->pcie_bus == pci.bus) && (device_param->pcie_device == (pci.device >> 3)) @@ -1158,13 +1152,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) NvU32 BusId = 0; NvU32 BusSlotId = 0; - int rc1 = hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId); + if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue; - if (rc1 == -1) continue; - - int rc2 = hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId); - - if (rc2 == -1) continue; + if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue; if ((device_param->pcie_bus == BusId) && (device_param->pcie_device == (BusSlotId >> 3)) @@ -1191,13 +1181,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) NvU32 BusId = 0; NvU32 BusSlotId = 0; - int rc1 = hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId); + if (hm_NvAPI_GPU_GetBusId (hashcat_ctx, nvGPUHandle[i], &BusId) == -1) continue; - if (rc1 == -1) continue; - - int rc2 = hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId); - - if (rc2 == -1) continue; + if (hm_NvAPI_GPU_GetBusSlotId (hashcat_ctx, nvGPUHandle[i], &BusSlotId) == -1) continue; if ((device_param->pcie_bus == BusId) && (device_param->pcie_device == (BusSlotId >> 3)) @@ -1237,9 +1223,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) hccalloc (tmp_in, sizeof (AdapterInfo)); - const int rc_adapter_info_adl = hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, tmp_in * sizeof (AdapterInfo)); - - if (rc_adapter_info_adl == -1) + if (hm_ADL_Adapter_AdapterInfo_Get (hashcat_ctx, lpAdapterInfo, tmp_in * sizeof (AdapterInfo)) == -1) { FREE_ADAPTERS; From 3c6f4b0e695942cee30d94697ab44837598d6231 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 10 Jun 2021 20:44:21 +0200 Subject: [PATCH 17/56] add identify/autodetect-only option --- include/types.h | 3 +++ src/hashcat.c | 21 ++++++++++++++------- src/user_options.c | 3 +++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/types.h b/include/types.h index 192c0998b..9760aa931 100644 --- a/include/types.h +++ b/include/types.h @@ -597,6 +597,7 @@ typedef enum user_options_defaults ADVICE_DISABLE = false, ATTACK_MODE = ATTACK_MODE_STRAIGHT, AUTODETECT = false, + AUTODETECT_ONLY = false, BENCHMARK_ALL = false, BENCHMARK = false, BITMAP_MAX = 18, @@ -685,6 +686,7 @@ typedef enum user_options_map { IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', + IDX_AUTODETECT_ONLY = 0xff4d, IDX_BACKEND_DEVICES = 'd', IDX_BACKEND_IGNORE_CUDA = 0xff01, IDX_BACKEND_IGNORE_OPENCL = 0xff02, @@ -1943,6 +1945,7 @@ typedef struct user_options bool attack_mode_chgd; bool autodetect; + bool autodetect_only; #ifdef WITH_BRAIN bool brain_host_chgd; bool brain_port_chgd; diff --git a/src/hashcat.c b/src/hashcat.c index c7532f61e..d367ef1d2 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1476,13 +1476,18 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) hcfree (usage_sort_buf[i].hash_name); } - event_log_info (hashcat_ctx, NULL); - - event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); - hcfree (usage_sort_buf); - return -1; + event_log_info (hashcat_ctx, NULL); + + if (user_options->autodetect_only == false) + { + event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); + + return -1; + } + + return 0; } // modes_cnt == 1 @@ -1494,12 +1499,14 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type."); event_log_warning (hashcat_ctx, NULL); - user_options->autodetect = false; - user_options->hash_mode = usage_sort_buf[0].hash_mode; hcfree (usage_sort_buf[0].hash_name); hcfree (usage_sort_buf); + + if (user_options->autodetect_only == true) return 0; + + user_options->autodetect = false; } /** diff --git a/src/user_options.c b/src/user_options.c index bc4465c5c..2ab1c632f 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -63,6 +63,7 @@ static const struct option long_options[] = {"hex-salt", no_argument, NULL, IDX_HEX_SALT}, {"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST}, {"hook-threads", required_argument, NULL, IDX_HOOK_THREADS}, + {"identify", no_argument, NULL, IDX_AUTODETECT_ONLY}, {"increment-max", required_argument, NULL, IDX_INCREMENT_MAX}, {"increment-min", required_argument, NULL, IDX_INCREMENT_MIN}, {"increment", no_argument, NULL, IDX_INCREMENT}, @@ -158,6 +159,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; user_options->autodetect = AUTODETECT; + user_options->autodetect_only = AUTODETECT_ONLY; user_options->backend_devices = NULL; user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA; user_options->backend_ignore_opencl = BACKEND_IGNORE_OPENCL; @@ -396,6 +398,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break; case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10); user_options->stdin_timeout_abort_chgd = true; break; + case IDX_AUTODETECT_ONLY: user_options->autodetect_only = true; break; case IDX_SPEED_ONLY: user_options->speed_only = true; break; case IDX_PROGRESS_ONLY: user_options->progress_only = true; break; case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; From 65d81c0f7b72a34b47612759fdc1a483f8454ecf Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 10 Jun 2021 22:43:06 +0200 Subject: [PATCH 18/56] Hashrate: Innerloop hashrate prediction requires update because of the new salt_repeats feature and also respect _loop2 kernel runtime --- docs/changes.txt | 1 + src/backend.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2e64845d9..053fdf58a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -59,6 +59,7 @@ - Dependencies: Updated LZMA SDK from 19.00 to 21.02 alpha - Dependencies: Updated xxHash from 0.1.0 to v0.8.0 - Stable XXH3 - Documentation: Update missing documentation in plugin developer guide for OPTS_TYPE_MP_MULTI_DISABLE and OPTS_TYPE_NATIVE_THREADS +- Hashrate: Innerloop hashrate prediction requires update because of the new salt_repeats feature and also respect _loop2 kernel runtime - Kernels: Add RC4 cipher to crypto library with optimized shared memory access pattern which will not cause any bank conflicts if -u <= 32 - Kernels: Add standalone true UTF8 to UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin - Modules: Recategorized HASH_CATEGORY option in various modules diff --git a/src/backend.c b/src/backend.c index 760a14b3c..0cc123ed4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -3017,6 +3017,28 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, } else { + // innerloop prediction to get a speed estimation is hard, because we don't know in advance how much + // time the different kernels take and if their weightnings are equally distributed. + // - for instance, a regular _loop kernel is likely to be the slowest, but _loop2 kernel can also be slow. + // in fact, _loop2 can be even slower (see iTunes backup >= 10.0). + // - hooks can have a large influence depending on the OS. + // spawning threads and memory allocations take a lot of time on windows (compared to linux). + // - the kernel execution can take shortcuts based on intermediate values + // while these intermediate valus depend on input values. + // - if we meassure runtimes of different kernels to find out about their weightning + // we need to call them with real input values otherwise we miss the shortcuts inside the kernel. + // - the problem is that these real input values could crack the hash which makes the chaos perfect. + // + // so the innerloop prediction is not perfectly accurate, because we: + // + // 1. completely ignore hooks and the time they take. + // 2. assume that the code in _loop and _loop2 is similar, + // but we respect the different iteration counts in _loop and _loop2. + // 3. ignore _comp kernel runtimes (probably irrelevant). + // + // as soon as the first restore checkpoint is reached the prediction is accurate. + // also the closer it gets to that point. + if (true) { if (device_param->is_cuda == true) @@ -3160,7 +3182,10 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, * speed */ - const float iter_part = (float) (loop_pos + loop_left) / iter; + const u32 iter1r = hashes->salts_buf[salt_pos].salt_iter * (salt_repeats + 1); + const u32 iter2r = hashes->salts_buf[salt_pos].salt_iter2 * (salt_repeats + 1); + + const double iter_part = (double) ((iter * salt_repeat) + loop_pos + loop_left) / (double) (iter1r + iter2r); const u64 perf_sum_all = (u64) (pws_cnt * iter_part); @@ -3176,7 +3201,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { if (speed_msec > 4000) { - device_param->outerloop_multi *= (double) iter / (double) (loop_pos + loop_left); + device_param->outerloop_multi *= 1 / iter_part; device_param->speed_pos = 1; @@ -3295,6 +3320,25 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, //bug? //while (status_ctx->run_thread_level2 == false) break; if (status_ctx->run_thread_level2 == false) break; + + /** + * speed + */ + + const u32 iter1r = hashes->salts_buf[salt_pos].salt_iter * (salt_repeats + 1); + const u32 iter2r = hashes->salts_buf[salt_pos].salt_iter2 * (salt_repeats + 1); + + const double iter_part = (double) (iter1r + (iter * salt_repeat) + loop_pos + loop_left) / (double) (iter1r + iter2r); + + const u64 perf_sum_all = (u64) (pws_cnt * iter_part); + + double speed_msec = hc_timer_get (device_param->timer_speed); + + const u32 speed_pos = device_param->speed_pos; + + device_param->speed_cnt[speed_pos] = perf_sum_all; + + device_param->speed_msec[speed_pos] = speed_msec; } } } From 51fe32042584d07f3edacb181024d47f74cfe19d Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 11 Jun 2021 18:36:19 +0200 Subject: [PATCH 19/56] Unit-Tests: Added missing support for OPTS_TYPE_LOOP_PREPARE, OPTS_TYPE_LOOP_PREPARE2 and salt_repeats in self-test --- docs/changes.txt | 1 + src/selftest.c | 109 ++++++++++++++++++++++++++++------------------- 2 files changed, 66 insertions(+), 44 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 053fdf58a..beb3a04e2 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -65,6 +65,7 @@ - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET - Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK +- Unit-Tests: Added missing support for OPTS_TYPE_LOOP_PREPARE, OPTS_TYPE_LOOP_PREPARE2 and salt_repeats in self-test - Unit-Tests: Added missing unit-test for Stargazer Stellar Wallet XLM * changes v6.2.0 -> v6.2.1 diff --git a/src/selftest.c b/src/selftest.c index 088f6f225..422cecc1a 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -481,55 +481,67 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param } } + const u32 loop_step = hashconfig->kernel_loops_min + ((hashconfig->kernel_loops_max - hashconfig->kernel_loops_min) / 32); + const u32 salt_pos = 0; salt_t *salt_buf = &hashes->st_salts_buf[salt_pos]; - const u32 loop_step = hashconfig->kernel_loops_min + ((hashconfig->kernel_loops_max - hashconfig->kernel_loops_min) / 32); + const u32 salt_repeats = hashes->salts_buf[salt_pos].salt_repeats; - const u32 iter = salt_buf->salt_iter; - - for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step) + for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++) { - u32 loop_left = iter - loop_pos; + device_param->kernel_params_buf32[34] = salt_repeat; - loop_left = MIN (loop_left, loop_step); - - device_param->kernel_params_buf32[28] = loop_pos; - device_param->kernel_params_buf32[29] = loop_left; - - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1; - - if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + if (hashconfig->opts_type & OPTS_TYPE_LOOP_PREPARE) { - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 0, 1, false, 0) == -1) return -1; - } - } - - if (hashconfig->opts_type & OPTS_TYPE_HOOK23) - { - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_23, 0, 1, false, 0) == -1) return -1; - - if (device_param->is_cuda == true) - { - if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1; + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2P, 0, 1, false, 0) == -1) return -1; } - if (device_param->is_opencl == true) + const u32 iter = salt_buf->salt_iter; + + for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step) { - if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + u32 loop_left = iter - loop_pos; + + loop_left = MIN (loop_left, loop_step); + + device_param->kernel_params_buf32[28] = loop_pos; + device_param->kernel_params_buf32[29] = loop_left; + + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1; + + if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED) + { + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 0, 1, false, 0) == -1) return -1; + } } - module_ctx->module_hook23 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0); - - if (device_param->is_cuda == true) + if (hashconfig->opts_type & OPTS_TYPE_HOOK23) { - if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1; - } + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_23, 0, 1, false, 0) == -1) return -1; - if (device_param->is_opencl == true) - { - if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + if (device_param->is_cuda == true) + { + if (hc_cuMemcpyDtoH (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + } + + module_ctx->module_hook23 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0); + + if (device_param->is_cuda == true) + { + if (hc_cuMemcpyHtoD (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1; + } } } @@ -538,20 +550,30 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (run_kernel (hashcat_ctx, device_param, KERN_RUN_INIT2, 0, 1, false, 0) == -1) return -1; } - if (hashconfig->opts_type & OPTS_TYPE_LOOP2) + for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++) { - const u32 iter2 = salt_buf->salt_iter2; + device_param->kernel_params_buf32[34] = salt_repeat; - for (u32 loop_pos = 0; loop_pos < iter2; loop_pos += loop_step) + if (hashconfig->opts_type & OPTS_TYPE_LOOP2_PREPARE) { - u32 loop_left = iter2 - loop_pos; + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2P, 0, 1, false, 0) == -1) return -1; + } - loop_left = MIN (loop_left, loop_step); + if (hashconfig->opts_type & OPTS_TYPE_LOOP2) + { + const u32 iter2 = salt_buf->salt_iter2; - device_param->kernel_params_buf32[28] = loop_pos; - device_param->kernel_params_buf32[29] = loop_left; + for (u32 loop_pos = 0; loop_pos < iter2; loop_pos += loop_step) + { + u32 loop_left = iter2 - loop_pos; - if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2, 0, 1, false, 0) == -1) return -1; + loop_left = MIN (loop_left, loop_step); + + device_param->kernel_params_buf32[28] = loop_pos; + device_param->kernel_params_buf32[29] = loop_left; + + if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2, 0, 1, false, 0) == -1) return -1; + } } } @@ -602,14 +624,13 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param // finish : cleanup and restore - device_param->kernel_params_buf32[27] = 0; device_param->kernel_params_buf32[28] = 0; device_param->kernel_params_buf32[29] = 0; device_param->kernel_params_buf32[30] = 0; device_param->kernel_params_buf32[31] = 0; device_param->kernel_params_buf32[32] = 0; device_param->kernel_params_buf32[33] = 0; - device_param->kernel_params_buf64[34] = 0; + device_param->kernel_params_buf32[34] = 0; if (device_param->is_cuda == true) { From 340e8d1033a55ace1832aa3d641e045b54951d49 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 11 Jun 2021 19:25:39 +0200 Subject: [PATCH 20/56] fix identify functionality --- include/types.h | 102 ++++++++++++++++++++++----------------------- src/hashcat.c | 4 +- src/usage.c | 1 + src/user_options.c | 6 +-- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/include/types.h b/include/types.h index 9760aa931..2b240ba59 100644 --- a/include/types.h +++ b/include/types.h @@ -597,7 +597,6 @@ typedef enum user_options_defaults ADVICE_DISABLE = false, ATTACK_MODE = ATTACK_MODE_STRAIGHT, AUTODETECT = false, - AUTODETECT_ONLY = false, BENCHMARK_ALL = false, BENCHMARK = false, BITMAP_MAX = 18, @@ -620,6 +619,7 @@ typedef enum user_options_defaults HEX_SALT = false, HEX_WORDLIST = false, HOOK_THREADS = 0, + IDENTIFY = false, INCREMENT = false, INCREMENT_MAX = PW_MAX, INCREMENT_MIN = 1, @@ -686,7 +686,6 @@ typedef enum user_options_map { IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', - IDX_AUTODETECT_ONLY = 0xff4d, IDX_BACKEND_DEVICES = 'd', IDX_BACKEND_IGNORE_CUDA = 0xff01, IDX_BACKEND_IGNORE_OPENCL = 0xff02, @@ -727,73 +726,74 @@ typedef enum user_options_map IDX_HEX_SALT = 0xff1a, IDX_HEX_WORDLIST = 0xff1b, IDX_HOOK_THREADS = 0xff1c, + IDX_IDENTIFY = 0xff1d, IDX_INCREMENT = 'i', - IDX_INCREMENT_MAX = 0xff1d, - IDX_INCREMENT_MIN = 0xff1e, - IDX_INDUCTION_DIR = 0xff1f, - IDX_KEEP_GUESSING = 0xff20, + IDX_INCREMENT_MAX = 0xff1e, + IDX_INCREMENT_MIN = 0xff1f, + IDX_INDUCTION_DIR = 0xff20, + IDX_KEEP_GUESSING = 0xff21, IDX_KERNEL_ACCEL = 'n', IDX_KERNEL_LOOPS = 'u', IDX_KERNEL_THREADS = 'T', - IDX_KEYBOARD_LAYOUT_MAPPING = 0xff21, - IDX_KEYSPACE = 0xff22, - IDX_LEFT = 0xff23, + IDX_KEYBOARD_LAYOUT_MAPPING = 0xff22, + IDX_KEYSPACE = 0xff23, + IDX_LEFT = 0xff24, IDX_LIMIT = 'l', - IDX_LOGFILE_DISABLE = 0xff24, - IDX_LOOPBACK = 0xff25, - IDX_MACHINE_READABLE = 0xff26, - IDX_MARKOV_CLASSIC = 0xff27, - IDX_MARKOV_DISABLE = 0xff28, - IDX_MARKOV_HCSTAT2 = 0xff29, + IDX_LOGFILE_DISABLE = 0xff25, + IDX_LOOPBACK = 0xff26, + IDX_MACHINE_READABLE = 0xff27, + IDX_MARKOV_CLASSIC = 0xff28, + IDX_MARKOV_DISABLE = 0xff29, + IDX_MARKOV_HCSTAT2 = 0xff2a, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff2a, + IDX_NONCE_ERROR_CORRECTIONS = 0xff2b, IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPTIMIZED_KERNEL_ENABLE = 'O', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2b, - IDX_OUTFILE_CHECK_DIR = 0xff2c, - IDX_OUTFILE_CHECK_TIMER = 0xff2d, - IDX_OUTFILE_FORMAT = 0xff2e, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2c, + IDX_OUTFILE_CHECK_DIR = 0xff2d, + IDX_OUTFILE_CHECK_TIMER = 0xff2e, + IDX_OUTFILE_FORMAT = 0xff2f, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff2f, - IDX_POTFILE_PATH = 0xff30, - IDX_PROGRESS_ONLY = 0xff31, - IDX_QUIET = 0xff32, - IDX_REMOVE = 0xff33, - IDX_REMOVE_TIMER = 0xff34, - IDX_RESTORE = 0xff35, - IDX_RESTORE_DISABLE = 0xff36, - IDX_RESTORE_FILE_PATH = 0xff37, + IDX_POTFILE_DISABLE = 0xff30, + IDX_POTFILE_PATH = 0xff31, + IDX_PROGRESS_ONLY = 0xff32, + IDX_QUIET = 0xff33, + IDX_REMOVE = 0xff34, + IDX_REMOVE_TIMER = 0xff35, + IDX_RESTORE = 0xff36, + IDX_RESTORE_DISABLE = 0xff37, + IDX_RESTORE_FILE_PATH = 0xff38, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff38, - IDX_RP_GEN_FUNC_MIN = 0xff39, + IDX_RP_GEN_FUNC_MAX = 0xff39, + IDX_RP_GEN_FUNC_MIN = 0xff3a, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff3a, + IDX_RP_GEN_SEED = 0xff3b, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff3b, - IDX_SCRYPT_TMTO = 0xff3c, + IDX_RUNTIME = 0xff3c, + IDX_SCRYPT_TMTO = 0xff3d, IDX_SEGMENT_SIZE = 'c', - IDX_SELF_TEST_DISABLE = 0xff3d, + IDX_SELF_TEST_DISABLE = 0xff3e, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff3e, - IDX_SHOW = 0xff3f, + IDX_SESSION = 0xff3f, + IDX_SHOW = 0xff40, IDX_SKIP = 's', IDX_SLOW_CANDIDATES = 'S', - IDX_SPEED_ONLY = 0xff40, - IDX_SPIN_DAMP = 0xff41, - IDX_STATUS = 0xff42, - IDX_STATUS_JSON = 0xff43, - IDX_STATUS_TIMER = 0xff44, - IDX_STDOUT_FLAG = 0xff45, - IDX_STDIN_TIMEOUT_ABORT = 0xff46, - IDX_TRUECRYPT_KEYFILES = 0xff47, - IDX_USERNAME = 0xff48, - IDX_VERACRYPT_KEYFILES = 0xff49, - IDX_VERACRYPT_PIM_START = 0xff4a, - IDX_VERACRYPT_PIM_STOP = 0xff4b, + IDX_SPEED_ONLY = 0xff41, + IDX_SPIN_DAMP = 0xff42, + IDX_STATUS = 0xff43, + IDX_STATUS_JSON = 0xff44, + IDX_STATUS_TIMER = 0xff45, + IDX_STDOUT_FLAG = 0xff46, + IDX_STDIN_TIMEOUT_ABORT = 0xff47, + IDX_TRUECRYPT_KEYFILES = 0xff48, + IDX_USERNAME = 0xff49, + IDX_VERACRYPT_KEYFILES = 0xff4a, + IDX_VERACRYPT_PIM_START = 0xff4b, + IDX_VERACRYPT_PIM_STOP = 0xff4c, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4c, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4d, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; @@ -1945,7 +1945,6 @@ typedef struct user_options bool attack_mode_chgd; bool autodetect; - bool autodetect_only; #ifdef WITH_BRAIN bool brain_host_chgd; bool brain_port_chgd; @@ -1954,6 +1953,7 @@ typedef struct user_options #endif bool hash_mode_chgd; bool hccapx_message_pair_chgd; + bool identify; bool increment_max_chgd; bool increment_min_chgd; bool kernel_accel_chgd; diff --git a/src/hashcat.c b/src/hashcat.c index d367ef1d2..7d309dff8 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1480,7 +1480,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, NULL); - if (user_options->autodetect_only == false) + if (user_options->identify == false) { event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); @@ -1504,7 +1504,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) hcfree (usage_sort_buf[0].hash_name); hcfree (usage_sort_buf); - if (user_options->autodetect_only == true) return 0; + if (user_options->identify == true) return 0; user_options->autodetect = false; } diff --git a/src/usage.c b/src/usage.c index b63e417c2..3ea1397ba 100644 --- a/src/usage.c +++ b/src/usage.c @@ -120,6 +120,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -2, --custom-charset2 | CS | User-defined charset ?2 | -2 ?l?d?s", " -3, --custom-charset3 | CS | User-defined charset ?3 |", " -4, --custom-charset4 | CS | User-defined charset ?4 |", + " --identify | | Shows all supported algorithms for input hashes | --identify my.hash", " -i, --increment | | Enable mask increment mode |", " --increment-min | Num | Start mask incrementing at X | --increment-min=4", " --increment-max | Num | Stop mask incrementing at X | --increment-max=8", diff --git a/src/user_options.c b/src/user_options.c index 2ab1c632f..cb2c73379 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -63,7 +63,7 @@ static const struct option long_options[] = {"hex-salt", no_argument, NULL, IDX_HEX_SALT}, {"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST}, {"hook-threads", required_argument, NULL, IDX_HOOK_THREADS}, - {"identify", no_argument, NULL, IDX_AUTODETECT_ONLY}, + {"identify", no_argument, NULL, IDX_IDENTIFY}, {"increment-max", required_argument, NULL, IDX_INCREMENT_MAX}, {"increment-min", required_argument, NULL, IDX_INCREMENT_MIN}, {"increment", no_argument, NULL, IDX_INCREMENT}, @@ -159,7 +159,6 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; user_options->autodetect = AUTODETECT; - user_options->autodetect_only = AUTODETECT_ONLY; user_options->backend_devices = NULL; user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA; user_options->backend_ignore_opencl = BACKEND_IGNORE_OPENCL; @@ -198,6 +197,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->hex_salt = HEX_SALT; user_options->hex_wordlist = HEX_WORDLIST; user_options->hook_threads = HOOK_THREADS; + user_options->identify = IDENTIFY; user_options->increment = INCREMENT; user_options->increment_max = INCREMENT_MAX; user_options->increment_min = INCREMENT_MIN; @@ -398,7 +398,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break; case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10); user_options->stdin_timeout_abort_chgd = true; break; - case IDX_AUTODETECT_ONLY: user_options->autodetect_only = true; break; + case IDX_IDENTIFY: user_options->identify = true; break; case IDX_SPEED_ONLY: user_options->speed_only = true; break; case IDX_PROGRESS_ONLY: user_options->progress_only = true; break; case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; From a25db47215b40356edb334cf0e953b84c95c68ef Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 11 Jun 2021 20:12:59 +0200 Subject: [PATCH 21/56] updated output messages for identify functionality --- src/hashcat.c | 61 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 7d309dff8..61b6cb68f 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1464,21 +1464,31 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (modes_cnt > 1) { - event_log_info (hashcat_ctx, "The following %d hash-modes match the structure of your input hash:", modes_cnt); - event_log_info (hashcat_ctx, NULL); - event_log_info (hashcat_ctx, " # | Name | Category"); - event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + if (user_options->quiet == false) + { + event_log_info (hashcat_ctx, "The following %d hash-modes match the structure of your input hash:", modes_cnt); + event_log_info (hashcat_ctx, NULL); + event_log_info (hashcat_ctx, " # | Name | Category"); + event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + } for (int i = 0; i < modes_cnt; i++) { - event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + if (user_options->quiet == false) + { + event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + } + else + { + event_log_info (hashcat_ctx, "%u", usage_sort_buf[i].hash_mode); + } hcfree (usage_sort_buf[i].hash_name); } hcfree (usage_sort_buf); - event_log_info (hashcat_ctx, NULL); + if (user_options->quiet == false) event_log_info (hashcat_ctx, NULL); if (user_options->identify == false) { @@ -1492,12 +1502,39 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) // modes_cnt == 1 - event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode."); - event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:"); - event_log_warning (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); - event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!"); - event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type."); - event_log_warning (hashcat_ctx, NULL); + if (user_options->identify == false) + { + event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode."); + event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:"); + } + + if (user_options->identify == true) + { + if (user_options->quiet == true) + { + event_log_info (hashcat_ctx, "%u", usage_sort_buf[0].hash_mode); + } + else + { + event_log_info (hashcat_ctx, "The following hash-mode match the structure of your input hash:"); + event_log_info (hashcat_ctx, NULL); + event_log_info (hashcat_ctx, " # | Name | Category"); + event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); + event_log_info (hashcat_ctx, NULL); + } + } + else + { + event_log_info (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); + } + + if (user_options->identify == false) + { + event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!"); + event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type."); + event_log_warning (hashcat_ctx, NULL); + } user_options->hash_mode = usage_sort_buf[0].hash_mode; From 7fc0ac4ef17e3aed85bcdf782ed89a2af87f9ad3 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 12 Jun 2021 10:47:48 +0200 Subject: [PATCH 22/56] Do not initialize backend devices in case --id is used and some bug fixes --- docs/changes.txt | 3 ++- extra/tab_completion/hashcat.sh | 2 +- src/backend.c | 13 +++++++------ src/bitmap.c | 15 ++++++++------- src/cpt.c | 15 ++++++++------- src/debugfile.c | 25 +++++++++++++------------ src/dictstat.c | 17 +++++++++-------- src/hashcat.c | 8 ++++---- src/hwmon.c | 19 ++++++++++--------- src/induct.c | 23 ++++++++++++----------- src/loopback.c | 23 ++++++++++++----------- src/main.c | 1 + src/outfile_check.c | 13 +++++++------ src/potfile.c | 1 + src/restore.c | 1 + src/terminal.c | 2 ++ src/tuningdb.c | 15 ++++++++------- src/user_options.c | 17 +++++++++++++++++ 18 files changed, 123 insertions(+), 90 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index beb3a04e2..084d3033b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -26,7 +26,8 @@ ## Features ## -- Autodetect hash-type: performs an automatic analysis of the input hash(es), associating compatible algorithms, or executing the attack if only one compatible format is found. +- Autodetect hash-type: performs an automatic analysis of the input hash(es), associating compatible algorithms, or executing the attack if only one compatible format is found +- Autodetect hash-type: Added option --identify to limit hashcat to perform only autodetection of hash-type and to skip the backend device initialization ## ## Bugs diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index feac5c7e1..fac85172a 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -426,7 +426,7 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -D -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password --identify" local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-server-timer --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist" COMPREPLY=() diff --git a/src/backend.c b/src/backend.c index 0cc123ed4..bc3e00c0c 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5157,12 +5157,13 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) backend_ctx->enabled = false; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (DEVICES_MAX, sizeof (hc_device_param_t)); diff --git a/src/bitmap.c b/src/bitmap.c index f161d3027..fb7367631 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -79,13 +79,14 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) bitmap_ctx->enabled = false; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; bitmap_ctx->enabled = true; diff --git a/src/cpt.c b/src/cpt.c index dc40d612c..d60e30bf6 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -15,13 +15,14 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = false; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; cpt_ctx->enabled = true; diff --git a/src/debugfile.c b/src/debugfile.c index 041b46f28..28eeb59f8 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -86,18 +86,19 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) debugfile_ctx->enabled = false; - if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->stdout_flag == true) return 0; - if (user_options->speed_only == true) return 0; - if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; - if (user_options->debug_mode == 0) return 0; + if (user_options->benchmark == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->stdout_flag == true) return 0; + if (user_options->speed_only == true) return 0; + if (user_options->progress_only == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; + if (user_options->debug_mode == 0) return 0; debugfile_ctx->enabled = true; diff --git a/src/dictstat.c b/src/dictstat.c index 66d49ccce..97fcdd92d 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -56,14 +56,15 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) dictstat_ctx->enabled = false; - if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->benchmark == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; diff --git a/src/hashcat.c b/src/hashcat.c index 61b6cb68f..97ee1c725 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1464,7 +1464,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (modes_cnt > 1) { - if (user_options->quiet == false) + if (user_options->machine_readable == false) { event_log_info (hashcat_ctx, "The following %d hash-modes match the structure of your input hash:", modes_cnt); event_log_info (hashcat_ctx, NULL); @@ -1474,7 +1474,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) for (int i = 0; i < modes_cnt; i++) { - if (user_options->quiet == false) + if (user_options->machine_readable == false) { event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); } @@ -1488,7 +1488,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) hcfree (usage_sort_buf); - if (user_options->quiet == false) event_log_info (hashcat_ctx, NULL); + if (user_options->machine_readable == false) event_log_info (hashcat_ctx, NULL); if (user_options->identify == false) { @@ -1510,7 +1510,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (user_options->identify == true) { - if (user_options->quiet == true) + if (user_options->machine_readable == true) { event_log_info (hashcat_ctx, "%u", usage_sort_buf[0].hash_mode); } diff --git a/src/hwmon.c b/src/hwmon.c index de6dafd5f..845f4c674 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -966,15 +966,16 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return 0; #endif // WITH_HWMON - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->stdout_flag == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; - if (user_options->hwmon_disable == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->stdout_flag == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; + if (user_options->hwmon_disable == true) return 0; hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); diff --git a/src/induct.c b/src/induct.c index b11befb79..536bec8ff 100644 --- a/src/induct.c +++ b/src/induct.c @@ -39,17 +39,18 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) induct_ctx->enabled = false; - if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->stdout_flag == true) return 0; - if (user_options->speed_only == true) return 0; - if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->benchmark == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->stdout_flag == true) return 0; + if (user_options->speed_only == true) return 0; + if (user_options->progress_only == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) && (user_options->attack_mode != ATTACK_MODE_ASSOCIATION)) return 0; diff --git a/src/loopback.c b/src/loopback.c index 694ef1a87..269f8cd2d 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -60,17 +60,18 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = false; - if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->stdout_flag == true) return 0; - if (user_options->speed_only == true) return 0; - if (user_options->progress_only == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->benchmark == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->stdout_flag == true) return 0; + if (user_options->speed_only == true) return 0; + if (user_options->progress_only == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; loopback_ctx->enabled = true; loopback_ctx->fp.pfp = NULL; diff --git a/src/main.c b/src/main.c index f98673bd8..03f804915 100644 --- a/src/main.c +++ b/src/main.c @@ -189,6 +189,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA if (user_options->stdout_flag == true) return; if (user_options->backend_info == true) return; if (user_options->speed_only == true) return; + if (user_options->identify == true) return; if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { diff --git a/src/outfile_check.c b/src/outfile_check.c index c7c670c47..359806985 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -343,12 +343,13 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) outcheck_ctx->enabled = false; - if (user_options->keyspace == true) return 0; - if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; - if (user_options->speed_only == true) return 0; - if (user_options->progress_only == true) return 0; - if (user_options->backend_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->benchmark == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->speed_only == true) return 0; + if (user_options->progress_only == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->identify == true) return 0; if (hashconfig->outfile_check_disable == true) return 0; diff --git a/src/potfile.c b/src/potfile.c index 6e86984b1..18a2883b5 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -119,6 +119,7 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->progress_only == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; if (user_options->potfile_disable == true) return 0; if (hashconfig->potfile_disable == true) return 0; diff --git a/src/restore.c b/src/restore.c index 7d3c41ff4..03b7d3125 100644 --- a/src/restore.c +++ b/src/restore.c @@ -309,6 +309,7 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->progress_only == true) return 0; if (user_options->usage == true) return 0; if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; if (user_options->restore_disable == true) return 0; if (argc == 0) return 0; diff --git a/src/terminal.c b/src/terminal.c index 6809ca8cd..848ef20dc 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -30,6 +30,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) if (user_options->stdout_flag == true) return; if (user_options->show == true) return; if (user_options->left == true) return; + if (user_options->identify == true) return; if (user_options->benchmark == true) { @@ -101,6 +102,7 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const if (user_options->stdout_flag == true) return; if (user_options->show == true) return; if (user_options->left == true) return; + if (user_options->identify == true) return; char start_buf[32]; memset (start_buf, 0, sizeof (start_buf)); char stop_buf[32]; memset (start_buf, 0, sizeof (stop_buf)); diff --git a/src/tuningdb.c b/src/tuningdb.c index eae22ed1e..74caf7f7a 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -54,13 +54,14 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = false; - if (user_options->hash_info == true) return 0; - if (user_options->keyspace == true) return 0; - if (user_options->left == true) return 0; - if (user_options->backend_info == true) return 0; - if (user_options->show == true) return 0; - if (user_options->usage == true) return 0; - if (user_options->version == true) return 0; + if (user_options->hash_info == true) return 0; + if (user_options->keyspace == true) return 0; + if (user_options->left == true) return 0; + if (user_options->backend_info == true) return 0; + if (user_options->show == true) return 0; + if (user_options->usage == true) return 0; + if (user_options->version == true) return 0; + if (user_options->identify == true) return 0; tuning_db->enabled = true; diff --git a/src/user_options.c b/src/user_options.c index cb2c73379..9acef8d3e 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1085,6 +1085,16 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->identify == true) + { + if (user_options->hash_mode_chgd == true) + { + event_log_error (hashcat_ctx, "Can't change --hash-type (-m) in identify mode."); + + return -1; + } + } + if (user_options->benchmark == true) { // sanity checks based on automatically overwritten configuration variables by @@ -1639,6 +1649,11 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx) { user_options->session = "left"; } + + if (user_options->identify == true) + { + user_options->session = "identify"; + } } } @@ -1678,6 +1693,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) || user_options->keyspace == true || user_options->speed_only == true || user_options->progress_only == true + || user_options->identify == true || user_options->usage == true) { user_options->hwmon_disable = true; @@ -3032,6 +3048,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->hex_salt); logfile_top_uint (user_options->hex_wordlist); logfile_top_uint (user_options->hook_threads); + logfile_top_uint (user_options->identify); logfile_top_uint (user_options->increment); logfile_top_uint (user_options->increment_max); logfile_top_uint (user_options->increment_min); From ee7fca82f5a2f1f8a0049c2a29778a85849adec4 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 12 Jun 2021 11:42:19 +0200 Subject: [PATCH 23/56] Scrypt Kernels: Re-enable scrypt based kernels to use kernel cache --- docs/changes.txt | 2 ++ src/backend.c | 61 ++++++++++++++++++++++---------------- src/modules/module_08900.c | 7 +---- src/modules/module_09300.c | 7 +---- src/modules/module_15700.c | 7 +---- src/modules/module_22700.c | 7 +---- src/modules/module_25600.c | 25 +++++++++++----- src/modules/module_25800.c | 25 +++++++++++----- 8 files changed, 75 insertions(+), 66 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 084d3033b..074e83110 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -50,6 +50,7 @@ - Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support - RC4 Kernels: Improved performance by 20%+ for hash-modes Kerberos 5 (etype 23), MS Office (<= 2003) and PDF (<= 1.6) by using new RC4 code +- Scrypt Kernels: Re-enable scrypt based kernels to use kernel cache - Status Screen: Show currently running kernel type (pure, optimized) and generator type (host, device) - UTF8-to-UTF16: Replaced naive UTF8 to UTF16 conversion with true conversion for RAR3, AES Crypt, MultiBit HD (scrypt) and Umbraco HMAC-SHA1 @@ -63,6 +64,7 @@ - Hashrate: Innerloop hashrate prediction requires update because of the new salt_repeats feature and also respect _loop2 kernel runtime - Kernels: Add RC4 cipher to crypto library with optimized shared memory access pattern which will not cause any bank conflicts if -u <= 32 - Kernels: Add standalone true UTF8 to UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin +- Kernel Cache: Add module_jit_build_options() string from modules to kernel cache checksum calculation - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET - Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK diff --git a/src/backend.c b/src/backend.c index bc3e00c0c..d868645b4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -8676,29 +8676,11 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) #endif /** - * device_name_chksum + * device_name_chksum_amp_mp */ - char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY); - // The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes. - // ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels. - - const u32 extra_value = (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) ? ATTACK_MODE_ASSOCIATION : ATTACK_MODE_NONE; - - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s-%d-%u-%u", - backend_ctx->comptime, - backend_ctx->cuda_driver_version, - device_param->is_opencl, - device_param->opencl_platform_vendor_id, - device_param->device_name, - device_param->opencl_device_version, - device_param->opencl_driver_version, - device_param->vector_width, - hashconfig->kern_type, - extra_value); - const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s", backend_ctx->comptime, backend_ctx->cuda_driver_version, @@ -8710,12 +8692,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) md5_ctx_t md5_ctx; - md5_init (&md5_ctx); - md5_update (&md5_ctx, (u32 *) device_name_chksum, dnclen); - md5_final (&md5_ctx); - - snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", md5_ctx.h[0]); - md5_init (&md5_ctx); md5_update (&md5_ctx, (u32 *) device_name_chksum_amp_mp, dnclen_amp_mp); md5_final (&md5_ctx); @@ -8934,6 +8910,38 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_options_module '%s'", device_id + 1, build_options_module_buf); #endif + /** + * device_name_chksum + */ + + char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); + + // The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes. + // ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels. + + const u32 extra_value = (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) ? ATTACK_MODE_ASSOCIATION : ATTACK_MODE_NONE; + + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s-%d-%u-%u-%s", + backend_ctx->comptime, + backend_ctx->cuda_driver_version, + device_param->is_opencl, + device_param->opencl_platform_vendor_id, + device_param->device_name, + device_param->opencl_device_version, + device_param->opencl_driver_version, + device_param->vector_width, + hashconfig->kern_type, + extra_value, + build_options_module_buf); + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, (u32 *) device_name_chksum, dnclen); + md5_final (&md5_ctx); + + snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", md5_ctx.h[0]); + /** * kernel source filename */ @@ -8971,6 +8979,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } hcfree (build_options_module_buf); + + hcfree (device_name_chksum); } /** @@ -9082,7 +9092,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_clUnloadPlatformCompiler (hashcat_ctx, platform_id) == -1) return -1; } - hcfree (device_name_chksum); hcfree (device_name_chksum_amp_mp); // some algorithm collide too fast, make that impossible diff --git a/src/modules/module_08900.c b/src/modules/module_08900.c index dac69671c..de2a936d6 100644 --- a/src/modules/module_08900.c +++ b/src/modules/module_08900.c @@ -243,11 +243,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (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 true; @@ -438,7 +433,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_kernel_loops_max; diff --git a/src/modules/module_09300.c b/src/modules/module_09300.c index 5408f71b8..05dcbc585 100644 --- a/src/modules/module_09300.c +++ b/src/modules/module_09300.c @@ -235,11 +235,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (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 true; @@ -395,7 +390,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_kernel_loops_max; diff --git a/src/modules/module_15700.c b/src/modules/module_15700.c index 16b0ceac0..cb2d939ab 100644 --- a/src/modules/module_15700.c +++ b/src/modules/module_15700.c @@ -256,11 +256,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (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 true; @@ -504,7 +499,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_kernel_loops_max; diff --git a/src/modules/module_22700.c b/src/modules/module_22700.c index 51409e06c..599144173 100644 --- a/src/modules/module_22700.c +++ b/src/modules/module_22700.c @@ -243,11 +243,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (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 true; @@ -443,7 +438,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_kernel_loops_max; diff --git a/src/modules/module_25600.c b/src/modules/module_25600.c index 561c04d77..ed48b2476 100644 --- a/src/modules/module_25600.c +++ b/src/modules/module_25600.c @@ -59,6 +59,20 @@ typedef struct bcrypt_tmp } bcrypt_tmp_t; +u32 module_kernel_loops_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 kernel_loops_min = 1024; + + return kernel_loops_min; +} + +u32 module_kernel_loops_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 kernel_loops_max = 1024; + + return kernel_loops_max; +} + 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 (bcrypt_tmp_t); @@ -66,11 +80,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; @@ -321,11 +330,11 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; diff --git a/src/modules/module_25800.c b/src/modules/module_25800.c index 154e9bc5c..964588174 100644 --- a/src/modules/module_25800.c +++ b/src/modules/module_25800.c @@ -59,6 +59,20 @@ typedef struct bcrypt_tmp } bcrypt_tmp_t; +u32 module_kernel_loops_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 kernel_loops_min = 1024; + + return kernel_loops_min; +} + +u32 module_kernel_loops_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 kernel_loops_max = 1024; + + return kernel_loops_max; +} + 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 (bcrypt_tmp_t); @@ -66,11 +80,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; @@ -321,11 +330,11 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + 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_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; From 02b2ca41c5189840d5bb67a22447dd8214cc2182 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 12 Jun 2021 16:51:47 +0200 Subject: [PATCH 24/56] add unit-test and set pw_max to 16 for ProgressEncode --- src/modules/module_26200.c | 9 +++- tools/test_modules/m26200.pm | 102 +++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tools/test_modules/m26200.pm diff --git a/src/modules/module_26200.c b/src/modules/module_26200.c index b9445df79..63989796e 100644 --- a/src/modules/module_26200.c +++ b/src/modules/module_26200.c @@ -57,6 +57,13 @@ bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE return false; } +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 = 16; + + return pw_max; +} + char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; @@ -170,7 +177,7 @@ void module_init (module_ctx_t *module_ctx) 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_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; diff --git a/tools/test_modules/m26200.pm b/tools/test_modules/m26200.pm new file mode 100644 index 000000000..a89596625 --- /dev/null +++ b/tools/test_modules/m26200.pm @@ -0,0 +1,102 @@ +#!/usr/bin/env perl + +## +## Author......: See docs/credits.txt +## License.....: MIT +## + +use strict; +use warnings; + +sub module_constraints { [[0, 16], [-1, -1], [-1, -1], [-1, -1], [0, 16]] } + +my @PE_CONST = ( + 0, 49345, 49537, 320, 49921, 960, 640, 49729, 50689, 1728, 1920, 51009, 1280, 50625, 50305, 1088, + 52225, 3264, 3456, 52545, 3840, 53185, 52865, 3648, 2560, 51905, 52097, 2880, 51457, 2496, 2176, 51265, + 55297, 6336, 6528, 55617, 6912, 56257, 55937, 6720, 7680, 57025, 57217, 8000, 56577, 7616, 7296, 56385, + 5120, 54465, 54657, 5440, 55041, 6080, 5760, 54849, 53761, 4800, 4992, 54081, 4352, 53697, 53377, 4160, + 61441, 12480, 12672, 61761, 13056, 62401, 62081, 12864, 13824, 63169, 63361, 14144, 62721, 13760, 13440, 62529, + 15360, 64705, 64897, 15680, 65281, 16320, 16000, 65089, 64001, 15040, 15232, 64321, 14592, 63937, 63617, 14400, + 10240, 59585, 59777, 10560, 60161, 11200, 10880, 59969, 60929, 11968, 12160, 61249, 11520, 60865, 60545, 11328, + 58369, 9408, 9600, 58689, 9984, 59329, 59009, 9792, 8704, 58049, 58241, 9024, 57601, 8640, 8320, 57409, + 40961, 24768, 24960, 41281, 25344, 41921, 41601, 25152, 26112, 42689, 42881, 26432, 42241, 26048, 25728, 42049, + 27648, 44225, 44417, 27968, 44801, 28608, 28288, 44609, 43521, 27328, 27520, 43841, 26880, 43457, 43137, 26688, + 30720, 47297, 47489, 31040, 47873, 31680, 31360, 47681, 48641, 32448, 32640, 48961, 32000, 48577, 48257, 31808, + 46081, 29888, 30080, 46401, 30464, 47041, 46721, 30272, 29184, 45761, 45953, 29504, 45313, 29120, 28800, 45121, + 20480, 37057, 37249, 20800, 37633, 21440, 21120, 37441, 38401, 22208, 22400, 38721, 21760, 38337, 38017, 21568, + 39937, 23744, 23936, 40257, 24320, 40897, 40577, 24128, 23040, 39617, 39809, 23360, 39169, 22976, 22656, 38977, + 34817, 18624, 18816, 35137, 19200, 35777, 35457, 19008, 19968, 36545, 36737, 20288, 36097, 19904, 19584, 35905, + 17408, 33985, 34177, 17728, 34561, 18368, 18048, 34369, 33281, 17088, 17280, 33601, 16640, 33217, 32897, 16448 +); + +sub PE_encode +{ + my $word_str = shift; + + my $word_str_len = length($word_str); + + my @word = split('', $word_str, $word_str_len); + + my @scratch = (0) x 16; + my @target = (0) x 16; + my $hash = 17; + + for (my $i=0; $i<5; $i++) { + for (my $j=0; $j<$word_str_len; $j++) { + my $idx = 15 - ($j % 16); + $scratch[$idx] ^= ord($word[$j]); + } + + for (my $j=0; $j<16; $j+=2) { + for (my $k=15; $k>=0; $k--) { + $hash = (($hash & 0xffff) >> 8 ^ $PE_CONST[($hash & 0xff)] ^ $PE_CONST[$scratch[$k]]); + } + + $scratch[$j] = $hash & 0xff; + $scratch[$j+1] = ($hash >> 8) & 0xff; + } + } + + my $low; + for (my $i=0; $i<16; $i++) { + $low = $scratch[$i] & 0x7f; + + if ($low >= 65 && $low <= 90 || $low >= 97 && $low <= 122) { + $target[$i] = $low; + } else { + $target[$i] = ((($scratch[$i] & 0xff) >> 4) + 0x61) & 0xff; + } + + $target[$i] = chr($target[$i]); + } + + return join '', @target; +} + +sub module_generate_hash +{ + my $word = shift; + + my $hash = PE_encode ($word); + + return $hash; +} + +sub module_verify_hash +{ + my $line = shift; + + my ($hash, $word) = split (':', $line); + + return unless defined $hash; + return unless defined $word; + +# my $word_packed = pack_if_HEX_notation ($word); + +# my $new_hash = module_generate_hash ($word_packed); + my $new_hash = module_generate_hash ($word); + + return ($new_hash, $word); +} + +1; From 42799fafb8f4c77141683eb3c58a13336629beb2 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 12 Jun 2021 17:10:36 +0200 Subject: [PATCH 25/56] cleanup unit-test code --- tools/test_modules/m26200.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/test_modules/m26200.pm b/tools/test_modules/m26200.pm index a89596625..a3fc0dd79 100644 --- a/tools/test_modules/m26200.pm +++ b/tools/test_modules/m26200.pm @@ -91,10 +91,9 @@ sub module_verify_hash return unless defined $hash; return unless defined $word; -# my $word_packed = pack_if_HEX_notation ($word); + my $word_packed = pack_if_HEX_notation ($word); -# my $new_hash = module_generate_hash ($word_packed); - my $new_hash = module_generate_hash ($word); + my $new_hash = module_generate_hash ($word_packed); return ($new_hash, $word); } From 3ee77aa581c781a24bce9ea1e659b74ec2e44ee7 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 12 Jun 2021 18:38:23 +0200 Subject: [PATCH 26/56] Prepare for v6.2.2 --- docs/changes.txt | 4 ++-- docs/readme.txt | 4 ++-- extra/tab_completion/hashcat.sh | 2 +- src/Makefile | 2 +- tools/package_bin.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4ea6f37ae..b3a8b8291 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,4 +1,4 @@ -* changes v6.2.1 -> v6.x.x +* changes v6.2.1 -> v6.2.2 ## ## Algorithms @@ -9,6 +9,7 @@ - Added hash-mode: FortiGate256 (FortiOS256) - Added hash-mode: Linux Kernel Crypto API (2.4) - Added hash-mode: MurmurHash +- Added hash-mode: OpenEdge Progress Encode - Added hash-mode: md5(utf16le($pass)) - Added hash-mode: sha1(utf16le($pass)) - Added hash-mode: sha256(utf16le($pass)) @@ -112,7 +113,6 @@ - Added hash-mode: Umbraco HMAC-SHA1 - Added hash-mode: sha1($salt.sha1($pass.$salt)) - Added hash-mode: sha1(sha1($pass).$salt) -- Added hash-mode: OpenEdge Progress Encode ## ## Features diff --git a/docs/readme.txt b/docs/readme.txt index da17fcbba..f97bc42cd 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -7,7 +7,7 @@ |_____| /___________/ |_____| /_____/ /_______| : : : -hashcat v6.2.1 +hashcat v6.2.2 ============== AMD GPUs on Linux require "RadeonOpenCompute (ROCm)" Software Platform (3.1 or later) @@ -256,6 +256,7 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Lotus Notes/Domino 5 - Lotus Notes/Domino 6 - Lotus Notes/Domino 8 +- OpenEdge Progress Encode - Oracle Transportation Management (SHA256) - Huawei sha1(md5($pass).$salt) - AuthMe sha256 @@ -351,7 +352,6 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or - Web2py pbkdf2-sha512 - Django (PBKDF2-SHA256) - Django (SHA-1) -- OpenEdge Progress Encode - Atlassian (PBKDF2-HMAC-SHA1) - Ruby on Rails Restful-Authentication - Python passlib pbkdf2-sha512 diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index fac85172a..ec48c339d 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -411,7 +411,7 @@ _hashcat_contains () _hashcat () { - local VERSION=6.2.1 + local VERSION=6.2.2 local ATTACK_MODES="0 1 3 6 7 9" local HCCAPX_MESSAGE_PAIRS="0 1 2 3 4 5" diff --git a/src/Makefile b/src/Makefile index 77029e3f9..e2ec05c6d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ SHARED ?= 0 DEBUG := 0 PRODUCTION := 0 -PRODUCTION_VERSION := v6.2.1 +PRODUCTION_VERSION := v6.2.2 ENABLE_CUBIN ?= 1 ENABLE_BRAIN ?= 1 ENABLE_UNRAR ?= 1 diff --git a/tools/package_bin.sh b/tools/package_bin.sh index 9ef5dfc66..e2f3a7659 100755 --- a/tools/package_bin.sh +++ b/tools/package_bin.sh @@ -6,7 +6,7 @@ ## export IN=$HOME/hashcat -export OUT=$HOME/xy/hashcat-6.2.1 +export OUT=$HOME/xy/hashcat-6.2.2 rm -rf $OUT rm -rf $OUT.7z From d92aefbe4020313a67b3494d38450e7ba8cc1e86 Mon Sep 17 00:00:00 2001 From: Royce Williams Date: Sat, 12 Jun 2021 10:04:59 -0800 Subject: [PATCH 27/56] changes.txt slight rework --- docs/changes.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index b3a8b8291..0face1ef8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -27,33 +27,33 @@ ## Features ## -- Autodetect hash-type: performs an automatic analysis of the input hash(es), associating compatible algorithms, or executing the attack if only one compatible format is found -- Autodetect hash-type: Added option --identify to limit hashcat to perform only autodetection of hash-type and to skip the backend device initialization +- Autodetect hash-type: performs an automatic analysis of input hash(es), either listing compatible algorithms, or executing the attack (if only one compatible format is found) +- Autodetect hash-type: added option --identify to only perform autodetection of hash-type, without back-end device initialization ## ## Bugs ## -- Fixed error message in -a 9 mode with rules in case number of words from wordlist are not in sync with number of unique salts -- Fixed error handling logic in monitor thread to not return in case of error (disc full, permission error, ...) but to retry instead -- Fixed false negatives with TrueCrypt/VeraCrypt in case zip or gzip compressed files were used as keyfiles -- Fixed free memory size output for skipped GPU (both automatic and manual) of --backend-info information screen +- Fixed error message in -a 9 mode with rules when number of words from wordlist is not in sync with number of unique salts +- Fixed error-handling logic in monitor thread to not return in case of error (disk full, permission error, ...) but to retry instead +- Fixed false negatives with TrueCrypt/VeraCrypt when zip- or gzip-compressed files were used as keyfiles +- Fixed free memory-size output for skipped GPU (both automatic and manual) of --backend-info information screen ## ## Improvements ## - AES Crypt Plugin: Reduced max password length from 256 to 128 which improved performance by 22% -- CUDA Backend: Do not warn about missing CUDA SDK installation if --stdout is used -- Folder Management: Add support for XDG Base Directory specification if hashcat was installed using make install +- CUDA Backend: If --stdout is used, do not warn about missing CUDA SDK +- Folder Management: Add support for XDG Base Directory specification when hashcat is installed using 'make install' - Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux) -- OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name in case OpenCL runtime supports this query -- Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations +- OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name (when supported by OpenCL runtime) +- Performance Monitor: Suggest -S to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support -- RC4 Kernels: Improved performance by 20%+ for hash-modes Kerberos 5 (etype 23), MS Office (<= 2003) and PDF (<= 1.6) by using new RC4 code -- Scrypt Kernels: Re-enable scrypt based kernels to use kernel cache -- Status Screen: Show currently running kernel type (pure, optimized) and generator type (host, device) -- UTF8-to-UTF16: Replaced naive UTF8 to UTF16 conversion with true conversion for RAR3, AES Crypt, MultiBit HD (scrypt) and Umbraco HMAC-SHA1 +- RC4 Kernels: Improved performance by 20%+ with new RC4 code in hash-modes Kerberos 5 (etype 23), MS Office (<= 2003) and PDF (<= 1.6) +- Scrypt Kernels: Re-enable use of kernel cache in scrypt-based kernels +- Status Screen: Show currently-running kernel type (pure, optimized) and generator type (host, device) +- UTF8-to-UTF16: Replaced naive UTF8-to-UTF16 conversion with true conversion for RAR3, AES Crypt, MultiBit HD (scrypt) and Umbraco HMAC-SHA1 ## ## Technical @@ -62,9 +62,9 @@ - Dependencies: Updated LZMA SDK from 19.00 to 21.02 alpha - Dependencies: Updated xxHash from 0.1.0 to v0.8.0 - Stable XXH3 - Documentation: Update missing documentation in plugin developer guide for OPTS_TYPE_MP_MULTI_DISABLE and OPTS_TYPE_NATIVE_THREADS -- Hashrate: Innerloop hashrate prediction requires update because of the new salt_repeats feature and also respect _loop2 kernel runtime +- Hashrate: Update inner-loop hashrate prediction to handle new salt_repeats feature and also respect _loop2 kernel runtime - Kernels: Add RC4 cipher to crypto library with optimized shared memory access pattern which will not cause any bank conflicts if -u <= 32 -- Kernels: Add standalone true UTF8 to UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin +- Kernels: Add standalone true UTF8-to-UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin - Kernel Cache: Add module_jit_build_options() string from modules to kernel cache checksum calculation - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET From bc4ce4cbeb84ec7df8b23645068b282ed7e3bebd Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 12 Jun 2021 20:13:31 +0200 Subject: [PATCH 28/56] Add support for CPU/GPU device temperature and fanspeed using iokit (Apple) --- docs/changes.txt | 1 + include/ext_iokit.h | 125 ++++++++++++++++++ include/types.h | 8 ++ src/Makefile | 4 +- src/backend.c | 11 ++ src/ext_iokit.c | 307 ++++++++++++++++++++++++++++++++++++++++++++ src/hwmon.c | 175 ++++++++++++++++++++++--- src/monitor.c | 14 ++ 8 files changed, 625 insertions(+), 20 deletions(-) create mode 100644 include/ext_iokit.h create mode 100644 src/ext_iokit.c diff --git a/docs/changes.txt b/docs/changes.txt index 074e83110..ad2a0fbae 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -46,6 +46,7 @@ - CUDA Backend: Do not warn about missing CUDA SDK installation if --stdout is used - Folder Management: Add support for XDG Base Directory specification if hashcat was installed using make install - Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux) +- Hardware Monitor: Add support for CPU/GPU device temperature and fanspeed using iokit (Apple) - OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name in case OpenCL runtime supports this query - Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support diff --git a/include/ext_iokit.h b/include/ext_iokit.h new file mode 100644 index 000000000..b6cd9c5ea --- /dev/null +++ b/include/ext_iokit.h @@ -0,0 +1,125 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _EXT_IOKIT_H +#define _EXT_IOKIT_H + +#ifdef __APPLE__ +#include + +// Apple SMC Keys +#define HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT "SGHT" +#define HM_IOKIT_SMC_CPU_PROXIMITY "TC0P" +#define HM_IOKIT_SMC_GPU_PROXIMITY "TG0P" +#define HM_IOKIT_SMC_PECI_GPU "TCGC" + +#define KERNEL_INDEX_SMC 2 + +#define DATATYPE_FPE2 "fpe2" +#define DATATYPE_UINT8 "ui8 " +#define DATATYPE_UINT16 "ui16" +#define DATATYPE_UINT32 "ui32" +#define DATATYPE_SP78 "sp78" + +typedef enum +{ + SMC_CMD_READ_BYTES = 5, + SMC_CMD_WRITE_BYTES = 6, + SMC_CMD_READ_INDEX = 8, + SMC_CMD_READ_KEYINFO = 9, + SMC_CMD_READ_PLIMIT = 11, + SMC_CMD_READ_VERS = 12 + +} SMCCommands_t; + +typedef struct +{ + char major; + char minor; + char build; + char reserved[1]; + UInt16 release; + +} SMCKeyData_vers_t; + +typedef struct +{ + UInt16 version; + UInt16 length; + UInt32 cpuPLimit; + UInt32 gpuPLimit; + UInt32 memPLimit; + +} SMCKeyData_pLimitData_t; + +typedef struct +{ + UInt32 dataSize; + UInt32 dataType; + + char dataAttributes; + +} SMCKeyData_keyInfo_t; + +typedef char SMCBytes_t[32]; + +typedef struct +{ + UInt32 key; + + SMCKeyData_vers_t vers; + SMCKeyData_pLimitData_t pLimitData; + SMCKeyData_keyInfo_t keyInfo; + + char result; + char status; + char data8; + + UInt32 data32; + SMCBytes_t bytes; + +} SMCKeyData_t; + +typedef char UInt32Char_t[5]; + +typedef struct +{ + UInt32Char_t key; + UInt32 dataSize; + UInt32Char_t dataType; + SMCBytes_t bytes; + +} SMCVal_t; + +#endif // __APPLE__ + +typedef int HM_ADAPTER_IOKIT; + +typedef void *IOKIT_LIB; + +typedef struct hm_iokit_lib +{ + #if defined(__APPLE__) + io_connect_t conn; + #endif // __APPLE__ + +} hm_iokit_lib_t; + +typedef hm_iokit_lib_t IOKIT_PTR; + +UInt32 hm_IOKIT_strtoul (char *str, int size, int base); +void hm_IOKIT_ultostr (char *str, UInt32 val); +kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn); +kern_return_t hm_IOKIT_SMCClose (io_connect_t conn); +kern_return_t hm_IOKIT_SMCCall (int index, SMCKeyData_t *inData, SMCKeyData_t *outData, io_connect_t conn); +kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t conn); +int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx); +int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp); +bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret); +int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed); +bool iokit_init (void *hashcat_ctx); +bool iokit_close (void *hashcat_ctx); + +#endif // _EXT_IOKIT_H diff --git a/include/types.h b/include/types.h index 2b240ba59..d85efcb43 100644 --- a/include/types.h +++ b/include/types.h @@ -611,7 +611,11 @@ typedef enum user_options_defaults DEBUG_MODE = 0, FORCE = false, HWMON_DISABLE = false, + #if defined (__APPLE__) + HWMON_TEMP_ABORT = 100, + #else HWMON_TEMP_ABORT = 90, + #endif HASH_INFO = false, HASH_MODE = 0, HCCAPX_MESSAGE_PAIR = 0, @@ -1589,6 +1593,7 @@ typedef struct backend_ctx bool need_nvml; bool need_nvapi; bool need_sysfs; + bool need_iokit; int comptime; @@ -1632,6 +1637,7 @@ typedef enum kernel_workload #include "ext_nvapi.h" #include "ext_nvml.h" #include "ext_sysfs.h" +#include "ext_iokit.h" typedef struct hm_attrs { @@ -1639,6 +1645,7 @@ typedef struct hm_attrs HM_ADAPTER_NVML nvml; HM_ADAPTER_NVAPI nvapi; HM_ADAPTER_SYSFS sysfs; + HM_ADAPTER_IOKIT iokit; int od_version; @@ -1663,6 +1670,7 @@ typedef struct hwmon_ctx void *hm_nvml; void *hm_nvapi; void *hm_sysfs; + void *hm_iokit; hm_attrs_t *hm_device; diff --git a/src/Makefile b/src/Makefile index 77029e3f9..33961ecae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -315,6 +315,7 @@ endif # FreeBSD ifeq ($(UNAME),Darwin) export MACOSX_DEPLOYMENT_TARGET=10.9 CFLAGS_NATIVE := $(CFLAGS) +CFLAGS_NATIVE += -DWITH_HWMON ifeq ($(shell test $(DARWIN_VERSION) -le 15; echo $$?), 0) CFLAGS_NATIVE += -DMISSING_CLOCK_GETTIME @@ -322,6 +323,7 @@ endif LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -framework OpenCL +LFLAGS_NATIVE += -framework IOKit LFLAGS_NATIVE += -lpthread LFLAGS_NATIVE += -liconv endif # Darwin @@ -364,7 +366,7 @@ EMU_OBJS_ALL += emu_inc_truecrypt_crc32 emu_inc_truecrypt_keyfile emu EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 emu_inc_ecc_secp256k1 EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish -OBJS_ALL := affinity autotune backend benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_cuda ext_nvapi ext_nvml ext_nvrtc ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL) +OBJS_ALL := affinity autotune backend benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_cuda ext_nvapi ext_nvml ext_nvrtc ext_OpenCL ext_sysfs ext_iokit ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL) ifeq ($(ENABLE_BRAIN),1) OBJS_ALL += brain diff --git a/src/backend.c b/src/backend.c index d868645b4..b58d8d433 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5653,6 +5653,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) bool need_nvml = false; bool need_nvapi = false; bool need_sysfs = false; + bool need_iokit = false; int backend_devices_idx = 0; @@ -5901,10 +5902,12 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->skipped = true; } + #if !defined (__APPLE__) if ((backend_ctx->opencl_device_types_filter & CL_DEVICE_TYPE_GPU) == 0) { device_param->skipped = true; } + #endif if ((device_param->opencl_platform_vendor_id == VENDOR_ID_NV) && (device_param->opencl_device_vendor_id == VENDOR_ID_NV)) { @@ -6659,6 +6662,13 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // vendor specific + #if defined (__APPLE__) + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + if (device_param->skipped == false) need_iokit = true; + } + #endif + if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) { if ((device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_vendor_id == VENDOR_ID_AMD)) @@ -7333,6 +7343,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->need_nvml = need_nvml; backend_ctx->need_nvapi = need_nvapi; backend_ctx->need_sysfs = need_sysfs; + backend_ctx->need_iokit = need_iokit; backend_ctx->comptime = comptime; diff --git a/src/ext_iokit.c b/src/ext_iokit.c new file mode 100644 index 000000000..05b297ba3 --- /dev/null +++ b/src/ext_iokit.c @@ -0,0 +1,307 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "memory.h" +#include "shared.h" +#include "event.h" +#include "ext_iokit.h" + +#if defined (__APPLE__) +#include + +UInt32 hm_IOKIT_strtoul (char *str, int size, int base) +{ + int i; + + UInt32 total = 0; + + for (i = 0; i < size; i++) + { + if (base == 16) + { + total += str[i] << (size - 1 - i) * 8; + } + else + { + total += (unsigned char)(str[i] << (size - 1 - i) * 8); + } + } + return total; +} + +void hm_IOKIT_ultostr (char *str, UInt32 val) +{ + str[0] = '\0'; + + sprintf (str, "%c%c%c%c", (unsigned int)(val >> 24), (unsigned int)(val >> 16), (unsigned int)(val >> 8), (unsigned int)(val)); +} + +kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn) +{ + kern_return_t result; + io_iterator_t iterator; + io_object_t device; + + CFMutableDictionaryRef matchingDictionary = IOServiceMatching ("AppleSMC"); + + result = IOServiceGetMatchingServices (kIOMasterPortDefault, matchingDictionary, &iterator); + + if (result != kIOReturnSuccess) + { + event_log_error (hashcat_ctx, "IOServiceGetMatchingServices(): %08x", result); + + return 1; + } + + device = IOIteratorNext (iterator); + + IOObjectRelease (iterator); + + if (device == 0) + { + event_log_error (hashcat_ctx, "hm_IOKIT_SMCOpen(): no SMC found."); + + return 1; + } + + result = IOServiceOpen (device, mach_task_self(), 0, conn); + + IOObjectRelease (device); + + if (result != kIOReturnSuccess) + { + event_log_error (hashcat_ctx, "IOServiceOpen(): %08x", result); + + return 1; + } + + return kIOReturnSuccess; +} + +kern_return_t hm_IOKIT_SMCClose (io_connect_t conn) +{ + return IOServiceClose (conn); +} + +kern_return_t hm_IOKIT_SMCCall (int index, SMCKeyData_t *inData, SMCKeyData_t *outData, io_connect_t conn) +{ + size_t inDataSize = sizeof (SMCKeyData_t); + size_t outDataSize = sizeof (SMCKeyData_t); + + #if MAC_OS_X_VERSION_10_5 + return IOConnectCallStructMethod (conn, index, inData, inDataSize, outData, &outDataSize); + #else + return IOConnectMethodStructureIStructureO (conn, index, inDataSize, &outDataSize, inData, outData); + #endif +} + +kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t conn) +{ + SMCKeyData_t inData; + SMCKeyData_t outData; + + memset (&inData, 0, sizeof (SMCKeyData_t)); + memset (&outData, 0, sizeof (SMCKeyData_t)); + memset (val, 0, sizeof (SMCVal_t)); + + inData.key = hm_IOKIT_strtoul (key, 4, 16); + + inData.data8 = SMC_CMD_READ_KEYINFO; + + if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1; + + if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1; + + val->dataSize = outData.keyInfo.dataSize; + + hm_IOKIT_ultostr (val->dataType, outData.keyInfo.dataType); + + inData.keyInfo.dataSize = val->dataSize; + + inData.data8 = SMC_CMD_READ_BYTES; + + if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1; + + memcpy(val->bytes, outData.bytes, sizeof(outData.bytes)); + + return kIOReturnSuccess; +} + +int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; + + SMCVal_t val; + + memset (&val, 0, sizeof (SMCVal_t)); + + int alarm = -1; + + if (hm_IOKIT_SMCReadKey (HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT, &val, iokit->conn) == kIOReturnSuccess) + { + if (val.dataSize > 0) + { + if (strcmp(val.dataType, DATATYPE_UINT8) == 0) + { + alarm = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10); + } + } + + return alarm; + } + + return -1; +} + +int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; + + SMCVal_t val; + + memset (&val, 0, sizeof (SMCVal_t)); + + if (hm_IOKIT_SMCReadKey (key, &val, iokit->conn) == kIOReturnSuccess) + { + if (val.dataSize > 0) + { + if (strcmp(val.dataType, DATATYPE_SP78) == 0) + { + // convert sp78 value to temperature + int intValue = val.bytes[0] * 256 + (unsigned char)val.bytes[1]; + + *temp = (intValue / 256.0); + + return 1; + } + } + } + + // read failed + + *temp = 0.0; + + return -1; +} + +bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret) +{ + SMCVal_t val; + + memset (&val, 0, sizeof (SMCVal_t)); + + if (hm_IOKIT_SMCReadKey (key, &val, conn) == kIOReturnSuccess) + { + if (val.dataSize > 0) + { + if (strcmp(val.dataType, DATATYPE_FPE2) == 0) + { + // convert fpe2 value to RPM + *ret = ntohs (*(UInt16*)val.bytes) / 4.0; + + return true; + } + } + } + + // read failed + *ret = -1.f; + + return false; +} + +int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed) +{ + *fan_speed = 0; + + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; + + SMCVal_t val; + + UInt32Char_t key; + + int i, totalFans = 0; + + memset (&val, 0, sizeof (SMCVal_t)); + + if (hm_IOKIT_SMCReadKey ("FNum", &val, iokit->conn) == kIOReturnSuccess) + { + totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10); + + for (i = 0; i < totalFans; i++) + { + float actual_speed = 0.0f; + float minimum_speed = 0.0f; + float maximum_speed = 0.0f; + float rpm = 0.0f; + float pct = 0.0f; + + memset (&key, 0, sizeof (UInt32Char_t)); + sprintf (key, "F%dAc", i); + hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &actual_speed); + if (actual_speed < 0.f) continue; + + memset (&key, 0, sizeof (UInt32Char_t)); + sprintf(key, "F%dMn", i); + hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &minimum_speed); + if (minimum_speed < 0.f) continue; + + memset (&key, 0, sizeof (UInt32Char_t)); + sprintf (key, "F%dMx", i); + hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed); + if (maximum_speed < 0.f) continue; + + rpm = actual_speed - minimum_speed; + if (rpm < 0.f) rpm = 0.f; + + pct = rpm / (maximum_speed - minimum_speed); + pct *= 100.f; + + *fan_speed = pct; + + break; + } + } + + return 1; +} + +bool iokit_init (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; + + memset (iokit, 0, sizeof (IOKIT_PTR)); + + if (hm_IOKIT_SMCOpen (hashcat_ctx, &iokit->conn) == kIOReturnSuccess) return true; + + hcfree (hwmon_ctx->hm_iokit); + + hwmon_ctx->hm_iokit = NULL; + + return false; +} + +bool iokit_close (void *hashcat_ctx) +{ + hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; + + IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; + + hm_IOKIT_SMCClose (iokit->conn); + + return true; +} + +#endif // __APPLE__ diff --git a/src/hwmon.c b/src/hwmon.c index 845f4c674..af9c7acfd 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -245,7 +245,39 @@ int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { + #if defined (__APPLE__) + if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + if (hwmon_ctx->hm_iokit) + { + double temperature = 0.0; + + char *key = NULL; + + if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) key = HM_IOKIT_SMC_CPU_PROXIMITY; + else + { + key = HM_IOKIT_SMC_GPU_PROXIMITY; + + if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_INTEL_BEIGNET) + { + key = HM_IOKIT_SMC_PECI_GPU; + } + } + + if (hm_IOKIT_SMCGetTemperature(hashcat_ctx, key, &temperature) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; + + return -1; + } + + return (int) temperature; + } + } + #else if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + #endif if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) { @@ -414,7 +446,26 @@ int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { + #if defined (__APPLE__) + if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + if (hwmon_ctx->hm_iokit) + { + int speed = 0; + + if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, &speed) == -1) + { + hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; + + return -1; + } + + return speed; + } + } + #else if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; + #endif if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) { @@ -987,6 +1038,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); hm_attrs_t *hm_adapters_sysfs = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_iokit = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); #define FREE_ADAPTERS \ do { \ @@ -994,6 +1046,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hcfree (hm_adapters_nvapi); \ hcfree (hm_adapters_nvml); \ hcfree (hm_adapters_sysfs); \ + hcfree (hm_adapters_iokit); \ } while (0) if (backend_ctx->need_nvml == true) @@ -1053,6 +1106,27 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } + #if defined(__APPLE__) + if (backend_ctx->need_iokit == true) + { + hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR)); + + if (iokit_init (hashcat_ctx) == false) + { + hcfree (hwmon_ctx->hm_iokit); + + hwmon_ctx->hm_iokit = NULL; + } + + if (hwmon_ctx->hm_adl) + { + hcfree (hwmon_ctx->hm_iokit); + + hwmon_ctx->hm_iokit = NULL; + } + } + #endif + if (hwmon_ctx->hm_nvml) { if (hm_NVML_nvmlInit (hashcat_ctx) == 0) @@ -1283,7 +1357,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs || hwmon_ctx->hm_iokit) { if (true) { @@ -1291,6 +1365,8 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { hc_device_param_t *device_param = &backend_ctx->devices_param[backend_devices_idx]; + if (device_param->skipped == true) continue; + if (device_param->is_cuda == true) { // nothing to do @@ -1300,21 +1376,57 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) { const u32 device_id = device_param->device_id; + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (hwmon_ctx->hm_iokit)) + { + hm_adapters_iokit[device_id].buslanes_get_supported = false; + hm_adapters_iokit[device_id].corespeed_get_supported = false; + hm_adapters_iokit[device_id].fanspeed_get_supported = true; + hm_adapters_iokit[device_id].fanpolicy_get_supported = false; + hm_adapters_iokit[device_id].memoryspeed_get_supported = false; + hm_adapters_iokit[device_id].temperature_get_supported = true; + hm_adapters_iokit[device_id].utilization_get_supported = false; + } + if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - hm_adapters_sysfs[device_id].buslanes_get_supported = true; - hm_adapters_sysfs[device_id].corespeed_get_supported = true; - hm_adapters_sysfs[device_id].fanspeed_get_supported = true; - hm_adapters_sysfs[device_id].fanpolicy_get_supported = true; - hm_adapters_sysfs[device_id].memoryspeed_get_supported = true; - hm_adapters_sysfs[device_id].temperature_get_supported = true; - hm_adapters_sysfs[device_id].utilization_get_supported = true; + if (hwmon_ctx->hm_sysfs) + { + hm_adapters_sysfs[device_id].buslanes_get_supported = true; + hm_adapters_sysfs[device_id].corespeed_get_supported = true; + hm_adapters_sysfs[device_id].fanspeed_get_supported = true; + hm_adapters_sysfs[device_id].fanpolicy_get_supported = true; + hm_adapters_sysfs[device_id].memoryspeed_get_supported = true; + hm_adapters_sysfs[device_id].temperature_get_supported = true; + hm_adapters_sysfs[device_id].utilization_get_supported = true; + } } } } } - if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs == NULL) + #if defined(__APPLE__) + if (backend_ctx->need_iokit == true) + { + hwmon_ctx->hm_iokit = (IOKIT_PTR *) hcmalloc (sizeof (IOKIT_PTR)); + + if (iokit_init (hashcat_ctx) == false) + { + hcfree (hwmon_ctx->hm_iokit); + + hwmon_ctx->hm_iokit = NULL; + } + + if (hwmon_ctx->hm_adl) + { + hcfree (hwmon_ctx->hm_iokit); + + hwmon_ctx->hm_iokit = NULL; + } + } + #endif + + + if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs == NULL && hwmon_ctx->hm_iokit == NULL) { FREE_ADAPTERS; @@ -1345,13 +1457,17 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 device_id = device_param->device_id; + hwmon_ctx->hm_device[backend_devices_idx].adl = 0; + hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; + hwmon_ctx->hm_device[backend_devices_idx].iokit = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; + hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + if (device_param->is_cuda == true) { - hwmon_ctx->hm_device[backend_devices_idx].adl = 0; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi; hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml; - hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; if (hwmon_ctx->hm_nvml) { @@ -1384,15 +1500,32 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->is_opencl == true) { + #if defined(__APPLE__) + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + if (hwmon_ctx->hm_iokit) + { + hwmon_ctx->hm_device[backend_devices_idx].iokit = hm_adapters_iokit[device_id].iokit; + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_iokit[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_iokit[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_iokit[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_iokit[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_iokit[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_iokit[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_iokit[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_iokit[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_iokit[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_iokit[device_id].utilization_get_supported; + } + } + #else if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; + #endif if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) { hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[device_id].adl; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = hm_adapters_sysfs[device_id].sysfs; // not used - hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; - hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; - hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + hwmon_ctx->hm_device[backend_devices_idx].sysfs = hm_adapters_sysfs[device_id].sysfs; if (hwmon_ctx->hm_adl) { @@ -1427,11 +1560,8 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->opencl_device_vendor_id == VENDOR_ID_NV) { - hwmon_ctx->hm_device[backend_devices_idx].adl = 0; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; hwmon_ctx->hm_device[backend_devices_idx].nvapi = hm_adapters_nvapi[device_id].nvapi; hwmon_ctx->hm_device[backend_devices_idx].nvml = hm_adapters_nvml[device_id].nvml; - hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; if (hwmon_ctx->hm_nvml) { @@ -1517,6 +1647,13 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) sysfs_close (hashcat_ctx); } + #if defined (__APPLE__) + if (hwmon_ctx->hm_iokit) + { + iokit_close (hashcat_ctx); + } + #endif + // free memory hcfree (hwmon_ctx->od_clock_mem_status); diff --git a/src/monitor.c b/src/monitor.c index 02f1ac07e..b61a41824 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -130,6 +130,20 @@ static int monitor (hashcat_ctx_t *hashcat_ctx) myabort (hashcat_ctx); } + #if defined (__APPLE__) + // experimental feature, check the "Sensor Graphic Hot" sensor through IOKIT/SMC to catch a GPU overtemp alarm + else if (temperature > (int) (user_options->hwmon_temp_abort - 10)) + { + if (hm_IOKIT_SMCGetSensorGraphicHot (hashcat_ctx) == 1) + { + event_log_error (hashcat_ctx, "hm_IOKIT_SMCGetSensorGraphicHot(): Sensor Graphics HoT, GPU Overtemp"); + + EVENT_DATA (EVENT_MONITOR_TEMP_ABORT, &backend_devices_idx, sizeof (int)); + + myabort (hashcat_ctx); + } + } + #endif } for (int backend_devices_idx = 0; backend_devices_idx < backend_ctx->backend_devices_cnt; backend_devices_idx++) From 4dc20533bd7c10794de142ece634d5adcfae105a Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 12 Jun 2021 20:24:43 +0200 Subject: [PATCH 29/56] fix ext_iokit.h --- include/ext_iokit.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/ext_iokit.h b/include/ext_iokit.h index b6cd9c5ea..b01146b57 100644 --- a/include/ext_iokit.h +++ b/include/ext_iokit.h @@ -6,7 +6,7 @@ #ifndef _EXT_IOKIT_H #define _EXT_IOKIT_H -#ifdef __APPLE__ +#if defined(__APPLE__) #include // Apple SMC Keys @@ -109,6 +109,7 @@ typedef struct hm_iokit_lib typedef hm_iokit_lib_t IOKIT_PTR; +#if defined(__APPLE__) UInt32 hm_IOKIT_strtoul (char *str, int size, int base); void hm_IOKIT_ultostr (char *str, UInt32 val); kern_return_t hm_IOKIT_SMCOpen (void *hashcat_ctx, io_connect_t *conn); @@ -121,5 +122,6 @@ bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret); int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed); bool iokit_init (void *hashcat_ctx); bool iokit_close (void *hashcat_ctx); +#endif // __APPLE__ #endif // _EXT_IOKIT_H From 9908cb184b2599a12d6ab7e55f30b75f87995cbf Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 13 Jun 2021 14:51:01 +0200 Subject: [PATCH 30/56] hashcat 6.2.2 --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index e2ec05c6d..2c691bc47 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ SHARED ?= 0 DEBUG := 0 -PRODUCTION := 0 +PRODUCTION := 1 PRODUCTION_VERSION := v6.2.2 ENABLE_CUBIN ?= 1 ENABLE_BRAIN ?= 1 From c6b10bb0b6eb570af3e09182770008349e7600cb Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 13 Jun 2021 15:12:33 +0200 Subject: [PATCH 31/56] Unset PRODUCTION option --- docs/changes.txt | 2 ++ src/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0face1ef8..fa3d12ab9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,3 +1,5 @@ +* changes v6.2.2 -> v6.2.x + * changes v6.2.1 -> v6.2.2 ## diff --git a/src/Makefile b/src/Makefile index 2c691bc47..e2ec05c6d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,7 +5,7 @@ SHARED ?= 0 DEBUG := 0 -PRODUCTION := 1 +PRODUCTION := 0 PRODUCTION_VERSION := v6.2.2 ENABLE_CUBIN ?= 1 ENABLE_BRAIN ?= 1 From 8ebf4b98584213891f6e48570c91c31d22b80a81 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 13 Jun 2021 15:49:11 +0200 Subject: [PATCH 32/56] Fixed 'E' rule in pure kernel mode which was ignoring letters that are in positions that are multiples of 4 --- OpenCL/inc_rp.cl | 24 +++++++++++------------- docs/changes.txt | 7 +++++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/OpenCL/inc_rp.cl b/OpenCL/inc_rp.cl index 9a50e1802..8cecc661d 100644 --- a/OpenCL/inc_rp.cl +++ b/OpenCL/inc_rp.cl @@ -688,7 +688,9 @@ DECLSPEC int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const DECLSPEC int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, u32 *buf, const int len) { - if ((len + 4) >= RP_PASSWORD_SIZE) return (len); // cheap way to not need to check for overflow of i + 1 + if (len >= RP_PASSWORD_SIZE) return (len); + + u32 rem = 0xff; for (int i = 0, idx = 0; i < len; i += 4, idx += 1) { @@ -696,22 +698,18 @@ DECLSPEC int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p buf[idx] = t | generate_cmask (t); - u32 out0 = 0; - u32 out1 = 0; + u32 out = rem; - if (((t >> 0) & 0xff) == p0) out0 |= 0x0000ff00; - if (((t >> 8) & 0xff) == p0) out0 |= 0x00ff0000; - if (((t >> 16) & 0xff) == p0) out0 |= 0xff000000; - if (((t >> 24) & 0xff) == p0) out1 |= 0x000000ff; + rem = 0; - buf[idx + 0] &= ~(generate_cmask (buf[idx + 0]) & out0); - buf[idx + 1] &= ~(generate_cmask (buf[idx + 1]) & out1); + if (((t >> 0) & 0xff) == p0) out |= 0x0000ff00; + if (((t >> 8) & 0xff) == p0) out |= 0x00ff0000; + if (((t >> 16) & 0xff) == p0) out |= 0xff000000; + if (((t >> 24) & 0xff) == p0) rem |= 0x000000ff; + + buf[idx] &= ~(generate_cmask (buf[idx]) & out); } - const u32 t = buf[0]; - - buf[0] = t & ~(0x00000020 & generate_cmask (t)); - return (len); } diff --git a/docs/changes.txt b/docs/changes.txt index fa3d12ab9..ae3649c8c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,5 +1,12 @@ * changes v6.2.2 -> v6.2.x +## +## Bugs +## + +- Fixed 'E' rule in pure kernel mode which was ignoring letters that are in positions that are multiples of 4 + + * changes v6.2.1 -> v6.2.2 ## From 624994f9204f7310f9d02bd50339c59e53d3916e Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 14 Jun 2021 13:18:33 +0200 Subject: [PATCH 33/56] Backend Information: Added new column showing the PCI Address per CUDA/OpenCL device to easier identify broken cards --- docs/changes.txt | 5 +++++ src/terminal.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index ae3649c8c..098b6a3d3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -6,6 +6,11 @@ - Fixed 'E' rule in pure kernel mode which was ignoring letters that are in positions that are multiples of 4 +## +## Improvements +## + +- Backend Information: Added new column showing the PCI Address per CUDA/OpenCL device to easier identify broken cards * changes v6.2.1 -> v6.2.2 diff --git a/src/terminal.c b/src/terminal.c index 848ef20dc..0b6c8a37a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -731,6 +731,10 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) u32 device_maxclock_frequency = device_param->device_maxclock_frequency; u64 device_available_mem = device_param->device_available_mem; u64 device_global_mem = device_param->device_global_mem; + u8 pcie_domain = device_param->pcie_domain; + u8 pcie_bus = device_param->pcie_bus; + u8 pcie_device = device_param->pcie_device; + u8 pcie_function = device_param->pcie_function; if (device_param->device_id_alias_cnt) { @@ -746,6 +750,7 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency); event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB", device_global_mem / 1024 / 1024); event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024); + event_log_info (hashcat_ctx, " PCI.Addr.BDFe..: %04x:%02x:%02x.%d", (u16) pcie_domain, pcie_bus, pcie_device, pcie_function); event_log_info (hashcat_ctx, NULL); } } @@ -815,6 +820,24 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024); event_log_info (hashcat_ctx, " OpenCL.Version.: %s", opencl_device_c_version); event_log_info (hashcat_ctx, " Driver.Version.: %s", opencl_driver_version); + + if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) + { + u8 pcie_bus = device_param->pcie_bus; + u8 pcie_device = device_param->pcie_device; + u8 pcie_function = device_param->pcie_function; + + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_vendor_id == VENDOR_ID_AMD)) + { + event_log_info (hashcat_ctx, " PCI.Addr.BDF...: %02x:%02x.%d", pcie_bus, pcie_device, pcie_function); + } + + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_NV) && (device_param->opencl_device_vendor_id == VENDOR_ID_NV)) + { + event_log_info (hashcat_ctx, " PCI.Addr.BDF...: %02x:%02x.%d", pcie_bus, pcie_device, pcie_function); + } + } + event_log_info (hashcat_ctx, NULL); } } From a7a3cf024e10ad3c50dc6f04ab957aea9fb5bcb1 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Tue, 15 Jun 2021 11:53:06 +0200 Subject: [PATCH 34/56] Update docs/limits.txt regarding UTF16 support in kernels --- docs/limits.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/limits.txt b/docs/limits.txt index 0ee928080..88024faec 100644 --- a/docs/limits.txt +++ b/docs/limits.txt @@ -26,6 +26,8 @@ It only means the filename itself. ## Hashing algorithms that internally use UTF-16 characters could in special cases lead to false negatives ## +For optimized kernels only (-O): Since hashcat v6.2.1 there's true UTF16 support for pure kernels: + The UTF-16 conversion implementation used within the kernel code is very elementary and for performance reasons does not respect all complicated encoding rules required to correctly convert, for instance, ASCII or UTF-8 to UTF-16LE (or UTF-16BE). @@ -33,6 +35,8 @@ or UTF-8 to UTF-16LE (or UTF-16BE). The implementation most likely fails with multi-byte characters, because we basically add a zero byte every second byte within the kernel conversion code. +Since hashcat v6.2.1 there's true UTF16 support for pure kernels. + ## ## The use of --keep-guessing eventually skips reporting duplicate passwords ## From 2d7f67fd2368cd50776ed09d6429113b49b21669 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Tue, 15 Jun 2021 14:06:24 +0200 Subject: [PATCH 35/56] Alias Devices: Show a warning in case the user specifically listed a device to use which in a later step is skipped because it is an alias of another active device --- docs/changes.txt | 1 + src/backend.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 098b6a3d3..48e1ca44d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -10,6 +10,7 @@ ## Improvements ## +- Alias Devices: Show a warning in case the user specifically listed a device to use which in a later step is skipped because it is an alias of another active device - Backend Information: Added new column showing the PCI Address per CUDA/OpenCL device to easier identify broken cards * changes v6.2.1 -> v6.2.2 diff --git a/src/backend.c b/src/backend.c index d868645b4..9f3a54f52 100644 --- a/src/backend.c +++ b/src/backend.c @@ -131,6 +131,17 @@ static int backend_ctx_find_alias_devices (hashcat_ctx_t *hashcat_ctx) backend_ctx->opencl_devices_active--; backend_ctx->backend_devices_active--; + + // show a warning for specifically listed devices if they are an alias + + if (backend_ctx->backend_devices_filter != (u64) -1) + { + if (backend_ctx->backend_devices_filter & (1ULL << alias_device->device_id)) + { + event_log_warning (hashcat_ctx, "The device #%d specifically listed was skipped because it is an alias of device #%d", alias_device->device_id + 1, backend_device->device_id + 1); + event_log_warning (hashcat_ctx, NULL); + } + } } } From 6ecc45cd6dc17dcecc7db50230f11a7a0904f933 Mon Sep 17 00:00:00 2001 From: Arseniy Sharoglazov Date: Tue, 15 Jun 2021 23:51:20 +0300 Subject: [PATCH 36/56] Removing a special character from ru_cp1251.hcchr --- charsets/standard/Russian/ru_cp1251.hcchr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charsets/standard/Russian/ru_cp1251.hcchr b/charsets/standard/Russian/ru_cp1251.hcchr index 46e471415..c9c3dc0b7 100644 --- a/charsets/standard/Russian/ru_cp1251.hcchr +++ b/charsets/standard/Russian/ru_cp1251.hcchr @@ -1 +1 @@ -¨¸¹ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ \ No newline at end of file +¨¸ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ \ No newline at end of file From 1486476adb03d541028b876b73911a2f65a785a7 Mon Sep 17 00:00:00 2001 From: Arseniy Sharoglazov Date: Tue, 15 Jun 2021 23:54:45 +0300 Subject: [PATCH 37/56] Adding ru_cp866.hcchr --- charsets/standard/Russian/ru_cp866.hcchr | 1 + 1 file changed, 1 insertion(+) create mode 100644 charsets/standard/Russian/ru_cp866.hcchr diff --git a/charsets/standard/Russian/ru_cp866.hcchr b/charsets/standard/Russian/ru_cp866.hcchr new file mode 100644 index 000000000..ce95ad6b4 --- /dev/null +++ b/charsets/standard/Russian/ru_cp866.hcchr @@ -0,0 +1 @@ +€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñ \ No newline at end of file From a9cd76ca52f244a98f94d0b59cb739ca993c5104 Mon Sep 17 00:00:00 2001 From: Arseniy Sharoglazov Date: Tue, 15 Jun 2021 23:55:10 +0300 Subject: [PATCH 38/56] Adding ru_cp866-special.hcchr --- charsets/special/Russian/ru_cp866-special.hcchr | 1 + 1 file changed, 1 insertion(+) create mode 100644 charsets/special/Russian/ru_cp866-special.hcchr diff --git a/charsets/special/Russian/ru_cp866-special.hcchr b/charsets/special/Russian/ru_cp866-special.hcchr new file mode 100644 index 000000000..415104477 --- /dev/null +++ b/charsets/special/Russian/ru_cp866-special.hcchr @@ -0,0 +1 @@ +€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯àáâãäåæçèéêëìíîïðñü \ No newline at end of file From 9ad0438baac777fc101ec43015e10052089a6384 Mon Sep 17 00:00:00 2001 From: philsmd <921533+philsmd@users.noreply.github.com> Date: Wed, 16 Jun 2021 10:45:45 +0200 Subject: [PATCH 39/56] fixed typos in github feature request template --- .github/ISSUE_TEMPLATE/feature_request_-_add_new_algorithm.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_request_-_add_new_algorithm.md b/.github/ISSUE_TEMPLATE/feature_request_-_add_new_algorithm.md index c6a99220b..f7ae9691e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request_-_add_new_algorithm.md +++ b/.github/ISSUE_TEMPLATE/feature_request_-_add_new_algorithm.md @@ -7,10 +7,10 @@ assignees: '' --- -**Is your request based on a publicly know cryptographic schema and where can we find information about?** +**Is your request based on a publicly known cryptographic schema and where can we find information about?** For instance: - The hashing function XY is a public known hash algorithm on Wikipedia. -- The password protection for the application XY was made by public by security researcher XY and there's a paper called ... +- The password protection for the application XY was made public by security researcher XY and there's a paper called ... - The cryptographic schema used in protocol XY can be found in the OSS code on it's GitHub repository. **Describe alternatives you've considered** From 8548af5e79e3061c790eb9600ee378a7a691c8a8 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 16 Jun 2021 12:13:04 +0200 Subject: [PATCH 40/56] Fixed false negative in hash-mode 15900 (DPAPI masterkey file v2) if password was longer than 64 characters. Bug was also present in SHA512 based TC and VC kernels, but had no effect because maximum password length is 64. --- OpenCL/m06221-pure.cl | 2 +- OpenCL/m06222-pure.cl | 2 +- OpenCL/m06223-pure.cl | 2 +- OpenCL/m13721-pure.cl | 2 +- OpenCL/m13722-pure.cl | 2 +- OpenCL/m13723-pure.cl | 2 +- OpenCL/m15900-pure.cl | 2 +- docs/changes.txt | 1 + 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/OpenCL/m06221-pure.cl b/OpenCL/m06221-pure.cl index fbd139fe0..6e0027b2e 100644 --- a/OpenCL/m06221-pure.cl +++ b/OpenCL/m06221-pure.cl @@ -228,7 +228,7 @@ KERNEL_FQ void m06221_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m06222-pure.cl b/OpenCL/m06222-pure.cl index 78bd93c9b..7333d397f 100644 --- a/OpenCL/m06222-pure.cl +++ b/OpenCL/m06222-pure.cl @@ -228,7 +228,7 @@ KERNEL_FQ void m06222_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m06223-pure.cl b/OpenCL/m06223-pure.cl index fc1312acb..77069c25f 100644 --- a/OpenCL/m06223-pure.cl +++ b/OpenCL/m06223-pure.cl @@ -228,7 +228,7 @@ KERNEL_FQ void m06223_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 4e9c3edaf..8f02851fc 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -270,7 +270,7 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index f7cbbb83e..27ea184db 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -321,7 +321,7 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index 382d67be9..d906d17d7 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -386,7 +386,7 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/OpenCL/m15900-pure.cl b/OpenCL/m15900-pure.cl index c44a61149..78caf5fd7 100644 --- a/OpenCL/m15900-pure.cl +++ b/OpenCL/m15900-pure.cl @@ -255,7 +255,7 @@ KERNEL_FQ void m15900_init (KERN_ATTR_TMPS_ESALT (dpapimk_tmp_v2_t, dpapimk_t)) sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w5, w5, w6, w7); + sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); tmps[gid].ipad64[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad64[1] = sha512_hmac_ctx.ipad.h[1]; diff --git a/docs/changes.txt b/docs/changes.txt index 48e1ca44d..ce298a695 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -5,6 +5,7 @@ ## - Fixed 'E' rule in pure kernel mode which was ignoring letters that are in positions that are multiples of 4 +- Fixed false negative in hash-mode 15900 (DPAPI masterkey file v2) if password was longer than 64 characters ## ## Improvements From f9fab1cadf152d0b5e852b67066ddf09e450df4c Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 17 Jun 2021 09:43:21 +0200 Subject: [PATCH 41/56] Tests: Changed tests for VeraCrypt from -a 0 to -a 3, because password extension is not available to all shells --- docs/changes.txt | 6 ++++++ tools/test.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index ce298a695..906375f8b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -14,6 +14,12 @@ - Alias Devices: Show a warning in case the user specifically listed a device to use which in a later step is skipped because it is an alias of another active device - Backend Information: Added new column showing the PCI Address per CUDA/OpenCL device to easier identify broken cards +## +## Technical +## + +- Tests: Changed tests for VeraCrypt from -a 0 to -a 3, because password extension is not available to all shells + * changes v6.2.1 -> v6.2.2 ## diff --git a/tools/test.sh b/tools/test.sh index 9d06afed7..79b56a517 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -2783,7 +2783,7 @@ function veracrypt_test() # The hash-cipher combination might be invalid (e.g. RIPEMD-160 + Kuznyechik) [ -f "${filename}" ] || return - CMD="echo hashca{a..z} | ./${BIN} ${OPTS} -a 0 -m ${hash_type} ${filename}" + CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} ${filename} hashc?lt" echo "> Testing hash type ${hash_type} with attack mode 0, markov ${MARKOV}, single hash, Device-Type ${TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt" From 62397283c107f79f37acfa6f21147a1d069a49a5 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Thu, 17 Jun 2021 09:45:30 +0200 Subject: [PATCH 42/56] VeraCrypt: Increase password length support for non-boot volumes from 64 to 128. See https://github.com/hashcat/hashcat/issues/2616 for details. --- OpenCL/inc_common.cl | 73 ++++++++-------- OpenCL/inc_common.h | 2 +- OpenCL/inc_truecrypt_keyfile.cl | 64 ++++++++++++++ OpenCL/inc_truecrypt_keyfile.h | 1 + OpenCL/inc_veracrypt_keyfile.cl | 99 ++++++++++++++++++++++ OpenCL/inc_veracrypt_keyfile.h | 12 +++ OpenCL/m06211-pure.cl | 87 ++++++++++--------- OpenCL/m06212-pure.cl | 87 ++++++++++--------- OpenCL/m06213-pure.cl | 87 ++++++++++--------- OpenCL/m06221-pure.cl | 144 +++++++++++--------------------- OpenCL/m06222-pure.cl | 144 +++++++++++--------------------- OpenCL/m06223-pure.cl | 144 +++++++++++--------------------- OpenCL/m06231-pure.cl | 104 ++++++++++------------- OpenCL/m06232-pure.cl | 104 ++++++++++------------- OpenCL/m06233-pure.cl | 104 ++++++++++------------- OpenCL/m13711-pure.cl | 87 ++++++++++--------- OpenCL/m13712-pure.cl | 87 ++++++++++--------- OpenCL/m13713-pure.cl | 87 ++++++++++--------- OpenCL/m13721-pure.cl | 144 +++++++++++--------------------- OpenCL/m13722-pure.cl | 144 +++++++++++--------------------- OpenCL/m13723-pure.cl | 144 +++++++++++--------------------- OpenCL/m13731-pure.cl | 104 ++++++++++------------- OpenCL/m13732-pure.cl | 104 ++++++++++------------- OpenCL/m13733-pure.cl | 104 ++++++++++------------- OpenCL/m13751-pure.cl | 108 +++++++++++------------- OpenCL/m13752-pure.cl | 108 +++++++++++------------- OpenCL/m13753-pure.cl | 108 +++++++++++------------- OpenCL/m13771-pure.cl | 104 ++++++++++------------- OpenCL/m13772-pure.cl | 104 ++++++++++------------- OpenCL/m13773-pure.cl | 104 ++++++++++------------- docs/changes.txt | 1 + include/cpu_crc32.h | 2 +- src/Makefile | 1 - src/cpu_crc32.c | 10 +-- src/emu_inc_truecrypt_crc32.c | 11 --- src/emu_inc_truecrypt_keyfile.c | 11 --- src/emu_inc_truecrypt_xts.c | 11 --- src/emu_inc_veracrypt_xts.c | 11 --- src/modules/module_06211.c | 9 +- src/modules/module_06212.c | 9 +- src/modules/module_06213.c | 9 +- src/modules/module_06221.c | 11 ++- src/modules/module_06222.c | 11 ++- src/modules/module_06223.c | 9 +- src/modules/module_06231.c | 9 +- src/modules/module_06232.c | 9 +- src/modules/module_06233.c | 9 +- src/modules/module_06241.c | 9 +- src/modules/module_06242.c | 9 +- src/modules/module_06243.c | 9 +- src/modules/module_13711.c | 11 ++- src/modules/module_13712.c | 11 ++- src/modules/module_13713.c | 11 ++- src/modules/module_13721.c | 11 ++- src/modules/module_13722.c | 11 ++- src/modules/module_13723.c | 11 ++- src/modules/module_13731.c | 11 ++- src/modules/module_13732.c | 11 ++- src/modules/module_13733.c | 11 ++- src/modules/module_13741.c | 9 +- src/modules/module_13742.c | 9 +- src/modules/module_13743.c | 9 +- src/modules/module_13751.c | 11 ++- src/modules/module_13752.c | 11 ++- src/modules/module_13753.c | 11 ++- src/modules/module_13761.c | 9 +- src/modules/module_13762.c | 9 +- src/modules/module_13763.c | 9 +- src/modules/module_13771.c | 11 ++- src/modules/module_13772.c | 11 ++- src/modules/module_13773.c | 11 ++- 71 files changed, 1605 insertions(+), 1681 deletions(-) create mode 100644 OpenCL/inc_veracrypt_keyfile.cl create mode 100644 OpenCL/inc_veracrypt_keyfile.h delete mode 100644 src/emu_inc_truecrypt_crc32.c delete mode 100644 src/emu_inc_truecrypt_keyfile.c delete mode 100644 src/emu_inc_truecrypt_xts.c delete mode 100644 src/emu_inc_veracrypt_xts.c diff --git a/OpenCL/inc_common.cl b/OpenCL/inc_common.cl index e55fabbb0..bf8aeccd5 100644 --- a/OpenCL/inc_common.cl +++ b/OpenCL/inc_common.cl @@ -2627,34 +2627,15 @@ DECLSPEC int hc_find_keyboard_layout_map (const u32 search, const int search_len return -1; } -DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) +DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt) { - u32 out_buf[16] = { 0 }; + u32 out_buf[32] = { 0 }; u8 *out_ptr = (u8 *) out_buf; int out_len = 0; - // TC/VC passwords are limited to 64 - - u32 w[16]; - - w[ 0] = w0[0]; - w[ 1] = w0[1]; - w[ 2] = w0[2]; - w[ 3] = w0[3]; - w[ 4] = w1[0]; - w[ 5] = w1[1]; - w[ 6] = w1[2]; - w[ 7] = w1[3]; - w[ 8] = w2[0]; - w[ 9] = w2[1]; - w[10] = w2[2]; - w[11] = w2[3]; - w[12] = w3[0]; - w[13] = w3[1]; - w[14] = w3[2]; - w[15] = w3[3]; + // TC/VC passwords are limited to 128 u8 *w_ptr = (u8 *) w; @@ -2733,22 +2714,38 @@ DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w0, u32 *w1, u32 *w2, u32 } } - w0[0] = out_buf[ 0]; - w0[1] = out_buf[ 1]; - w0[2] = out_buf[ 2]; - w0[3] = out_buf[ 3]; - w1[0] = out_buf[ 4]; - w1[1] = out_buf[ 5]; - w1[2] = out_buf[ 6]; - w1[3] = out_buf[ 7]; - w2[0] = out_buf[ 8]; - w2[1] = out_buf[ 9]; - w2[2] = out_buf[10]; - w2[3] = out_buf[11]; - w3[0] = out_buf[12]; - w3[1] = out_buf[13]; - w3[2] = out_buf[14]; - w3[3] = out_buf[15]; + w[ 0] = out_buf[ 0]; + w[ 1] = out_buf[ 1]; + w[ 2] = out_buf[ 2]; + w[ 3] = out_buf[ 3]; + w[ 4] = out_buf[ 4]; + w[ 5] = out_buf[ 5]; + w[ 6] = out_buf[ 6]; + w[ 7] = out_buf[ 7]; + w[ 8] = out_buf[ 8]; + w[ 9] = out_buf[ 9]; + w[10] = out_buf[10]; + w[11] = out_buf[11]; + w[12] = out_buf[12]; + w[13] = out_buf[13]; + w[14] = out_buf[14]; + w[15] = out_buf[15]; + w[16] = out_buf[16]; + w[17] = out_buf[17]; + w[18] = out_buf[18]; + w[19] = out_buf[19]; + w[20] = out_buf[20]; + w[21] = out_buf[21]; + w[22] = out_buf[22]; + w[23] = out_buf[23]; + w[24] = out_buf[24]; + w[25] = out_buf[25]; + w[26] = out_buf[26]; + w[27] = out_buf[27]; + w[28] = out_buf[28]; + w[29] = out_buf[29]; + w[30] = out_buf[30]; + w[31] = out_buf[31]; return out_len; } diff --git a/OpenCL/inc_common.h b/OpenCL/inc_common.h index 88e49ff5e..91d59b736 100644 --- a/OpenCL/inc_common.h +++ b/OpenCL/inc_common.h @@ -256,7 +256,7 @@ DECLSPEC int is_valid_hex_32 (const u32 v); DECLSPEC int is_valid_base58_8 (const u8 v); DECLSPEC int is_valid_base58_32 (const u32 v); DECLSPEC int hc_find_keyboard_layout_map (const u32 search, const int search_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); -DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); +DECLSPEC int hc_execute_keyboard_layout_mapping (u32 *w, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt); DECLSPEC void make_utf16be (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16beN (const u32x *in, u32x *out1, u32x *out2); DECLSPEC void make_utf16le (const u32x *in, u32x *out1, u32x *out2); diff --git a/OpenCL/inc_truecrypt_keyfile.cl b/OpenCL/inc_truecrypt_keyfile.cl index 4822c811a..667aa15fd 100644 --- a/OpenCL/inc_truecrypt_keyfile.cl +++ b/OpenCL/inc_truecrypt_keyfile.cl @@ -33,3 +33,67 @@ DECLSPEC u32 u8add (const u32 a, const u32 b) return r; } + +DECLSPEC u32 hc_apply_keyfile_tc (u32 *w, const int pw_len, const GLOBAL_AS tc_t *tc) +{ + if (tc->keyfile_enabled == 0) return pw_len; + + if (pw_len > 64) + { + w[ 0] = u8add (w[ 0], tc->keyfile_buf32[ 0]); + w[ 1] = u8add (w[ 1], tc->keyfile_buf32[ 1]); + w[ 2] = u8add (w[ 2], tc->keyfile_buf32[ 2]); + w[ 3] = u8add (w[ 3], tc->keyfile_buf32[ 3]); + w[ 4] = u8add (w[ 4], tc->keyfile_buf32[ 4]); + w[ 5] = u8add (w[ 5], tc->keyfile_buf32[ 5]); + w[ 6] = u8add (w[ 6], tc->keyfile_buf32[ 6]); + w[ 7] = u8add (w[ 7], tc->keyfile_buf32[ 7]); + w[ 8] = u8add (w[ 8], tc->keyfile_buf32[ 8]); + w[ 9] = u8add (w[ 9], tc->keyfile_buf32[ 9]); + w[10] = u8add (w[10], tc->keyfile_buf32[10]); + w[11] = u8add (w[11], tc->keyfile_buf32[11]); + w[12] = u8add (w[12], tc->keyfile_buf32[12]); + w[13] = u8add (w[13], tc->keyfile_buf32[13]); + w[14] = u8add (w[14], tc->keyfile_buf32[14]); + w[15] = u8add (w[15], tc->keyfile_buf32[15]); + w[16] = u8add (w[16], tc->keyfile_buf32[16]); + w[17] = u8add (w[17], tc->keyfile_buf32[17]); + w[18] = u8add (w[18], tc->keyfile_buf32[18]); + w[19] = u8add (w[19], tc->keyfile_buf32[19]); + w[20] = u8add (w[20], tc->keyfile_buf32[20]); + w[21] = u8add (w[21], tc->keyfile_buf32[21]); + w[22] = u8add (w[22], tc->keyfile_buf32[22]); + w[23] = u8add (w[23], tc->keyfile_buf32[23]); + w[24] = u8add (w[24], tc->keyfile_buf32[24]); + w[25] = u8add (w[25], tc->keyfile_buf32[25]); + w[26] = u8add (w[26], tc->keyfile_buf32[26]); + w[27] = u8add (w[27], tc->keyfile_buf32[27]); + w[28] = u8add (w[28], tc->keyfile_buf32[28]); + w[29] = u8add (w[29], tc->keyfile_buf32[29]); + w[30] = u8add (w[30], tc->keyfile_buf32[30]); + w[31] = u8add (w[31], tc->keyfile_buf32[31]); + + return 128; + } + else + { + w[ 0] = u8add (w[ 0], tc->keyfile_buf16[ 0]); + w[ 1] = u8add (w[ 1], tc->keyfile_buf16[ 1]); + w[ 2] = u8add (w[ 2], tc->keyfile_buf16[ 2]); + w[ 3] = u8add (w[ 3], tc->keyfile_buf16[ 3]); + w[ 4] = u8add (w[ 4], tc->keyfile_buf16[ 4]); + w[ 5] = u8add (w[ 5], tc->keyfile_buf16[ 5]); + w[ 6] = u8add (w[ 6], tc->keyfile_buf16[ 6]); + w[ 7] = u8add (w[ 7], tc->keyfile_buf16[ 7]); + w[ 8] = u8add (w[ 8], tc->keyfile_buf16[ 8]); + w[ 9] = u8add (w[ 9], tc->keyfile_buf16[ 9]); + w[10] = u8add (w[10], tc->keyfile_buf16[10]); + w[11] = u8add (w[11], tc->keyfile_buf16[11]); + w[12] = u8add (w[12], tc->keyfile_buf16[12]); + w[13] = u8add (w[13], tc->keyfile_buf16[13]); + w[14] = u8add (w[14], tc->keyfile_buf16[14]); + w[15] = u8add (w[15], tc->keyfile_buf16[15]); + + return 64; + } +} diff --git a/OpenCL/inc_truecrypt_keyfile.h b/OpenCL/inc_truecrypt_keyfile.h index ff0628bba..1530b0920 100644 --- a/OpenCL/inc_truecrypt_keyfile.h +++ b/OpenCL/inc_truecrypt_keyfile.h @@ -7,5 +7,6 @@ #define _INC_TRUECRYPT_KEYFILE_H DECLSPEC u32 u8add (const u32 a, const u32 b); +DECLSPEC u32 hc_apply_keyfile_tc (u32 *w, const int pw_len, const GLOBAL_AS tc_t *tc); #endif // _INC_TRUECRYPT_KEYFILE_H diff --git a/OpenCL/inc_veracrypt_keyfile.cl b/OpenCL/inc_veracrypt_keyfile.cl new file mode 100644 index 000000000..c76d4bf2b --- /dev/null +++ b/OpenCL/inc_veracrypt_keyfile.cl @@ -0,0 +1,99 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "inc_vendor.h" +#include "inc_types.h" +#include "inc_platform.h" +#include "inc_common.h" +#include "inc_veracrypt_keyfile.h" + +DECLSPEC u32 u8add (const u32 a, const u32 b) +{ + const u32 a1 = (a >> 0) & 0xff; + const u32 a2 = (a >> 8) & 0xff; + const u32 a3 = (a >> 16) & 0xff; + const u32 a4 = (a >> 24) & 0xff; + + const u32 b1 = (b >> 0) & 0xff; + const u32 b2 = (b >> 8) & 0xff; + const u32 b3 = (b >> 16) & 0xff; + const u32 b4 = (b >> 24) & 0xff; + + const u32 r1 = (a1 + b1) & 0xff; + const u32 r2 = (a2 + b2) & 0xff; + const u32 r3 = (a3 + b3) & 0xff; + const u32 r4 = (a4 + b4) & 0xff; + + const u32 r = r1 << 0 + | r2 << 8 + | r3 << 16 + | r4 << 24; + + return r; +} + +DECLSPEC u32 hc_apply_keyfile_vc (u32 *w, const int pw_len, const GLOBAL_AS vc_t *vc) +{ + if (vc->keyfile_enabled == 0) return pw_len; + + if (pw_len > 64) + { + w[ 0] = u8add (w[ 0], vc->keyfile_buf32[ 0]); + w[ 1] = u8add (w[ 1], vc->keyfile_buf32[ 1]); + w[ 2] = u8add (w[ 2], vc->keyfile_buf32[ 2]); + w[ 3] = u8add (w[ 3], vc->keyfile_buf32[ 3]); + w[ 4] = u8add (w[ 4], vc->keyfile_buf32[ 4]); + w[ 5] = u8add (w[ 5], vc->keyfile_buf32[ 5]); + w[ 6] = u8add (w[ 6], vc->keyfile_buf32[ 6]); + w[ 7] = u8add (w[ 7], vc->keyfile_buf32[ 7]); + w[ 8] = u8add (w[ 8], vc->keyfile_buf32[ 8]); + w[ 9] = u8add (w[ 9], vc->keyfile_buf32[ 9]); + w[10] = u8add (w[10], vc->keyfile_buf32[10]); + w[11] = u8add (w[11], vc->keyfile_buf32[11]); + w[12] = u8add (w[12], vc->keyfile_buf32[12]); + w[13] = u8add (w[13], vc->keyfile_buf32[13]); + w[14] = u8add (w[14], vc->keyfile_buf32[14]); + w[15] = u8add (w[15], vc->keyfile_buf32[15]); + w[16] = u8add (w[16], vc->keyfile_buf32[16]); + w[17] = u8add (w[17], vc->keyfile_buf32[17]); + w[18] = u8add (w[18], vc->keyfile_buf32[18]); + w[19] = u8add (w[19], vc->keyfile_buf32[19]); + w[20] = u8add (w[20], vc->keyfile_buf32[20]); + w[21] = u8add (w[21], vc->keyfile_buf32[21]); + w[22] = u8add (w[22], vc->keyfile_buf32[22]); + w[23] = u8add (w[23], vc->keyfile_buf32[23]); + w[24] = u8add (w[24], vc->keyfile_buf32[24]); + w[25] = u8add (w[25], vc->keyfile_buf32[25]); + w[26] = u8add (w[26], vc->keyfile_buf32[26]); + w[27] = u8add (w[27], vc->keyfile_buf32[27]); + w[28] = u8add (w[28], vc->keyfile_buf32[28]); + w[29] = u8add (w[29], vc->keyfile_buf32[29]); + w[30] = u8add (w[30], vc->keyfile_buf32[30]); + w[31] = u8add (w[31], vc->keyfile_buf32[31]); + + return 128; + } + else + { + w[ 0] = u8add (w[ 0], vc->keyfile_buf16[ 0]); + w[ 1] = u8add (w[ 1], vc->keyfile_buf16[ 1]); + w[ 2] = u8add (w[ 2], vc->keyfile_buf16[ 2]); + w[ 3] = u8add (w[ 3], vc->keyfile_buf16[ 3]); + w[ 4] = u8add (w[ 4], vc->keyfile_buf16[ 4]); + w[ 5] = u8add (w[ 5], vc->keyfile_buf16[ 5]); + w[ 6] = u8add (w[ 6], vc->keyfile_buf16[ 6]); + w[ 7] = u8add (w[ 7], vc->keyfile_buf16[ 7]); + w[ 8] = u8add (w[ 8], vc->keyfile_buf16[ 8]); + w[ 9] = u8add (w[ 9], vc->keyfile_buf16[ 9]); + w[10] = u8add (w[10], vc->keyfile_buf16[10]); + w[11] = u8add (w[11], vc->keyfile_buf16[11]); + w[12] = u8add (w[12], vc->keyfile_buf16[12]); + w[13] = u8add (w[13], vc->keyfile_buf16[13]); + w[14] = u8add (w[14], vc->keyfile_buf16[14]); + w[15] = u8add (w[15], vc->keyfile_buf16[15]); + + return 64; + } +} diff --git a/OpenCL/inc_veracrypt_keyfile.h b/OpenCL/inc_veracrypt_keyfile.h new file mode 100644 index 000000000..331b36c68 --- /dev/null +++ b/OpenCL/inc_veracrypt_keyfile.h @@ -0,0 +1,12 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _INC_VERACRYPT_KEYFILE_H +#define _INC_VERACRYPT_KEYFILE_H + +DECLSPEC u32 u8add (const u32 a, const u32 b); +DECLSPEC u32 hc_apply_keyfile_vc (u32 *w, const int pw_len, const GLOBAL_AS vc_t *vc); + +#endif // _INC_VERACRYPT_KEYFILE_H diff --git a/OpenCL/m06211-pure.cl b/OpenCL/m06211-pure.cl index e5886a5ae..2fa16348f 100644 --- a/OpenCL/m06211-pure.cl +++ b/OpenCL/m06211-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -108,52 +110,50 @@ KERNEL_FQ void m06211_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -173,6 +173,11 @@ KERNEL_FQ void m06211_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06212-pure.cl b/OpenCL/m06212-pure.cl index 3e4a1b759..f714e733c 100644 --- a/OpenCL/m06212-pure.cl +++ b/OpenCL/m06212-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -108,52 +110,50 @@ KERNEL_FQ void m06212_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -173,6 +173,11 @@ KERNEL_FQ void m06212_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06213-pure.cl b/OpenCL/m06213-pure.cl index 87961685d..09b99d792 100644 --- a/OpenCL/m06213-pure.cl +++ b/OpenCL/m06213-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -108,52 +110,50 @@ KERNEL_FQ void m06213_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -173,6 +173,11 @@ KERNEL_FQ void m06213_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06221-pure.cl b/OpenCL/m06221-pure.cl index 6e0027b2e..8172d9c3a 100644 --- a/OpenCL/m06221-pure.cl +++ b/OpenCL/m06221-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc64_tmp @@ -130,105 +132,50 @@ KERNEL_FQ void m06221_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -254,6 +201,15 @@ KERNEL_FQ void m06221_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06222-pure.cl b/OpenCL/m06222-pure.cl index 7333d397f..690d1ffa7 100644 --- a/OpenCL/m06222-pure.cl +++ b/OpenCL/m06222-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc64_tmp @@ -130,105 +132,50 @@ KERNEL_FQ void m06222_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -254,6 +201,15 @@ KERNEL_FQ void m06222_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06223-pure.cl b/OpenCL/m06223-pure.cl index 77069c25f..7d251da66 100644 --- a/OpenCL/m06223-pure.cl +++ b/OpenCL/m06223-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc64_tmp @@ -130,105 +132,50 @@ KERNEL_FQ void m06223_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -254,6 +201,15 @@ KERNEL_FQ void m06223_init (KERN_ATTR_TMPS_ESALT (tc64_tmp_t, tc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06231-pure.cl b/OpenCL/m06231-pure.cl index a2f917dcc..687343337 100644 --- a/OpenCL/m06231-pure.cl +++ b/OpenCL/m06231-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -210,69 +212,50 @@ KERNEL_FQ void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -314,6 +297,11 @@ KERNEL_FQ void m06231_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06232-pure.cl b/OpenCL/m06232-pure.cl index 7baf3df06..d123edc8a 100644 --- a/OpenCL/m06232-pure.cl +++ b/OpenCL/m06232-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -210,69 +212,50 @@ KERNEL_FQ void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -314,6 +297,11 @@ KERNEL_FQ void m06232_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m06233-pure.cl b/OpenCL/m06233-pure.cl index aec511bb5..73456851e 100644 --- a/OpenCL/m06233-pure.cl +++ b/OpenCL/m06233-pure.cl @@ -21,7 +21,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -30,9 +32,9 @@ typedef struct tc } tc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" +#include "inc_truecrypt_keyfile.cl" #endif typedef struct tc_tmp @@ -210,69 +212,50 @@ KERNEL_FQ void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_tc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -314,6 +297,11 @@ KERNEL_FQ void m06233_init (KERN_ATTR_TMPS_ESALT (tc_tmp_t, tc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl index 0602b1f7d..812a9ecfc 100644 --- a/OpenCL/m13711-pure.cl +++ b/OpenCL/m13711-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -150,52 +152,50 @@ KERNEL_FQ void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -215,6 +215,11 @@ KERNEL_FQ void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl index e8e0dc840..f60004897 100644 --- a/OpenCL/m13712-pure.cl +++ b/OpenCL/m13712-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -201,52 +203,50 @@ KERNEL_FQ void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -266,6 +266,11 @@ KERNEL_FQ void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl index 493fd68f1..4a18a3885 100644 --- a/OpenCL/m13713-pure.cl +++ b/OpenCL/m13713-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -266,52 +268,50 @@ KERNEL_FQ void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); ripemd160_hmac_ctx_t ripemd160_hmac_ctx; - ripemd160_hmac_init_64 (&ripemd160_hmac_ctx, w0, w1, w2, w3); + ripemd160_hmac_init (&ripemd160_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = ripemd160_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = ripemd160_hmac_ctx.ipad.h[1]; @@ -331,6 +331,11 @@ KERNEL_FQ void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { ripemd160_hmac_ctx_t ripemd160_hmac_ctx2 = ripemd160_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j << 24; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 8f02851fc..dd1b8f752 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_tmp @@ -172,105 +174,50 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -296,6 +243,15 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index 27ea184db..80a9fb1b6 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_tmp @@ -223,105 +225,50 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -347,6 +294,15 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index d906d17d7..465c5000d 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_tmp @@ -288,105 +290,50 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; - u32 w4[4]; - u32 w5[4]; - u32 w6[4]; - u32 w7[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; - w4[0] = pws[gid].i[16]; - w4[1] = pws[gid].i[17]; - w4[2] = pws[gid].i[18]; - w4[3] = pws[gid].i[19]; - w5[0] = pws[gid].i[20]; - w5[1] = pws[gid].i[21]; - w5[2] = pws[gid].i[22]; - w5[3] = pws[gid].i[23]; - w6[0] = pws[gid].i[24]; - w6[1] = pws[gid].i[25]; - w6[2] = pws[gid].i[26]; - w6[3] = pws[gid].i[27]; - w7[0] = pws[gid].i[28]; - w7[1] = pws[gid].i[29]; - w7[2] = pws[gid].i[30]; - w7[3] = pws[gid].i[31]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); - w4[0] = hc_swap32_S (w4[0]); - w4[1] = hc_swap32_S (w4[1]); - w4[2] = hc_swap32_S (w4[2]); - w4[3] = hc_swap32_S (w4[3]); - w5[0] = hc_swap32_S (w5[0]); - w5[1] = hc_swap32_S (w5[1]); - w5[2] = hc_swap32_S (w5[2]); - w5[3] = hc_swap32_S (w5[3]); - w6[0] = hc_swap32_S (w6[0]); - w6[1] = hc_swap32_S (w6[1]); - w6[2] = hc_swap32_S (w6[2]); - w6[3] = hc_swap32_S (w6[3]); - w7[0] = hc_swap32_S (w7[0]); - w7[1] = hc_swap32_S (w7[1]); - w7[2] = hc_swap32_S (w7[2]); - w7[3] = hc_swap32_S (w7[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha512_hmac_ctx_t sha512_hmac_ctx; - sha512_hmac_init_128 (&sha512_hmac_ctx, w0, w1, w2, w3, w4, w5, w6, w7); + sha512_hmac_init_swap (&sha512_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha512_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha512_hmac_ctx.ipad.h[1]; @@ -412,6 +359,15 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t)) { sha512_hmac_ctx_t sha512_hmac_ctx2 = sha512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl index 52e4b28e1..53c0aee63 100644 --- a/OpenCL/m13731-pure.cl +++ b/OpenCL/m13731-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -252,69 +254,50 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -356,6 +339,11 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl index faeb8911b..fde64f5cd 100644 --- a/OpenCL/m13732-pure.cl +++ b/OpenCL/m13732-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -303,69 +305,50 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -407,6 +390,11 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl index 9d8e38195..63d5b1a4c 100644 --- a/OpenCL/m13733-pure.cl +++ b/OpenCL/m13733-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -368,69 +370,50 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); whirlpool_hmac_ctx_t whirlpool_hmac_ctx; - whirlpool_hmac_init_64 (&whirlpool_hmac_ctx, w0, w1, w2, w3, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); + whirlpool_hmac_init_swap (&whirlpool_hmac_ctx, w, pw_len, s_MT0, s_MT1, s_MT2, s_MT3, s_MT4, s_MT5, s_MT6, s_MT7); tmps[gid].ipad[ 0] = whirlpool_hmac_ctx.ipad.h[ 0]; tmps[gid].ipad[ 1] = whirlpool_hmac_ctx.ipad.h[ 1]; @@ -472,6 +455,11 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { whirlpool_hmac_ctx_t whirlpool_hmac_ctx2 = whirlpool_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index a609660be..e795fe1e6 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -156,69 +158,50 @@ KERNEL_FQ void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha256_hmac_ctx_t sha256_hmac_ctx; - sha256_hmac_init_64 (&sha256_hmac_ctx, w0, w1, w2, w3); + sha256_hmac_init_swap (&sha256_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; @@ -244,6 +227,15 @@ KERNEL_FQ void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index ff3c0bc95..5ae1b2468 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -207,69 +209,50 @@ KERNEL_FQ void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha256_hmac_ctx_t sha256_hmac_ctx; - sha256_hmac_init_64 (&sha256_hmac_ctx, w0, w1, w2, w3); + sha256_hmac_init_swap (&sha256_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; @@ -295,6 +278,15 @@ KERNEL_FQ void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 65956c669..0d33af281 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc_tmp @@ -272,69 +274,50 @@ KERNEL_FQ void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); sha256_hmac_ctx_t sha256_hmac_ctx; - sha256_hmac_init_64 (&sha256_hmac_ctx, w0, w1, w2, w3); + sha256_hmac_init_swap (&sha256_hmac_ctx, w, pw_len); tmps[gid].ipad[0] = sha256_hmac_ctx.ipad.h[0]; tmps[gid].ipad[1] = sha256_hmac_ctx.ipad.h[1]; @@ -360,6 +343,15 @@ KERNEL_FQ void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t)) { sha256_hmac_ctx_t sha256_hmac_ctx2 = sha256_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + u32 w4[4]; + u32 w5[4]; + u32 w6[4]; + u32 w7[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index 8e66df13b..2c5e24985 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_sbog_tmp @@ -222,69 +224,50 @@ KERNEL_FQ void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); streebog512_hmac_ctx_t streebog512_hmac_ctx; - streebog512_hmac_init_64 (&streebog512_hmac_ctx, w0, w1, w2, w3, s_sbob_sl64); + streebog512_hmac_init_swap (&streebog512_hmac_ctx, w, pw_len, s_sbob_sl64); tmps[gid].ipad_hash[0] = streebog512_hmac_ctx.ipad.h[0]; tmps[gid].ipad_hash[1] = streebog512_hmac_ctx.ipad.h[1]; @@ -328,6 +311,11 @@ KERNEL_FQ void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { streebog512_hmac_ctx_t streebog512_hmac_ctx2 = streebog512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index 14c853ecc..449a2c2b9 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_sbog_tmp @@ -273,69 +275,50 @@ KERNEL_FQ void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); streebog512_hmac_ctx_t streebog512_hmac_ctx; - streebog512_hmac_init_64 (&streebog512_hmac_ctx, w0, w1, w2, w3, s_sbob_sl64); + streebog512_hmac_init_swap (&streebog512_hmac_ctx, w, pw_len, s_sbob_sl64); tmps[gid].ipad_hash[0] = streebog512_hmac_ctx.ipad.h[0]; tmps[gid].ipad_hash[1] = streebog512_hmac_ctx.ipad.h[1]; @@ -379,6 +362,11 @@ KERNEL_FQ void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { streebog512_hmac_ctx_t streebog512_hmac_ctx2 = streebog512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 16aee20ef..7299593f8 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -23,7 +23,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -36,10 +38,10 @@ typedef struct vc } vc_t; #ifdef KERNEL_STATIC -#include "inc_truecrypt_keyfile.cl" #include "inc_truecrypt_crc32.cl" #include "inc_truecrypt_xts.cl" #include "inc_veracrypt_xts.cl" +#include "inc_veracrypt_keyfile.cl" #endif typedef struct vc64_sbog_tmp @@ -338,69 +340,50 @@ KERNEL_FQ void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) * base */ - u32 w0[4]; - u32 w1[4]; - u32 w2[4]; - u32 w3[4]; + u32 w[32]; - w0[0] = pws[gid].i[ 0]; - w0[1] = pws[gid].i[ 1]; - w0[2] = pws[gid].i[ 2]; - w0[3] = pws[gid].i[ 3]; - w1[0] = pws[gid].i[ 4]; - w1[1] = pws[gid].i[ 5]; - w1[2] = pws[gid].i[ 6]; - w1[3] = pws[gid].i[ 7]; - w2[0] = pws[gid].i[ 8]; - w2[1] = pws[gid].i[ 9]; - w2[2] = pws[gid].i[10]; - w2[3] = pws[gid].i[11]; - w3[0] = pws[gid].i[12]; - w3[1] = pws[gid].i[13]; - w3[2] = pws[gid].i[14]; - w3[3] = pws[gid].i[15]; + w[ 0] = pws[gid].i[ 0]; + w[ 1] = pws[gid].i[ 1]; + w[ 2] = pws[gid].i[ 2]; + w[ 3] = pws[gid].i[ 3]; + w[ 4] = pws[gid].i[ 4]; + w[ 5] = pws[gid].i[ 5]; + w[ 6] = pws[gid].i[ 6]; + w[ 7] = pws[gid].i[ 7]; + w[ 8] = pws[gid].i[ 8]; + w[ 9] = pws[gid].i[ 9]; + w[10] = pws[gid].i[10]; + w[11] = pws[gid].i[11]; + w[12] = pws[gid].i[12]; + w[13] = pws[gid].i[13]; + w[14] = pws[gid].i[14]; + w[15] = pws[gid].i[15]; + w[16] = pws[gid].i[16]; + w[17] = pws[gid].i[17]; + w[18] = pws[gid].i[18]; + w[19] = pws[gid].i[19]; + w[20] = pws[gid].i[20]; + w[21] = pws[gid].i[21]; + w[22] = pws[gid].i[22]; + w[23] = pws[gid].i[23]; + w[24] = pws[gid].i[24]; + w[25] = pws[gid].i[25]; + w[26] = pws[gid].i[26]; + w[27] = pws[gid].i[27]; + w[28] = pws[gid].i[28]; + w[29] = pws[gid].i[29]; + w[30] = pws[gid].i[30]; + w[31] = pws[gid].i[31]; - const u32 pw_len = pws[gid].pw_len; + u32 pw_len = pws[gid].pw_len; - hc_execute_keyboard_layout_mapping (w0, w1, w2, w3, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); + hc_execute_keyboard_layout_mapping (w, pw_len, s_keyboard_layout_mapping_buf, keyboard_layout_mapping_cnt); - w0[0] = u8add (w0[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 0]); - w0[1] = u8add (w0[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 1]); - w0[2] = u8add (w0[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 2]); - w0[3] = u8add (w0[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 3]); - w1[0] = u8add (w1[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 4]); - w1[1] = u8add (w1[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 5]); - w1[2] = u8add (w1[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 6]); - w1[3] = u8add (w1[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 7]); - w2[0] = u8add (w2[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 8]); - w2[1] = u8add (w2[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[ 9]); - w2[2] = u8add (w2[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[10]); - w2[3] = u8add (w2[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[11]); - w3[0] = u8add (w3[0], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[12]); - w3[1] = u8add (w3[1], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[13]); - w3[2] = u8add (w3[2], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[14]); - w3[3] = u8add (w3[3], esalt_bufs[DIGESTS_OFFSET].keyfile_buf[15]); - - w0[0] = hc_swap32_S (w0[0]); - w0[1] = hc_swap32_S (w0[1]); - w0[2] = hc_swap32_S (w0[2]); - w0[3] = hc_swap32_S (w0[3]); - w1[0] = hc_swap32_S (w1[0]); - w1[1] = hc_swap32_S (w1[1]); - w1[2] = hc_swap32_S (w1[2]); - w1[3] = hc_swap32_S (w1[3]); - w2[0] = hc_swap32_S (w2[0]); - w2[1] = hc_swap32_S (w2[1]); - w2[2] = hc_swap32_S (w2[2]); - w2[3] = hc_swap32_S (w2[3]); - w3[0] = hc_swap32_S (w3[0]); - w3[1] = hc_swap32_S (w3[1]); - w3[2] = hc_swap32_S (w3[2]); - w3[3] = hc_swap32_S (w3[3]); + pw_len = hc_apply_keyfile_vc (w, pw_len, &esalt_bufs[DIGESTS_OFFSET]); streebog512_hmac_ctx_t streebog512_hmac_ctx; - streebog512_hmac_init_64 (&streebog512_hmac_ctx, w0, w1, w2, w3, s_sbob_sl64); + streebog512_hmac_init_swap (&streebog512_hmac_ctx, w, pw_len, s_sbob_sl64); tmps[gid].ipad_hash[0] = streebog512_hmac_ctx.ipad.h[0]; tmps[gid].ipad_hash[1] = streebog512_hmac_ctx.ipad.h[1]; @@ -444,6 +427,11 @@ KERNEL_FQ void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t)) { streebog512_hmac_ctx_t streebog512_hmac_ctx2 = streebog512_hmac_ctx; + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + w0[0] = j; w0[1] = 0; w0[2] = 0; diff --git a/docs/changes.txt b/docs/changes.txt index 906375f8b..3134003f7 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -13,6 +13,7 @@ - Alias Devices: Show a warning in case the user specifically listed a device to use which in a later step is skipped because it is an alias of another active device - Backend Information: Added new column showing the PCI Address per CUDA/OpenCL device to easier identify broken cards +- VeraCrypt: Increase password length support for non-boot volumes from 64 to 128 ## ## Technical diff --git a/include/cpu_crc32.h b/include/cpu_crc32.h index 700762250..bf0e5da94 100644 --- a/include/cpu_crc32.h +++ b/include/cpu_crc32.h @@ -9,7 +9,7 @@ #include #include -int cpu_crc32 (const char *filename, u8 keytab[64]); +int cpu_crc32 (const char *filename, u8 *keytab, const size_t keytabsz); u32 cpu_crc32_buffer (const u8 *buf, const size_t length); #endif // _CPU_CRC32_H diff --git a/src/Makefile b/src/Makefile index e2ec05c6d..5232e88e0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -360,7 +360,6 @@ CXXFLAGS := EMU_OBJS_ALL := emu_general emu_inc_common emu_inc_platform emu_inc_scalar emu_inc_simd EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized -EMU_OBJS_ALL += emu_inc_truecrypt_crc32 emu_inc_truecrypt_keyfile emu_inc_truecrypt_xts emu_inc_veracrypt_xts EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 emu_inc_ecc_secp256k1 EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish diff --git a/src/cpu_crc32.c b/src/cpu_crc32.c index 8c426b609..840c55901 100644 --- a/src/cpu_crc32.c +++ b/src/cpu_crc32.c @@ -88,7 +88,7 @@ u32 cpu_crc32_buffer (const u8 *buf, const size_t length) return crc ^ 0xffffffff; } -int cpu_crc32 (const char *filename, u8 keytab[64]) +int cpu_crc32 (const char *filename, u8 *keytab, const size_t keytabsz) { u32 crc = ~0U; @@ -110,10 +110,10 @@ int cpu_crc32 (const char *filename, u8 keytab[64]) { crc = crc32tab[(crc ^ buf[fpos]) & 0xff] ^ (crc >> 8); - keytab[kpos++] += (crc >> 24) & 0xff; if (kpos >= 64) kpos = 0; - keytab[kpos++] += (crc >> 16) & 0xff; if (kpos >= 64) kpos = 0; - keytab[kpos++] += (crc >> 8) & 0xff; if (kpos >= 64) kpos = 0; - keytab[kpos++] += (crc >> 0) & 0xff; if (kpos >= 64) kpos = 0; + keytab[kpos++] += (crc >> 24) & 0xff; if (kpos >= keytabsz) kpos = 0; + keytab[kpos++] += (crc >> 16) & 0xff; if (kpos >= keytabsz) kpos = 0; + keytab[kpos++] += (crc >> 8) & 0xff; if (kpos >= keytabsz) kpos = 0; + keytab[kpos++] += (crc >> 0) & 0xff; if (kpos >= keytabsz) kpos = 0; } hcfree (buf); diff --git a/src/emu_inc_truecrypt_crc32.c b/src/emu_inc_truecrypt_crc32.c deleted file mode 100644 index 579de208e..000000000 --- a/src/emu_inc_truecrypt_crc32.c +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "emu_general.h" - -#include "inc_truecrypt_crc32.cl" - diff --git a/src/emu_inc_truecrypt_keyfile.c b/src/emu_inc_truecrypt_keyfile.c deleted file mode 100644 index eee4a0b36..000000000 --- a/src/emu_inc_truecrypt_keyfile.c +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "emu_general.h" - -#include "inc_truecrypt_keyfile.cl" - diff --git a/src/emu_inc_truecrypt_xts.c b/src/emu_inc_truecrypt_xts.c deleted file mode 100644 index 5787898d4..000000000 --- a/src/emu_inc_truecrypt_xts.c +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "emu_general.h" - -#include "inc_truecrypt_xts.cl" - diff --git a/src/emu_inc_veracrypt_xts.c b/src/emu_inc_veracrypt_xts.c deleted file mode 100644 index 1539c8968..000000000 --- a/src/emu_inc_veracrypt_xts.c +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "emu_general.h" - -#include "inc_veracrypt_xts.cl" - diff --git a/src/modules/module_06211.c b/src/modules/module_06211.c index b7526ca19..b7aa35874 100644 --- a/src/modules/module_06211.c +++ b/src/modules/module_06211.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -204,13 +206,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06212.c b/src/modules/module_06212.c index c16985b9d..9ac3487c7 100644 --- a/src/modules/module_06212.c +++ b/src/modules/module_06212.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -204,13 +206,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06213.c b/src/modules/module_06213.c index 6be1409f3..04430ec31 100644 --- a/src/modules/module_06213.c +++ b/src/modules/module_06213.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -202,13 +204,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06221.c b/src/modules/module_06221.c index e318746af..38cb70ed8 100644 --- a/src/modules/module_06221.c +++ b/src/modules/module_06221.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -138,8 +140,6 @@ int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); return parser_status; @@ -189,13 +189,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06222.c b/src/modules/module_06222.c index 5700f4c7b..4873b8fab 100644 --- a/src/modules/module_06222.c +++ b/src/modules/module_06222.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -138,8 +140,6 @@ int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); - - hcfree (tmpdata); return parser_status; @@ -189,13 +189,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06223.c b/src/modules/module_06223.c index 28194b850..8d4261420 100644 --- a/src/modules/module_06223.c +++ b/src/modules/module_06223.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -187,13 +189,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06231.c b/src/modules/module_06231.c index 30cb38dac..c9699c033 100644 --- a/src/modules/module_06231.c +++ b/src/modules/module_06231.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -197,13 +199,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06232.c b/src/modules/module_06232.c index 023ccac41..496b9c575 100644 --- a/src/modules/module_06232.c +++ b/src/modules/module_06232.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -197,13 +199,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06233.c b/src/modules/module_06233.c index b6ef79b8a..e6ba28e2d 100644 --- a/src/modules/module_06233.c +++ b/src/modules/module_06233.c @@ -59,7 +59,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -193,13 +195,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index 1a583dbf2..47da47ffb 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -198,13 +200,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index 5bc0e3a7e..014b5d161 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -198,13 +200,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index 81f057d7b..a84abdd7c 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -60,7 +60,9 @@ typedef struct tc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -198,13 +200,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) tc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + tc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index ebebd9985..ffab1e130 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -145,7 +147,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 64; // VC nowadays support 128, but RipeMD160 for container were removed before update from 64->128 return pw_max; } @@ -214,13 +216,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index 8abc7c3b3..91cf21029 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -145,7 +147,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 64; // VC nowadays support 128, but RipeMD160 for container were removed before update from 64->128 return pw_max; } @@ -214,13 +216,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index 795352d22..ca15c4a01 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -145,7 +147,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 64; // VC nowadays support 128, but RipeMD160 for container were removed before update from 64->128 return pw_max; } @@ -214,13 +216,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index fd7e30599..72162ba85 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -155,7 +157,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -224,13 +226,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index 06c960bf2..d595a69d8 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -155,7 +157,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -224,13 +226,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index a474dc1b1..65ed55545 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -155,7 +157,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -224,13 +226,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 0c697031d..da13dd99f 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -134,7 +136,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -203,13 +205,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index f8214d2b3..1945e3b9a 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -134,7 +136,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -203,13 +205,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index eb612be6d..72443b7d3 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -134,7 +136,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -203,13 +205,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index 8622cb541..7ad01f942 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -216,13 +218,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index b5497ba07..308fa9084 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -216,13 +218,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index 18eaa4869..10f808d9e 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -216,13 +218,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index 9ac5e3a49..7ea17284f 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -164,7 +166,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -233,13 +235,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index 3eec844f3..8dcae3693 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -164,7 +166,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -233,13 +235,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index e21c48529..630969373 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -65,7 +65,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -164,7 +166,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -233,13 +235,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index 3d5cb4684..5193f0a29 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -235,13 +237,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index d8e743fc1..4780398ef 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -235,13 +237,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index 97105bbd4..594b63519 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -66,7 +66,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -235,13 +237,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index 262f963cd..2afe73f00 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -69,7 +69,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -158,7 +160,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -227,13 +229,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index 2d780d551..ab274128d 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -69,7 +69,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -158,7 +160,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -227,13 +229,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index ac67b6e00..157d2ea88 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -69,7 +69,9 @@ typedef struct vc { u32 salt_buf[32]; u32 data_buf[112]; - u32 keyfile_buf[16]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; u32 signature; keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; @@ -158,7 +160,7 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con // this overrides the reductions of PW_MAX in case optimized kernel is selected // IOW, even in optimized kernel mode it support length 64 - const u32 pw_max = 64; + const u32 pw_max = 128; return pw_max; } @@ -227,13 +229,16 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE { if (hc_path_read (keyfile)) { - cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); } keyfile = strtok_r ((char *) NULL, ",", &saveptr); } hcfree (keyfiles); + + vc->keyfile_enabled = 1; } // keyboard layout mapping From 3119525ea331c0c9931b87342237e762004751b7 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 18 Jun 2021 07:57:15 +0200 Subject: [PATCH 43/56] Fixed integer overflow in Recovered/Time status view column caused by division > 0 but < 1 --- docs/changes.txt | 1 + include/status.h | 6 ++-- src/status.c | 73 +++++++++++++++++++++++++++++------------------- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3134003f7..0b524ef66 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -6,6 +6,7 @@ - Fixed 'E' rule in pure kernel mode which was ignoring letters that are in positions that are multiples of 4 - Fixed false negative in hash-mode 15900 (DPAPI masterkey file v2) if password was longer than 64 characters +- Fixed integer overflow in Recovered/Time status view column caused by division > 0 but < 1 ## ## Improvements diff --git a/include/status.h b/include/status.h index 5b0bae311..3c1b00ddc 100644 --- a/include/status.h +++ b/include/status.h @@ -77,9 +77,9 @@ char *status_get_speed_sec_dev (const hashcat_ctx_t *hash int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx); int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx); int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); +double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx); int status_get_salt_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx); int status_get_innerloop_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx); diff --git a/src/status.c b/src/status.c index 93d4404fe..e445474bf 100644 --- a/src/status.c +++ b/src/status.c @@ -1556,7 +1556,7 @@ int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx) for (int i = 0; i < CPT_CACHE; i++) { - const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; if ((timestamp + 60) > now) @@ -1581,7 +1581,7 @@ int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx) for (int i = 0; i < CPT_CACHE; i++) { - const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; if ((timestamp + 3600) > now) @@ -1606,7 +1606,7 @@ int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx) for (int i = 0; i < CPT_CACHE; i++) { - const u32 cracked = cpt_ctx->cpt_buf[i].cracked; + const u32 cracked = cpt_ctx->cpt_buf[i].cracked; const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; if ((timestamp + 86400) > now) @@ -1618,37 +1618,58 @@ int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx) return cpt_cur_day; } -int status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx) +double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx) { const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; const double msec_real = status_get_msec_real (hashcat_ctx); - const double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60); + const double min_real = (msec_real / 1000) / 60; - return (int) cpt_avg_min; + double cpt_avg_min = 0; + + if (min_real > 1) + { + cpt_avg_min = (double) cpt_ctx->cpt_total / min_real; + } + + return cpt_avg_min; } -int status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx) +double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx) { const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; const double msec_real = status_get_msec_real (hashcat_ctx); - const double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600); + const double hour_real = (msec_real / 1000) / (60 * 60); - return (int) cpt_avg_hour; + double cpt_avg_hour = 0; + + if (hour_real > 1) + { + cpt_avg_hour = (double) cpt_ctx->cpt_total / hour_real; + } + + return cpt_avg_hour; } -int status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx) +double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx) { const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx; const double msec_real = status_get_msec_real (hashcat_ctx); - const double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400); + const double day_real = (msec_real / 1000) / (60 * 60 * 24); - return (int) cpt_avg_day; + double cpt_avg_day = 0; + + if (day_real > 1) + { + cpt_avg_day = (double) cpt_ctx->cpt_total / day_real; + } + + return cpt_avg_day; } char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) @@ -1663,13 +1684,13 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) const int cpt_cur_hour = status_get_cpt_cur_hour (hashcat_ctx); const int cpt_cur_day = status_get_cpt_cur_day (hashcat_ctx); - const int cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx); - const int cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx); - const int cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx); + const double cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx); + const double cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx); + const double cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx); - if ((cpt_ctx->cpt_start + 86400) < now) + if ((cpt_ctx->cpt_start + (60 * 60 * 24)) < now) { - hc_asprintf (&cpt, "CUR:%d,%d,%d AVG:%d,%d,%d (Min,Hour,Day)", + hc_asprintf (&cpt, "CUR:%d,%d,%d AVG:%.2f,%.2f,%.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -1677,29 +1698,23 @@ char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx) cpt_avg_hour, cpt_avg_day); } - else if ((cpt_ctx->cpt_start + 3600) < now) + else if ((cpt_ctx->cpt_start + (60 * 60)) < now) { - hc_asprintf (&cpt, "CUR:%d,%d,N/A AVG:%d,%d,%d (Min,Hour,Day)", + hc_asprintf (&cpt, "CUR:%d,%d,N/A AVG:%.2f,%.2f,N/a (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); + cpt_avg_hour); } else if ((cpt_ctx->cpt_start + 60) < now) { - hc_asprintf (&cpt, "CUR:%d,N/A,N/A AVG:%d,%d,%d (Min,Hour,Day)", + hc_asprintf (&cpt, "CUR:%d,N/A,N/A AVG:%.2f,N/A,N/A (Min,Hour,Day)", cpt_cur_min, - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); + cpt_avg_min); } else { - hc_asprintf (&cpt, "CUR:N/A,N/A,N/A AVG:%d,%d,%d (Min,Hour,Day)", - cpt_avg_min, - cpt_avg_hour, - cpt_avg_day); + hc_asprintf (&cpt, "CUR:N/A,N/A,N/A AVG:N/A,N/A,N/A (Min,Hour,Day)"); } return cpt; From 0d79250feab71114112287dd8dbec835f4afcd40 Mon Sep 17 00:00:00 2001 From: Xanadrel <1734198+Xanadrel@users.noreply.github.com> Date: Fri, 18 Jun 2021 13:13:16 +0200 Subject: [PATCH 44/56] Fix memory leak with status (with brain enabled) --- src/hashcat.c | 4 ++-- src/status.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 97ee1c725..86c1ba7d6 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1775,6 +1775,8 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st #ifdef WITH_BRAIN hashcat_status->brain_session = status_get_brain_session (hashcat_ctx); hashcat_status->brain_attack = status_get_brain_attack (hashcat_ctx); + hashcat_status->brain_rx_all = status_get_brain_rx_all (hashcat_ctx); + hashcat_status->brain_tx_all = status_get_brain_tx_all (hashcat_ctx); #endif hashcat_status->status_string = status_get_status_string (hashcat_ctx); hashcat_status->status_number = status_get_status_number (hashcat_ctx); @@ -1827,8 +1829,6 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st device_info->brain_link_send_bytes_dev = status_get_brain_link_send_bytes_dev (hashcat_ctx, device_id); device_info->brain_link_recv_bytes_sec_dev = status_get_brain_link_recv_bytes_sec_dev (hashcat_ctx, device_id); device_info->brain_link_send_bytes_sec_dev = status_get_brain_link_send_bytes_sec_dev (hashcat_ctx, device_id); - hashcat_status->brain_rx_all = status_get_brain_rx_all (hashcat_ctx); - hashcat_status->brain_tx_all = status_get_brain_tx_all (hashcat_ctx); #endif } diff --git a/src/status.c b/src/status.c index e445474bf..e424af3b3 100644 --- a/src/status.c +++ b/src/status.c @@ -2268,6 +2268,10 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca hcfree (hashcat_status->guess_mod); hcfree (hashcat_status->guess_charset); hcfree (hashcat_status->cpt); + #ifdef WITH_BRAIN + hcfree (hashcat_status->brain_rx_all); + hcfree (hashcat_status->brain_tx_all); + #endif hashcat_status->hash_target = NULL; hashcat_status->hash_name = NULL; @@ -2281,6 +2285,10 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca hashcat_status->guess_mod = NULL; hashcat_status->guess_charset = NULL; hashcat_status->cpt = NULL; + #ifdef WITH_BRAIN + hashcat_status->brain_rx_all = NULL; + hashcat_status->brain_tx_all = NULL; + #endif for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { From 05125eb67c9da98e349dabea50f81f24080f6347 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 18 Jun 2021 23:48:39 +0200 Subject: [PATCH 45/56] LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes --- OpenCL/m01500_a3-pure.cl | 14 ++++---------- OpenCL/m03000_a3-pure.cl | 10 ++-------- docs/changes.txt | 1 + 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/OpenCL/m01500_a3-pure.cl b/OpenCL/m01500_a3-pure.cl index d4312dbbb..f7a8ad45c 100644 --- a/OpenCL/m01500_a3-pure.cl +++ b/OpenCL/m01500_a3-pure.cl @@ -2229,9 +2229,7 @@ KERNEL_FQ void m01500_mxx (KERN_ATTR_BITSLICE ()) u32 tmpResult = 0; - #ifdef _unroll #pragma unroll - #endif for (int i = 0; i < 32; i++) { const u32 b0 = -((search[0] >> i) & 1); @@ -2247,12 +2245,12 @@ KERNEL_FQ void m01500_mxx (KERN_ATTR_BITSLICE ()) const u32 r0 = search[0]; const u32 r1 = search[1]; + #ifdef KERNEL_STATIC const u32 r2 = 0; const u32 r3 = 0; - - #ifdef KERNEL_STATIC - #include COMPARE_M #endif + + #include COMPARE_M } } else @@ -2260,9 +2258,7 @@ KERNEL_FQ void m01500_mxx (KERN_ATTR_BITSLICE ()) u32 out0[32]; u32 out1[32]; - #ifdef _unroll #pragma unroll - #endif for (int i = 0; i < 32; i++) { out0[i] = out[ 0 + 31 - i]; @@ -2272,15 +2268,13 @@ KERNEL_FQ void m01500_mxx (KERN_ATTR_BITSLICE ()) transpose32c (out0); transpose32c (out1); - #ifdef _unroll #pragma unroll - #endif for (int slice = 0; slice < 32; slice++) { const u32 r0 = out0[31 - slice]; const u32 r1 = out1[31 - slice]; - const u32 r2 = 0; #ifdef KERNEL_STATIC + const u32 r2 = 0; const u32 r3 = 0; #endif diff --git a/OpenCL/m03000_a3-pure.cl b/OpenCL/m03000_a3-pure.cl index da58c34df..a44b6f065 100644 --- a/OpenCL/m03000_a3-pure.cl +++ b/OpenCL/m03000_a3-pure.cl @@ -2070,9 +2070,7 @@ KERNEL_FQ void m03000_mxx (KERN_ATTR_BITSLICE ()) u32 tmpResult = 0; - #ifdef _unroll #pragma unroll - #endif for (int i = 0; i < 32; i++) { const u32 b0 = -((search[0] >> i) & 1); @@ -2088,8 +2086,8 @@ KERNEL_FQ void m03000_mxx (KERN_ATTR_BITSLICE ()) const u32 r0 = search[0]; const u32 r1 = search[1]; - const u32 r2 = 0; #ifdef KERNEL_STATIC + const u32 r2 = 0; const u32 r3 = 0; #endif @@ -2101,9 +2099,7 @@ KERNEL_FQ void m03000_mxx (KERN_ATTR_BITSLICE ()) u32 out0[32]; u32 out1[32]; - #ifdef _unroll #pragma unroll - #endif for (int i = 0; i < 32; i++) { out0[i] = out[ 0 + 31 - i]; @@ -2113,15 +2109,13 @@ KERNEL_FQ void m03000_mxx (KERN_ATTR_BITSLICE ()) transpose32c (out0); transpose32c (out1); - #ifdef _unroll #pragma unroll - #endif for (int slice = 0; slice < 32; slice++) { const u32 r0 = out0[31 - slice]; const u32 r1 = out1[31 - slice]; - const u32 r2 = 0; #ifdef KERNEL_STATIC + const u32 r2 = 0; const u32 r3 = 0; #endif diff --git a/docs/changes.txt b/docs/changes.txt index 0b524ef66..c99027da2 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -20,6 +20,7 @@ ## Technical ## +- LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes - Tests: Changed tests for VeraCrypt from -a 0 to -a 3, because password extension is not available to all shells * changes v6.2.1 -> v6.2.2 From 5fb6fc50c232202c02e384488f33d234e338af1d Mon Sep 17 00:00:00 2001 From: philsmd <921533+philsmd@users.noreply.github.com> Date: Sat, 19 Jun 2021 11:00:03 +0200 Subject: [PATCH 46/56] -m 24800 = Umbraco HMAC-SHA1 is not salted --- src/modules/module_24800.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module_24800.c b/src/modules/module_24800.c index f7abd0acf..c978cb358 100644 --- a/src/modules/module_24800.c +++ b/src/modules/module_24800.c @@ -23,7 +23,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_NOT_ITERATED; static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE | OPTS_TYPE_PT_UTF16LE; -static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const u32 SALT_TYPE = SALT_TYPE_NONE; static const char *ST_PASS = "hashcat"; static const char *ST_HASH = "8uigXlGMNI7BzwLCJlDbcKR2FP4="; From 09513ed78be9b63710047a88d3ff77f560c09e8b Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 12:32:02 +0200 Subject: [PATCH 47/56] fix starting message --- src/terminal.c | 12 +++++++++++- src/user_options.c | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index 0b6c8a37a..312d04a04 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -32,7 +32,12 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) if (user_options->left == true) return; if (user_options->identify == true) return; - if (user_options->benchmark == true) + if (user_options->usage == true) + { + event_log_info (hashcat_ctx, "%s (%s) starting in help mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, NULL); + } + else if (user_options->benchmark == true) { if (user_options->machine_readable == false) { @@ -79,6 +84,11 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) event_log_info (hashcat_ctx, "%s (%s) starting in autodetect mode...", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); } + else if (user_options->hash_info == true) + { + event_log_info (hashcat_ctx, "%s (%s) starting in hash-info mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, NULL); + } else { event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag); diff --git a/src/user_options.c b/src/user_options.c index 9acef8d3e..09cca2496 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1172,6 +1172,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->hash_info == true) + { + event_log_error (hashcat_ctx, "Use of --hash-info/example is not allowed in benchmark mode."); + + return -1; + } + if (user_options->increment == true) { event_log_error (hashcat_ctx, "Can't change --increment (-i) in benchmark mode."); From fc77e1b975364f5cf3b200b2ee24aea4dec88431 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 15:23:59 +0200 Subject: [PATCH 48/56] update hm_IOKIT_get_fan_speed_current(), get rid of minimum_speed --- src/ext_iokit.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/ext_iokit.c b/src/ext_iokit.c index 05b297ba3..a8a6debce 100644 --- a/src/ext_iokit.c +++ b/src/ext_iokit.c @@ -141,10 +141,10 @@ int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx) memset (&val, 0, sizeof (SMCVal_t)); - int alarm = -1; - if (hm_IOKIT_SMCReadKey (HM_IOKIT_SMC_SENSOR_GRAPHICS_HOT, &val, iokit->conn) == kIOReturnSuccess) { + int alarm = -1; + if (val.dataSize > 0) { if (strcmp(val.dataType, DATATYPE_UINT8) == 0) @@ -230,44 +230,28 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed) UInt32Char_t key; - int i, totalFans = 0; - memset (&val, 0, sizeof (SMCVal_t)); if (hm_IOKIT_SMCReadKey ("FNum", &val, iokit->conn) == kIOReturnSuccess) { - totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10); + int totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10); - for (i = 0; i < totalFans; i++) + for (int i = 0; i < totalFans; i++) { float actual_speed = 0.0f; - float minimum_speed = 0.0f; float maximum_speed = 0.0f; - float rpm = 0.0f; - float pct = 0.0f; memset (&key, 0, sizeof (UInt32Char_t)); sprintf (key, "F%dAc", i); hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &actual_speed); if (actual_speed < 0.f) continue; - memset (&key, 0, sizeof (UInt32Char_t)); - sprintf(key, "F%dMn", i); - hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &minimum_speed); - if (minimum_speed < 0.f) continue; - memset (&key, 0, sizeof (UInt32Char_t)); sprintf (key, "F%dMx", i); hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed); if (maximum_speed < 0.f) continue; - rpm = actual_speed - minimum_speed; - if (rpm < 0.f) rpm = 0.f; - - pct = rpm / (maximum_speed - minimum_speed); - pct *= 100.f; - - *fan_speed = pct; + *fan_speed = (actual_speed / maximum_speed) * 100.f; break; } From 65b41fcb8f3e3782f3fbb6c708749d2070480fa2 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 15:27:13 +0200 Subject: [PATCH 49/56] cleanup docs/changes.txt --- docs/changes.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index ad2a0fbae..074e83110 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -46,7 +46,6 @@ - CUDA Backend: Do not warn about missing CUDA SDK installation if --stdout is used - Folder Management: Add support for XDG Base Directory specification if hashcat was installed using make install - Hardware Monitor: Add support for GPU device utilization readings from sysfs (AMD on Linux) -- Hardware Monitor: Add support for CPU/GPU device temperature and fanspeed using iokit (Apple) - OpenCL Backend: Use CL_DEVICE_BOARD_NAME_AMD instead of CL_DEVICE_NAME for device name in case OpenCL runtime supports this query - Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support From 9b211ada85208b2a8b007b361f3ee7809536d42c Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 19 Jun 2021 17:12:08 +0200 Subject: [PATCH 50/56] Update user_options.c --- src/user_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user_options.c b/src/user_options.c index 09cca2496..fc63e2127 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1174,7 +1174,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) if (user_options->hash_info == true) { - event_log_error (hashcat_ctx, "Use of --hash-info/example is not allowed in benchmark mode."); + event_log_error (hashcat_ctx, "Use of --hash-info is not allowed in benchmark mode."); return -1; } From 3a6481da4e4d90eff6f6a98f8db2cb078f58dfe8 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 20:32:07 +0200 Subject: [PATCH 51/56] show all fans in hwmon output --- include/ext_iokit.h | 3 ++- include/hwmon.h | 3 +++ include/status.h | 3 +++ include/types.h | 3 +++ src/ext_iokit.c | 26 +++++++++++++++++++++----- src/hashcat.c | 3 +++ src/hwmon.c | 45 +++++++++++++++++++-------------------------- src/status.c | 17 +++++++++++++++++ src/terminal.c | 12 ++++++++++++ 9 files changed, 83 insertions(+), 32 deletions(-) diff --git a/include/ext_iokit.h b/include/ext_iokit.h index b01146b57..089c30240 100644 --- a/include/ext_iokit.h +++ b/include/ext_iokit.h @@ -18,6 +18,7 @@ #define KERNEL_INDEX_SMC 2 #define DATATYPE_FPE2 "fpe2" +#define DATATYPE_FLT "flt " #define DATATYPE_UINT8 "ui8 " #define DATATYPE_UINT16 "ui16" #define DATATYPE_UINT32 "ui32" @@ -119,7 +120,7 @@ kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t int hm_IOKIT_SMCGetSensorGraphicHot (void *hashcat_ctx); int hm_IOKIT_SMCGetTemperature (void *hashcat_ctx, char *key, double *temp); bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret); -int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed); +int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf); bool iokit_init (void *hashcat_ctx); bool iokit_close (void *hashcat_ctx); #endif // __APPLE__ diff --git a/include/hwmon.h b/include/hwmon.h index 7976cd9ac..c758c60ba 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -16,6 +16,9 @@ int hm_get_threshold_shutdown_with_devices_idx (hashcat_ctx_t *hashcat_ctx, cons int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); +#if defined(__APPLE__) +int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf); +#endif int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx); diff --git a/include/status.h b/include/status.h index 5b0bae311..adf16ddf4 100644 --- a/include/status.h +++ b/include/status.h @@ -98,6 +98,9 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hash char *status_get_brain_rx_all (const hashcat_ctx_t *hashcat_ctx); char *status_get_brain_tx_all (const hashcat_ctx_t *hashcat_ctx); #endif +#if defined(__APPLE__) +char *status_get_hwmon_fan_dev (const hashcat_ctx_t *hashcat_ctx); +#endif char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx); int status_get_corespeed_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx); int status_get_memoryspeed_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx); diff --git a/include/types.h b/include/types.h index d85efcb43..05ed728a8 100644 --- a/include/types.h +++ b/include/types.h @@ -2251,6 +2251,9 @@ typedef struct device_info double exec_msec_dev; char *speed_sec_dev; char *guess_candidates_dev; + #if defined(__APPLE__) + char *hwmon_fan_dev; + #endif char *hwmon_dev; int corespeed_dev; int memoryspeed_dev; diff --git a/src/ext_iokit.c b/src/ext_iokit.c index a8a6debce..19ec6c3a6 100644 --- a/src/ext_iokit.c +++ b/src/ext_iokit.c @@ -202,6 +202,13 @@ bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret) { if (val.dataSize > 0) { + if (strcmp(val.dataType, DATATYPE_FLT) == 0) + { + *ret = *(float *) val.bytes; + + return true; + } + if (strcmp(val.dataType, DATATYPE_FPE2) == 0) { // convert fpe2 value to RPM @@ -218,10 +225,8 @@ bool hm_IOKIT_SMCGetFanRPM (char *key, io_connect_t conn, float *ret) return false; } -int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed) +int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf) { - *fan_speed = 0; - hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; IOKIT_PTR *iokit = hwmon_ctx->hm_iokit; @@ -236,8 +241,13 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed) { int totalFans = hm_IOKIT_strtoul ((char *)val.bytes, val.dataSize, 10); + if (totalFans <= 0) return -1; + + char tmp_buf[16]; + for (int i = 0; i < totalFans; i++) { + int fan_speed = 0; float actual_speed = 0.0f; float maximum_speed = 0.0f; @@ -251,10 +261,16 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, int *fan_speed) hm_IOKIT_SMCGetFanRPM (key, iokit->conn, &maximum_speed); if (maximum_speed < 0.f) continue; - *fan_speed = (actual_speed / maximum_speed) * 100.f; + fan_speed = (actual_speed / maximum_speed) * 100.f; - break; + memset (tmp_buf, 0, sizeof (tmp_buf)); + snprintf (tmp_buf, sizeof (tmp_buf) - 1, "Fan%d: %d%%, ", i, fan_speed); + strncat (fan_speed_buf, tmp_buf, strlen (tmp_buf)); } + + // remove last two bytes + size_t out_len = strlen (fan_speed_buf); + fan_speed_buf[out_len-2] = '\0'; } return 1; diff --git a/src/hashcat.c b/src/hashcat.c index 97ee1c725..2d1025c91 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1806,6 +1806,9 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); device_info->guess_candidates_dev = status_get_guess_candidates_dev (hashcat_ctx, device_id); + #if defined(__APPLE__) + device_info->hwmon_fan_dev = status_get_hwmon_fan_dev (hashcat_ctx); + #endif device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); device_info->corespeed_dev = status_get_corespeed_dev (hashcat_ctx, device_id); device_info->memoryspeed_dev = status_get_memoryspeed_dev (hashcat_ctx, device_id); diff --git a/src/hwmon.c b/src/hwmon.c index af9c7acfd..a38c74c27 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -418,6 +418,25 @@ int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac return -1; } +#if defined(__APPLE__) +int hm_get_fanspeed_apple (hashcat_ctx_t *hashcat_ctx, char *fan_speed_buf) +{ + hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + + if (hwmon_ctx->enabled == false) return -1; + + if (hwmon_ctx->hm_iokit) + { + if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, fan_speed_buf) == 0) + { + return 1; + } + } + + return -1; +} +#endif + int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int backend_device_idx) { hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; @@ -446,26 +465,7 @@ int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back if (backend_ctx->devices_param[backend_device_idx].is_opencl == true) { - #if defined (__APPLE__) - if (backend_ctx->devices_param[backend_device_idx].opencl_platform_vendor_id == VENDOR_ID_APPLE) - { - if (hwmon_ctx->hm_iokit) - { - int speed = 0; - - if (hm_IOKIT_get_fan_speed_current (hashcat_ctx, &speed) == -1) - { - hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; - - return -1; - } - - return speed; - } - } - #else if ((backend_ctx->devices_param[backend_device_idx].opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; - #endif if (backend_ctx->devices_param[backend_device_idx].opencl_device_vendor_id == VENDOR_ID_AMD) { @@ -1117,13 +1117,6 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hwmon_ctx->hm_iokit = NULL; } - - if (hwmon_ctx->hm_adl) - { - hcfree (hwmon_ctx->hm_iokit); - - hwmon_ctx->hm_iokit = NULL; - } } #endif diff --git a/src/status.c b/src/status.c index 93d4404fe..c3aad4d2c 100644 --- a/src/status.c +++ b/src/status.c @@ -1959,6 +1959,23 @@ char *status_get_brain_link_send_bytes_sec_dev (const hashcat_ctx_t *hashcat_ctx } #endif +#if defined(__APPLE__) +char *status_get_hwmon_fan_dev (const hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + char *fanspeed_str = (char *) hcmalloc (HCBUFSIZ_TINY); + + hc_thread_mutex_lock (status_ctx->mux_hwmon); + + hm_get_fanspeed_apple ((hashcat_ctx_t *) hashcat_ctx, fanspeed_str); + + hc_thread_mutex_unlock (status_ctx->mux_hwmon); + + return fanspeed_str; +} +#endif + char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int backend_devices_idx) { const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; diff --git a/src/terminal.c b/src/terminal.c index 848ef20dc..48ae37757 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1781,6 +1781,10 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (hwmon_ctx->enabled == true) { + #if defined(__APPLE__) + bool first_dev = true; + #endif + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -1791,6 +1795,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->hwmon_dev == NULL) continue; + #if defined(__APPLE__) + if (first_dev && device_info->hwmon_fan_dev) + { + event_log_info (hashcat_ctx, "Hardware.Mon.SMC.: %s", device_info->hwmon_fan_dev); + first_dev = false; + } + #endif + event_log_info (hashcat_ctx, "Hardware.Mon.#%d..: %s", device_id + 1, device_info->hwmon_dev); From 1703d24c1a0d150359e2a6799dbf90ebfdf7a64f Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 20:46:09 +0200 Subject: [PATCH 52/56] hide fan speed from hwmon output if not detected --- docs/credits.txt | 2 +- src/ext_iokit.c | 2 +- src/hwmon.c | 7 ------- src/terminal.c | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/credits.txt b/docs/credits.txt index 9a4a17716..002014c51 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -22,7 +22,7 @@ Gabriele "matrix" Gristina (@gm4tr1x) * Compressed wordlist feature * OpenCL Info feature * Apple macOS port -* Hardware monitor initial code base +* Hardware monitor initial code base and maintenance * Test suite initial code base * Makefile initial code base * Multithreading initial code base diff --git a/src/ext_iokit.c b/src/ext_iokit.c index 19ec6c3a6..12de48069 100644 --- a/src/ext_iokit.c +++ b/src/ext_iokit.c @@ -270,7 +270,7 @@ int hm_IOKIT_get_fan_speed_current (void *hashcat_ctx, char *fan_speed_buf) // remove last two bytes size_t out_len = strlen (fan_speed_buf); - fan_speed_buf[out_len-2] = '\0'; + if (out_len > 2) fan_speed_buf[out_len-2] = '\0'; } return 1; diff --git a/src/hwmon.c b/src/hwmon.c index a38c74c27..093b7b3bd 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1408,13 +1408,6 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hwmon_ctx->hm_iokit = NULL; } - - if (hwmon_ctx->hm_adl) - { - hcfree (hwmon_ctx->hm_iokit); - - hwmon_ctx->hm_iokit = NULL; - } } #endif diff --git a/src/terminal.c b/src/terminal.c index 48ae37757..7fee3f166 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1796,7 +1796,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->hwmon_dev == NULL) continue; #if defined(__APPLE__) - if (first_dev && device_info->hwmon_fan_dev) + if (first_dev && strlen (device_info->hwmon_fan_dev) > 0) { event_log_info (hashcat_ctx, "Hardware.Mon.SMC.: %s", device_info->hwmon_fan_dev); first_dev = false; From dac7fafec9395916ee73b51358126565887ea344 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 19 Jun 2021 21:15:37 +0200 Subject: [PATCH 53/56] remove unused hm_IOKIT_SMCCall() call --- src/ext_iokit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ext_iokit.c b/src/ext_iokit.c index 12de48069..1b1ef35ca 100644 --- a/src/ext_iokit.c +++ b/src/ext_iokit.c @@ -114,8 +114,6 @@ kern_return_t hm_IOKIT_SMCReadKey (UInt32Char_t key, SMCVal_t *val, io_connect_t if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1; - if (hm_IOKIT_SMCCall (KERNEL_INDEX_SMC, &inData, &outData, conn) != kIOReturnSuccess) return 1; - val->dataSize = outData.keyInfo.dataSize; hm_IOKIT_ultostr (val->dataType, outData.keyInfo.dataType); From 13806f11b36bcbdef0cda55188e57fa5f5ef70b5 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 20 Jun 2021 11:14:28 +0200 Subject: [PATCH 54/56] Add missing entry on new macOS hardware monitor --- docs/changes.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index c99027da2..579baeb9d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -8,6 +8,12 @@ - Fixed false negative in hash-mode 15900 (DPAPI masterkey file v2) if password was longer than 64 characters - Fixed integer overflow in Recovered/Time status view column caused by division > 0 but < 1 +## +## Features +## + +- Added temperature watchdog and fanspeed readings for CPU and GPU on macOS using iokit + ## ## Improvements ## From 2c48bba62d795ce8db7c1c253f4334ecbe1e61d6 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 20 Jun 2021 12:40:55 +0200 Subject: [PATCH 55/56] Autodetect: Limit the number of errors per hash-mode try to 100 to avoid long startup time --- docs/changes.txt | 1 + src/hashcat.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 579baeb9d..6216738a3 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -26,6 +26,7 @@ ## Technical ## +- Autodetect: Limit the number of errors per hash-mode try to 100 to avoid long startup time - LM: Workaround JiT compiler bug in -m 3000 on NV leading to false negatives with large amount of hashes - Tests: Changed tests for VeraCrypt from -a 0 to -a 3, because password extension is not available to all shells diff --git a/src/hashcat.c b/src/hashcat.c index 8328f6c91..d403b4b2d 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1271,6 +1271,8 @@ bool autodetect_hashmode_test (hashcat_ctx_t *hashcat_ctx) { HCFILE fp; + int error_count = 0; + if (hc_fopen (&fp, hashfile, "rb") == false) return false; char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); @@ -1301,6 +1303,17 @@ bool autodetect_hashmode_test (hashcat_ctx_t *hashcat_ctx) break; } + + // abort this list after 100 errors + + if (error_count == 100) + { + break; + } + else + { + error_count++; + } } hcfree (line_buf); From 5a5ec0c5db89fc83edf5992d44d9ccdf074ca619 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Mon, 21 Jun 2021 13:40:46 +0200 Subject: [PATCH 56/56] Added hash-mode: VeraCrypt PBKDF2-HMAC-Streebog-512 + boot-mode --- docs/changes.txt | 8 + src/modules/module_13781.c | 378 +++++++++++++++++++++++++++++++++++++ src/modules/module_13782.c | 378 +++++++++++++++++++++++++++++++++++++ src/modules/module_13783.c | 378 +++++++++++++++++++++++++++++++++++++ tools/test.sh | 2 +- 5 files changed, 1143 insertions(+), 1 deletion(-) create mode 100644 src/modules/module_13781.c create mode 100644 src/modules/module_13782.c create mode 100644 src/modules/module_13783.c diff --git a/docs/changes.txt b/docs/changes.txt index 6216738a3..22de852fd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,5 +1,13 @@ * changes v6.2.2 -> v6.2.x +## +## Algorithms +## + +- Added hash-mode: VeraCrypt PBKDF2-HMAC-Streebog-512 + XTS 512 bit + boot-mode +- Added hash-mode: VeraCrypt PBKDF2-HMAC-Streebog-512 + XTS 1024 bit + boot-mode +- Added hash-mode: VeraCrypt PBKDF2-HMAC-Streebog-512 + XTS 1536 bit + boot-mode + ## ## Bugs ## diff --git a/src/modules/module_13781.c b/src/modules/module_13781.c new file mode 100644 index 000000000..aaa4ad96f --- /dev/null +++ b/src/modules/module_13781.c @@ -0,0 +1,378 @@ +/** + * 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 "cpu_crc32.h" +#include "keyboard_layout.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_FDE; +static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 512 bit + boot-mode"; +static const u64 KERN_TYPE = 13771; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "2bfe4a72e13388a9ce074bbe0711a48d62f123df85b09e0350771edc4a0e4f397038a49b900275c9158145a96b52f95e92f927b3f963c7eadb71a07518d643231041c457d2794d0aa505f794153b52b24441271185d386833fbabf0e880c51b544f583d0db2ab6a926ddd3cdd0b68a61d7f5fe3f0ac6aa06ca676a868f373d35073605cf9d521ff55862b5005213a881a7b9025afc3409fa34dc86496620835df072fecd5b501f15e08113835c510d9f0bfd09d2ef1ac0e7bd01f0523d74a54fe984eb497cb960cce5bb154e024dc0c6c61a61e20a45a8f8ef319c63ca9646fbe00930302a5910891a1bc84bd936c926ca535b3b40c9e0ab255363b24a28bb8216d3d32244a725774e6ebbd73d6d3f2a2adcbc28d5341679cbb747efd56db1a09ce80b24640583ffc6f7ca5bd60d59114afcc78601184ba8feadb8d472f86c32bebf70e8158aa56f9db3b3200ef432aa7b370aa4ba408ef11b70d6806f1a21aaa3b629fa06f71dac0ae3e0ce95c7e5b550fc8c46017e151cbbcdf64b3b62b1b846a08925a217227286acfdad35b28407d589bec9578c2a4e9a4320f4a78e1e590fdf53c0a20fe0a1bb6c7d693abcd0e991c449e569477980d4b8972d21e4abc917d897e48ca427c954c3a3e0c8465ef40de51ffc9188047c043224c4a18638f1d91cd88c36623a1d880f18fd0d6ca0b3bbfa7d5d795acfb63576e2c2d83772e8"; + +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 vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + int pim_check; // marker for _extended kernel + +} vc64_sbog_tmp_t; + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +static const int ROUNDS_VERACRYPT_200000 = 200000; +static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // AMD Radeon Pro W5700X Compute Engine; 1.2 (Apr 22 2021 21:54:44); 11.3.1; 20E241 + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const vc_t *vc = (const vc_t *) hashes->esalts_buf; + + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; + + if (vc64_sbog_tmp->pim == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, vc64_sbog_tmp->pim); + } +} + +bool module_potfile_disable (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 bool potfile_disable = true; + + return potfile_disable; +} + +bool module_outfile_check_disable (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 bool outfile_check_disable = true; + + return outfile_check_disable; +} + +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 (vc_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 (vc64_sbog_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 64 + + const u32 pw_max = 64; + + return pw_max; +} + +int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) +{ + const size_t st_hash_len = strlen (hashconfig->st_hash); + + char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + + for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) + { + const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); + + tmpdata[i] = c; + } + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); + + hcfree (tmpdata); + + return parser_status; +} + +int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, hashes_t *hashes) +{ + // note: if module_hash_binary_parse exists, then module_hash_decode is not called + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO); + + #define VC_HEADER_SIZE 512 + + char *in = (char *) hcmalloc (VC_HEADER_SIZE); + + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp); + + hc_fclose (&fp); + + if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); + + hash_t *hashes_buf = hashes->hashes_buf; + + hash_t *hash = &hashes_buf[0]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, in, VC_HEADER_SIZE); + + if (parser_status != PARSER_OK) return 0; + + hcfree (in); + + // keyfiles + + vc_t *vc = (vc_t *) hash->esalt; + + if (user_options->veracrypt_keyfiles) + { + char *keyfiles = hcstrdup (user_options->veracrypt_keyfiles); + + char *saveptr = NULL; + + char *keyfile = strtok_r (keyfiles, ",", &saveptr); + + while (keyfile) + { + if (hc_path_read (keyfile)) + { + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); + } + + keyfile = strtok_r ((char *) NULL, ",", &saveptr); + } + + hcfree (keyfiles); + + vc->keyfile_enabled = 1; + } + + // keyboard layout mapping + + if (user_options->keyboard_layout_mapping) + { + if (hc_path_read (user_options->keyboard_layout_mapping)) + { + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); + } + } + + // veracrypt PIM + + salt_t *salt = hash->salt; + + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) + { + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + + salt->salt_iter = vc->pim_stop * 2048; + salt->salt_iter--; + } + + return 1; +} + +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; + + vc_t *vc = (vc_t *) esalt_buf; + + const float entropy = get_entropy ((const u8 *) line_buf, line_len); + + if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); + + memcpy (vc->salt_buf, line_buf, 64); + + memcpy (vc->data_buf, line_buf + 64, 512 - 64); + + salt->salt_buf[0] = vc->salt_buf[0]; + + salt->salt_len = 4; + + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; + + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; + + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; + + return (PARSER_OK); +} + +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_build_plain_postprocess; + module_ctx->module_deep_comp_kernel = 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_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = module_hash_binary_parse; + 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_DEFAULT; + module_ctx->module_hash_init_selftest = module_hash_init_selftest; + 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_outfile_check_disable; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = module_potfile_disable; + 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_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_13782.c b/src/modules/module_13782.c new file mode 100644 index 000000000..550b64ed0 --- /dev/null +++ b/src/modules/module_13782.c @@ -0,0 +1,378 @@ +/** + * 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 "cpu_crc32.h" +#include "keyboard_layout.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_FDE; +static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1024 bit + boot-mode"; +static const u64 KERN_TYPE = 13772; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "af7a64c7c81f608527552532cc7049b0d369e2ce20202d7a41ffb94300cbc9c7ce2130247f49ace4c1512fc3d1b4289ca965e8eb065b35faee5b8479a4e43c4a269f4ee7f6d20f22fe61b2570d46df07b4307f44ba6926f3b44524f0a47be2a0d677d225e2c50ff618b2e5078a19f0613a856bb3145d765cc4c1726aef27b5f03648dcf421b040e7b4fde3193ad9f8a0ae6d91c079610f826e3d556776753d8ca11320632c16a2e49a4eec6e8371681b39be2d7bb826d81dea19eb1dda2e6c71c520a2ad9128b3209a7caf10c196a16ac6f4267ffea8e7be7ddb856976438e0e997773dab75e3dfe0c047f82e4ed0b6e107261b891c4b161fa3c29017428afaaabee5c2dc727fa23b4195265716d92d06e7b828535a77521113077e6f219d7ca721eb5dab66524a530ca3ceba52e3703ec3f435ad1dfee092b090174f4acd1546107db5b403a0ba4fa90c0b4ec19af92a54ebedfd28783dcd83c78499bd33baf3ed10af229ff29634110e2970b6c04232dc95120a365947688abe011f0c8de0e651d9bd112ce0bdf80c4e37c77b962d92f1418272e7484df5217f5f2f3ba1e9b965773ed2727c5d03938516dd789236479b5ff340335c92260b1ad82a313ffa568f912fac799f93b857aaff7b4d76cb525f120a0a9efc376d39c8e27866eff689be01f5adf693ae63ad4b2a77ca96ea985ab7931457f4d8d1afaeb7e423dd752"; + +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 vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + int pim_check; // marker for _extended kernel + +} vc64_sbog_tmp_t; + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +static const int ROUNDS_VERACRYPT_200000 = 200000; +static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // AMD Radeon Pro W5700X Compute Engine; 1.2 (Apr 22 2021 21:54:44); 11.3.1; 20E241 + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const vc_t *vc = (const vc_t *) hashes->esalts_buf; + + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; + + if (vc64_sbog_tmp->pim == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, vc64_sbog_tmp->pim); + } +} + +bool module_potfile_disable (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 bool potfile_disable = true; + + return potfile_disable; +} + +bool module_outfile_check_disable (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 bool outfile_check_disable = true; + + return outfile_check_disable; +} + +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 (vc_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 (vc64_sbog_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 64 + + const u32 pw_max = 64; + + return pw_max; +} + +int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) +{ + const size_t st_hash_len = strlen (hashconfig->st_hash); + + char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + + for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) + { + const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); + + tmpdata[i] = c; + } + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); + + hcfree (tmpdata); + + return parser_status; +} + +int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, hashes_t *hashes) +{ + // note: if module_hash_binary_parse exists, then module_hash_decode is not called + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO); + + #define VC_HEADER_SIZE 512 + + char *in = (char *) hcmalloc (VC_HEADER_SIZE); + + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp); + + hc_fclose (&fp); + + if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); + + hash_t *hashes_buf = hashes->hashes_buf; + + hash_t *hash = &hashes_buf[0]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, in, VC_HEADER_SIZE); + + if (parser_status != PARSER_OK) return 0; + + hcfree (in); + + // keyfiles + + vc_t *vc = (vc_t *) hash->esalt; + + if (user_options->veracrypt_keyfiles) + { + char *keyfiles = hcstrdup (user_options->veracrypt_keyfiles); + + char *saveptr = NULL; + + char *keyfile = strtok_r (keyfiles, ",", &saveptr); + + while (keyfile) + { + if (hc_path_read (keyfile)) + { + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); + } + + keyfile = strtok_r ((char *) NULL, ",", &saveptr); + } + + hcfree (keyfiles); + + vc->keyfile_enabled = 1; + } + + // keyboard layout mapping + + if (user_options->keyboard_layout_mapping) + { + if (hc_path_read (user_options->keyboard_layout_mapping)) + { + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); + } + } + + // veracrypt PIM + + salt_t *salt = hash->salt; + + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) + { + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + + salt->salt_iter = vc->pim_stop * 2048; + salt->salt_iter--; + } + + return 1; +} + +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; + + vc_t *vc = (vc_t *) esalt_buf; + + const float entropy = get_entropy ((const u8 *) line_buf, line_len); + + if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); + + memcpy (vc->salt_buf, line_buf, 64); + + memcpy (vc->data_buf, line_buf + 64, 512 - 64); + + salt->salt_buf[0] = vc->salt_buf[0]; + + salt->salt_len = 4; + + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; + + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; + + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; + + return (PARSER_OK); +} + +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_build_plain_postprocess; + module_ctx->module_deep_comp_kernel = 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_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = module_hash_binary_parse; + 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_DEFAULT; + module_ctx->module_hash_init_selftest = module_hash_init_selftest; + 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_outfile_check_disable; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = module_potfile_disable; + 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_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/modules/module_13783.c b/src/modules/module_13783.c new file mode 100644 index 000000000..155aa0cd0 --- /dev/null +++ b/src/modules/module_13783.c @@ -0,0 +1,378 @@ +/** + * 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 "cpu_crc32.h" +#include "keyboard_layout.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_FDE; +static const char *HASH_NAME = "VeraCrypt Streebog-512 + XTS 1536 bit + boot-mode"; +static const u64 KERN_TYPE = 13773; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_USES_BITS_64 + | OPTI_TYPE_SLOW_HASH_SIMD_LOOP; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_LOOP_EXTENDED + | OPTS_TYPE_KEYBOARD_MAPPING + | OPTS_TYPE_COPY_TMPS; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "0c9d7444e9e64a833e857163787b2f6349224bdb4bbf788ce25156c870514226674725be3eebc3f2a2c2ee8adbf8bb3ec1405a333e8e091cec0c5aa77fa9b65048ca01d954912bf3a3b1c38c00297a33ea0e014156ce08d9526150c085e5e2776a1faeb272c6e9539f466f4f93ffe6497c77d3aed54ffcdf1a3e6171cffac7b2ad96bd9e7cc553058894058def68beea05891b0ce734b6a166b8a5f24b4052fc7014b424bd6c33c9d710fb409cdf1a6c7567c1ba6a3010b03f9bda8aa2ef6733542d198a316da0c83106a6c31043f11ac191169db3db994493168ea996737355ccff84f27f6792b3dc87025d3594edb9e759ba3885980df17bc8c751ce3aba0df67aa7997906348729e81c4893cc654dc6b1da3ff7c588a327f45b8acff976d0593cc607dad48a25468d7c3ebc6dd49aa32fc526dd513852cdec4b36f3683b4998800afa25bb968c242d4c66b9b0c77b20d7bd40ffb403e9e087990d59c94ee7d36e9ebfa35a310bab963c253596e6bc89f67d5307823851c526ac789d0628a3eb81f2cdfd7d7612d8be1dade1b17f30aa2bb5d02eb8534caca0c334a269085939a5041c4ad112d325b1bfe3e9851bfdcad80bbc05ecbddc3f2ac09e2ad7182daf6ca5ccc510a100514f5d2dce1ff5046e0c8e7edf0bdc27f8fcdf4e9b3bce786c24bfa28dacee65ee8c913fc18eee5df61b8a43224f3a9c4e1b5de7b600d9e0"; + +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 vc64_sbog_tmp +{ + u64 ipad_raw[8]; + u64 opad_raw[8]; + + u64 ipad_hash[8]; + u64 opad_hash[8]; + + u64 dgst[32]; + u64 out[32]; + + u64 pim_key[32]; + int pim; // marker for cracked + int pim_check; // marker for _extended kernel + +} vc64_sbog_tmp_t; + +typedef struct vc +{ + u32 salt_buf[32]; + u32 data_buf[112]; + u32 keyfile_buf16[16]; + u32 keyfile_buf32[32]; + u32 keyfile_enabled; + u32 signature; + + keyboard_layout_mapping_t keyboard_layout_mapping_buf[256]; + int keyboard_layout_mapping_cnt; + + int pim_multi; // 2048 for boot (not SHA-512 or Whirlpool), 1000 for others + int pim_start; + int pim_stop; + +} vc_t; + +static const int ROUNDS_VERACRYPT_200000 = 200000; +static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + // AMD Radeon Pro W5700X Compute Engine; 1.2 (Apr 22 2021 21:54:44); 11.3.1; 20E241 + if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) + { + return true; + } + } + + return false; +} + +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const vc_t *vc = (const vc_t *) hashes->esalts_buf; + + u32 tmp_buf[64] = { 0 }; + + memcpy (tmp_buf, src_buf, src_len); + + execute_keyboard_layout_mapping (tmp_buf, src_len, vc->keyboard_layout_mapping_buf, vc->keyboard_layout_mapping_cnt); + + const vc64_sbog_tmp_t *vc64_sbog_tmp = (const vc64_sbog_tmp_t *) tmps; + + if (vc64_sbog_tmp->pim == 0) + { + return snprintf ((char *) dst_buf, dst_sz, "%s", (char *) tmp_buf); + } + else + { + return snprintf ((char *) dst_buf, dst_sz, "%s (PIM=%d)", (char *) tmp_buf, vc64_sbog_tmp->pim); + } +} + +bool module_potfile_disable (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 bool potfile_disable = true; + + return potfile_disable; +} + +bool module_outfile_check_disable (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 bool outfile_check_disable = true; + + return outfile_check_disable; +} + +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 (vc_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 (vc64_sbog_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 64 + + const u32 pw_max = 64; + + return pw_max; +} + +int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash) +{ + const size_t st_hash_len = strlen (hashconfig->st_hash); + + char *tmpdata = (char *) hcmalloc (st_hash_len / 2); + + for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2) + { + const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j); + + tmpdata[i] = c; + } + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, tmpdata, st_hash_len / 2); + + hcfree (tmpdata); + + return parser_status; +} + +int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, hashes_t *hashes) +{ + // note: if module_hash_binary_parse exists, then module_hash_decode is not called + + HCFILE fp; + + if (hc_fopen (&fp, hashes->hashfile, "rb") == false) return (PARSER_HAVE_ERRNO); + + #define VC_HEADER_SIZE 512 + + char *in = (char *) hcmalloc (VC_HEADER_SIZE); + + const size_t n = hc_fread (in, 1, VC_HEADER_SIZE, &fp); + + hc_fclose (&fp); + + if (n != VC_HEADER_SIZE) return (PARSER_VC_FILE_SIZE); + + hash_t *hashes_buf = hashes->hashes_buf; + + hash_t *hash = &hashes_buf[0]; + + const int parser_status = module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash->hook_salt, hash->hash_info, in, VC_HEADER_SIZE); + + if (parser_status != PARSER_OK) return 0; + + hcfree (in); + + // keyfiles + + vc_t *vc = (vc_t *) hash->esalt; + + if (user_options->veracrypt_keyfiles) + { + char *keyfiles = hcstrdup (user_options->veracrypt_keyfiles); + + char *saveptr = NULL; + + char *keyfile = strtok_r (keyfiles, ",", &saveptr); + + while (keyfile) + { + if (hc_path_read (keyfile)) + { + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf16, 64); + cpu_crc32 (keyfile, (u8 *) vc->keyfile_buf32, 128); + } + + keyfile = strtok_r ((char *) NULL, ",", &saveptr); + } + + hcfree (keyfiles); + + vc->keyfile_enabled = 1; + } + + // keyboard layout mapping + + if (user_options->keyboard_layout_mapping) + { + if (hc_path_read (user_options->keyboard_layout_mapping)) + { + initialize_keyboard_layout_mapping (user_options->keyboard_layout_mapping, vc->keyboard_layout_mapping_buf, &vc->keyboard_layout_mapping_cnt); + } + } + + // veracrypt PIM + + salt_t *salt = hash->salt; + + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) + { + vc->pim_start = user_options->veracrypt_pim_start; + vc->pim_stop = user_options->veracrypt_pim_stop; + + salt->salt_iter = vc->pim_stop * 2048; + salt->salt_iter--; + } + + return 1; +} + +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; + + vc_t *vc = (vc_t *) esalt_buf; + + const float entropy = get_entropy ((const u8 *) line_buf, line_len); + + if (entropy < MIN_SUFFICIENT_ENTROPY_FILE) return (PARSER_INSUFFICIENT_ENTROPY); + + memcpy (vc->salt_buf, line_buf, 64); + + memcpy (vc->data_buf, line_buf + 64, 512 - 64); + + salt->salt_buf[0] = vc->salt_buf[0]; + + salt->salt_len = 4; + + salt->salt_iter = ROUNDS_VERACRYPT_200000; + salt->salt_iter--; + + vc->pim_multi = 2048; + vc->pim_start = 0; + vc->pim_stop = 0; + + vc->signature = 0x41524556; // "VERA" + + digest[0] = vc->data_buf[0]; + + return (PARSER_OK); +} + +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_build_plain_postprocess; + module_ctx->module_deep_comp_kernel = 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_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = module_hash_binary_parse; + 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_DEFAULT; + module_ctx->module_hash_init_selftest = module_hash_init_selftest; + 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_outfile_check_disable; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = module_potfile_disable; + 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_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/tools/test.sh b/tools/test.sh index 79b56a517..cb031dbf2 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -13,7 +13,7 @@ TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" TC_MODES="6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243" # List of VeraCrypt modes which have test containers -VC_MODES="13711 13712 13713 13721 13722 13723 13731 13732 13733 13741 13742 13743 13751 13752 13753 13761 13762 13763 13771 13772 13773" +VC_MODES="13711 13712 13713 13721 13722 13723 13731 13732 13733 13741 13742 13743 13751 13752 13753 13761 13762 13763 13771 13772 13773 13781 13782 13783" # List of modes which either are OPTS_TYPE_PT_NEVERCRACK or produce collisions NEVER_CRACK="9720 9820 14900 18100"