Skip to content

Instantly share code, notes, and snippets.

@ryosan-470
Last active February 28, 2017 08:21
Show Gist options
  • Save ryosan-470/e998c720451f8ec849b0 to your computer and use it in GitHub Desktop.
Save ryosan-470/e998c720451f8ec849b0 to your computer and use it in GitHub Desktop.
The patch of pkcrack to build on Mac OSX and Homebrew
diff --git Makefile Makefile
index af87e95..04928f1 100644
--- Makefile
+++ Makefile
@@ -1,5 +1,5 @@
CC=gcc
-CFLAGS=-O6 -Wall
+CFLAGS=-O3 -Wall
#CFLAGS=-g
RM=rm -f
@@ -36,7 +36,7 @@ clean:
$(RM) pkcrack
$(RM) *.o
$(RM) findkey
- $(RM) zipdec~1
+ $(RM) zipdecrypt
$(RM) extract
$(RM) makekey
$(RM) *.exe
diff --git exfunc.c exfunc.c
index 18cdf4a..6b358e6 100644
--- exfunc.c
+++ exfunc.c
@@ -41,7 +41,11 @@
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <ctype.h>
#include "headers.h"
diff --git extract.c extract.c
index 6cb7800..38380ba 100644
--- extract.c
+++ extract.c
@@ -68,7 +68,11 @@
#endif
#include <fcntl.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#include "headers.h"
diff --git main.c main.c
index 8e58072..d90f4a3 100644
--- main.c
+++ main.c
@@ -80,7 +80,9 @@ static char RCSID[]="$Id: main.c,v 1.15 2002/11/12 16:58:02 lucifer Exp $";
#include <sys/stat.h>
#include <fcntl.h>
-#include <malloc.h>
+#ifndef __APPLE__
+ #include <malloc.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git readhead.c readhead.c
index 3ab563c..e1be9c1 100644
--- readhead.c
+++ readhead.c
@@ -55,7 +55,11 @@
/* Functions to read signature and headers */
/******************************************************************************/
#include <stdio.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#ifndef _WIN32
diff --git zipdecrypt.c zipdecrypt.c
index d26931f..df7cef1 100644
--- zipdecrypt.c
+++ zipdecrypt.c
@@ -84,7 +84,11 @@ static char RCSID[]="$Id: zipdecrypt.c,v 1.16 2003/01/05 14:40:37 lucifer Exp $"
#include <sys/stat.h>
#include <fcntl.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#include "pkctypes.h"
#include "crc.h"
diff --git a/src/Makefile b/src/Makefile
index af87e95..04928f1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
CC=gcc
-CFLAGS=-O6 -Wall
+CFLAGS=-O3 -Wall
#CFLAGS=-g
RM=rm -f
@@ -36,7 +36,7 @@ clean:
$(RM) pkcrack
$(RM) *.o
$(RM) findkey
- $(RM) zipdec~1
+ $(RM) zipdecrypt
$(RM) extract
$(RM) makekey
$(RM) *.exe
diff --git a/src/exfunc.c b/src/exfunc.c
index 18cdf4a..6b358e6 100644
--- a/src/exfunc.c
+++ b/src/exfunc.c
@@ -41,7 +41,11 @@
#include <stdio.h>
#include <string.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <ctype.h>
#include "headers.h"
diff --git a/src/extract.c b/src/extract.c
index 6cb7800..38380ba 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -68,7 +68,11 @@
#endif
#include <fcntl.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#include "headers.h"
diff --git a/src/main.c b/src/main.c
index 8e58072..d90f4a3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,7 +80,9 @@ static char RCSID[]="$Id: main.c,v 1.15 2002/11/12 16:58:02 lucifer Exp $";
#include <sys/stat.h>
#include <fcntl.h>
-#include <malloc.h>
+#ifndef __APPLE__
+ #include <malloc.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git a/src/readhead.c b/src/readhead.c
index 3ab563c..e1be9c1 100644
--- a/src/readhead.c
+++ b/src/readhead.c
@@ -55,7 +55,11 @@
/* Functions to read signature and headers */
/******************************************************************************/
#include <stdio.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#ifndef _WIN32
diff --git a/src/zipdecrypt.c b/src/zipdecrypt.c
index d26931f..df7cef1 100644
--- a/src/zipdecrypt.c
+++ b/src/zipdecrypt.c
@@ -84,7 +84,11 @@ static char RCSID[]="$Id: zipdecrypt.c,v 1.16 2003/01/05 14:40:37 lucifer Exp $"
#include <sys/stat.h>
#include <fcntl.h>
-#include <malloc.h>
+#ifdef __APPLE__
+ #include <stdlib.h>
+#else
+ #include <malloc.h>
+#endif
#include <string.h>
#include "pkctypes.h"
#include "crc.h"
@ryosan-470
Copy link
Author

ryosan-470 commented Mar 31, 2015

How to apply the patch

Move to src directory and use patch command, something like this:

$ cd /path/to/pkcrack-x.xx/src
$ patch -p0 < pkcrack_for_osx.diff

I wrote this patch to install the pkcrack from Homebrew. Please refer to Homebrew/legacy-homebrew#38187 to know more detail.

🎉 This patch and the fomula to install pkcrack is merged.
Homebrew/legacy-homebrew@a3f9664

So, if you want to install its on your Mac, run below:

$ brew install pkcrack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment