PKZIP: improve decompression and allow up to 320KB data length

pull/2053/head
philsmd 5 years ago
parent 581839d402
commit 316b2952b5
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF

@ -263,13 +263,13 @@ enum
} \
MZ_MACRO_END
//case state_index:;
#define TINFL_CR_RETURN(state_index, result) \
do \
{ \
status = result; \
r->m_state = state_index; \
goto common_exit; \
case state_index:; \
} \
MZ_MACRO_END
@ -411,7 +411,7 @@ typedef struct
tinfl_decompressor m_decomp;
mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed;
int m_window_bits;
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE];
mz_uint8 m_dict[1]; // hashcat-patched: we do not need m_dict because we have our own output buffer
tinfl_status m_last_status;
} inflate_state;
@ -458,7 +458,7 @@ int mz_inflateEnd(mz_streamp pStream);
int mz_inflateInit2(mz_streamp pStream, int window_bits, inflate_state*);
const mz_uint8 pIn_xor_byte (const mz_uint8 c, mz_streamp pStream)
DECLSPEC const mz_uint8 pIn_xor_byte (const mz_uint8 c, mz_streamp pStream)
{
mz_uint8 r = c;
@ -472,7 +472,7 @@ const mz_uint8 pIn_xor_byte (const mz_uint8 c, mz_streamp pStream)
}
void memcpy_g(void *dest, GLOBAL_AS const void *src, size_t n, mz_streamp pStream){
DECLSPEC void memcpy_g(void *dest, GLOBAL_AS const void *src, size_t n, mz_streamp pStream){
GLOBAL_AS char *csrc = (GLOBAL_AS char *)src;
char *cdest = (char *)dest;
for (int i=0; i<n; i++){
@ -480,7 +480,7 @@ void memcpy_g(void *dest, GLOBAL_AS const void *src, size_t n, mz_streamp pStrea
}
}
tinfl_status tinfl_decompress(tinfl_decompressor *r, GLOBAL_AS const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags, mz_streamp pStream)
DECLSPEC tinfl_status tinfl_decompress(tinfl_decompressor *r, GLOBAL_AS const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags, mz_streamp pStream)
{
const int s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 };
@ -944,7 +944,7 @@ common_exit:
}
int mz_inflateInit2(mz_streamp pStream, int window_bits, inflate_state *pDecomp)
DECLSPEC int mz_inflateInit2(mz_streamp pStream, int window_bits, inflate_state *pDecomp)
{
if (pStream == 0)
return MZ_STREAM_ERROR;
@ -972,7 +972,7 @@ int mz_inflateInit2(mz_streamp pStream, int window_bits, inflate_state *pDecomp)
return MZ_OK;
}
int mz_inflate(mz_streamp pStream, int flush)
DECLSPEC int mz_inflate(mz_streamp pStream, int flush)
{
inflate_state *pState;
mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
@ -1102,3 +1102,101 @@ int mz_inflate(mz_streamp pStream, int flush)
return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
}
// hashcat-patched: helper function for shifted u32
DECLSPEC u32 GETSHIFTEDINT (u32 *a, const int n)
{
const int d = n / 4;
const int m = n & 3;
u64 tmp = hl32_to_64_S (a[d + 1], a[d + 0]);
tmp >>= m * 8;
return l32_from_64_S (tmp);
}
// hashcat-patched: faster memcpy for our large (TINFL_LZ_DICT_SIZE) move of bytes from the old output to the window/lookup table
DECLSPEC void hc_shift_inflate_dict (u8 *buf, const u32 offset, const u32 len)
{
u32 *ptr = (u32 *) buf;
// we need to use len - 4 here to avoid buffer overflows caused by the u64 type in GETSHIFTEDINT
u32 i, j;
for (i = 0, j = 0; i < len - 4; i += 4, j++)
{
ptr[j] = GETSHIFTEDINT (ptr, offset + i);
}
// final step (last 4 bytes are special):
ptr[j] = (buf[offset + i + 3] << 24) | (buf[offset + i + 2] << 16) | (buf[offset + i + 1] << 8) | buf[offset + i];
}
// hashcat-patched: the mz_inflate () function from above doesn't work for us because we need to allow larger input/output and
// we only need the crc32 checksum actually
DECLSPEC int hc_inflate (mz_streamp pStream)
{
// we can't use the full TINFL_LZ_DICT_SIZE buffer because even with only 16 input bytes
// we can get pretty close to our max available output buffer:
// size_t in_bytes = MZ_MIN (TINFL_LZ_DICT_SIZE, pStream->avail_in);
size_t in_bytes = MZ_MIN (16, pStream->avail_in);
mz_uint decomp_flags = ((pStream->avail_in - in_bytes) > 0) ? TINFL_FLAG_HAS_MORE_INPUT : 0;
decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;
inflate_state *pState = pStream->state;
size_t out_bytes = pStream->avail_out;
tinfl_status status = tinfl_decompress (&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out + pStream->total_out, &out_bytes, decomp_flags, pStream);
for (int i = 0; i < out_bytes; i++)
{
pStream->crc32 = CRC32 (pStream->crc32, pStream->next_out[pStream->total_out + i], pStream->crc32tab);
}
pStream->next_in += (mz_uint) in_bytes;
pStream->avail_in -= (mz_uint) in_bytes;
pStream->total_in += (mz_uint) in_bytes;
pStream->avail_out -= out_bytes;
pStream->total_out += out_bytes;
if (pStream->avail_out < TINFL_LZ_DICT_SIZE)
{
// reset:
// move the last TINFL_LZ_DICT_SIZE bytes to the start of the output buffer
// memcpy (pStream->next_out, pStream->next_out + pStream->total_out - TINFL_LZ_DICT_SIZE, TINFL_LZ_DICT_SIZE);
hc_shift_inflate_dict (pStream->next_out, pStream->total_out - TINFL_LZ_DICT_SIZE, TINFL_LZ_DICT_SIZE);
pStream->avail_out = TINFL_LZ_DICT_SIZE;
pStream->total_out = TINFL_LZ_DICT_SIZE;
}
if (status < 0)
{
return MZ_DATA_ERROR;
}
if (in_bytes == 0)
{
return MZ_STREAM_END;
}
if (pStream->avail_in == 0)
{
return MZ_STREAM_END;
}
return (status == TINFL_STATUS_DONE) ? MZ_STREAM_END : MZ_OK;
}

@ -94,13 +94,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_rp.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -749,11 +749,11 @@ KERNEL_FQ void m17200_sxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate
@ -975,11 +975,11 @@ KERNEL_FQ void m17200_mxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -751,11 +751,11 @@ KERNEL_FQ void m17200_sxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate
@ -981,11 +981,11 @@ KERNEL_FQ void m17200_mxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -764,11 +764,11 @@ KERNEL_FQ void m17200_sxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate
@ -1006,11 +1006,11 @@ KERNEL_FQ void m17200_mxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) continue; // failed to inflate

