Skip to content
Open
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
68 changes: 28 additions & 40 deletions src/7z_common_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ struct fmt_tests sevenzip_tests[] = {

sevenzip_salt_t *sevenzip_salt;

#define YEL "\x1b[0;33m"
#define NRM "\x1b[0m"

int sevenzip_trust_padding;

static char *comp_type[16] = { "stored", "LZMA1", "LZMA2", "PPMD", NULL, NULL, "BZIP2", "DEFLATE" };
Expand Down Expand Up @@ -140,23 +137,23 @@ int sevenzip_valid(char *ciphertext, struct fmt_main *self)
&& type != 128) {
if (john_main_process && !warned[type]) {
warned[type] = 1;
fprintf(stderr, YEL "Warning: Not loading files with unsupported compression type %s (0x%02x)\n" NRM,
fprintf_color(color_warning, stderr, "Warning: Not loading files with unsupported compression type %s (0x%02x)\n",
comp_type[c_type] ? comp_type[c_type] : "(unknown)", type);
#if !HAVE_LIBBZ2
if (type == 6)
fprintf(stderr, YEL "Rebuild with libbz2 to get support for that type.\n" NRM);
fprintf_color(color_warning, stderr, "Rebuild with libbz2 to get support for that type.\n");
#endif
#if !HAVE_LIBZ
if (type == 7)
fprintf(stderr, YEL "Rebuild with libz (zlib) to get support for that type.\n" NRM);
fprintf_color(color_warning, stderr, "Rebuild with libz (zlib) to get support for that type.\n");
#endif
}
goto err;
}
if (john_main_process && !ldr_in_pot && !self_test_running &&
options.verbosity > VERB_DEFAULT && !warned[type]) {
warned[type] = 1;
fprintf(stderr, YEL "Saw file(s) with compression type %s%s%s (0x%02x)\n" NRM,
fprintf_color(color_notice, stderr, "Saw file(s) with compression type %s%s%s (0x%02x)\n",
precomp_type[p_type], p_type ? "+" : "", comp_type[c_type], type);
}
if ((p = strtokm(NULL, "$")) == NULL) /* NumCyclesPower */
Expand All @@ -174,11 +171,8 @@ int sevenzip_valid(char *ciphertext, struct fmt_main *self)
goto err;
len = atoi(p);
if (len > 0 && strstr(self->params.label, "-opencl")) {
static int warned;

if (!warned++)
fprintf(stderr, YEL "%s: Warning: Not loading hashes with salt due to optimizations. Please report!\n" NRM,
self->params.label);
if (!ldr_in_pot && john_main_process)
WARN_ONCE(color_warning, stderr, "%s: Warning: Not loading hashes with salt due to optimizations. Please report!\n", self->params.label);
goto err;
}
if (len > 16)
Expand Down Expand Up @@ -355,7 +349,7 @@ int sevenzip_decrypt(unsigned char *derived_key)

#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "\nType %02x (%s%s%s) AES length %zu, packed len %zu, pad size %d, crc len %zu\n",
fprintf_color(color_notice, stderr, "\nType %02x (%s%s%s) AES length %zu, packed len %zu, pad size %d, crc len %zu\n",
sevenzip_salt->type, precomp_type[p_type] ? precomp_type[p_type] : "",
p_type ? "+" : "",
comp_type[c_type] ? comp_type[c_type] : "(unknown)",
Expand All @@ -379,12 +373,11 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (buf[i] != 0) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG) {
fprintf(stderr, YEL "Early padding check failed, ");
fprintf_color(color_warning, stderr, "Early padding check failed, ");
dump_stderr_msg("padding", buf + 16 - pad_size, pad_size);
fprintf(stderr, NRM);
}
if (sevenzip_salt->type == 0x80)
fprintf(stderr, YEL "We don't have data for complete decryption\n");
WARN_ONCE(color_warning, stderr, "We don't have data for complete decryption\n");
break;
#else
return 0;
Expand All @@ -395,13 +388,13 @@ int sevenzip_decrypt(unsigned char *derived_key)
}
#if DEBUG
if (!nbytes && !benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "Early padding check passed\n");
fprintf_color(color_notice, stderr, "Early padding check passed\n");
else
nbytes = 0;
#else
if (self_test_running)
#endif
if (sevenzip_salt->type == 0x80) /* We only have truncated data */
return 1;
#endif
}

