2019-03-21 19:18:39 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
PKZIP Kernels for Hashcat (c) 2018, European Union
|
|
|
|
|
|
|
|
PKZIP Kernels for Hashcat has been developed by the Joint Research Centre of the European Commission.
|
|
|
|
It is released as open source software under the MIT License.
|
|
|
|
|
|
|
|
PKZIP Kernels for Hashcat makes use of two primary external components, which continue to be subject
|
|
|
|
to the terms and conditions stipulated in the respective licences they have been released under. These
|
|
|
|
external components include, but are not necessarily limited to, the following:
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
1. Hashcat: MIT License
|
|
|
|
|
|
|
|
Copyright (c) 2015-2018 Jens Steube
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
|
|
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
|
|
portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
|
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
2. Miniz: MIT License
|
|
|
|
|
|
|
|
Copyright 2013-2014 RAD Game Tools and Valve Software
|
|
|
|
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
|
|
|
|
|
|
|
All Rights Reserved.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
|
|
documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
|
|
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
|
|
conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
|
|
portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
|
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
The European Union disclaims all liability related to or arising out of the use made by third parties of
|
|
|
|
any external components and dependencies which may be included with PKZIP Kernels for Hashcat.
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
The MIT License
|
|
|
|
|
|
|
|
Copyright (c) 2018, EUROPEAN UNION
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
|
|
documentation files (the "Software"), to deal in the Software without restriction, including without
|
|
|
|
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
|
|
|
conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
|
|
portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
|
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2019-05-10 10:50:03 +00:00
|
|
|
Author: Sein Coray
|
|
|
|
Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp5g=
|
2019-03-21 19:18:39 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "bitops.h"
|
|
|
|
#include "convert.h"
|
|
|
|
#include "shared.h"
|
|
|
|
|
|
|
|
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
|
2019-05-10 10:50:03 +00:00
|
|
|
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_8;
|
2019-03-21 19:18:39 +00:00
|
|
|
static const u32 HASH_CATEGORY = HASH_CATEGORY_ARCHIVE;
|
2019-05-24 20:11:51 +00:00
|
|
|
static const char *HASH_NAME = "PKZIP (Mixed Multi-File Checksum-Only)";
|
2019-03-21 19:18:39 +00:00
|
|
|
static const u64 KERN_TYPE = 17230;
|
|
|
|
static const u32 OPTI_TYPE = 0;
|
2022-04-08 12:11:50 +00:00
|
|
|
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
|
|
|
| 0;
|
2019-03-21 19:18:39 +00:00
|
|
|
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
|
|
|
static const char *ST_PASS = "hashcat";
|
|
|
|
static const char *ST_HASH = "$pkzip2$8*1*1*0*8*24*a425*8827*3bd479d541019c2f32395046b8fbca7e1dca218b9b5414975be49942c3536298e9cc939e*1*0*8*24*2a74*882a*537af57c30fd9fd4b3eefa9ce55b6bff3bbfada237a7c1dace8ebf3bb0de107426211da3*1*0*8*24*2a74*882a*5f406b4858d3489fd4a6a6788798ac9b924b5d0ca8b8e5a6371739c9edcfd28c82f75316*1*0*8*24*2a74*882a*1843aca546b2ea68bd844d1e99d4f74d86417248eb48dd5e956270e42a331c18ea13f5ed*1*0*8*24*2a74*882a*aca3d16543bbfb2e5d2659f63802e0fa5b33e0a1f8ae47334019b4f0b6045d3d8eda3af1*1*0*8*24*2a74*882a*fbe0efc9e10ae1fc9b169bd060470bf3e39f09f8d83bebecd5216de02b81e35fe7e7b2f2*1*0*8*24*2a74*882a*537886dbabffbb7cac77deb01dc84760894524e6966183b4478a4ef56f0c657375a235a1*1*0*8*24*eda7*5096*40eb30ef1ddd9b77b894ed46abf199b480f1e5614fde510855f92ae7b8026a11f80e4d5f*$/pkzip2$";
|
|
|
|
|
2019-06-07 13:52:37 +00:00
|
|
|
#define MAX_DATA (320 * 1024)
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-05-10 10:50:03 +00:00
|
|
|
// this is required to force mingw to accept the packed attribute
|
|
|
|
#pragma pack(push,1)
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-05-10 10:50:03 +00:00
|
|
|
struct pkzip_hash
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
|
|
|
u8 data_type_enum;
|
|
|
|
u8 magic_type_enum;
|
|
|
|
u32 compressed_length;
|
|
|
|
u32 uncompressed_length;
|
|
|
|
u32 crc32;
|
2019-05-17 13:28:49 +00:00
|
|
|
u32 offset;
|
|
|
|
u32 additional_offset;
|
2019-03-21 19:18:39 +00:00
|
|
|
u8 compression_type;
|
|
|
|
u32 data_length;
|
|
|
|
u16 checksum_from_crc;
|
|
|
|
u16 checksum_from_timestamp;
|
2019-06-07 17:42:28 +00:00
|
|
|
u32 data[MAX_DATA / 4]; // a quarter because of the u32 type
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-05-10 10:50:03 +00:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
typedef struct pkzip_hash pkzip_hash_t;
|
|
|
|
|
|
|
|
struct pkzip
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
|
|
|
u8 hash_count;
|
|
|
|
u8 checksum_size;
|
|
|
|
u8 version;
|
2019-05-10 10:50:03 +00:00
|
|
|
|
2019-03-21 19:18:39 +00:00
|
|
|
pkzip_hash_t hashes[8];
|
2019-05-10 10:50:03 +00:00
|
|
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
typedef struct pkzip pkzip_t;
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
static const char *SIGNATURE_PKZIP_V1 = "$pkzip$";
|
|
|
|
static const char *SIGNATURE_PKZIP_V2 = "$pkzip2$";
|
|
|
|
|
|
|
|
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; }
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2020-07-15 09:27:46 +00:00
|
|
|
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
|
|
|
|
{
|
|
|
|
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE)
|
|
|
|
{
|
|
|
|
// self-test failed
|
|
|
|
if ((device_param->opencl_device_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-03-21 19:18:39 +00:00
|
|
|
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 (pkzip_t);
|
|
|
|
|
|
|
|
return esalt_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hex_to_binary (const char *source, int len, char* out)
|
|
|
|
{
|
2019-05-20 20:03:55 +00:00
|
|
|
for (int i = 0, j = 0; j < len; i += 1, j += 2)
|
|
|
|
{
|
|
|
|
out[i] = hex_to_u8 ((const u8 *) &source[j]);
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
pkzip_t *pkzip = (pkzip_t *) esalt_buf;
|
|
|
|
|
|
|
|
u32 *digest = (u32 *) digest_buf;
|
|
|
|
|
|
|
|
char input[line_len + 1];
|
|
|
|
input[line_len] = '\0';
|
2019-06-07 15:24:13 +00:00
|
|
|
memcpy (&input, line_buf, line_len);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
char *saveptr = NULL;
|
|
|
|
|
|
|
|
char *p = strtok_r (input, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
2019-03-21 19:18:39 +00:00
|
|
|
|
|
|
|
pkzip->version = 1;
|
2019-06-07 15:24:13 +00:00
|
|
|
|
|
|
|
if (strlen (p) == 9) pkzip->version = 2;
|
2019-03-21 19:18:39 +00:00
|
|
|
|
|
|
|
char sub[2];
|
2019-06-07 15:24:13 +00:00
|
|
|
sub[0] = p[strlen (p) - 1];
|
2019-03-21 19:18:39 +00:00
|
|
|
sub[1] = '\0';
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hash_count = atoi (sub);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
|
|
|
// check here that the hash_count is valid for the attack type
|
2019-06-07 15:24:13 +00:00
|
|
|
if (pkzip->hash_count > 8) return PARSER_HASH_VALUE;
|
|
|
|
if (pkzip->hash_count < 3) return PARSER_HASH_VALUE;
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->checksum_size = atoi (p);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
|
|
|
|
2019-06-07 15:24:13 +00:00
|
|
|
for (int i = 0; i < pkzip->hash_count; i++)
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].data_type_enum = atoi (p);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (pkzip->hashes[i].data_type_enum > 3) return PARSER_HASH_LENGTH;
|
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].magic_type_enum = atoi (p);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-07 15:24:13 +00:00
|
|
|
if (pkzip->hashes[i].data_type_enum > 1)
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].compressed_length = strtoul (p, NULL, 16);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].uncompressed_length = strtoul (p, NULL, 16);
|
2019-06-07 13:52:37 +00:00
|
|
|
if (pkzip->hashes[i].compressed_length > MAX_DATA)
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
|
|
|
return PARSER_TOKEN_LENGTH;
|
|
|
|
}
|
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-21 07:56:50 +00:00
|
|
|
u32 crc32 = 0;
|
|
|
|
sscanf (p, "%x", &crc32);
|
|
|
|
pkzip->hashes[i].crc32 = crc32;
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].offset = strtoul (p, NULL, 16);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].additional_offset = strtoul (p, NULL, 16);
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].compression_type = atoi (p);
|
2019-05-20 17:54:16 +00:00
|
|
|
if (pkzip->hashes[i].compression_type != 8 && pkzip->hashes[i].compression_type != 0) return PARSER_PKZIP_CT_UNMATCHED;
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-07 15:24:13 +00:00
|
|
|
pkzip->hashes[i].data_length = strtoul (p, NULL, 16);
|
2019-03-21 19:18:39 +00:00
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-21 07:56:50 +00:00
|
|
|
u16 checksum_from_crc = 0;
|
|
|
|
sscanf (p, "%hx", &checksum_from_crc);
|
|
|
|
pkzip->hashes[i].checksum_from_crc = checksum_from_crc;
|
|
|
|
|
2019-06-07 15:24:13 +00:00
|
|
|
if (pkzip->version == 2)
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
2019-06-21 07:56:50 +00:00
|
|
|
u16 checksum_from_timestamp = 0;
|
|
|
|
sscanf (p, "%hx", &checksum_from_timestamp);
|
|
|
|
pkzip->hashes[i].checksum_from_timestamp = checksum_from_timestamp;
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pkzip->hashes[i].checksum_from_timestamp = pkzip->hashes[i].checksum_from_crc;
|
|
|
|
}
|
|
|
|
|
2019-06-29 15:14:19 +00:00
|
|
|
p = strtok_r (NULL, "*", &saveptr);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (p == NULL) return PARSER_HASH_LENGTH;
|
|
|
|
|
2019-06-07 15:24:13 +00:00
|
|
|
hex_to_binary (p, strlen (p), (char *) &(pkzip->hashes[i].data));
|
2019-03-21 19:18:39 +00:00
|
|
|
|
|
|
|
// fake salt
|
2019-08-01 16:28:48 +00:00
|
|
|
salt->salt_buf[i] = pkzip->hashes[i].data[0];
|
2019-05-10 10:50:03 +00:00
|
|
|
|
|
|
|
if (i == 0) digest[i] = pkzip->hashes[i].checksum_from_crc;
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 10:50:03 +00:00
|
|
|
salt->salt_len = pkzip->hash_count << 2;
|
|
|
|
|
2019-03-21 19:18:39 +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)
|
|
|
|
{
|
|
|
|
const pkzip_t *pkzip = (const pkzip_t *) esalt_buf;
|
|
|
|
|
|
|
|
int out_len = 0;
|
|
|
|
|
|
|
|
if (pkzip->version == 1)
|
|
|
|
{
|
|
|
|
sprintf (line_buf, "%s", SIGNATURE_PKZIP_V1);
|
|
|
|
out_len += 7;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf (line_buf, "%s", SIGNATURE_PKZIP_V2);
|
|
|
|
out_len += 8;
|
|
|
|
}
|
|
|
|
out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hash_count, pkzip->checksum_size);
|
|
|
|
|
|
|
|
for (int cnt = 0; cnt < pkzip->hash_count; cnt++)
|
|
|
|
{
|
2019-05-14 12:00:18 +00:00
|
|
|
if (cnt > 0)
|
|
|
|
{
|
|
|
|
out_len += sprintf (line_buf + out_len, "*");
|
|
|
|
}
|
2019-03-21 19:18:39 +00:00
|
|
|
out_len += sprintf (line_buf + out_len, "%i*%i*", pkzip->hashes[cnt].data_type_enum, pkzip->hashes[cnt].magic_type_enum);
|
|
|
|
if (pkzip->hashes[cnt].data_type_enum > 1)
|
|
|
|
{
|
|
|
|
out_len += sprintf (line_buf + out_len, "%x*%x*%x*%x*%x*", pkzip->hashes[cnt].compressed_length, pkzip->hashes[cnt].uncompressed_length, pkzip->hashes[cnt].crc32, pkzip->hashes[cnt].offset, pkzip->hashes[cnt].additional_offset);
|
|
|
|
}
|
|
|
|
|
2019-05-20 17:49:32 +00:00
|
|
|
out_len += sprintf (line_buf + out_len, "%i*%x*%04x*", pkzip->hashes[cnt].compression_type, pkzip->hashes[cnt].data_length, pkzip->hashes[cnt].checksum_from_crc);
|
2019-03-21 19:18:39 +00:00
|
|
|
if (pkzip->version == 2)
|
|
|
|
{
|
2019-05-20 17:49:32 +00:00
|
|
|
out_len += sprintf (line_buf + out_len, "%04x*", pkzip->hashes[cnt].checksum_from_timestamp);
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
|
2019-05-14 12:00:18 +00:00
|
|
|
for (u32 i = 0; i < pkzip->hashes[cnt].data_length / 4; i++)
|
|
|
|
{
|
|
|
|
out_len += sprintf (line_buf + out_len, "%08x", byte_swap_32 (pkzip->hashes[cnt].data[i]));
|
|
|
|
}
|
|
|
|
for (u32 i = 0; i < pkzip->hashes[cnt].data_length % 4; i++)
|
2019-03-21 19:18:39 +00:00
|
|
|
{
|
2019-05-14 12:00:18 +00:00
|
|
|
out_len += sprintf (line_buf + out_len, "%02x", (pkzip->hashes[cnt].data[pkzip->hashes[cnt].data_length / 4] >> i*8) & 0xff);
|
2019-03-21 19:18:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pkzip->version == 1)
|
|
|
|
{
|
|
|
|
out_len += sprintf (line_buf + out_len, "*$/pkzip$");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out_len += sprintf (line_buf + out_len, "*$/pkzip2$");
|
|
|
|
}
|
|
|
|
|
|
|
|
return out_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;
|
2019-03-21 19:18:39 +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;
|
2021-08-10 15:59:52 +00:00
|
|
|
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
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;
|
2021-08-01 14:25:37 +00:00
|
|
|
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
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;
|
2021-11-28 12:58:27 +00:00
|
|
|
module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT;
|
2019-05-10 10:50:03 +00:00
|
|
|
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
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;
|
2019-05-10 10:50:03 +00:00
|
|
|
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
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;
|
2019-05-19 12:46:05 +00:00
|
|
|
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
|
|
|
|
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
|
2020-08-29 14:12:15 +00:00
|
|
|
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;
|
2019-03-21 19:18:39 +00:00
|
|
|
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;
|
2019-05-10 10:50:03 +00:00
|
|
|
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
|
2019-03-21 19:18:39 +00:00
|
|
|
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_DEFAULT;
|
|
|
|
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_DEFAULT;
|
2020-07-15 09:27:46 +00:00
|
|
|
module_ctx->module_unstable_warning = module_unstable_warning;
|
2019-03-21 19:18:39 +00:00
|
|
|
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
|
|
|
}
|