Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAR5 formats: Canonicalize ciphertext for pot entries #5578

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/opencl_rar5_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ struct fmt_main fmt_opencl_rar5 = {
reset,
fmt_default_prepare,
valid,
fmt_default_split,
split,
get_binary,
get_salt,
{
Expand Down
20 changes: 20 additions & 0 deletions src/rar5_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define SIZE_PSWCHECK 8
#define SIZE_PSWCHECK_CSUM 4
#define SIZE_INITV 16
#define CIPHERTEXT_LENGTH (TAG_LENGTH+2+1+32+1+2+1+2*SIZE_INITV+1+1+1+2*SIZE_PSWCHECK)

#define FORMAT_TAG "$rar5$"
#define TAG_LENGTH (sizeof(FORMAT_TAG)-1)
Expand Down Expand Up @@ -107,6 +108,25 @@ static int valid(char *ciphertext, struct fmt_main *self)
return 0;
}

/*
* We don't care about the IV, so canonicalize it in order to recognize
* otherwise same hashes coming from pot file.
*/
static char *split(char *ciphertext, int index, struct fmt_main *self)
{
static char out[CIPHERTEXT_LENGTH + 1];
int i;

char *p = strnzcpy(out, ciphertext, sizeof(out));

for (i = 0; i < 5; i++)
p = strchr(p, '$') + 1;
for (i = 0; i < SIZE_INITV * 2; i++)
p[i] = '0';

return out;
}

static void *get_salt(char *ciphertext)
{
char *ctcopy = xstrdup(ciphertext);
Expand Down
2 changes: 1 addition & 1 deletion src/rar5_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ struct fmt_main fmt_rar5 = {
fmt_default_reset,
fmt_default_prepare,
valid,
fmt_default_split,
split,
get_binary,
get_salt,
{
Expand Down