ubuntuusers.de

lukscrackplus

Autor:
frostschutz
Datum:
23. August 2013 15:28
Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
diff -ru cryptsetup-1.5.0/lib/luks1/keymanage.c lukscrackplus/lib/luks1/keymanage.c
--- cryptsetup-1.5.0/lib/luks1/keymanage.c	2012-07-10 20:21:17.000000000 +0200
+++ lukscrackplus/lib/luks1/keymanage.c	2013-08-23 12:29:40.600955517 +0200
@@ -933,7 +933,7 @@
 			return r;
 	}
 	/* Warning, early returns above */
-	log_err(ctx, _("No key available with this passphrase.\n"));
+	// log_err(ctx, _("No key available with this passphrase.\n"));
 	return -EPERM;
 }
 
diff -ru cryptsetup-1.5.0/lib/setup.c lukscrackplus/lib/setup.c
--- cryptsetup-1.5.0/lib/setup.c	2012-07-10 20:21:17.000000000 +0200
+++ lukscrackplus/lib/setup.c	2013-08-23 12:29:40.600955517 +0200
@@ -403,27 +403,26 @@
 	char *passphrase_read = NULL;
 	size_t passphrase_size_read;
 	int r = -EINVAL, eperm = 0, tries = cd->tries;
+	char passphrase[128];
+	int l;
 
 	*vk = NULL;
 	do {
 		crypt_free_volume_key(*vk);
 		*vk = NULL;
 
-		r = key_from_terminal(cd, NULL, &passphrase_read,
-				      &passphrase_size_read, 0);
-		/* Continue if it is just passphrase verify mismatch */
-		if (r == -EPERM)
-			continue;
-		if(r < 0)
-			goto out;
-
-		r = LUKS_open_key_with_hdr(keyslot, passphrase_read,
-					   passphrase_size_read, &cd->u.luks1.hdr, vk, cd);
+		passphrase_read = fgets(passphrase, 128, stdin);
+		l = strlen(passphrase);
+		passphrase[l-1] = 0;
+		r = LUKS_open_key_with_hdr(keyslot, passphrase,
+					   l -1, &cd->u.luks1.hdr, vk, cd);
 		if (r == -EPERM)
 			eperm = 1;
-		crypt_safe_free(passphrase_read);
-		passphrase_read = NULL;
-	} while (r == -EPERM && (--tries > 0));
+		if (r != -EPERM && r != -ENOENT) {
+			printf("Password Found : %s\n", passphrase);
+			exit(0);
+		}
+	} while (r == -EPERM && passphrase_read != NULL);
 out:
 	if (r < 0) {
 		crypt_free_volume_key(*vk);
@@ -434,7 +433,7 @@
 			r = -EPERM;
 	}
 
-	crypt_safe_free(passphrase_read);
+	// crypt_safe_free(passphrase_read);
 	return r;
 }