keychaindump
keychaindump copied to clipboard
Will not compile on El Capitan
$ gcc keychaindump.c -o keychaindump -lcrypto keychaindump.c:12:10: fatal error: 'openssl/des.h' file not found #include <openssl/des.h> ^ 1 error generated.
Same problem running on macOS Sierra.
Same here
This worked:
brew install openssl gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include
the same works with macports:
gcc keychaindump.c -o keychaindump -lcrypto -I /opt/local/include
Not building here using any of the above methods.
For example: working from @henno's comment: gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include
I get:
keychaindump.c:449:9: warning: implicit declaration of function 'geteuid' is invalid in C99 [-Wimplicit-function-declaration]
if (geteuid()) {
^
keychaindump.c:490:21: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
keychaindump.c:490:21: note: place parentheses around the assignment to silence this warning
if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
^
( )
keychaindump.c:490:21: note: use '==' to turn this assignment into an equality comparison
if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) {
^
==
2 warnings generated.
ld: library not found for -lcrypto
I get the above error too, any ideas?
Assuming you have used home-brew to install openssl, if you run brew link openssl
it gives you the correct method for fixing this.
➜ Downloads brew link openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
So the correct command (for now) is gcc keychaindump.c -o keychaindump -lcrypto -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
.
Related: Homebrew/brew#612
Not building here using any of the above methods.
For example: working from @henno's comment:
gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include
I get:keychaindump.c:449:9: warning: implicit declaration of function 'geteuid' is invalid in C99 [-Wimplicit-function-declaration] if (geteuid()) { ^ keychaindump.c:490:21: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) { ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keychaindump.c:490:21: note: place parentheses around the assignment to silence this warning if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) { ^ ( ) keychaindump.c:490:21: note: use '==' to turn this assignment into an equality comparison if (key_len = dump_wrapping_key(key, g_master_candidates[i], buffer, sz)) { ^ == 2 warnings generated. ld: library not found for -lcrypto
Had the same issue, but after executing brew reinstall SSL, brew gave me the following path for openssl : /usr/local/Cellar/openssl/
So using the right path would give : gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/Cellar/openssl/1.0.2q/include -L /usr/local/Cellar/openssl/1.0.2q/lib
1.0.2q may be another version depending on your system.
Worked with 2 warnings; Hope this will help
@mrRobotSAS I went ahead and fixed those warnings in #11
I needed to apply the following diff to get it to compile for me with home-brew's openssl.
diff --git a/keychaindump.c b/keychaindump.c
index f00bf4c..970598e 100644
--- a/keychaindump.c
+++ b/keychaindump.c
@@ -1,5 +1,6 @@
// Build instructions:
// $ gcc keychaindump.c -o keychaindump -lcrypto
+// $ gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include -L /usr/local/opt/openssl/lib
// Usage:
// $ sudo ./keychaindump [path to keychain file, leave blank for default]
@@ -12,6 +13,8 @@
#include <openssl/des.h>
#include <sys/sysctl.h>
+#define C_Block DES_cblock
+
// This structure's fields are pieced together from several sources,
// using the label as an identifier. See find_or_create_credentials.
typedef struct t_credentials {
@JonathanAnderson 's solution worked on Big Sur
gcc-10 keychaindump.c -o keychaindump -lcrypto -I/usr/local/Cellar/[email protected]/1.1.1i/include -L/usr/local/Cellar/[email protected]/1.1.1i/lib
However, no bueno. Looks like Apple finally fixed the issue that allowed this tool to work.