strazzere / android-unpacker

Android Unpacker presented at Defcon 22: Android Hacker Protection Level 0
Apache License 2.0
1.12k stars 331 forks source link

unable to compile native unpacker #41

Closed springrider closed 6 years ago

springrider commented 6 years ago

I am using android-ndk-r10d, under "native-unpacker " dir,
using "make" command, at first it prompts: [armeabi] Compile thumb : kisskiss <= kisskiss.c

./kisskiss.c: In function 'main':
./kisskiss.c:110:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for(int i = 0; i < found; i++) {
   ^
./kisskiss.c:110:3: note: use option -std=c99 or -std=gnu99 to compile your code

then I added "LOCAL_CFLAGS += -std=c99" in Android.mk and it passed, but when I "make" again, it says:

[armeabi] Compile thumb  : kisskiss <= kisskiss.c
./kisskiss.c: In function 'peek_memory':
./kisskiss.c:341:3: warning: implicit declaration of function 'pread64' [-Wimplicit-function-declaration]
   int read = pread64(memory_file, buffer, 8, address);
   ^
[armeabi] Executable     : kisskiss
./kisskiss.c:341: error: undefined reference to 'pread64'
./kisskiss.c:378: error: undefined reference to 'pread64'
collect2: error: ld returned 1 exit status
make[1]: *** [obj/local/armeabi/kisskiss] Error 1

any suggestion?

strazzere commented 6 years ago

I suggest repulling the directory and potentially using a more up to date ndk. Works fine for me on a fresh macbook which I've installed the ndk via brew;

[100%]tstrazzere@rocksteady:[~/repo/android/other-test/android-unpacker/native-unpacker] $ ls -l /usr/local/bin/ndk-build 
lrwxr-xr-x  1 tstrazzere  admin    47B Jan  6  2018 /usr/local/bin/ndk-build -> /usr/local/Caskroom/android-ndk/16b/ndk_exec.sh
[100%]tstrazzere@rocksteady:[~/repo/android/other-test/android-unpacker/native-unpacker] $ make
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.    
make[1]: Entering directory `/Users/tstrazzere/repo/android/other-test/android-unpacker/native-unpacker'
[arm64-v8a] Compile        : kisskiss <= kisskiss.c
./kisskiss.c:371:79: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
  printf(" [+] Attempting to search inside memory region 0x%llx to 0x%llx\n", memory->start, memory->end);
                                                           ~~~~               ^~~~~~~~~~~~~
                                                           %lx
./kisskiss.c:371:94: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
  printf(" [+] Attempting to search inside memory region 0x%llx to 0x%llx\n", memory->start, memory->end);
                                                                     ~~~~                    ^~~~~~~~~~~
                                                                     %lx
./kisskiss.c:395:92: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
      printf("  [+] Memory region 0x%llx to 0x%llx contained anticipated class path %s\n", memory->start, memory->end, class_path);
                                    ~~~~                                                   ^~~~~~~~~~~~~
                                    %lx
./kisskiss.c:395:107: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
      printf("  [+] Memory region 0x%llx to 0x%llx contained anticipated class path %s\n", memory->start, memory->end, class_path);
                                              ~~~~                                                        ^~~~~~~~~~~
                                              %lx
4 warnings generated.
[arm64-v8a] Executable     : kisskiss
[arm64-v8a] Install        : kisskiss => libs/arm64-v8a/kisskiss
[armeabi-v7a] Compile thumb  : kisskiss <= kisskiss.c
[armeabi-v7a] Executable     : kisskiss
[armeabi-v7a] Install        : kisskiss => libs/armeabi-v7a/kisskiss
[x86] Compile        : kisskiss <= kisskiss.c
[x86] Executable     : kisskiss
[x86] Install        : kisskiss => libs/x86/kisskiss
[x86_64] Compile        : kisskiss <= kisskiss.c
./kisskiss.c:371:79: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
  printf(" [+] Attempting to search inside memory region 0x%llx to 0x%llx\n", memory->start, memory->end);
                                                           ~~~~               ^~~~~~~~~~~~~
                                                           %lx
./kisskiss.c:371:94: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
  printf(" [+] Attempting to search inside memory region 0x%llx to 0x%llx\n", memory->start, memory->end);
                                                                     ~~~~                    ^~~~~~~~~~~
                                                                     %lx
./kisskiss.c:395:92: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
      printf("  [+] Memory region 0x%llx to 0x%llx contained anticipated class path %s\n", memory->start, memory->end, class_path);
                                    ~~~~                                                   ^~~~~~~~~~~~~
                                    %lx
./kisskiss.c:395:107: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
      printf("  [+] Memory region 0x%llx to 0x%llx contained anticipated class path %s\n", memory->start, memory->end, class_path);
                                              ~~~~                                                        ^~~~~~~~~~~
                                              %lx
4 warnings generated.
[x86_64] Executable     : kisskiss
[x86_64] Install        : kisskiss => libs/x86_64/kisskiss
make[1]: Leaving directory `/Users/tstrazzere/repo/android/other-test/android-unpacker/native-unpacker'
springrider commented 6 years ago

so sorry for the late reply, I didn't know you reply so quick. will try it now and update the result.

springrider commented 6 years ago

yep it's the ndk version caused the problem. I used brew to install new version ndk and it works now, thanks alot for your time!

strazzere commented 6 years ago

Not a problem, glad it worked!