2022-06-15 11:01:22 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "bitops.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "shared.h"
|
|
|
|
#include "memory.h"
|
|
|
|
|
|
|
|
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
|
|
|
|
static const u32 DGST_POS0 = 0;
|
|
|
|
static const u32 DGST_POS1 = 1;
|
|
|
|
static const u32 DGST_POS2 = 2;
|
|
|
|
static const u32 DGST_POS3 = 3;
|
|
|
|
static const u32 DGST_SIZE = DGST_SIZE_4_16;
|
|
|
|
static const u32 HASH_CATEGORY = HASH_CATEGORY_FDE;
|
|
|
|
static const char *HASH_NAME = "LUKS v1 SHA-1 + Twofish";
|
2022-07-05 03:49:04 +00:00
|
|
|
static const u64 KERN_TYPE = 14613; // old kernel used here
|
2022-06-15 11:01:22 +00:00
|
|
|
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
|
|
|
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
|
|
|
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
|
|
|
| OPTS_TYPE_PT_GENERATE_LE;
|
|
|
|
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
|
|
|
static const char *ST_PASS = "hashcat";
|
|
|
|
static const char *ST_HASH = "$luks$1$sha1$twofish$xts-plain64$256$151351$13141718422ca869ae072d33b700c8c43a1796294bb74240d7aa60f03f322d1a$88c148ac32ee23d671dd8b93bcad963e479d0f0778b66365a937aa3351c36587449491f946333c86d82777ea509634f32fa3254517414df0b2c143d2a3678f181b8662cee92a6fa20e4ee4a0b9deb4c5bafef32d30cf8fdf4a56a5f39046b0585269ddf25173178c4e9c570c237057922ac4127d72ae8fafbeabce564cdc559221556cb9fb0388a420fce4579921f4181174f99bd165f093bec131ea327d9d8eab21b2c4ca0807ef18e488d32107c45ab43812a2794c6aa65e8fb0d1cbba8242c45dd514066e227ad08f0a01f706be70392c54d0b6410eb3ac62130481bf77847ee4565d317346eda2e9572ed17b43ab07b0ee369397b2710c1c3cb2199dfd62e2a99d568ae4eda29cb53381d65935ee4d7379d7d3d8c4f375f7ad6ef19fbd5315311e980ec692e0bc07b1aabc0b793894d1256392df5a154368b5a00e2dee87ec065cb7a8f686db050b7bedae5da36247dcbeac458565429a9ca746b9944e360028f02427ecf3bcd3cd5500467da85c70114c7c7404e3a85625b418e259b219184fdeb1a660fb1624abac0c263682216b630ee67bc1b4b0edc1923276e2c9b1ac11cb8a92061ed2d2d7fb2a125cf52a78007d44b1c7bd6ca01c1ca321f19097173fb3ba8a19f6a09d18604d953cb263988900445105b72e100bc0eba0436bb7784847c22c61049d47804e2346e58d4d70e73ca6ae9a8e8fe7067e2603028650a2a0715a03498677ca7f4452d96ad16138ec6869ad2767410ac467b038e9718a4d595656d4a1272b2b322b1d905e5bf5363cc965acf1eea68ee654a91e9107593f2e1621a2845e7259f49f1810b8b664c8f83b357a0807a1cb0ec3349430d69b5202b9385253da341fedcc1575e905021bdff2b65fcbcbabb38fd68567a4a2f535988f062ba4bbc732bb099e5b297b858b5e79a9bb6b8c2e8d24b5cb3ed7a4b0afcd1b6dfa7d2ff88f895e159f9163893cb339b29e534a45e0db02736f65b785888e3c7f737443747c4f25f9ff008b64d847a5c12bb4dc25670554b3800b4dcddac4fbdf3734b559388040bed475915d0d31b95b4a1bf3d602a49e1db2ca980c7dc82f8ba2efe850efb7abf6b2f22847d61b2da0a82825106609bb5a3c1865c18dbe4563cd28f44c6dc6bde45d922b21be8a2ffa2835e3fb80eff56e60123daa889d4f821cecd79253eeadb0c34e20bef90ea197092d45f8faab743ee98f89edac95e3221dee504dcee57e66d3f931016d457530f0fb414a556faf8fc7c159dc1711fbbbb63ced5bc532e9e04a3fb28a323f6a4749ec3d2f322df544241f4dbc0d08f42e16bdb26fb81e8cfdc9a79640edc33b5d3df0f1747dc11e4fd4a6436d919242b955e069091ef0b480cd8faa9999ef4de0ccabdd373fb3c09b58101d1a40bb48215a11ace424a836320981aeba12ae9aaf0364f38f9862edcacb0552c339e69db132ac76734cef7cc8aad52504e3d7c80f41febbe7ffbd8002695544cd854e7f7aea8b135ccb64376989756220d0ab93aaa9ca88eabcc8f5f560fb01dfb0a09d0322078a6709894b9f05a8bc56aa7b5b70783bc287f2bcab0a6e423d91d5cbde2e92779dedd5ad65bc4f6a3a456439280acd2236562eb266d1737b2dea4e4198044ae6b5af5e0874894065cbb084f56406723a139a25e754f29958546b5e08cf6840ec8935c377ac1a6360f68030a6527b1c01c867aeac04eac6c298bb246db8e2cf8595adca60d2f5fc999220f0c767cd265c1dbe25c7e7f4b6776b2d8ed7507f56293def1427cbe42fcbf42989deac93fb1f2384824fcc4148a2b8deb9ea361c5b3a8ed24b58de01978c99c5f116ceca19aa7053bf1de450bfed8a0cb0ac6b42a9713b40b94d1a3fe5dfaf1caef14d2677d783c568a91d8b2ef73a889d64db1ff2ba28381bcea99d72255a294dfe856445cd33c799afc8f1aa3ac0150ef5097792d21770cbd0a0d3812bc3715280c80dc73d4b373cda7213841fc7021a367f79d73996dd1e107eb386a3a46515b8f2949e76c94c2c9ad98a130774670c51fbeff5a328124ec75d98f7bc73831f02b4b603c3d2359318391bc3def64b99460ccb399d5844dc09ea82559b107655dd194ebb2f05998c025a8a1b42cbb8f84d85d9a0b1a6047900d3c7f2759029652421d93212632023becc1555b1b21cf2eeb1ad5f87f19e181e8121875bb2c33b70a7e5d87d06f935c432facc4f379392f5c1e437cd88e352bb20cfd4dd2f0333d2f9d71879fe157ffac28ed9c739207dcafbd19d5f3aeb56bc81508cfadcee5a3f4b17f33450a50dd9f6487114731dc3843e5ac12f4cb2d6456049c9364a34700e229c8175c52e7ed2fec0cdd765654237a427f65908ae88195b10e01bc42bada9bfb4827c85d5d1cf14b9fd6ca8928c0593b0a3ad71cc7b8e643aafbbe61c27f02a30bddeba41fdeffcbb65a539a1d7a2eb7946b5916ec288d541b1772100b2e66064606a45f6c47f1af9f9541363c2bed45569e7744068995c5bff70552c9ac60fd31dd33a6fca6c27239bddc585003d50e80875188ef97ab162fe0ac99ead98cb6325110d5ae668d872ddef22ccb85d9ebfa662869724067fd070083d910b6efd0460844a1edc7ed60bf7fcd10d5cbb1be3ed1a42fc9b83884235d4570b0fe8921f081deaa1392561690100820c3e61c51555f3642fce23b6ff4373fcfa9adae6954cf76a85e353b0aa341263f239ab8cbad3ea2848d82c5aa7fa4a61e4d2f3eea6ec0d591b1b27892785bfd4d1fe07f77963bce1e49a9e34568520a6092e3d0c65a9c7d
|
|
|
|
|
|
|
|
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
|
|
|
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
|
|
|
u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; }
|
|
|
|
u32 module_dgst_pos2 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS2; }
|
|
|
|
u32 module_dgst_pos3 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS3; }
|
|
|
|
u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_SIZE; }
|
|
|
|
u32 module_hash_category (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_CATEGORY; }
|
|
|
|
const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return HASH_NAME; }
|
|
|
|
u64 module_kern_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return KERN_TYPE; }
|
|
|
|
u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTI_TYPE; }
|
|
|
|
u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return OPTS_TYPE; }
|
|
|
|
u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return SALT_TYPE; }
|
|
|
|
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
|
|
|
|
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
#define LUKS_STRIPES ( 4000)
|
|
|
|
#define LUKS_SALT_LEN ( 32)
|
|
|
|
#define LUKS_SALT_HEX_LEN ( LUKS_SALT_LEN * 2)
|
|
|
|
#define LUKS_CT_LEN ( 512)
|
|
|
|
#define LUKS_CT_HEX_LEN ( LUKS_CT_LEN * 2)
|
|
|
|
#define LUKS_AF_MIN_LEN (HC_LUKS_KEY_SIZE_128 / 8 * LUKS_STRIPES)
|
|
|
|
#define LUKS_AF_MIN_HEX_LEN ( LUKS_AF_MIN_LEN * 2)
|
|
|
|
#define LUKS_AF_MAX_LEN (HC_LUKS_KEY_SIZE_512 / 8 * LUKS_STRIPES)
|
|
|
|
#define LUKS_AF_MAX_HEX_LEN ( LUKS_AF_MAX_LEN * 2)
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
typedef enum hc_luks_hash_type
|
|
|
|
{
|
|
|
|
HC_LUKS_HASH_TYPE_SHA1 = 1,
|
|
|
|
HC_LUKS_HASH_TYPE_SHA256 = 2,
|
|
|
|
HC_LUKS_HASH_TYPE_SHA512 = 3,
|
|
|
|
HC_LUKS_HASH_TYPE_RIPEMD160 = 4,
|
|
|
|
HC_LUKS_HASH_TYPE_WHIRLPOOL = 5,
|
|
|
|
|
|
|
|
} hc_luks_hash_type_t;
|
|
|
|
|
|
|
|
typedef enum hc_luks_key_size
|
|
|
|
{
|
|
|
|
HC_LUKS_KEY_SIZE_128 = 128,
|
|
|
|
HC_LUKS_KEY_SIZE_256 = 256,
|
|
|
|
HC_LUKS_KEY_SIZE_512 = 512,
|
|
|
|
|
|
|
|
} hc_luks_key_size_t;
|
|
|
|
|
|
|
|
typedef enum hc_luks_cipher_type
|
|
|
|
{
|
|
|
|
HC_LUKS_CIPHER_TYPE_AES = 1,
|
|
|
|
HC_LUKS_CIPHER_TYPE_SERPENT = 2,
|
|
|
|
HC_LUKS_CIPHER_TYPE_TWOFISH = 3,
|
|
|
|
|
|
|
|
} hc_luks_cipher_type_t;
|
|
|
|
|
|
|
|
typedef enum hc_luks_cipher_mode
|
|
|
|
{
|
|
|
|
HC_LUKS_CIPHER_MODE_CBC_ESSIV_SHA256 = 1,
|
|
|
|
HC_LUKS_CIPHER_MODE_CBC_PLAIN = 2,
|
|
|
|
HC_LUKS_CIPHER_MODE_CBC_PLAIN64 = 3,
|
|
|
|
HC_LUKS_CIPHER_MODE_XTS_PLAIN = 4,
|
|
|
|
HC_LUKS_CIPHER_MODE_XTS_PLAIN64 = 5,
|
|
|
|
|
|
|
|
} hc_luks_cipher_mode_t;
|
|
|
|
|
|
|
|
typedef struct luks
|
|
|
|
{
|
2022-07-05 03:49:04 +00:00
|
|
|
int hash_type; // hc_luks_hash_type_t
|
|
|
|
int key_size; // hc_luks_key_size_t
|
|
|
|
int cipher_type; // hc_luks_cipher_type_t
|
|
|
|
int cipher_mode; // hc_luks_cipher_mode_t
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
u32 ct_buf[LUKS_CT_LEN / 4];
|
|
|
|
|
|
|
|
u32 af_buf[LUKS_AF_MAX_LEN / 4];
|
|
|
|
u32 af_len;
|
|
|
|
|
|
|
|
} luks_t;
|
|
|
|
|
|
|
|
typedef struct luks_tmp
|
|
|
|
{
|
|
|
|
u32 ipad32[8];
|
|
|
|
u64 ipad64[8];
|
|
|
|
|
|
|
|
u32 opad32[8];
|
|
|
|
u64 opad64[8];
|
|
|
|
|
|
|
|
u32 dgst32[32];
|
|
|
|
u64 dgst64[16];
|
|
|
|
|
|
|
|
u32 out32[32];
|
|
|
|
u64 out64[16];
|
|
|
|
|
|
|
|
} luks_tmp_t;
|
|
|
|
|
|
|
|
static const char *SIGNATURE_LUKS = "$luks$1$sha1$twofish$";
|
|
|
|
|
|
|
|
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
|
|
|
{
|
|
|
|
const u64 esalt_size = (const u64) sizeof (luks_t);
|
|
|
|
|
|
|
|
return esalt_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
|
|
|
{
|
|
|
|
const u64 tmp_size = (const u64) sizeof (luks_tmp_t);
|
|
|
|
|
|
|
|
return tmp_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
|
|
|
{
|
|
|
|
// this overrides the reductions of PW_MAX in case optimized kernel is selected
|
|
|
|
// IOW, even in optimized kernel mode it support length 256
|
|
|
|
|
|
|
|
const u32 pw_max = PW_MAX;
|
|
|
|
|
|
|
|
return pw_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
|
|
|
|
{
|
|
|
|
luks_t *luks = (luks_t *) esalt_buf;
|
|
|
|
|
|
|
|
hc_token_t token;
|
|
|
|
|
2023-04-11 17:34:01 +00:00
|
|
|
memset (&token, 0, sizeof (hc_token_t));
|
|
|
|
|
2022-06-15 11:01:22 +00:00
|
|
|
token.token_cnt = 7;
|
|
|
|
|
|
|
|
token.signatures_cnt = 1;
|
|
|
|
token.signatures_buf[0] = SIGNATURE_LUKS;
|
|
|
|
|
|
|
|
// signature with hash and cipher type
|
|
|
|
token.len[0] = 21;
|
|
|
|
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
|
|
|
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
|
|
|
|
|
|
|
// cipher mode
|
|
|
|
token.sep[1] = '$';
|
|
|
|
token.len_min[1] = 9;
|
|
|
|
token.len_max[1] = 16;
|
|
|
|
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
|
|
|
|
|
|
|
|
// key size
|
|
|
|
token.sep[2] = '$';
|
2023-04-11 17:34:01 +00:00
|
|
|
token.len[2] = 3;
|
|
|
|
token.attr[2] = TOKEN_ATTR_FIXED_LENGTH
|
2022-06-15 11:01:22 +00:00
|
|
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
|
|
|
|
|
|
|
// iter
|
|
|
|
token.sep[3] = '$';
|
|
|
|
token.len_min[3] = 1;
|
|
|
|
token.len_max[3] = 10;
|
|
|
|
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
|
|
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
|
|
|
|
|
|
|
// salt
|
|
|
|
token.sep[4] = '$';
|
2023-04-11 17:34:01 +00:00
|
|
|
token.len[4] = LUKS_SALT_HEX_LEN;
|
|
|
|
token.attr[4] = TOKEN_ATTR_FIXED_LENGTH
|
2022-06-15 11:01:22 +00:00
|
|
|
| TOKEN_ATTR_VERIFY_HEX;
|
|
|
|
|
|
|
|
// af
|
|
|
|
token.sep[5] = '$';
|
2022-07-05 03:49:04 +00:00
|
|
|
token.len_min[5] = LUKS_AF_MIN_HEX_LEN;
|
|
|
|
token.len_max[5] = LUKS_AF_MAX_HEX_LEN;
|
2022-06-15 11:01:22 +00:00
|
|
|
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
|
|
|
| TOKEN_ATTR_VERIFY_HEX;
|
|
|
|
|
|
|
|
// ct
|
|
|
|
token.sep[6] = '$';
|
2023-04-11 17:34:01 +00:00
|
|
|
token.len[6] = LUKS_CT_HEX_LEN;
|
|
|
|
token.attr[6] = TOKEN_ATTR_FIXED_LENGTH
|
2022-06-15 11:01:22 +00:00
|
|
|
| TOKEN_ATTR_VERIFY_HEX;
|
|
|
|
|
|
|
|
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
|
|
|
|
|
|
|
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
|
|
|
|
|
|
|
// hash type
|
|
|
|
|
|
|
|
luks->hash_type = HC_LUKS_HASH_TYPE_SHA1;
|
|
|
|
|
|
|
|
// cipher type
|
|
|
|
|
|
|
|
luks->cipher_type = HC_LUKS_CIPHER_TYPE_TWOFISH;
|
|
|
|
|
|
|
|
// cipher mode
|
|
|
|
|
|
|
|
const u8 *cipher_mode_pos = token.buf[1];
|
2022-09-13 23:00:20 +00:00
|
|
|
const u32 cipher_mode_len = token.len[1];
|
2022-06-15 11:01:22 +00:00
|
|
|
|
2022-09-13 23:00:20 +00:00
|
|
|
if ((strncmp ((const char *) cipher_mode_pos, "cbc-essiv:sha256", 16) == 0) && (cipher_mode_len == 16))
|
2022-06-15 11:01:22 +00:00
|
|
|
{
|
|
|
|
luks->cipher_mode = HC_LUKS_CIPHER_MODE_CBC_ESSIV_SHA256;
|
|
|
|
}
|
2022-09-13 23:00:20 +00:00
|
|
|
else if ((strncmp ((const char *) cipher_mode_pos, "cbc-plain", 9) == 0) && (cipher_mode_len == 9))
|
2022-06-15 11:01:22 +00:00
|
|
|
{
|
|
|
|
luks->cipher_mode = HC_LUKS_CIPHER_MODE_CBC_PLAIN;
|
|
|
|
}
|
2022-09-13 23:00:20 +00:00
|
|
|
else if ((strncmp ((const char *) cipher_mode_pos, "cbc-plain64", 11) == 0) && (cipher_mode_len == 11))
|
2022-06-15 11:01:22 +00:00
|
|
|
{
|
|
|
|
luks->cipher_mode = HC_LUKS_CIPHER_MODE_CBC_PLAIN64;
|
|
|
|
}
|
2022-09-13 23:00:20 +00:00
|
|
|
else if ((strncmp ((const char *) cipher_mode_pos, "xts-plain", 9) == 0) && (cipher_mode_len == 9))
|
2022-06-15 11:01:22 +00:00
|
|
|
{
|
|
|
|
luks->cipher_mode = HC_LUKS_CIPHER_MODE_XTS_PLAIN;
|
|
|
|
}
|
2022-09-13 23:00:20 +00:00
|
|
|
else if ((strncmp ((const char *) cipher_mode_pos, "xts-plain64", 11) == 0) && (cipher_mode_len == 11))
|
2022-06-15 11:01:22 +00:00
|
|
|
{
|
|
|
|
luks->cipher_mode = HC_LUKS_CIPHER_MODE_XTS_PLAIN64;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (PARSER_LUKS_CIPHER_MODE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// key size
|
|
|
|
|
|
|
|
const u8 *key_size_pos = token.buf[2];
|
|
|
|
|
|
|
|
const u32 key_size = hc_strtoul ((const char *) key_size_pos, NULL, 10);
|
|
|
|
|
|
|
|
if (key_size == 128)
|
|
|
|
{
|
|
|
|
luks->key_size = HC_LUKS_KEY_SIZE_128;
|
|
|
|
}
|
|
|
|
else if (key_size == 256)
|
|
|
|
{
|
|
|
|
luks->key_size = HC_LUKS_KEY_SIZE_256;
|
|
|
|
}
|
|
|
|
else if (key_size == 512)
|
|
|
|
{
|
|
|
|
luks->key_size = HC_LUKS_KEY_SIZE_512;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (PARSER_LUKS_KEY_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// salt
|
|
|
|
|
|
|
|
const u8 *salt_pos = token.buf[4];
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
salt->salt_len = hex_decode (salt_pos, LUKS_SALT_HEX_LEN, (u8 *) salt->salt_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// iter
|
|
|
|
|
|
|
|
const u8 *iter_pos = token.buf[3];
|
|
|
|
|
|
|
|
const u32 iter = hc_strtoul ((const char *) iter_pos, NULL, 10);
|
|
|
|
|
|
|
|
salt->salt_iter = iter - 1;
|
|
|
|
|
|
|
|
// af
|
|
|
|
|
|
|
|
u32 af_len = token.len[5] / 2;
|
|
|
|
|
|
|
|
if (af_len != (key_size / 8) * LUKS_STRIPES) return (PARSER_LUKS_FILE_SIZE);
|
|
|
|
|
|
|
|
const u8 *af_pos = token.buf[5];
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
luks->af_len = hex_decode (af_pos, token.len[5], (u8 *) luks->af_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// ct
|
|
|
|
|
|
|
|
u32 ct_len = token.len[6] / 2;
|
|
|
|
|
|
|
|
if (ct_len != LUKS_CT_LEN) return (PARSER_LUKS_FILE_SIZE);
|
|
|
|
|
|
|
|
const u8 *ct_pos = token.buf[6];
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
hex_decode (ct_pos, LUKS_CT_HEX_LEN, (u8 *) luks->ct_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
return (PARSER_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
|
|
|
|
{
|
|
|
|
luks_t *luks = (luks_t *) esalt_buf;
|
|
|
|
|
|
|
|
// cipher mode
|
|
|
|
|
2022-07-13 06:49:27 +00:00
|
|
|
char *cipher_mode = "";
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
switch (luks->cipher_mode)
|
|
|
|
{
|
|
|
|
case HC_LUKS_CIPHER_MODE_CBC_ESSIV_SHA256: cipher_mode = "cbc-essiv:sha256"; break;
|
|
|
|
case HC_LUKS_CIPHER_MODE_CBC_PLAIN: cipher_mode = "cbc-plain"; break;
|
|
|
|
case HC_LUKS_CIPHER_MODE_CBC_PLAIN64: cipher_mode = "cbc-plain64"; break;
|
|
|
|
case HC_LUKS_CIPHER_MODE_XTS_PLAIN: cipher_mode = "xts-plain"; break;
|
|
|
|
case HC_LUKS_CIPHER_MODE_XTS_PLAIN64: cipher_mode = "xts-plain64"; break;
|
2022-07-05 03:49:04 +00:00
|
|
|
default: return 0;
|
2022-06-15 11:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// key size
|
|
|
|
|
2022-07-13 06:49:27 +00:00
|
|
|
u32 key_size = 0;
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
switch (luks->key_size)
|
|
|
|
{
|
|
|
|
case HC_LUKS_KEY_SIZE_128: key_size = 128; break;
|
|
|
|
case HC_LUKS_KEY_SIZE_256: key_size = 256; break;
|
|
|
|
case HC_LUKS_KEY_SIZE_512: key_size = 512; break;
|
2022-07-05 03:49:04 +00:00
|
|
|
default: return 0;
|
2022-06-15 11:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// iterations
|
|
|
|
|
|
|
|
u32 iterations = salt->salt_iter + 1;
|
|
|
|
|
|
|
|
// salt
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
char salt_buf[LUKS_SALT_HEX_LEN + 1] = { 0 };
|
2022-06-15 11:01:22 +00:00
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
hex_encode ((const u8 *) salt->salt_buf, LUKS_SALT_LEN, (u8 *) salt_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// af
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
char af_buf[LUKS_AF_MAX_HEX_LEN + 1] = { 0 };
|
2022-06-15 11:01:22 +00:00
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
hex_encode ((const u8 *) luks->af_buf, luks->af_len, (u8 *) af_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// ct
|
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
char ct_buf[LUKS_CT_HEX_LEN + 1] = { 0 };
|
2022-06-15 11:01:22 +00:00
|
|
|
|
2022-07-05 03:49:04 +00:00
|
|
|
hex_encode ((const u8 *) luks->ct_buf, LUKS_CT_LEN, (u8 *) ct_buf);
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// output
|
|
|
|
|
|
|
|
int line_len = snprintf (line_buf, line_size, "%s%s$%u$%u$%s$%s$%s",
|
|
|
|
SIGNATURE_LUKS,
|
|
|
|
cipher_mode,
|
|
|
|
key_size,
|
|
|
|
iterations,
|
|
|
|
salt_buf,
|
|
|
|
af_buf,
|
|
|
|
ct_buf);
|
|
|
|
|
|
|
|
return line_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
void module_init (module_ctx_t *module_ctx)
|
|
|
|
{
|
|
|
|
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
|
|
|
|
module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT;
|
|
|
|
|
|
|
|
module_ctx->module_attack_exec = module_attack_exec;
|
|
|
|
module_ctx->module_benchmark_esalt = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_benchmark_mask = MODULE_DEFAULT;
|
2022-07-15 15:17:57 +00:00
|
|
|
module_ctx->module_benchmark_charset = MODULE_DEFAULT;
|
2022-06-15 11:01:22 +00:00
|
|
|
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_dgst_pos0 = module_dgst_pos0;
|
|
|
|
module_ctx->module_dgst_pos1 = module_dgst_pos1;
|
|
|
|
module_ctx->module_dgst_pos2 = module_dgst_pos2;
|
|
|
|
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
|
|
|
module_ctx->module_dgst_size = module_dgst_size;
|
|
|
|
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_esalt_size = module_esalt_size;
|
|
|
|
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_binary_save = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_decode = module_hash_decode;
|
|
|
|
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_encode = module_hash_encode;
|
|
|
|
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_mode = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hash_category = module_hash_category;
|
|
|
|
module_ctx->module_hash_name = module_hash_name;
|
|
|
|
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook_extra_param_size = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook_extra_param_init = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook_extra_param_term = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook12 = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook23 = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook_salt_size = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hook_size = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_jit_build_options = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_kern_type = module_kern_type;
|
|
|
|
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_opti_type = module_opti_type;
|
|
|
|
module_ctx->module_opts_type = module_opts_type;
|
|
|
|
module_ctx->module_outfile_check_disable = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_potfile_disable = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_pwdump_column = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_pw_max = module_pw_max;
|
|
|
|
module_ctx->module_pw_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_salt_max = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_salt_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_salt_type = module_salt_type;
|
|
|
|
module_ctx->module_separator = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_st_hash = module_st_hash;
|
|
|
|
module_ctx->module_st_pass = module_st_pass;
|
|
|
|
module_ctx->module_tmp_size = module_tmp_size;
|
|
|
|
module_ctx->module_unstable_warning = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
|
|
|
}
|