diff --git a/OpenCL/m13711-pure.cl b/OpenCL/m13711-pure.cl index e562ab14d..745adc55c 100644 --- a/OpenCL/m13711-pure.cl +++ b/OpenCL/m13711-pure.cl @@ -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) { diff --git a/OpenCL/m13712-pure.cl b/OpenCL/m13712-pure.cl index 042e6a4fd..95ff2190a 100644 --- a/OpenCL/m13712-pure.cl +++ b/OpenCL/m13712-pure.cl @@ -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) { diff --git a/OpenCL/m13713-pure.cl b/OpenCL/m13713-pure.cl index d7135e284..3f57e13ea 100644 --- a/OpenCL/m13713-pure.cl +++ b/OpenCL/m13713-pure.cl @@ -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) { diff --git a/OpenCL/m13721-pure.cl b/OpenCL/m13721-pure.cl index 209c1d62e..75b6bd7d6 100644 --- a/OpenCL/m13721-pure.cl +++ b/OpenCL/m13721-pure.cl @@ -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) { diff --git a/OpenCL/m13722-pure.cl b/OpenCL/m13722-pure.cl index 52b18f9ee..d7f2b9806 100644 --- a/OpenCL/m13722-pure.cl +++ b/OpenCL/m13722-pure.cl @@ -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) { diff --git a/OpenCL/m13723-pure.cl b/OpenCL/m13723-pure.cl index 3a49cc1b4..bbf2d8919 100644 --- a/OpenCL/m13723-pure.cl +++ b/OpenCL/m13723-pure.cl @@ -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) { diff --git a/OpenCL/m13731-pure.cl b/OpenCL/m13731-pure.cl index 06951a7d8..03161dd63 100644 --- a/OpenCL/m13731-pure.cl +++ b/OpenCL/m13731-pure.cl @@ -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) { diff --git a/OpenCL/m13732-pure.cl b/OpenCL/m13732-pure.cl index 41263e8a4..9451e0df5 100644 --- a/OpenCL/m13732-pure.cl +++ b/OpenCL/m13732-pure.cl @@ -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) { diff --git a/OpenCL/m13733-pure.cl b/OpenCL/m13733-pure.cl index 1d15ed3d2..1691f2791 100644 --- a/OpenCL/m13733-pure.cl +++ b/OpenCL/m13733-pure.cl @@ -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) { diff --git a/OpenCL/m13751-pure.cl b/OpenCL/m13751-pure.cl index fbd04283c..bdf7fde4c 100644 --- a/OpenCL/m13751-pure.cl +++ b/OpenCL/m13751-pure.cl @@ -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) { diff --git a/OpenCL/m13752-pure.cl b/OpenCL/m13752-pure.cl index ec02b0d8e..c903ed64b 100644 --- a/OpenCL/m13752-pure.cl +++ b/OpenCL/m13752-pure.cl @@ -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) { diff --git a/OpenCL/m13753-pure.cl b/OpenCL/m13753-pure.cl index 4781af53f..baa0e9e2b 100644 --- a/OpenCL/m13753-pure.cl +++ b/OpenCL/m13753-pure.cl @@ -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) { diff --git a/OpenCL/m13771-pure.cl b/OpenCL/m13771-pure.cl index a9ab042b9..ee6f9adc9 100644 --- a/OpenCL/m13771-pure.cl +++ b/OpenCL/m13771-pure.cl @@ -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) { diff --git a/OpenCL/m13772-pure.cl b/OpenCL/m13772-pure.cl index a44a0dab6..8c77189cc 100644 --- a/OpenCL/m13772-pure.cl +++ b/OpenCL/m13772-pure.cl @@ -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; diff --git a/OpenCL/m13773-pure.cl b/OpenCL/m13773-pure.cl index 701c1b0f9..3aa411572 100644 --- a/OpenCL/m13773-pure.cl +++ b/OpenCL/m13773-pure.cl @@ -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; diff --git a/tools/veracrypt2hashcat.py b/tools/veracrypt2hashcat.py index f29d01dfe..e08b2e175 100755 --- a/tools/veracrypt2hashcat.py +++ b/tools/veracrypt2hashcat.py @@ -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())