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 + Serpent";
|
2022-07-05 03:49:04 +00:00
|
|
|
static const u64 KERN_TYPE = 14642; // 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$serpent$xts-plain64$256$107691$de4943f59812487b6fdde7cc4a2126286070f2b658cb3cc3b78f3b6c174f94eb$285fce333f51d9383aa24f70940ebaf06a2ff9e8ed1ef523f39e21b5254ac38795536d0eaa3e89ce5dde836ae67dbd20f866c8ef809e0e0100f986f5fd82e91db794f1f5821195c98b742783a17da1e9523930f7550c817d5ea8fc17e53d3e62aab900787c1a276944919c3d10c6da3c669b77918bdde58a608f6d4475073c1d394492f04fccdbead2f85f3d5321e357419c40d26975ef566970b18e56cb47fe887bd5eeff2009c71f777255a8f4b1ddd26b90397e5340acb76cfb403d8132a63aa2b6be0b78180c3d8a80ac55ed275e96a86a57bb6ffcd26dd27abb50ef524fd4e569922c987257038327c95eba030d685e21164c58aecb7eb19887bdbacf1d398d48d62dae89241f09fb7d5e0d4736243419f09dddbdae271895b40f49b0c26196669d582f8769c53fe70d227c5302da1008f899bfcd5c490379d42f8bf508a3a33a3e3107468f57688fc49c25e48c7b25e1a544c1945cdbee7bb47bfee5413571a0a0ff2c1e34eb5dc1dd126cd801e5da87e2354240025a592ae2a0b08069d50cc1986b7fec35db668ac81198a905a10caa005bb6a77291d73008e7a3c01c29438e068a7479dc86aa10b3fff3717435af5074e1edbe5144b817a67b10c0ab07aa68f92fba10e64ea9d06da88e8235e342a27cd46b03883aa932d94e7817d35c36f208e608516e227c9d80bcc077ca40f42964cadeaccee99a1253461b18bf1d5d96c2d42af563afe233c12ed1f7addddc35957b0de57ee6c93817fc6bb134cc82bac044d561951b93c98325d1dcb9fbc991e85c6bc507034161949d7dbf2c65e765d5fab5d814512f75009fd74ccb11f680fafefb4fb51d5237d6f7aa4b93875ee908bafd8539d15b65a0e02bf96794c8045f08014bf3fe8be2cc4048d3ed6df40c7be6668e63c5973763a55b59622390e22f0fef4d54631d17c71eb973b7846474dbc1c00bcb395bc885320cf683d2f01252b5c2c03458720db374050fe19352295ed3ff99af4404ce37aebaeea38de9365cbf65e53f0263925f9100d7e9be2eedc05e551c5c68d40c0bd3ba5fdb9683c4339de5882f02d8e5d3dcecfa49c205be188d90efc6a1d951821f1cf21633d9de3a465a1146980a408adaef83b32b28b2f03c72deeb022b27769cd0903401cf6418a4d66c18831bf6c5bedecda4a9010295d00d98b59b1e5758f35faa01e9a18247fe841421c6454f76b72513c56dbaabf6bc1c5fe788ab7bb529cfdc26055a04331c43eb7468d013b57ba891b5ef7b75d118024edcbd403a950f2b64d66e6573ee8ecd8f1a58b8e4048aceb6ce11cb8957b895f2eb80c0d8ebcc2cd33d7a4f97bcd1581b18b4cff195b06e7e2f909f6aea276ea0195605c540377cfa4d283160be41ed692f15f2c63bbb5a3c84aff8e628f45e5be383bc2d058eaacba312fdc4fb244e9f901b0986df5ab2ecd8c16e660e43f872489e2e333ba257de84c83502b5aec976580f2458eadfdc450383add589ea3162be7295f6a8c6be9bdc38d212fe2549b243408a4d30fadcace98db15f3766c254e67f8be74e2fa8222ce7c6760c878e3f22f0919e0c4902234f50d9728448243110a6426bfc613c6a133c48554865b087600b4e37d8197e0d3dfb9d8e683026102dda1c5a29fba6a41f7c8c19b1c42bf11599ad21f35bbb1ff3678f8e34f76e617e31ee7a76f4f0c20f9f01109647c1d6ff286221c99d587bf273f66320ad12f0da0ff10e7de60bb0207413a746d6f56a09b1961be90823ce62c179008c626c5b673e3935c752ac716038cb01cc31b8ee1174a5c0d8c5c623ee200da926110f27d3a9354a8ba60f785a8844c3bb35b614e60b73232b21636ebea4acc800e11546c9ab288d02cbe8be7a72577c664a26bbff29e42d110ca6a014488b16da45a871d4f7caf185aaf9ae403f7e226ecb8cf459ec523cd77aa5dc2b10d67006aaba896596a299457f3e8862adf28c0082b54a73cad4e4f827d32f4ef4eb903cd07f27571756fb41283dec996114f695b0b1bc5692a7176166ee0dbe32d5e0e35844440a378b0977a9326f68add39fe02fb562ab1b73a32d12ef20dd724456be8ec81fd5de8a039d446c5a516b0aa154de5c5d6552f5ecb9846a0736d85abe3a93c4154b3ad2563b38cdbc65dca22adf7c8a975f114d7c384964238d4a681930e3ee0c1a81009d75665d14d1c2624c94f0b76ff14a7422ad83937ccfdb52479bfc655f7934d955e64e4df05e4d2f7e74f6ea4e28aa2162384dd74520aaccf97736b7d287741cfcc850bfc954cf7d8c6bcc9ef4cbbc09147db347a429c55c76d18dd22c1de52b87fb282dbd40b6c6de5ee775f1f665e8031ecbaeeff8a6d7fb3a746f630f9950d8d02c69dc4597dc8f40222faf6b76c441513520eaca0e4ac6e7ab7ba580e15e34d328c1fbcb4a74ae34ef2767035f072cf53ccef043b5ed7dad5f0307da367ecedb49e21119c6bd59eea7a1d252c615fbbc586ac78d19f2264391b354abbdf2a6113408e370313cbee53fced24a574dc08431e94dd74bea0e9725fa7fdfac52de03dae71d2677bef9e029d594d1669819484deba98b38b21d7a163a209a7c837d332c86112ca505ced7e0d9810aa7036215ac26d32a28fca3254886cd1a8fd302ec7d3e75ddcda99cfd6bd9b41b92306b299f54e022542d46d182ef5c4b2b2bf80c410a3c4325fa7ce1a059232ae08c301fa95a4c60a485cf73c767371a9e2913c69d701724791862c15afe89517d27bea042d134f4b7263524701a51173d91049dffba4fa322261b0d
|
|
|
|
|
|
|
|
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$serpent$";
|
|
|
|
|
|
|
|
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_SERPENT;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|