keychaindump icon indicating copy to clipboard operation
keychaindump copied to clipboard

Will not compile on El Capitan

Open steveswinsburg opened this issue 8 years ago • 11 comments

$ 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.

steveswinsburg avatar Nov 05 '16 08:11 steveswinsburg

Same problem running on macOS Sierra.

SailReal avatar Nov 10 '16 23:11 SailReal

Same here

henno avatar Nov 30 '16 08:11 henno

This worked:

brew install openssl gcc keychaindump.c -o keychaindump -lcrypto -I /usr/local/opt/openssl/include

henno avatar Nov 30 '16 08:11 henno

the same works with macports: gcc keychaindump.c -o keychaindump -lcrypto -I /opt/local/include

m0yellow avatar May 18 '17 19:05 m0yellow

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

F1LT3R avatar Jul 07 '17 16:07 F1LT3R

I get the above error too, any ideas?

barrett092 avatar Jul 31 '17 18:07 barrett092

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

danpolanco avatar Sep 19 '17 23:09 danpolanco

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

ghost avatar Mar 06 '19 10:03 ghost

@mrRobotSAS I went ahead and fixed those warnings in #11

thehappydinoa avatar Mar 11 '19 01:03 thehappydinoa

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 avatar Jul 06 '20 18:07 JonathanAnderson

@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.

Castle-Oak avatar Dec 25 '20 09:12 Castle-Oak