mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Tool veracrypt2hashcat.py code cleanup
This commit is contained in:
parent
d1b1a64a8c
commit
bd538bb755
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -46,6 +47,7 @@ typedef struct vc
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc_tmp
|
||||
{
|
||||
@ -212,7 +214,7 @@ KERNEL_FQ void m13711_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3];
|
||||
tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4];
|
||||
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 16; i += 5, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -261,7 +262,7 @@ KERNEL_FQ void m13712_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3];
|
||||
tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4];
|
||||
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 32; i += 5, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -326,7 +327,7 @@ KERNEL_FQ void m13713_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[3] = ripemd160_hmac_ctx.opad.h[3];
|
||||
tmps[gid].opad[4] = ripemd160_hmac_ctx.opad.h[4];
|
||||
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
ripemd160_hmac_update_global (&ripemd160_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 48; i += 5, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -238,7 +239,7 @@ KERNEL_FQ void m13721_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t))
|
||||
tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7];
|
||||
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -289,7 +290,7 @@ KERNEL_FQ void m13722_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t))
|
||||
tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7];
|
||||
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 16; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -354,7 +355,7 @@ KERNEL_FQ void m13723_init (KERN_ATTR_TMPS_ESALT (vc64_tmp_t, vc_t))
|
||||
tmps[gid].opad[6] = sha512_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha512_hmac_ctx.opad.h[7];
|
||||
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha512_hmac_update_global_swap (&sha512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 24; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -334,7 +335,7 @@ KERNEL_FQ void m13731_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14];
|
||||
tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15];
|
||||
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 16; i += 16, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -385,7 +386,7 @@ KERNEL_FQ void m13732_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14];
|
||||
tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15];
|
||||
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 32; i += 16, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -450,7 +451,7 @@ KERNEL_FQ void m13733_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
tmps[gid].opad[14] = whirlpool_hmac_ctx.opad.h[14];
|
||||
tmps[gid].opad[15] = whirlpool_hmac_ctx.opad.h[15];
|
||||
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
whirlpool_hmac_update_global_swap (&whirlpool_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 48; i += 16, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -222,7 +223,7 @@ KERNEL_FQ void m13751_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
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, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 16; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -273,7 +274,7 @@ KERNEL_FQ void m13752_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
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, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 32; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -338,7 +339,7 @@ KERNEL_FQ void m13753_init (KERN_ATTR_TMPS_ESALT (vc_tmp_t, vc_t))
|
||||
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, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 48; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -306,7 +307,7 @@ KERNEL_FQ void m13771_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t))
|
||||
tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6];
|
||||
tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7];
|
||||
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -357,7 +358,7 @@ KERNEL_FQ void m13772_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t))
|
||||
tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6];
|
||||
tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7];
|
||||
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
u32 i = 0;
|
||||
u32 j = 1;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#endif
|
||||
|
||||
#define VC_DATA_LEN (448)
|
||||
#define VC_SALT_LEN ( 64)
|
||||
|
||||
typedef struct vc
|
||||
{
|
||||
@ -422,7 +423,7 @@ KERNEL_FQ void m13773_init (KERN_ATTR_TMPS_ESALT (vc64_sbog_tmp_t, vc_t))
|
||||
tmps[gid].opad_raw[6] = streebog512_hmac_ctx.opad.s[6];
|
||||
tmps[gid].opad_raw[7] = streebog512_hmac_ctx.opad.s[7];
|
||||
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, 64);
|
||||
streebog512_hmac_update_global_swap (&streebog512_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, VC_SALT_LEN);
|
||||
|
||||
u32 i = 0;
|
||||
u32 j = 1;
|
||||
|
@ -1,5 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# Author......: See docs/credits.txt
|
||||
# License.....: MIT
|
||||
#
|
||||
|
||||
from argparse import ArgumentParser, ArgumentTypeError
|
||||
|
||||
|
||||
@ -23,9 +28,10 @@ def validate_offset(offset):
|
||||
offset = BOOTABLE_OFFSET + HIDDEN_OFFSET
|
||||
try:
|
||||
offset = int(offset)
|
||||
assert offset >= 0
|
||||
except (AssertionError, ValueError):
|
||||
raise ArgumentTypeError("offset is nether non-negative number nor bootable, hidden or bootable+hidden value")
|
||||
except ValueError as e:
|
||||
raise ArgumentTypeError("value is nether number nor allowed string") from e
|
||||
if offset < 0:
|
||||
raise ArgumentTypeError("value cannot be less than zero")
|
||||
return offset
|
||||
|
||||
|
||||
@ -42,14 +48,18 @@ if __name__ == "__main__":
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.path, "rb") as file:
|
||||
file.seek(args.offset)
|
||||
try:
|
||||
with open(args.path, "rb") as file:
|
||||
file.seek(args.offset)
|
||||
|
||||
header = file.read(HEADER_LENGTH)
|
||||
header = file.read(HEADER_LENGTH)
|
||||
|
||||
assert len(header) == HEADER_LENGTH, "less data than needed"
|
||||
if len(header) < HEADER_LENGTH:
|
||||
parser.error("file contains less data than needed")
|
||||
|
||||
salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:]
|
||||
salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:]
|
||||
|
||||
hash = SIGNATURE + salt.hex() + "$" + data.hex()
|
||||
print(hash)
|
||||
hash = SIGNATURE + salt.hex() + "$" + data.hex()
|
||||
print(hash)
|
||||
except IOError as e:
|
||||
parser.error(e.strerror.lower())
|
||||
|
Loading…
Reference in New Issue
Block a user