Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Tue, 29 Oct 2013 18:23:34 +0400
From: Solar Designer <solar@...nwall.com>
To: john-dev@...ts.openwall.com
Subject: descrypt-opencl "section 0" fix

Sayantan, magnum -

descrypt-opencl was failing to crack some of the hashes the correct
candidate passwords for which appeared in indices 0 to 31.  In a test
using pw-fake-unix and password.lst, 17 passwords among the first 32
were not cracked.  All of these 17 had unique salts - that is, there
were no other loaded hashes with the same salts.  Then I came up with a
simpler test case, using this one hash:

VTb0BiUKhqhjU

(corresponds to 123456) and a wordlist containing repeats of these two
lines:

123456
12345

With up to 32 lines (16 repetitions) in the wordlist file, the password
was not cracked.  With 33 lines (one 123456 added to the end of the
file), the password was cracked.

A section 0 cracked password initially results in cmp_out[i] = 1, but
after cmp_out[i]-- this turns into 0, so max stays at 0 and the
successful guess is not detected.

The attached patch attempts to and appears to correct this.  At least my
tests pass now.  Note that while I am patching both instances of the
code, I think I have tested only one of them.

Alexander

diff --git a/src/opencl_DES_bs_b.c b/src/opencl_DES_bs_b.c
index 7922c13..b22367b 100644
--- a/src/opencl_DES_bs_b.c
+++ b/src/opencl_DES_bs_b.c
@@ -571,27 +571,24 @@ int opencl_DES_bs_crypt_25(int *pcount, struct db_salt *salt)
 
 		HANDLE_CLERROR(clEnqueueReadBuffer(queue[ocl_gpu_id], cmp_out_gpu, CL_TRUE, 0, (salt -> count) * sizeof(unsigned int), cmp_out, 0, NULL, NULL),"Write FAILED\n");
 
-		for (i = 0; i < salt->count ;i++) {
-			if(!cmp_out[i]) {
+		for (i = 0; i < salt->count; i++) {
+			if (!cmp_out[i]) {
 				cmp_out[i] = ~(unsigned int)0;
-				continue ;
+				continue;
 			}
-			cmp_out[i]--;
 			if (cmp_out[i] > max)
 				max = cmp_out[i];
-
-			if(cmp_out[i] < min)
+			cmp_out[i]--;
+			if (cmp_out[i] < min)
 				min = cmp_out[i];
-
 		}
 
-		if (max) {
+		if (max--) {
 			HANDLE_CLERROR(clEnqueueReadBuffer(queue[ocl_gpu_id], B_gpu,CL_TRUE, 0, MULTIPLIER * 64 * sizeof(DES_bs_vector), B, 0, NULL, NULL),"Write FAILED\n");
 			clFinish(queue[ocl_gpu_id]);
-			return (max + 1)* DES_BS_DEPTH;
-		}
-
-		else return 0;
+			return (max + 1) * DES_BS_DEPTH;
+		} else
+			return 0;
 
 	}
 
@@ -671,29 +668,24 @@ int opencl_DES_bs_crypt_25(int *pcount, struct db_salt *salt)
 
 		HANDLE_CLERROR(clEnqueueReadBuffer(queue[ocl_gpu_id], cmp_out_gpu, CL_TRUE, 0, (salt->count) * sizeof(unsigned int), cmp_out, 0, NULL, NULL), "Write FAILED\n");
 
-		for (i = 0; i < salt->count ;i++) {
-			if(!cmp_out[i]) {
+		for (i = 0; i < salt->count; i++) {
+			if (!cmp_out[i]) {
 				cmp_out[i] = ~(unsigned int)0;
-				continue ;
+				continue;
 			}
-			cmp_out[i]--;
 			if (cmp_out[i] > max)
 				max = cmp_out[i];
-
-			if(cmp_out[i] < min)
+			cmp_out[i]--;
+			if (cmp_out[i] < min)
 				min = cmp_out[i];
-
 		}
 
-
-		if(max) {
-
+		if (max--) {
 			HANDLE_CLERROR(clEnqueueReadBuffer(queue[ocl_gpu_id], B_gpu, CL_TRUE, 0, MULTIPLIER * 64 * sizeof(DES_bs_vector), B, 0, NULL, NULL), "Write FAILED\n");
 			clFinish(queue[ocl_gpu_id]);
-			return (max + 1) * DES_BS_DEPTH ;
-		}
-
-		else return 0;
+			return (max + 1) * DES_BS_DEPTH;
+		} else
+			return 0;
 
 	}
 

Powered by blists - more mailing lists

Your e-mail address:

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