projects
/
platform
/
upstream
/
cryptsetup.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
99643a8
)
Fix some issues in dict example.
author
Milan Broz
<gmazyland@gmail.com>
Thu, 2 Aug 2012 10:51:28 +0000
(12:51 +0200)
committer
Milan Broz
<gmazyland@gmail.com>
Thu, 2 Aug 2012 10:51:28 +0000
(12:51 +0200)
misc/dict_search/luks_dict.c
patch
|
blob
|
history
diff --git
a/misc/dict_search/luks_dict.c
b/misc/dict_search/luks_dict.c
index
9b9ce81
..
26bc931
100644
(file)
--- a/
misc/dict_search/luks_dict.c
+++ b/
misc/dict_search/luks_dict.c
@@
-1,7
+1,7
@@
/*
* Example of LUKS password dictionary search
*
/*
* Example of LUKS password dictionary search
*
- * Run this as root, e.g. ./luks_
check
test.img /usr/share/john/password.lst 4
+ * Run this as root, e.g. ./luks_
dict
test.img /usr/share/john/password.lst 4
*
* Copyright (C) 2012 Milan Broz <asi@ucw.cz>
*
*
* Copyright (C) 2012 Milan Broz <asi@ucw.cz>
*
@@
-52,22
+52,22
@@
static void check(struct crypt_device *cd, const char *pwd_file, unsigned my_id,
len = strlen(pwd);
len = strlen(pwd);
- /* lines starting "#!comment" are comments */
- if (len >= 9 && !strncmp(pwd, "#!comment", 9)) {
- printf("skipping %s\n", pwd);
- continue;
- }
-
/* strip EOL - this is like a input from tty */
if (len && pwd[len - 1] == '\n') {
pwd[len - 1] = '\0';
len--;
}
/* strip EOL - this is like a input from tty */
if (len && pwd[len - 1] == '\n') {
pwd[len - 1] = '\0';
len--;
}
- //printf("%d: checking %s\n", my_id, pwd);
+ /* lines starting "#!comment" are comments */
+ if (len >= 9 && !strncmp(pwd, "#!comment", 9)) {
+ /* printf("skipping %s\n", pwd); */
+ continue;
+ }
+
+ /* printf("%d: checking %s\n", my_id, pwd); */
r = crypt_activate_by_passphrase(cd, NULL, CRYPT_ANY_SLOT, pwd, len, 0);
if (r >= 0) {
r = crypt_activate_by_passphrase(cd, NULL, CRYPT_ANY_SLOT, pwd, len, 0);
if (r >= 0) {
- printf("Found passphrase for slot %d:
%s
\n", r, pwd);
+ printf("Found passphrase for slot %d:
\"%s\"
\n", r, pwd);
break;
}
}
break;
}
}
@@
-92,6
+92,17
@@
int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
+ /* crypt_set_debug_level(CRYPT_DEBUG_ALL); */
+
+ /*
+ * Need to create temporary keyslot device-mapper devices and allocate loop if needed,
+ * so root is requried here.
+ */
+ if (getuid() != 0) {
+ printf("You must be root to run this program.\n");
+ exit(EXIT_FAILURE);
+ }
+
/* signal all children if anything happens */
prctl(PR_SET_PDEATHSIG, SIGHUP);
setpriority(PRIO_PROCESS, 0, -5);
/* signal all children if anything happens */
prctl(PR_SET_PDEATHSIG, SIGHUP);
setpriority(PRIO_PROCESS, 0, -5);
@@
-102,7
+113,7
@@
int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
- /* run scan in separate processes */
+ /* run scan in separate processes
, it is up to scheduler to assign CPUs inteligently
*/
for (i = 0; i < procs; i++)
check(cd, argv[2], i, procs);
for (i = 0; i < procs; i++)
check(cd, argv[2], i, procs);
@@
-111,7
+122,7
@@
int main(int argc, char *argv[])
if (WEXITSTATUS(status) == EXIT_SUCCESS)
continue;
/* kill rest of processes */
if (WEXITSTATUS(status) == EXIT_SUCCESS)
continue;
/* kill rest of processes */
- kill(0, SIG
TERM
);
+ kill(0, SIG
HUP
);
/* not reached */
break;
}
/* not reached */
break;
}