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 RIPEMD-160 + Twofish";
|
2022-07-05 03:49:04 +00:00
|
|
|
static const u64 KERN_TYPE = 14643; // 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$ripemd160$twofish$cbc-plain64$128$107691$262bb8c34b794cb0f3fa2e093662c0461a2213a152d57fd442672cc724de2c31$b7b51690133c8629c7428f82e06b48f33afe1fd508badbc86eac39aa76adedde4f1caf6e3978c41d20b30f52d8a7f359975be11b0116c943e8dea98815785036992968a9df92abd43fbe9a1885ec8f69007984b8b52f54c07d4e799ea6002b5a55f051a0247ee406f5185ffe736c4ac57e59c58e736ed17b0880d6893ac0ec822a7b2a1fd5b67e6732b7f7a5a9993bceecacf4ea92f0cd8d636bdc8cd506df99f915e10d1708399c0d574bfb9ca7aa6afa83678503dae53f21e222bef616e724697168a0e6dddf933062764f7d3990635934b4489130976ff90ce6a9da77c29d4cf8335e0977c135146976c69648ed289a66584c4dae3930799772fc404b114e88209db4ccb33514d595ca921ccad71ef12161cfb93048c1d858abf825c2b24d4fb93be516e5400f2bd3a6264ee16bec15d57c8baeb151461d499b0077c10a35b7c91a8f8d58ade772bad33d09d350568a183576a296cbd98b9492f6bd5a0d44566f9177c645a8d18865068da884950a454a7741f621b98ce1364b36b7448b9e3f22d9a682c759743edc58ecb8d0115c41879510ad7118829e6e5699a6ee54e5dde3993613132e5d8a692fba0548cbf5bfd980efacae7b57cf5c47d4631b6283da320461c2565c0912c2d5179196fb79250d98d8181208046986f231111cc1ec631c2388c7cf827b2b97cd848c31616d6c5c79d86702001d6017b1cc83d4bcd2b2dcffda79e398c519ce4cbab49147c1b4afbcf7c85c77d2c946ad5cc2345e3a5712f8fd469229973dcfae647ff127cb9427f5d3c5257c789ff13adb3c033ea26b48e7eb1682a6071dfc15ee4cf78fc78bd2db7d31287c4524566b3f60370d63fc6b76c97d4b2365fa363e597a4d6076a70b96468e1f5176f0c32429083a6d8c285b03c1d15393521359d6ccf2f814056f5d6e7951059c90d4c48a96c4f63168b380acd53b275b964abecbbaa5fb16f3e360063031b70c0aa90fad2e7d0a98d480d266ed4353b75a20c8d56d8975fa126fc8bc93b54a185c2494af06933519c17df27d04a319ade211b6c24891a0f8e5f39c4fb5d6584e792c917383ff041d0c938537f85ed593132c489c6694f06ace47cf1a61c9ee1450287dfb9635cd4f596e0582dcb50e58c08f6ebd7125a7d31718259fbde1ce527bf1fd9f0fb174ca65567e1a427eee57f07566b2a35dd8766eabaf578cf67a0c8563f5bf9a655937158cd83c92f6df04db25eeffaddaed6ad9887a36b7f18ea72182213be6f4fc3c6058214306eccfabacd51d9c822d165d7a31cf6b2e681e9a4cbc8a661a8cdfd4e70fcc9aa40ff719c5e5d6d95944a8f8d8147985bba198fd74620dff09881ff745fdcd24ad38290a2196292f6b7831caa91607da73ab10ad17416ef6957574b353adac36de1ec1d76b7cf160743aa8aed3fd6c316021edbcf4813d644249d82f0d3e577882625eacd156c59d8fafbfee10bcdf863a74973856cf0b501da83aff8d55f6dec82df267916802d200b4d353b01a9befc520c73a9041ae4e92792d156655847b2dcf6d1a5e2015de1d2238880587560fe2240bca6da0cac3985cc164dbee92186d8848988b6f192fd1cf571983e489800adf34dd70325430ad4db6d54bbbcd10b6b043897ee9e753ceb83f387c068ec4e2f8eb952912103ae2c7db09d91b0795d999edc4fd5b3af395e622c749dcacc4a84dc7de3b5b4527f14deee7c8fe6acbd4332c8f6c05e5281bef0656d0a273d6ffff10ff035c090ef982d0935931a4a415a26736c3347cdffe975edafa2ebeedfdaf21a89416285ec1a36a2bcb8fb5841c25849d8836b62baca447c38f39e727e79708274bba8272b444fea3e0ae8151b0102138e4d066b42d0349b91bd6acc2ef2d4938c58d2c618fa6189261ae9d42bc57bcd1a5f97c84dd564051cf784203df58108e746a70b636f919082799082e4013328bef1b50b82ba7ddce3a4d357760a5a6938b4c6d955bbcab3b308ef0a32901601a7626d239f0345dda04b45a62ed02bdba43f1af6c07987e3149105b3e1aefa885952ab9c124bedaf4a5c71738ae7c135589b4e25c6a2388ecf2aa0dfb8617f81bdde59032d8f8e7a9c683a20303e8e418b6b7e5af2ecb61d1e40a160ddbc3426b69195ee27ddbc9b1a5532da255c78edc3d4ce761db1cc3544ebb59fb177327585ac431a59dbd5755488651c0f085e1a178701173dc2028598a240f00ef1591af52939ac39390bb6f3ec9f2a0fe83f0bff11c3f0e54f2abe89b460481396c6990039731bf50623019f983635d02d45ac9e97ea73f4ec0177c9254f042ccc29d567f052aa2656992974a4483f81c46d0fcb41fb2314dd6a141e5845a15aae21deca5b749df616d30d7c0b3740b8e9a76de87c4103850c7213d408904ee864b12dc1ce76381432f4066d85920478c6c1fb534236db6642a551c374448e99159634f2f023c64e5577b87e9723cb67c619017f42ca9aed97e730710911a35facced5b094becbe54e3067f408a103e42164141f5861bcbd0f8d97305f7b438c577ef2c5376e131eb0dabcee5c6ce785626fe1598c376ccd65172b15d3ec96fbf9d5eb70016cbe162dcdc943697f34bb38c4d4a3926fb671e9a49524edae9dc1c13db1717cacca9dd98772c7d344ff06488fd3a5993af3375f121d27a125063ecedf1bb271e5e92810703a895f2c4158e2c4fecad06a03fa2c2b80022598b947b628eebde45cbad5bc09c9490c982c03d8d5f30d7369e4791c01387fa87808afa47099500874e07d6755302211aa42076
|
|
|
|
|
|
|
|
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$ripemd160$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] = 26;
|
|
|
|
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_RIPEMD160;
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
2023-08-18 19:22:13 +00:00
|
|
|
const luks_t *luks = (const luks_t *) esalt_buf;
|
2022-06-15 11:01:22 +00:00
|
|
|
|
|
|
|
// cipher mode
|
|
|
|
|
2023-08-18 19:22:13 +00:00
|
|
|
const 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;
|
|
|
|
}
|