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-512 + AES";
|
2022-07-05 03:49:04 +00:00
|
|
|
static const u64 KERN_TYPE = 14631; // 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$sha512$aes$cbc-plain64$256$71794$33221dc8fd2e55f191e19d77fe95f86f91af4c1858d65ccd0cfee1f515c84b97$177cb301cb1aac12235f6b619b48b0e4d8351ae45880e2aeefb6ab12ab489818472c46aa3b9dc9d948226ded327631d26e2bac9c7d23e8a7b6e9f1f307346c02d28b8aff8e0b1466e33b8b0b55de0a585f79d8045fb9f7c870999676b44defbd03b6d5d3e1deecab07961aa8b96067fce031167b8cfc5c1cc4d328f55dd9631c004c08bdb01b6579b468e3a67b50e782762fef9952868c1c768a80cc112700713219e97c1dedaeb3e46ed5c7addd4f3ce39000d5a765601e1e94bb87bcc7ed5dce6ba3cb49bb1a671fc3130d383981ebfa168574300658987532b3d86610a4dcddfd752bb91b018fdde1c61a40f778814f31bbf9e5252f23a6b042e15dfa5fb912f8600d5317681c2adf10f9510f3a27ae8749c93fd93766f3cf3a40426b1603c1b4f0aeea165e14050042ab2ec93e0a5a49512bb00ad7928393b278845826d81e558fb3c04946873bf471d8fce7bd035379d1e28db35b03d67f9a41bc399d605311a85777d6fe1742519fe84ea6c0f5eed8548be16425eaa5479216b46b638339b33194dc50950acc2123cf87824cbf58de925a85054ca4623f3ff5f7cb754fbb61c5f7be15a5f29680065beaf7428bf1c300779bf1b1d070f862a311cda8345aa5326d55cc361a86d3962a4a0708de9b10246acb68051699942f3d55109dce28f6cf522c70741e0a121f21ec160c0346eecfd50eb583cf9137abb84dafd621eae6ebb5b5b9def75edb25866aa3c43280841895d7d5d007fd12f89428e30e03aef8ce1f5f345b996dfb33dc1193085827055d0dbd255f51abe2d79e9babe1d31d492cb0c74b2021147e95da8e485399eed26a0a3092281a0780bb378fa5c27e4b17b465db350df5248e463daf4a47227856b9e51eedfc6a754d754e84efb808eb77a87e8eab7c96f72262a067a7b8c7a43e611de29cf4418195adef3c13b5933bd72e493ea0d87a878214282534a793eac250157f3599f6dedc8bd7407c198e41be34217e085eab32a16839d3516fda8bbbfc736dcc9342a1f164127b4aadc2a090304b002d2f303f0f0ef82f212ae06eb60a86b59dca5589e14736bbc9e032c5b5513f71e31dc7c049553c163c371cfc514ec92aa6cb635ef8cfb6e2d2c7883f139c3f0d95372631d59d2db3d4cb6a56a279c19cf429f9f029c8a2540e92992194bd3ce233b9fd896127692d2a5796fcdb2c4e2f3509a6381fe7a375fbc52095efe8669ddf2299562953068110a4ce005d926b7dd6e3b49bf26ff2669fbdbbe3f4693ece2eef2d0864165dc24a9abd3cf18d1ada7cde6b7899cc1f8326dbf4bee504a7e16e579d99363371dfba82937d8ced95ee4afd5891730219eb4ca51f534edcfa63fce40ccc6b3d0fa2e01b3d59df350f00a72eb83a71beec2f8e74ae03b9be5c11ef1d52ec9f673f5348eed73ec377e2858a1e7feec07733c89810edbb7932f0eb251dca4124e369b5627fd6ab04f1b53a2266cd2b0513d1ba975b63a9fa55cf48ac05b8383fab3711e3a0765b5a6e537fd45a4cd3d3dbdff102d066ef34d63a820242eeb4811fb55abd961823a4c83a9512f280e010d630bb3af213114168293536bd8896e7c3829a79018fa43c4423119bdf16a0c36c56ff29f5369848ddbc350a1a0bc01df6ca0bdef26752d97ffaa492b6b53f3f4ebb57dd557a37f909995ebe9260547d40c3b00fba1113a186016bc85b3c066c2977b4bcbdf3f3dbb70c30745a37d42fc4c755678f667792177ace0e155b050b0f7e9f78c2bf3dc14dfd3439310a2237dcc25d9c81468b949db592b1558a5b2ebedbc2c0e6bf69ae38016e48c25616e1bfb713ad66f3deecdeef7420f06e820ee242fcc53283cbaf8ef4f977efa06e91d8bc4d63a65b602f1d1ca1305eb26363c9412bcdbe31b8174a865ddfad76a02b0cf9aacec65db76f8b4957aa7b17e8430952ee3ce627294b74b6994b7a10bc3eeb3fbc97f1b5b0a2c1d3819f118d8c6107b430a119da379595e2ddc18f3725e8d2f875d91d90d9b6cdb4bf31c3834c935e19f4441cfade3ba5946dde8b2502726596fba48b9509a70130892fb04fb511274f18897af2101deb2a4106bc932ed03f5d43541c4c5d9b286725dc461fee6e6f4b7d9531b3de097868a56f6b5475b62929a6b7af5a208d3fbcd787c7155c4bbde1d946a4cd186374e2211770a9bb026d406ac7b5e44466e625fb25f4285940f022b4be45c9bdae746581757ae98df33206292ffdccfe3a039ca390c01ffb5e2c04bf8181c93d647e788d17b9c819c6601ed83c695a65c6abed151a359b1fa41f31ae97fc6424eac51957810dff12941fe12f3639fc2964ba206875cba90b4919098ba57a5963b70e36baccf4e90ef2455afcc68b0c57406e247175f2cebe0a37c5f4a67f23a2bbd284f95d783953299da868f805e4ea037fb99c2acf8e7fd3d8427f1875a2188cd6d66a69cbb1e118fe1e662f8d64bb85b305029ae9e7aea7ba6b46c4eb99cc9202bdc63861f1a34f2b1a73ad2fc58bbda90daf51b8114544fae1bdebf3d7fb449aa959fb65762758eedf5c0d197ef64aa073920c92c91f5f8a60ed588a7d8b553a34cf270e47bdc6fe8dae065963d45994af7bcb486c4e1a7eb640d3ec53592001b7cd32d6515735d154c6db3d880f975ea17f95bf687fcffe3ccad2a2fc9ca2af7985891526a869f5cefb5086d6f8d54080cc6e393c7b9c61ae9565a8f79dc88880fe41dde7063b0839f82b228d174563ecbedcda7b55fc17e8c2c431189391b5c149cf751795387a8e05c95fc56018040a149a146f
|
|
|
|
|
|
|
|
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$sha512$aes$";
|
|
|
|
|
|
|
|
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] = 19;
|
|
|
|
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_SHA512;
|
|
|
|
|
|
|
|
// cipher type
|
|
|
|
|
|
|
|
luks->cipher_type = HC_LUKS_CIPHER_TYPE_AES;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|