From d0dc41f98daba2b4a5da351c30c41bd0a7dcf3b2 Mon Sep 17 00:00:00 2001 From: Dylan Evans <62859381+fin3ss3g0d@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:43:00 -0400 Subject: [PATCH] PR comments polish 1 --- .gitignore | 1 - OpenCL/m12150-pure.cl | 30 +++++++----------------------- docs/credits.txt | 3 +++ src/modules/module_12150.c | 36 ++++++------------------------------ 4 files changed, 16 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 5d6b271d0..d8ff600bb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,3 @@ obj/*.o obj/*.a include/CL tools/luks_tests -.vscode/ diff --git a/OpenCL/m12150-pure.cl b/OpenCL/m12150-pure.cl index 0b8c0bd62..5b837c13d 100644 --- a/OpenCL/m12150-pure.cl +++ b/OpenCL/m12150-pure.cl @@ -1,5 +1,7 @@ -// m12150-pure.cl -//#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ #define NEW_SIMD_CODE @@ -39,28 +41,16 @@ KERNEL_FQ void m12150_init (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sh sha512_init (&ctx); - /*printf("Salt length: %d\n", salt_bufs[SALT_POS_HOST].salt_len); - printf("Iterations: %d\n", esalt_bufs[DIGESTS_OFFSET_HOST].iterations); - printf("Password: %s length: %d\n", pws[gid].i, pws[gid].pw_len); - printf("Salt: "); - for (int i = 0; i < 4; i++) { - printf("%08x", esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf[i]); - } - printf("\n");*/ - sha512_update_global_swap (&ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len); sha512_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len); sha512_final (&ctx); - //printf("Initial hash: "); for (int i = 0; i < 8; i++) { tmps[gid].dgst[i] = ctx.h[i]; tmps[gid].out[i] = ctx.h[i]; - //printf("%016llx", ctx.h[i]); } - //printf("\n"); } KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha512_t)) { @@ -92,9 +82,9 @@ KERNEL_FQ void m12150_loop(KERN_ATTR_TMPS_ESALT(shiro1_sha512_tmp_t, shiro1_sha5 digest_u32[15] = l32_from_64_S(tmps[gid].dgst[7]); for (u32 i = 0; i < LOOP_CNT; i++) { - sha512_init(&sha512_ctx); - sha512_update_global(&sha512_ctx, digest_u32, SHA512_DIGEST_LENGTH); - sha512_final(&sha512_ctx); + sha512_init (&sha512_ctx); + sha512_update (&sha512_ctx, digest_u32, SHA512_DIGEST_LENGTH); + sha512_final (&sha512_ctx); for (int j = 0; j < 8; j++) { tmps[gid].dgst[j] = sha512_ctx.h[j]; @@ -131,12 +121,6 @@ KERNEL_FQ void m12150_comp (KERN_ATTR_TMPS_ESALT (shiro1_sha512_tmp_t, shiro1_sh if (gid >= GID_CNT) return; - /*printf("Comparing hash: "); - for (int i = 0; i < 8; i++) { - printf("%016llx", tmps[gid].out[i]); - } - printf("\n");*/ - const u64 lid = get_local_id (0); const u64 a = tmps[gid].out[0]; diff --git a/docs/credits.txt b/docs/credits.txt index f126840c8..f8779c6aa 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -85,4 +85,7 @@ Brandon Chalk (@brandoncasaba) Jamie Riden * Web2py pbkdf2-sha512 plugin +Dylan Evans (@fin3ss3g0d) +* Apache Shiro 1 SHA-512 plugin + !!! All the package maintainers of hashcat !!! diff --git a/src/modules/module_12150.c b/src/modules/module_12150.c index b6360c98f..91d1c1e6f 100644 --- a/src/modules/module_12150.c +++ b/src/modules/module_12150.c @@ -1,4 +1,8 @@ -// https://github.com/hashcat/hashcat/blob/master/docs/hashcat-plugin-development-guide.md +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + #include "common.h" #include "types.h" #include "modules.h" @@ -120,11 +124,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); - /*for (int i = 0; i < token.token_cnt; i++) { - printf("Token %d: %.*s (length: %d)\n", i, token.len[i], token.buf[i], token.len[i]); - } - printf("\n");*/ - if (rc_tokenizer != PARSER_OK) { return (rc_tokenizer); } u8 tmp_buf[512]; @@ -140,31 +139,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *salt_pos = token.buf[3]; const int salt_len = token.len[3]; memset (tmp_buf, 0, sizeof (tmp_buf)); - //printf("Salt (b64): %.*s\n", salt_len, salt_pos); tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf); - /*printf("Decoded Salt (hex): "); - for (size_t i = 0; i < tmp_len; i++) { - printf("%02x", tmp_buf[i]); - } - printf("\n");*/ memcpy (shiro_sha512->salt_buf, tmp_buf, tmp_len); salt->salt_len = tmp_len; salt->salt_buf[0] = shiro_sha512->salt_buf[0]; salt->salt_buf[1] = shiro_sha512->salt_buf[1]; salt->salt_buf[2] = shiro_sha512->salt_buf[2]; salt->salt_buf[3] = shiro_sha512->salt_buf[3]; - // Print the salt as u32 values - /*printf("Salt (interpreted as u32): "); - for (int i = 0; i < 4; i++) { - printf("%08x", salt->salt_buf[i]); - } - printf("\n");*/ - // Print the salt as bytes for comparison - /*printf("Salt (interpreted as bytes): "); - for (int i = 0; i < tmp_len; i++) { - printf("%02x", ((u8 *)salt->salt_buf)[i]); - } - printf("\n");*/ // hash const u8 *hash_pos = token.buf[4]; @@ -181,11 +162,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[5] = byte_swap_64 (digest[5]); digest[6] = byte_swap_64 (digest[6]); digest[7] = byte_swap_64 (digest[7]); - /*printf("Hash: "); - for (int i = 0; i < 8; i++) { - printf("%016llx", digest[i]); - } - printf("\n");*/ return (PARSER_OK); } @@ -275,4 +251,4 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_tmp_size = module_tmp_size; module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; -} \ No newline at end of file +}