1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-23 07:08:19 +00:00

using hex_encode/hex_decode + small fixes

This commit is contained in:
Gabriele Gristina 2021-07-22 19:10:34 +02:00
parent db7cb16a3b
commit 6d83a69f7d
2 changed files with 13 additions and 29 deletions

View File

@ -53,7 +53,7 @@ KERNEL_FQ void m25200_init (KERN_ATTR_TMPS_ESALT (hmac_sha1_tmp_t, snmpv3_t))
* base
*/
const global u8 *pw_buf = (global u8 *) pws[gid].i;
const GLOBAL_AS u8 *pw_buf = (GLOBAL_AS u8 *) pws[gid].i;
const u32 pw_len = pws[gid].pw_len;
@ -63,7 +63,7 @@ KERNEL_FQ void m25200_init (KERN_ATTR_TMPS_ESALT (hmac_sha1_tmp_t, snmpv3_t))
u32 idx = 0;
u32 buf[32] = { 0 };
u32 buf[16] = { 0 };
u8 *tmp_buf = (u8 *) buf;
@ -94,13 +94,13 @@ KERNEL_FQ void m25200_loop (KERN_ATTR_TMPS_ESALT (hmac_sha1_tmp_t, snmpv3_t))
if (gid >= gid_max) return;
const global u8 *pw_buf = (global u8 *) pws[gid].i;
const GLOBAL_AS u8 *pw_buf = (GLOBAL_AS u8 *) pws[gid].i;
const u32 pw_len = pws[gid].pw_len;
u32 idx = tmps[gid].idx;
u32 buf[32] = { 0 };
u32 buf[16] = { 0 };
u8 *tmp_buf = (u8 *) buf;
@ -132,7 +132,7 @@ KERNEL_FQ void m25200_comp (KERN_ATTR_TMPS_ESALT (hmac_sha1_tmp_t, snmpv3_t))
if (gid >= gid_max) return;
const global u8 *engineID_buf = esalt_bufs[DIGESTS_OFFSET].engineID_buf;
const GLOBAL_AS u8 *engineID_buf = esalt_bufs[DIGESTS_OFFSET].engineID_buf;
u32 engineID_len = esalt_bufs[DIGESTS_OFFSET].engineID_len;

View File

@ -21,8 +21,7 @@ static const u32 DGST_SIZE = DGST_SIZE_4_4; // 4_3
static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL;
static const char *HASH_NAME = "SNMPv3 HMAC-SHA1-96";
static const u64 KERN_TYPE = 25200;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
@ -103,8 +102,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
token.len_min[1] = 1;
token.len_max[1] = 8;
token.sep[1] = '$';
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
| TOKEN_ATTR_VERIFY_DIGIT;
// salt
token.len_min[2] = 12 * 2;
token.len_max[2] = SNMPV3_SALT_MAX * 2;
@ -130,6 +129,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
// packet number
const u8 *packet_number_pos = token.buf[1];
const int packet_number_len = token.len[1];
@ -144,21 +144,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
u8 *salt_ptr = (u8 *) snmpv3->salt_buf;
int i;
int j;
snmpv3->salt_len = hex_decode (salt_pos, salt_len, salt_ptr);
for (i = 0, j = 0; i < salt_len; i += 2, j += 1)
{
salt_ptr[j] = hex_to_u8 (salt_pos + i);
}
for (i = 0; i < salt_len / 4; i++)
for (int i = 0; i < salt_len / 4; i++)
{
snmpv3->salt_buf[i] = byte_swap_32 (snmpv3->salt_buf[i]);
}
snmpv3->salt_len = salt_len / 2;
salt->salt_iter = 16384 - 1;
// handle unique salts detection
@ -180,12 +172,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
u8 *engineID_ptr = (u8 *) snmpv3->engineID_buf;
for (i = 0, j = 0; i < engineID_len; i += 2, j += 1)
{
engineID_ptr[j] = hex_to_u8 (engineID_pos + i);
}
snmpv3->engineID_len = engineID_len / 2;
snmpv3->engineID_len = hex_decode (engineID_pos, engineID_len, engineID_ptr);
// digest
@ -227,10 +214,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
line_len += snprintf (line_buf+line_len, 2, "$");
for (i = 0; i < snmpv3->engineID_len; i++)
{
line_len += snprintf (line_buf+line_len, 3, "%02x", snmpv3->engineID_buf[i]);
}
line_len += hex_encode (snmpv3->engineID_buf, snmpv3->engineID_len, (u8 *) line_buf+line_len);
line_len += snprintf (line_buf+line_len, 2, "$");