Skip to content

Commit

Permalink
Armory format: Pre-check for cracks within parallel section
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed Jan 13, 2024
1 parent 1d7397a commit c460f82
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/armory_fmt_plug.c
Expand Up @@ -27,6 +27,7 @@ john_register_one(&fmt_armory);

#include "base64_convert.h"
#include "formats.h"
#include "loader.h"
#include "memory.h"
#include "crc32.h"
#include "sha2.h"
Expand Down Expand Up @@ -412,10 +413,10 @@ static void derive_address(region_t *memory, derived_key *dk, uint8_t *da)

static int crypt_all(int *pcount, struct db_salt *salt)
{
int failed = 0, count = *pcount, index;
int failed = 0, cracked = !salt, count = *pcount, index;

#ifdef _OPENMP
#pragma omp parallel for default(none) private(index) shared(count, failed, max_threads, memory, saved_key, saved_salt, crypt_out)
#pragma omp parallel for default(none) private(index) shared(count, failed, cracked, salt, max_threads, memory, saved_key, saved_salt, crypt_out)
#endif
for (index = 0; index < count; index += MIN_KEYS_PER_CRYPT) {
#ifdef _OPENMP
Expand All @@ -427,6 +428,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
#else
const int t = 0;
#endif

errno = 0;
derived_key dk[MIN_KEYS_PER_CRYPT];
if (derive_keys(&memory[t], index, dk)) {
Expand All @@ -435,9 +437,19 @@ static int crypt_all(int *pcount, struct db_salt *salt)
break;
#endif
}

int subindex;
for (subindex = 0; subindex < MIN_KEYS_PER_CRYPT; subindex++)
for (subindex = 0; subindex < MIN_KEYS_PER_CRYPT; subindex++) {
derive_address(memory, &dk[subindex], crypt_out[index + subindex]);

if (salt) {
struct db_password *pw = salt->list;
do {
if (!memcmp(pw->binary, crypt_out[index + subindex], BINARY_SIZE))
cracked = -1;
} while ((pw = pw->next));
}
}
}

if (failed) {
Expand All @@ -451,8 +463,7 @@ static int crypt_all(int *pcount, struct db_salt *salt)
error();
}


return count;
return cracked ? count : 0;
}

static int cmp_all(void *binary, int count)
Expand Down

0 comments on commit c460f82

Please sign in to comment.