@ -100,7 +100,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -98,7 +98,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -98,7 +98,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -94,13 +94,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_rp.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -750,11 +750,11 @@ KERNEL_FQ void m17220_sxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1015,11 +1015,11 @@ KERNEL_FQ void m17220_mxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -750,11 +750,11 @@ KERNEL_FQ void m17220_sxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1017,11 +1017,11 @@ KERNEL_FQ void m17220_mxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -762,11 +762,11 @@ KERNEL_FQ void m17220_sxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1041,11 +1041,11 @@ KERNEL_FQ void m17220_mxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1078,4 +1078,4 @@ KERNEL_FQ void m17220_mxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
#undef CONST
#undef MAX_DATA
#undef update_key012
#undef update_key3
#undef update_key3

@ -94,13 +94,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_rp.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -759,11 +759,11 @@ KERNEL_FQ void m17225_sxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1087,11 +1087,11 @@ KERNEL_FQ void m17225_mxx (KERN_ATTR_RULES_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -759,11 +759,11 @@ KERNEL_FQ void m17225_sxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1088,11 +1088,11 @@ KERNEL_FQ void m17225_mxx (KERN_ATTR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate

@ -92,13 +92,13 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#include "inc_simd.cl"
#define MAX_LOCAL 512 // too much leaves no room for compiler optimizations, simply benchmark to find a good trade-off - make it as big as possible
#define TMPSIZ 32
#define TMPSIZ (2 * TINFL_LZ_DICT_SIZE)
#define CRC32(x,c,t) (((x) >> 8) ^ (t)[((x) ^ (c)) & 0xff])
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \
@ -771,11 +771,11 @@ KERNEL_FQ void m17225_sxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1112,11 +1112,11 @@ KERNEL_FQ void m17225_mxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
// inflateinit2 is needed because otherwise it checks for headers by default
mz_inflateInit2 (&infstream, -MAX_WBITS, &pStream);
int ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
int ret = hc_inflate (&infstream);
while (ret == MZ_OK)
{
ret = mz_inflate (&infstream, Z_SYNC_FLUSH);
ret = hc_inflate (&infstream);
}
if (ret != MZ_STREAM_END) break; // failed to inflate
@ -1202,4 +1202,4 @@ KERNEL_FQ void m17225_mxx (KERN_ATTR_VECTOR_ESALT (pkzip_t))
#undef CONST
#undef MAX_DATA
#undef update_key012
#undef update_key3
#undef update_key3

@ -100,7 +100,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -98,7 +98,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -98,7 +98,7 @@ Related publication: https://scitepress.org/PublicationsDetail.aspx?ID=KLPzPqStp
#define MSB(x) ((x) >> 24)
#define CONST 0x08088405
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
#define update_key012(k0,k1,k2,c,t) \
{ \

@ -107,8 +107,7 @@ static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$pkzip2$1*1*2*0*e3*1c5*eda7a8de*0*28*8*e3*eda7*5096*a9fc1f4e951c8fb3031a6f903e5f4e3211c8fdc4671547bf77f6f682afbfcc7475d83898985621a7af9bccd1349d1976500a68c48f630b7f22d7a0955524d768e34868880461335417ddd149c65a917c0eb0a4bf7224e24a1e04cf4ace5eef52205f4452e66ded937db9545f843a68b1e84a2e933cc05fb36d3db90e6c5faf1bee2249fdd06a7307849902a8bb24ec7e8a0886a4544ca47979a9dfeefe034bdfc5bd593904cfe9a5309dd199d337d3183f307c2cb39622549a5b9b8b485b7949a4803f63f67ca427a0640ad3793a519b2476c52198488e3e2e04cac202d624fb7d13c2*$/pkzip2$";
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_LEN (32 * 1024)
#define MAX_DATA (320 * 1024)
// this is required to force mingw to accept the packed attribute
#pragma pack(push,1)
@ -227,14 +226,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;
pkzip->hash.uncompressed_length = strtoul(p, NULL, 16);
if (pkzip->hash.compressed_length > MAX_DATA * 4)
if (pkzip->hash.compressed_length > MAX_DATA)
{
return PARSER_TOKEN_LENGTH;
}
if (pkzip->hash.uncompressed_length > MAX_LEN)
{
return PARSER_HASH_LENGTH;
}
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;

@ -107,7 +107,7 @@ static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$pkzip2$1*1*2*0*1d1*1c5*eda7a8de*0*28*0*1d1*eda7*5096*1dea673da43d9fc7e2be1a1f4f664269fceb6cb88723a97408ae1fe07f774d31d1442ea8485081e63f919851ca0b7588d5e3442317fff19fe547a4ef97492ed75417c427eea3c4e146e16c100a2f8b6abd7e5988dc967e5a0e51f641401605d673630ea52ebb04da4b388489901656532c9aa474ca090dbac7cf8a21428d57b42a71da5f3d83fed927361e5d385ca8e480a6d42dea5b4bf497d3a24e79fc7be37c8d1721238cbe9e1ea3ae1eb91fc02aabdf33070d718d5105b70b3d7f3d2c28b3edd822e89a5abc0c8fee117c7fbfbfd4b4c8e130977b75cb0b1da080bfe1c0859e6483c42f459c8069d45a76220e046e6c2a2417392fd87e4aa4a2559eaab3baf78a77a1b94d8c8af16a977b4bb45e3da211838ad044f209428dba82666bf3d54d4eed82c64a9b3444a44746b9e398d0516a2596d84243b4a1d7e87d9843f38e45b6be67fd980107f3ad7b8453d87300e6c51ac9f5e3f6c3b702654440c543b1d808b62f7a313a83b31a6faaeedc2620de7057cd0df80f70346fe2d4dccc318f0b5ed128bcf0643e63d754bb05f53afb2b0fa90b34b538b2ad3648209dff587df4fa18698e4fa6d858ad44aa55d2bba3b08dfdedd3e28b8b7caf394d5d9d95e452c2ab1c836b9d74538c2f0d24b9b577*$/pkzip2$";
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
// this is required to force mingw to accept the packed attribute
#pragma pack(push,1)
@ -226,7 +226,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;
pkzip->hash.uncompressed_length = strtoul(p, NULL, 16);
if (pkzip->hash.uncompressed_length > MAX_DATA * 4)
if (pkzip->hash.compressed_length > MAX_DATA)
{
return PARSER_TOKEN_LENGTH;
}

@ -107,8 +107,7 @@ static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$pkzip2$3*1*1*0*8*24*a425*8827*d1730095cd829e245df04ebba6c52c0573d49d3bbeab6cb385b7fa8a28dcccd3098bfdd7*1*0*8*24*2a74*882a*51281ac874a60baedc375ca645888d29780e20d4076edd1e7154a99bde982152a736311f*2*0*e3*1c5*eda7a8de*0*29*8*e3*eda7*5096*1455781b59707f5151139e018bdcfeebfc89bc37e372883a7ec0670a5eafc622feb338f9b021b6601a674094898a91beac70e41e675f77702834ca6156111a1bf7361bc9f3715d77dfcdd626634c68354c6f2e5e0a7b1e1ce84a44e632d0f6e36019feeab92fb7eac9dda8df436e287aafece95d042059a1b27d533c5eab62c1c559af220dc432f2eb1a38a70f29e8f3cb5a207704274d1e305d7402180fd47e026522792f5113c52a116d5bb25b67074ffd6f4926b221555234aabddc69775335d592d5c7d22462b75de1259e8342a9ba71cb06223d13c7f51f13be2ad76352c3b8ed*$/pkzip2$";
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_LEN (32 * 1024)
#define MAX_DATA (320 * 1024)
// this is required to force mingw to accept the packed attribute
#pragma pack(push,1)
@ -233,10 +232,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{
return PARSER_TOKEN_LENGTH;
}
if (pkzip->hashes[i].uncompressed_length > MAX_LEN)
{
return PARSER_HASH_LENGTH;
}
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;

@ -107,8 +107,7 @@ static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "$pkzip2$3*1*1*0*0*24*3e2c*3ef8*0619e9d17ff3f994065b99b1fa8aef41c056edf9fa4540919c109742dcb32f797fc90ce0*1*0*8*24*431a*3f26*18e2461c0dbad89bd9cc763067a020c89b5e16195b1ac5fa7fb13bd246d000b6833a2988*2*0*23*17*1e3c1a16*2e4*2f*0*23*1e3c*3f2d*54ea4dbc711026561485bbd191bf300ae24fa0997f3779b688cdad323985f8d3bb8b0c*$/pkzip2$";
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_LEN (32 * 1024)
#define MAX_DATA (320 * 1024)
// this is required to force mingw to accept the packed attribute
#pragma pack(push,1)
@ -233,10 +232,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{
return PARSER_TOKEN_LENGTH;
}
if (pkzip->hashes[i].uncompressed_length > MAX_LEN)
{
return PARSER_HASH_LENGTH;
}
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;

@ -107,7 +107,7 @@ 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$";
#define MAX_DATA (16 * 1024 * 1024)
#define MAX_DATA (320 * 1024)
// this is required to force mingw to accept the packed attribute
#pragma pack(push,1)
@ -229,7 +229,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
p = strtok(NULL, "*");
if (p == NULL) return PARSER_HASH_LENGTH;
pkzip->hashes[i].uncompressed_length = strtoul(p, NULL, 16);
if (pkzip->hashes[i].compressed_length > MAX_DATA * 4)
if (pkzip->hashes[i].compressed_length > MAX_DATA)
{
return PARSER_TOKEN_LENGTH;
}

Loading…
Cancel
Save