From 989c8b03a180177f9c247d7d89d53aa46634ed5a Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Wed, 12 Oct 2011 20:47:43 +0200
Subject: [PATCH] j7: Optionally output number of candidates tried in status line

---
 run/john.conf |    3 +++
 src/status.c  |   16 +++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/run/john.conf b/run/john.conf
index 215d2a8..b1980f3 100644
--- a/run/john.conf
+++ b/run/john.conf
@@ -42,6 +42,9 @@ TimeFormat = %c
 # reported figures will be less accurate (default 0.05%)
 ETAthreshold = 0.05%
 
+# When printing status, show number of candidates tried
+StatusShowCandidates = N
+
 # Always report (to screen and log) cracked passwords as UTF-8, regardless of
 # input encoding. This is recommended if you have your terminal set for UTF-8.
 AlwaysReportUTF8 = N
diff --git a/src/status.c b/src/status.c
index 3243e2d..337d863 100644
--- a/src/status.c
+++ b/src/status.c
@@ -48,6 +48,7 @@ struct status_main status;
 unsigned int status_restored_time = 0;
 static char* timeformat = NULL;
 static double ETAthreshold = 0.05;
+static int showcand;
 int (*status_get_progress)(int *) = NULL;
 
 static clock_t get_time(void)
@@ -79,6 +80,8 @@ void status_init(int (*get_progress)(int *), int start)
 		if ((ETAthreshold = atof(cfg_threshold)) < 0.01)
 			ETAthreshold = 0.01;
 
+	showcand = cfg_get_bool(SECTION_OPTIONS, NULL, "StatusShowCandidates", 0);
+
 	clk_tck_init();
 }
 
@@ -422,12 +425,15 @@ static void status_print_cracking(char *percent)
 {
 	unsigned int time = status_get_time();
 	char *key, saved_key[PLAINTEXT_BUFFER_SIZE] = "";
-	char s_cps[64];
+	char s_cps[64], cand[32] = "";
 
 	if (!(options.flags & FLG_STATUS_CHK))
 		if ((key = crk_get_key2()))
 			strnzcpy(saved_key, key, PLAINTEXT_BUFFER_SIZE);
 
+	if (showcand)
+		sprintf(cand, "/%.0f", (double)((long long)status.crypts.hi << 32) + status.crypts.lo);
+
 #ifdef HAVE_MPI
 	// we need to print until cr in one call, otherwise output gets interleaved
 	char nodeid[11] = "";
@@ -457,13 +463,13 @@ static void status_print_cracking(char *percent)
 
 	fprintf(stderr,
 	        "%s"
-	        "guesses: %u%s"
+	        "guesses: %u%s%s"
 	        "time: %u:%02u:%02u:%02u"
 	        "%s%s%s"
 	        "c/s: %s"
 	        "%s\n",
 	        nodeid,
-	        status.guess_count,
+	        status.guess_count, cand,
 	        mpi_p > 1 ? " " : "  ",
 	        time / 86400, time % 86400 / 3600, time % 3600 / 60, time % 60,
 	        strncmp(percent, " 100", 4) ? percent : " DONE",
@@ -473,11 +479,11 @@ static void status_print_cracking(char *percent)
 	        trying);
 #else
 	fprintf(stderr,
-		"guesses: %u  "
+		"guesses: %u%s  "
 		"time: %u:%02u:%02u:%02u"
 		"%s%s  "
 		"c/s: %s",
-		status.guess_count,
+		status.guess_count, cand,
 		time / 86400, time % 86400 / 3600, time % 3600 / 60, time % 60,
 		strncmp(percent, " 100", 4) ? percent : " DONE",
 		status_get_ETA(percent,time),
-- 
1.7.4.1