/* Complete decryption */
Expand All @@ -417,9 +410,8 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (out[i] != 0) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG) {
fprintf(stderr, YEL "Full data padding check failed, ");
fprintf_color(color_warning, stderr, "Full data padding check failed, ");
dump_stderr_msg("padding", out + sevenzip_salt->aes_length - pad_size, pad_size);
fprintf(stderr, NRM);
}
break;
#else
Expand All @@ -431,7 +423,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
}
#if DEBUG
if (!nbytes && !benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "Padding check passed\n");
fprintf_color(color_notice, stderr, "Padding check passed\n");
#endif
}

Expand All @@ -456,7 +448,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
out_size == crc_len) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "LZMA decoding passed, %zu/%zu -> %zu/%zu, props %02x%02x%02x%02x\n",
fprintf_color(color_notice, stderr, "LZMA decoding passed, %zu/%zu -> %zu/%zu, props %02x%02x%02x%02x\n",
in_size, sevenzip_salt->packed_size, out_size, crc_len, sevenzip_salt->decoder_props[0],
sevenzip_salt->decoder_props[1], sevenzip_salt->decoder_props[2], sevenzip_salt->decoder_props[3]);
#endif
Expand All @@ -465,7 +457,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
} else {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "LZMA decoding failed, %zu/%zu -> %zu/%zu, props %02x%02x%02x%02x\n" NRM,
fprintf_color(color_warning, stderr, "LZMA decoding failed, %zu/%zu -> %zu/%zu, props %02x%02x%02x%02x\n",
in_size, sevenzip_salt->packed_size, out_size, crc_len, sevenzip_salt->decoder_props[0],
sevenzip_salt->decoder_props[1], sevenzip_salt->decoder_props[2], sevenzip_salt->decoder_props[3]);
#endif
Expand All @@ -488,15 +480,15 @@ int sevenzip_decrypt(unsigned char *derived_key)
out_size == crc_len) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "LZMA2 decoding passed, %zu/%zu -> %zu/%zu, props %02x\n",
fprintf_color(color_notice, stderr, "LZMA2 decoding passed, %zu/%zu -> %zu/%zu, props %02x\n",
in_size, sevenzip_salt->packed_size, out_size, crc_len, sevenzip_salt->decoder_props[0]);
#endif
MEM_FREE(out);
out = new_out;
} else {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "LZMA2 decoding failed, %zu/%zu -> %zu/%zu, props %02x\n" NRM,
fprintf_color(color_warning, stderr, "LZMA2 decoding failed, %zu/%zu -> %zu/%zu, props %02x\n",
in_size, sevenzip_salt->packed_size, out_size, crc_len, sevenzip_salt->decoder_props[0]);
#endif
MEM_FREE(new_out);
Expand Down Expand Up @@ -526,7 +518,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (ret == BZ_STREAM_END) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "BZIP2 decoding passed, %zu/%zu -> %zu/%zu\n",
fprintf_color(color_notice, stderr, "BZIP2 decoding passed, %zu/%zu -> %zu/%zu\n",
sevenzip_salt->packed_size - inf_stream.avail_in, sevenzip_salt->packed_size,
crc_len - inf_stream.avail_out, crc_len);
#endif
Expand All @@ -535,7 +527,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
} else {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "BZIP2 decoding failed, %zu/%zu -> %zu/%zu\n" NRM,
fprintf_color(color_warning, stderr, "BZIP2 decoding failed, %zu/%zu -> %zu/%zu\n",
sevenzip_salt->packed_size - inf_stream.avail_in, sevenzip_salt->packed_size,
crc_len - inf_stream.avail_out, crc_len);
#endif
Expand Down Expand Up @@ -564,7 +556,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (ret == Z_STREAM_END) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "DEFLATE decoding passed, %zu/%zu -> %zu/%zu\n",
fprintf_color(color_notice, stderr, "DEFLATE decoding passed, %zu/%zu -> %zu/%zu\n",
sevenzip_salt->packed_size - inf_stream.avail_in, sevenzip_salt->packed_size,
crc_len - inf_stream.avail_out, crc_len);
#endif
Expand All @@ -573,7 +565,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
} else {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "DEFLATE decoding failed, %zu/%zu -> %zu/%zu\n" NRM,
fprintf_color(color_warning, stderr, "DEFLATE decoding failed, %zu/%zu -> %zu/%zu\n",
sevenzip_salt->packed_size - inf_stream.avail_in, sevenzip_salt->packed_size,
crc_len - inf_stream.avail_out, crc_len);
#endif
Expand All @@ -586,7 +578,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (p_type) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "Decoding %s, props %02x\n", precomp_type[p_type], sevenzip_salt->preproc_props);
fprintf_color(color_notice, stderr, "Decoding %s, props %02x\n", precomp_type[p_type], sevenzip_salt->preproc_props);
#endif
if (p_type == 1) {
uint32_t state;
Expand All @@ -595,12 +587,8 @@ int sevenzip_decrypt(unsigned char *derived_key)
x86_Convert(out, crc_len, 0, &state, 0);
}
else if (p_type == 2) {
if (!benchmark_running && options.verbosity >= VERB_DEFAULT) {
static int warned;

if (!warned++)
fprintf(stderr, YEL "Can't decode BCJ2, so skipping CRC check" NRM);
}
if (!benchmark_running && options.verbosity >= VERB_DEFAULT)
WARN_ONCE(color_warning, stderr, "Can't decode BCJ2, so skipping CRC check");
goto exit_good;
}
else if (p_type == 3)
Expand All @@ -620,7 +608,7 @@ int sevenzip_decrypt(unsigned char *derived_key)
Delta_Decode(state, sevenzip_salt->preproc_props + 1, out, crc_len);
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "DELTA decoding can't fail so result unknown\n" NRM);
fprintf_color(color_notice, stderr, "DELTA decoding can't fail so result unknown\n");
#endif
}
}
Expand All @@ -636,13 +624,13 @@ int sevenzip_decrypt(unsigned char *derived_key)
if (ccrc == sevenzip_salt->crc) {
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, "CRC check passed (%08x)\n", ccrc);
fprintf_color(color_notice, stderr, "CRC check passed (%08x)\n", ccrc);
#endif
goto exit_good;
}
#if DEBUG
if (!benchmark_running && options.verbosity >= VERB_DEBUG)
fprintf(stderr, YEL "CRC failed, %08x vs %08x\n" NRM, ccrc, sevenzip_salt->crc);
fprintf_color(color_warning, stderr, "CRC failed, %08x vs %08x\n", ccrc, sevenzip_salt->crc);
#endif

