From ee9d5c586b9a07f6fa0574a3bc389905f84587d9 Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Sat, 24 Sep 2011 19:12:34 +0200
Subject: [PATCH] j7: Optionally emit a status line for every cracked password

---
 doc/OPTIONS   |    6 ++++++
 src/cracker.c |    3 +++
 src/options.c |    4 +++-
 src/options.h |    2 ++
 4 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/doc/OPTIONS b/doc/OPTIONS
index 451eca6..424b2a8 100644
--- a/doc/OPTIONS
+++ b/doc/OPTIONS
@@ -259,6 +259,12 @@ needed, and the log file is simply going to be deleted when done, then
 running in --nolog mode may be used.
 
 
+--crack-status          show status line on every crack
+
+This will automagically emit a status line at every cracked password. This is
+mostly for testing.
+
+
 	Additional utilities.
 
 There are some related utilities in John's run directory:
diff --git a/src/cracker.c b/src/cracker.c
index 9cd2bc3..3eb0fbf 100644
--- a/src/cracker.c
+++ b/src/cracker.c
@@ -132,6 +132,9 @@ static int crk_process_guess(struct db_salt *salt, struct db_password *pw,
 	log_guess(crk_db->options->flags & DB_LOGIN ? replogin : "?",
 		dupe ? NULL : pw->source, repkey, key, crk_db->options->field_sep_char);
 
+	if (options.flags & FLG_CRKSTAT)
+		event_pending = event_status = 1;
+
 	crk_db->guess_count++;
 	status.guess_count++;
 
diff --git a/src/options.c b/src/options.c
index 71cdf8e..de8cd5e 100644
--- a/src/options.c
+++ b/src/options.c
@@ -121,6 +121,7 @@ static struct opt_entry opt_list[] = {
 	{"config", FLG_CONFIG_CLI, FLG_NONE, 0, OPT_REQ_PARAM,
 		OPT_FMT_STR_ALLOC, &options.config},
 	{"nolog", FLG_NOLOG, FLG_NOLOG},
+	{"crack-status", FLG_CRKSTAT, FLG_CRKSTAT},
 	{NULL}
 };
 
@@ -174,7 +175,8 @@ static struct opt_entry opt_list[] = {
 "--mem-file-size=SIZE      size threshold for wordlist preload (default 5 MB)\n" \
 "--field-separator-char=C  use 'C' instead of the ':' in input and pot files\n" \
 "--fix-state-delay=N       performance tweak, see documentation\n" \
-"--nolog                   disables creation and writing to john.log file\n"
+"--nolog                   disables creation and writing to john.log file\n" \
+"--crack-status            emit a status line whenever a password is cracked\n"
 
 #define JOHN_USAGE_PLUGIN \
 "--plugin=NAME[,..]        load this (these) dynamic plugin(s)\n"
diff --git a/src/options.h b/src/options.h
index 37e7743..fc1edfa 100644
--- a/src/options.h
+++ b/src/options.h
@@ -97,6 +97,8 @@
 /* Markov mode enabled */
 #define FLG_MKV_CHK			0x40000000
 #define FLG_MKV_SET			(FLG_MKV_CHK | FLG_CRACKING_SET)
+/* Emit a status line for every password cracked */
+#define FLG_CRKSTAT			0x00080000
 
 /*
  * Structure with option flags and all the parameters.
-- 
1.7.4.1

