mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Add new function is_valid_printable_32() to check if 32 bit integer consist only of printable characters and update -m 26610 as example use case
This commit is contained in:
parent
4fe68b0d4f
commit
d5a74b2536
@ -2806,6 +2806,24 @@ DECLSPEC int is_valid_base58_32 (const u32 v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLSPEC int is_valid_printable_8 (const u8 v)
|
||||||
|
{
|
||||||
|
if (v > (u8) 0x7e) return 0;
|
||||||
|
if (v < (u8) 0x20) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int is_valid_printable_32 (const u32 v)
|
||||||
|
{
|
||||||
|
if (is_valid_printable_8 ((u8) (v >> 0)) == 0) return 0;
|
||||||
|
if (is_valid_printable_8 ((u8) (v >> 8)) == 0) return 0;
|
||||||
|
if (is_valid_printable_8 ((u8) (v >> 16)) == 0) return 0;
|
||||||
|
if (is_valid_printable_8 ((u8) (v >> 24)) == 0) return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
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_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)
|
||||||
{
|
{
|
||||||
for (int idx = 0; idx < keyboard_layout_mapping_cnt; idx++)
|
for (int idx = 0; idx < keyboard_layout_mapping_cnt; idx++)
|
||||||
|
@ -311,6 +311,8 @@ DECLSPEC int is_valid_hex_8 (const u8 v);
|
|||||||
DECLSPEC int is_valid_hex_32 (const u32 v);
|
DECLSPEC int is_valid_hex_32 (const u32 v);
|
||||||
DECLSPEC int is_valid_base58_8 (const u8 v);
|
DECLSPEC int is_valid_base58_8 (const u8 v);
|
||||||
DECLSPEC int is_valid_base58_32 (const u32 v);
|
DECLSPEC int is_valid_base58_32 (const u32 v);
|
||||||
|
DECLSPEC int is_valid_printable_8 (const u8 v);
|
||||||
|
DECLSPEC int is_valid_printable_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_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 (PRIVATE_AS u32 *w, 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 (PRIVATE_AS 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 (PRIVATE_AS const u32x *in, PRIVATE_AS u32x *out1, PRIVATE_AS u32x *out2);
|
DECLSPEC void make_utf16be (PRIVATE_AS const u32x *in, PRIVATE_AS u32x *out1, PRIVATE_AS u32x *out2);
|
||||||
|
@ -334,12 +334,12 @@ KERNEL_FQ void m25500_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh
|
|||||||
|
|
||||||
// iv
|
// iv
|
||||||
|
|
||||||
const u32 iv[4] = {
|
const u32 iv[4];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1],
|
iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2],
|
iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]
|
iv[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2];
|
||||||
};
|
iv[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3];
|
||||||
|
|
||||||
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
||||||
|
|
||||||
|
@ -334,12 +334,12 @@ KERNEL_FQ void m26600_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh
|
|||||||
|
|
||||||
// iv
|
// iv
|
||||||
|
|
||||||
const u32 iv[4] = {
|
const u32 iv[4];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1],
|
iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2],
|
iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]
|
iv[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2];
|
||||||
};
|
iv[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3];
|
||||||
|
|
||||||
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
||||||
|
|
||||||
|
@ -335,12 +335,13 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh
|
|||||||
AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4);
|
AES_GCM_Init (ukey, key_len, key, subKey, s_te0, s_te1, s_te2, s_te3, s_te4);
|
||||||
|
|
||||||
// iv
|
// iv
|
||||||
const u32 iv[4] = {
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0],
|
u32 iv[4];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2],
|
iv[0] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[0];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3]
|
iv[1] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[1];
|
||||||
};
|
iv[2] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[2];
|
||||||
|
iv[3] = esalt_bufs[DIGESTS_OFFSET_HOST].iv_buf[3];
|
||||||
|
|
||||||
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
const u32 iv_len = esalt_bufs[DIGESTS_OFFSET_HOST].iv_len;
|
||||||
|
|
||||||
@ -349,12 +350,13 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh
|
|||||||
AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0);
|
AES_GCM_Prepare_J0 (iv, iv_len, subKey, J0);
|
||||||
|
|
||||||
//ct
|
//ct
|
||||||
u32 ct[4] = {
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[0],
|
u32 ct[4];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[1],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[2],
|
ct[0] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[0];
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[3]
|
ct[1] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[1];
|
||||||
};
|
ct[2] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[2];
|
||||||
|
ct[3] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[3];
|
||||||
|
|
||||||
u32 pt[4] = { 0 };
|
u32 pt[4] = { 0 };
|
||||||
|
|
||||||
@ -365,41 +367,24 @@ KERNEL_FQ void m26610_comp (KERN_ATTR_TMPS_ESALT (pbkdf2_sha256_tmp_t, pbkdf2_sh
|
|||||||
|
|
||||||
// if ((gid == 0) && (lid == 0)) printf ("pt[0]=%08x\n", pt[0]); // should be 5b7b2274 or [{"type"
|
// if ((gid == 0) && (lid == 0)) printf ("pt[0]=%08x\n", pt[0]); // should be 5b7b2274 or [{"type"
|
||||||
|
|
||||||
// cast plaintext buffer to byte such that we can do a byte per byte comparison
|
u32 digest[4];
|
||||||
PRIVATE_AS const u32 *u32OutBufPtr = (PRIVATE_AS u32 *) pt;
|
|
||||||
PRIVATE_AS const u8 *u8OutBufPtr = (PRIVATE_AS u8 *) u32OutBufPtr;
|
|
||||||
|
|
||||||
// the best comparison I can think of is checking each byte
|
digest[0] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[0];
|
||||||
// whether it's ASCII, if so we're good,
|
digest[1] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[1];
|
||||||
// if not, decryption was not successful
|
digest[2] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[2];
|
||||||
bool correct = true;
|
digest[3] = esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[3];
|
||||||
|
|
||||||
for(int i=0;i<16;i++)
|
|
||||||
{
|
|
||||||
if(u8OutBufPtr[i] >=20 && u8OutBufPtr[i] <= 0x7e) {
|
|
||||||
//if ((gid == 0) && (lid == 0)) printf("correct ASCII byte[%d]=0x%02x\n", i, u8OutBufPtr[i]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//if ((gid == 0) && (lid == 0)) printf("NOT correct! byte[%d]=0x%02x\n", i, u8OutBufPtr[i]);
|
|
||||||
correct = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const u32 digest[4] =
|
|
||||||
{
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[0],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[1],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[2],
|
|
||||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct_buf[3],
|
|
||||||
};
|
|
||||||
|
|
||||||
//if ((gid == 0) && (lid == 0)) printf ("ct[0]=%08x\n", ct[0]);
|
//if ((gid == 0) && (lid == 0)) printf ("ct[0]=%08x\n", ct[0]);
|
||||||
//if ((gid == 0) && (lid == 0)) printf ("ct[1]=%08x\n", ct[1]);
|
//if ((gid == 0) && (lid == 0)) printf ("ct[1]=%08x\n", ct[1]);
|
||||||
//if ((gid == 0) && (lid == 0)) printf ("ct[2]=%08x\n", ct[2]);
|
//if ((gid == 0) && (lid == 0)) printf ("ct[2]=%08x\n", ct[2]);
|
||||||
//if ((gid == 0) && (lid == 0)) printf ("ct[3]=%08x\n", ct[3]);
|
//if ((gid == 0) && (lid == 0)) printf ("ct[3]=%08x\n", ct[3]);
|
||||||
|
|
||||||
if (correct)
|
const int correct = is_valid_printable_32 (pt[0])
|
||||||
|
+ is_valid_printable_32 (pt[1])
|
||||||
|
+ is_valid_printable_32 (pt[2])
|
||||||
|
+ is_valid_printable_32 (pt[3]);
|
||||||
|
|
||||||
|
if (correct == 4)
|
||||||
{
|
{
|
||||||
int digest_pos = find_hash (digest, DIGESTS_CNT, &digests_buf[DIGESTS_OFFSET_HOST]);
|
int digest_pos = find_hash (digest, DIGESTS_CNT, &digests_buf[DIGESTS_OFFSET_HOST]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user