From fddfd835d24f1dc0fc578309611320754d4d10ff Mon Sep 17 00:00:00 2001 From: unix-ninja Date: Fri, 19 Oct 2018 15:35:52 -0400 Subject: [PATCH] Support 64 bit timestamps properly --- OpenCL/m18100_a0-pure.cl | 4 ++-- OpenCL/m18100_a1-pure.cl | 4 ++-- OpenCL/m18100_a3-pure.cl | 4 ++-- src/interface.c | 11 +++++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/OpenCL/m18100_a0-pure.cl b/OpenCL/m18100_a0-pure.cl index 420c6f9c4..bb0894e19 100644 --- a/OpenCL/m18100_a0-pure.cl +++ b/OpenCL/m18100_a0-pure.cl @@ -32,7 +32,7 @@ __kernel void m18100_mxx (__global pw_t *pws, __constant const kernel_rule_t *ru COPY_PW (pws[gid]); - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32 s[64] = { 0 }; @@ -125,7 +125,7 @@ __kernel void m18100_sxx (__global pw_t *pws, __constant const kernel_rule_t *ru COPY_PW (pws[gid]); - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32 s[64] = { 0 }; diff --git a/OpenCL/m18100_a1-pure.cl b/OpenCL/m18100_a1-pure.cl index b58389975..815eec778 100644 --- a/OpenCL/m18100_a1-pure.cl +++ b/OpenCL/m18100_a1-pure.cl @@ -37,7 +37,7 @@ __kernel void m18100_mxx (__global pw_t *pws, __global const kernel_rule_t *rule w[idx] = swap32_S (pws[gid].i[idx]); } - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32 s[64] = { 0 }; @@ -155,7 +155,7 @@ __kernel void m18100_sxx (__global pw_t *pws, __global const kernel_rule_t *rule w[idx] = swap32_S (pws[gid].i[idx]); } - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32 s[64] = { 0 }; diff --git a/OpenCL/m18100_a3-pure.cl b/OpenCL/m18100_a3-pure.cl index 15e32de93..a71516aa8 100644 --- a/OpenCL/m18100_a3-pure.cl +++ b/OpenCL/m18100_a3-pure.cl @@ -37,7 +37,7 @@ __kernel void m18100_mxx (__global pw_t *pws, __global const kernel_rule_t *rule w[idx] = pws[gid].i[idx]; } - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32x s[64] = { 0 }; @@ -141,7 +141,7 @@ __kernel void m18100_sxx (__global pw_t *pws, __global const kernel_rule_t *rule w[idx] = pws[gid].i[idx]; } - const u32 salt_len = salt_bufs[salt_pos].salt_len; + const u32 salt_len = 8; u32x s[64] = { 0 }; diff --git a/src/interface.c b/src/interface.c index 83bfb912b..5e6c97742 100644 --- a/src/interface.c +++ b/src/interface.c @@ -5201,6 +5201,10 @@ int totp_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE // convert ascii timestamp to ulong timestamp u64 timestamp = hc_strtoull ((const char *) salt_pos, NULL, 10); + // store the original salt value. Step division will destroy granularity for output + salt->salt_buf[3] = ((u32) (timestamp >> 0)); + salt->salt_buf[2] = ((u32) (timestamp >> 32)); + // divide our timestamp by our step. We will use the RFC 6238 default of 30 for now timestamp /= 30; @@ -5208,8 +5212,8 @@ int totp_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE salt->salt_buf[1] = byte_swap_32 ((u32) (timestamp >> 0)); salt->salt_buf[0] = byte_swap_32 ((u32) (timestamp >> 32)); - // our salt will always be 8 bytes - salt->salt_len = 8; + // our salt will always be 8 bytes, but we are going to cheat and store it twice, so... + salt->salt_len = 16; return (PARSER_OK); } @@ -22331,8 +22335,7 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le // we also need to multiply salt by our step to see the floor of our original timestamp range. // again, we will use the default RFC 6238 step of 30. - u64 tmp_salt_buf = (((u64) byte_swap_32 (salt.salt_buf[0])) << 32) | ((u64) byte_swap_32 (salt.salt_buf[1])); - tmp_salt_buf *= 30; + u64 tmp_salt_buf = (((u64) (salt.salt_buf[2])) << 32) | ((u64) (salt.salt_buf[3])); snprintf (out_buf, out_len - 1, "%06d:%llu", digest_buf[1], tmp_salt_buf); }