exit_bad:
Expand Down
6 changes: 2 additions & 4 deletions src/LM_fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ static void init(struct fmt_main *self)
fmt_LM.params.max_keys_per_crypt = DES_bs_max_kpc;
#endif

static int warned;
if (!warned && options.target_enc > CP_DOS_HI && !options.listconf &&
if (options.target_enc > CP_DOS_HI && !options.listconf &&
sizeof(tests) / sizeof(tests[0]) > 16) {
fprintf_color(color_warning, stderr,
WARN_ONCE(color_warning, stderr,
"Warning: LM formats incompatible with %s encoding, disabling some tests\n",
cp_id2name(options.target_enc));
tests[16].ciphertext = NULL; // Truncates the array after 16 entries
warned = 1;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ static void bench_set_keys(struct fmt_main *format,
}

if (warn == 1) {
fprintf(stderr, "Warning: not enough candidates under "
"benchmark length %d\n", length);
fprintf_color(color_warning, stderr,
"Warning: not enough candidates under benchmark length %d\n",
length);
warn = 2;
}

Expand Down
4 changes: 3 additions & 1 deletion src/bestcrypt_ve_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ john_register_one(&fmt_bestcrypt_ve);
#endif

#include "arch.h"
#include "john.h"
#include "misc.h"
#include "common.h"
#include "formats.h"
Expand Down Expand Up @@ -229,7 +230,8 @@ static int valid(char *ciphertext, struct fmt_main *self)
if (atoi(p) != 8 && atoi(p) != 9 && atoi(p) != 10 && atoi(p) != 11 && atoi(p) != 15)
goto err;
if (atoi(p) == 11) {
fprintf(stderr, "Warning: " FORMAT_LABEL ": RC6 encryption not supported yet!\n");
if (john_main_process && !ldr_in_pot)
fprintf_color(color_warning, stderr, "Warning: " FORMAT_LABEL ": RC6 encryption not supported yet!\n");
goto err;
}
if ((p = strtokm(NULL, "$")) == NULL) // salt
Expand Down
5 changes: 3 additions & 2 deletions src/bitshares_fmt_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ static int crypt_all(int *pcount, struct db_salt *salt)
any_cracked |= 1;

if (memcmp(km, out_full, 4) != 0) {
fprintf(stderr, "Warning: " FORMAT_LABEL ": Good padding, but bad checksum"
" (corrupted data or false positive?) - will keep guessing\n");
fprintf_color(color_warning, stderr,
"Warning: " FORMAT_LABEL ": Good padding, but bad checksum"
" (corrupted data or false positive?) - will keep guessing\n");
fmt_bitshares.params.flags |= FMT_NOT_EXACT;
}
}
Expand Down
33 changes: 13 additions & 20 deletions src/c3_fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,11 @@ static void init(struct fmt_main *self)
*
* That's why, don't require FLG_TEST_CHK to be set.
*/
if (options.flags & FLG_PASSWD) {
fprintf(stderr,
"\n%s: --subformat option is only for --test or --list=format-tests\n", FORMAT_LABEL);
error();
}
if (options.flags & FLG_PASSWD)
error_msg("\n%s: --subformat option is only for --test or --list=format-tests\n", FORMAT_LABEL);

if (!strcmp(options.subformat, "?")) {
fprintf(stderr, "Subformat may either be a verbatim salt, or: descrypt, md5crypt, bcrypt, sha256crypt, sha512crypt, sunmd5, scrypt, yescrypt, gost-yescrypt\n\n");
error();
error_msg("Subformat may either be a verbatim salt, or: descrypt, md5crypt, bcrypt, sha256crypt, sha512crypt, sunmd5, scrypt, yescrypt, gost-yescrypt\n\n");
} else if (!strcasecmp(options.subformat, "md5crypt") ||
!strcasecmp(options.subformat, "md5")) {
static struct fmt_tests tests[] = {
Expand Down Expand Up @@ -262,22 +258,18 @@ static void init(struct fmt_main *self)
#endif
if (c && strlen(c) >= 13)
tests[i].ciphertext = xstrdup(c);
else {
fprintf(stderr, "%s not supported on this system\n",
else
error_msg("%s not supported on this system\n",
options.subformat);
error();
}

/* No need to replace tests that we're not going to use */
if (tests != self->params.tests)
break;
}

if (strlen(tests[0].ciphertext) == 13) {
fprintf(stderr, "%s not supported on this system\n",
if (strlen(tests[0].ciphertext) == 13)
error_msg("%s not supported on this system\n",
options.subformat);
error();
}
}
}

Expand Down Expand Up @@ -371,11 +363,12 @@ static int valid(char *ciphertext, struct fmt_main *self)

if (id != 10 && !ldr_in_pot)
if (john_main_process)
fprintf(stderr, "Warning: "
"hash encoding string length %d, type id %c%c\n"
"appears to be unsupported on this system; "
"will not load such hashes.\n",
length, id > 0x20 ? '$' : '#', id > 0x20 ? id : '0' + id);
fprintf_color(color_warning, stderr,
"Warning: "
"hash encoding string length %d, type id %c%c\n"
"appears to be unsupported on this system; "
"will not load such hashes.\n",
length, id > 0x20 ? '$' : '#', id > 0x20 ? id : '0' + id);

if (!sup_length[length])
sup_length[length] = -1;
Expand Down
3 changes: 2 additions & 1 deletion src/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "config.h"
#include "options.h"

const char* const color_none = "";
char *color_error, *color_notice, *color_warning, *color_end;

/*
Expand Down Expand Up @@ -40,5 +41,5 @@ void color_init()
color_warning = parse_esc(cfg_get_param(SECTION_OPTIONS, NULL, "ColorWarning"));
color_end = parse_esc(cfg_get_param(SECTION_OPTIONS, NULL, "ColorEnd"));
} else
color_error = color_notice = color_warning = color_end = "";
color_error = color_notice = color_warning = color_end = (char*)color_none;
}
Loading