From cf3ab8e2dc78906717108d9a909694dd5f3cecf2 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 11 Apr 2023 21:17:25 +0200 Subject: [PATCH] Handle signed/unsigned PDF permission P value for all PDF hash-modes --- OpenCL/m10400_a0-optimized.cl | 26 ++++++++++++---------- OpenCL/m10400_a1-optimized.cl | 26 ++++++++++++---------- OpenCL/m10400_a3-optimized.cl | 26 ++++++++++++---------- OpenCL/m10410_a0-optimized.cl | 26 ++++++++++++---------- OpenCL/m10410_a1-optimized.cl | 26 ++++++++++++---------- OpenCL/m10410_a3-optimized.cl | 26 ++++++++++++---------- OpenCL/m10420_a0-optimized.cl | 26 ++++++++++++---------- OpenCL/m10420_a1-optimized.cl | 26 ++++++++++++---------- OpenCL/m10420_a3-optimized.cl | 26 ++++++++++++---------- OpenCL/m10500-pure.cl | 26 ++++++++++++---------- OpenCL/m10700-optimized.cl | 26 ++++++++++++---------- OpenCL/m10700-pure.cl | 26 ++++++++++++---------- OpenCL/m25400-pure.cl | 2 ++ docs/changes.txt | 1 + src/modules/module_10400.c | 36 +++++++++++++++++++----------- src/modules/module_10410.c | 36 +++++++++++++++++++----------- src/modules/module_10420.c | 36 +++++++++++++++++++----------- src/modules/module_10500.c | 42 +++++++++++++++++++++++------------ src/modules/module_10600.c | 24 ++++++++++---------- src/modules/module_10700.c | 26 +++++++++++----------- src/modules/module_25400.c | 19 ++++++++++++++-- 21 files changed, 310 insertions(+), 224 deletions(-) diff --git a/OpenCL/m10400_a0-optimized.cl b/OpenCL/m10400_a0-optimized.cl index afdd6ac1c..e442a7e8b 100644 --- a/OpenCL/m10400_a0-optimized.cl +++ b/OpenCL/m10400_a0-optimized.cl @@ -20,22 +20,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10400_a1-optimized.cl b/OpenCL/m10400_a1-optimized.cl index 4247d2cc0..3c0165749 100644 --- a/OpenCL/m10400_a1-optimized.cl +++ b/OpenCL/m10400_a1-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10400_a3-optimized.cl b/OpenCL/m10400_a3-optimized.cl index 096d2e172..8687ae809 100644 --- a/OpenCL/m10400_a3-optimized.cl +++ b/OpenCL/m10400_a3-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a0-optimized.cl b/OpenCL/m10410_a0-optimized.cl index cdf6145ce..aa1acad0b 100644 --- a/OpenCL/m10410_a0-optimized.cl +++ b/OpenCL/m10410_a0-optimized.cl @@ -20,22 +20,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a1-optimized.cl b/OpenCL/m10410_a1-optimized.cl index 6e2467a78..b37624c5b 100644 --- a/OpenCL/m10410_a1-optimized.cl +++ b/OpenCL/m10410_a1-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10410_a3-optimized.cl b/OpenCL/m10410_a3-optimized.cl index 44a4f8789..5e789cca8 100644 --- a/OpenCL/m10410_a3-optimized.cl +++ b/OpenCL/m10410_a3-optimized.cl @@ -18,22 +18,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a0-optimized.cl b/OpenCL/m10420_a0-optimized.cl index ab069e9a1..32b1df8c1 100644 --- a/OpenCL/m10420_a0-optimized.cl +++ b/OpenCL/m10420_a0-optimized.cl @@ -30,22 +30,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a1-optimized.cl b/OpenCL/m10420_a1-optimized.cl index 25dad86a7..5c2ef872d 100644 --- a/OpenCL/m10420_a1-optimized.cl +++ b/OpenCL/m10420_a1-optimized.cl @@ -28,22 +28,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10420_a3-optimized.cl b/OpenCL/m10420_a3-optimized.cl index 06e0ac3b0..797c7d16b 100644 --- a/OpenCL/m10420_a3-optimized.cl +++ b/OpenCL/m10420_a3-optimized.cl @@ -28,22 +28,24 @@ CONSTANT_VK u32a padding[8] = typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10500-pure.cl b/OpenCL/m10500-pure.cl index 905b88f5a..f45c40d42 100644 --- a/OpenCL/m10500-pure.cl +++ b/OpenCL/m10500-pure.cl @@ -17,22 +17,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10700-optimized.cl b/OpenCL/m10700-optimized.cl index 488ddf58e..f037f466b 100644 --- a/OpenCL/m10700-optimized.cl +++ b/OpenCL/m10700-optimized.cl @@ -19,22 +19,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m10700-pure.cl b/OpenCL/m10700-pure.cl index 81e67da1e..327c76e71 100644 --- a/OpenCL/m10700-pure.cl +++ b/OpenCL/m10700-pure.cl @@ -25,22 +25,24 @@ typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; diff --git a/OpenCL/m25400-pure.cl b/OpenCL/m25400-pure.cl index 8ab75831c..6ad2d1034 100644 --- a/OpenCL/m25400-pure.cl +++ b/OpenCL/m25400-pure.cl @@ -38,6 +38,8 @@ typedef struct pdf u32 rc4key[2]; u32 rc4data[2]; + int P_minus; + } pdf_t; typedef struct pdf14_tmp diff --git a/docs/changes.txt b/docs/changes.txt index 448e026ac..e838fab01 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -45,6 +45,7 @@ - Skip chained generated rules that exceed the maximum number of function calls - Fixed incorrect plaintext check for 25400 and 26610. Increased plaintext check to 32 bytes to prevent false positives. - Fixed bug in --stdout that caused certain rules to malfunction +- Handle signed/unsigned PDF permission P value for all PDF hash-modes ## ## Technical diff --git a/src/modules/module_10400.c b/src/modules/module_10400.c index 05bd67c95..e7352fae2 100644 --- a/src/modules/module_10400.c +++ b/src/modules/module_10400.c @@ -44,22 +44,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -214,6 +216,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -291,7 +297,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const pdf_t *pdf = (const pdf_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10410.c b/src/modules/module_10410.c index cdf598787..9aa05f47f 100644 --- a/src/modules/module_10410.c +++ b/src/modules/module_10410.c @@ -46,22 +46,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -235,6 +237,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -312,7 +318,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const pdf_t *pdf = (const pdf_t *) esalt_buf; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10420.c b/src/modules/module_10420.c index 908021b3b..397c152d3 100644 --- a/src/modules/module_10420.c +++ b/src/modules/module_10420.c @@ -45,22 +45,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -222,6 +224,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -322,7 +328,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *rc4key = (const u8 *) pdf->rc4key; - const int line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x"; + + const int line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 40, diff --git a/src/modules/module_10500.c b/src/modules/module_10500.c index c253847cd..3cf1e08c1 100644 --- a/src/modules/module_10500.c +++ b/src/modules/module_10500.c @@ -45,22 +45,24 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; + + int P_minus; } pdf_t; @@ -245,6 +247,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -379,7 +385,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (pdf->id_len == 32) { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, @@ -416,7 +426,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, diff --git a/src/modules/module_10600.c b/src/modules/module_10600.c index 4218bc019..8f12154d1 100644 --- a/src/modules/module_10600.c +++ b/src/modules/module_10600.c @@ -51,22 +51,22 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; } pdf_t; diff --git a/src/modules/module_10700.c b/src/modules/module_10700.c index 3f1e78b89..51d351c39 100644 --- a/src/modules/module_10700.c +++ b/src/modules/module_10700.c @@ -47,22 +47,22 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, typedef struct pdf { - int V; - int R; - int P; + int V; + int R; + int P; - int enc_md; + int enc_md; - u32 id_buf[8]; - u32 u_buf[32]; - u32 o_buf[32]; + u32 id_buf[8]; + u32 u_buf[32]; + u32 o_buf[32]; - int id_len; - int o_len; - int u_len; + int id_len; + int o_len; + int u_len; - u32 rc4key[2]; - u32 rc4data[2]; + u32 rc4key[2]; + u32 rc4data[2]; } pdf_t; @@ -71,7 +71,7 @@ typedef struct pdf17l8_tmp union { u32 dgst32[16]; - u64 dgst64[8]; + u64 dgst64[8]; } d; u32 dgst_len; diff --git a/src/modules/module_25400.c b/src/modules/module_25400.c index baad6e6fd..f3c57908f 100644 --- a/src/modules/module_25400.c +++ b/src/modules/module_25400.c @@ -69,6 +69,8 @@ typedef struct pdf u32 rc4key[2]; u32 rc4data[2]; + int P_minus; + } pdf_t; typedef struct pdf14_tmp @@ -354,6 +356,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // validate data + pdf->P_minus = 0; + + if (P_pos[0] == 0x2d) pdf->P_minus = 1; + const int V = strtol ((const char *) V_pos, NULL, 10); const int R = strtol ((const char *) R_pos, NULL, 10); const int P = strtol ((const char *) P_pos, NULL, 10); @@ -568,9 +574,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE int line_len = 0; pdf_t *pdf = (pdf_t *) esalt_buf; + if (pdf->id_len == 32) { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128, @@ -608,7 +619,11 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE } else { - line_len = snprintf (line_buf, line_size, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s", + char *line_format = "$pdf$%d*%d*%d*%u*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + if (pdf->P_minus == 1) line_format = "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x%s"; + + line_len = snprintf (line_buf, line_size, line_format, pdf->V, pdf->R, 128,