Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sun, 06 Nov 2011 22:35:34 +0100
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: generic crypt warnings

2011-11-02 08:34, Solar Designer wrote:
> On Tue, Nov 01, 2011 at 10:23:20PM +0100, magnum wrote:
>> When loading generic crypt hashes, warnings are emitted for unrecognised
>> hashes not only in the input file (which is good) but also in the pot
>> file (which is not so good). I've been trying to figure out how to mute
>> them but I'm not sure. Is there a way for valid() to know whether it's
>> given pot hashes or input hashes?
> 
> As Jim said, I think we'll need to add a global variable.

This patch seems to do the job but I have a feeling it's not as
straight-forward as it could be. I had a hard time following the code.
I'm posting it to the wiki anyway, maybe it can be improved later.

magnum

>From ee3b5b1a6884e1030578ca5131f2cac5e397a24f Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Thu, 3 Nov 2011 19:03:52 +0100
Subject: [PATCH] mute warnings from c3 when loading pot file

---
 src/c3_fmt.c  |    1 +
 src/loader.c  |    2 ++
 src/options.h |    3 +++
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/c3_fmt.c b/src/c3_fmt.c
index e1fabf7..e01ed96 100644
--- a/src/c3_fmt.c
+++ b/src/c3_fmt.c
@@ -196,6 +196,7 @@ static int valid(char *ciphertext, struct fmt_main *pFmt)
 #ifdef HAVE_MPI
 		if (mpi_id == 0)
 #endif
+		if (options.loadingpot == 0)
 		fprintf(stderr, "Generic crypt(3) module: "
 		    "hash encoding string length %d, type id %c%c\n"
 		    "appears to be unsupported on this system; "
diff --git a/src/loader.c b/src/loader.c
index 31c6056..21442ef 100644
--- a/src/loader.c
+++ b/src/loader.c
@@ -579,6 +579,7 @@ static void ldr_load_pot_line(struct db_main *db, char *line)
 	struct db_password *current;
 	char *flds[10] = {0};
 
+	options.loadingpot = 1;
 	unprepared = ldr_get_field(&line, db->options->field_sep_char);
 	flds[1] = unprepared;
 	ciphertext = format->methods.prepare(flds, format);
@@ -595,6 +596,7 @@ static void ldr_load_pot_line(struct db_main *db, char *line)
 		    !strcmp(current->source, ciphertext))
 			current->binary = NULL;
 	} while ((current = current->next_hash));
+	options.loadingpot = 0;
 }
 
 void ldr_load_pot_file(struct db_main *db, char *name)
diff --git a/src/options.h b/src/options.h
index 44959ae..d72a1d8 100644
--- a/src/options.h
+++ b/src/options.h
@@ -188,6 +188,9 @@ struct options_main {
 
 /* Forced min/max_keys_per_crypt (for testing purposes) */
 	int mkpc;
+
+/* Ugly flag to mute warnings from crypt format */
+	int loadingpot;
 };
 
 extern struct options_main options;
-- 
1.7.5.4


Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