├── .DS_Store ├── AndroidManifest.xml ├── jni ├── Android.mk ├── Application.mk ├── Log.cpp ├── Log.h ├── Main.cpp ├── Main.h ├── Utils.cpp └── Utils.h ├── proguard-project.txt └── project.properties /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FateHack/dumpSo/b8ac1f988d9aa7e9bfc5517392cd16d0f7f815ee/.DS_Store -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_MODULE := fate 7 | LOCAL_C_INCLUDES := \ 8 | $(LOCAL_PATH)/ \ 9 | $(LOCAL_PATH)/libzip/ 10 | 11 | LOCAL_CFLAGS := -DANDROID_NDK -Wno-psabi \ 12 | -DDISABLE_IMPORTGL 13 | 14 | 15 | LOCAL_SRC_FILES +=\ 16 | Utils.cpp\ 17 | Main.cpp\ 18 | 19 | 20 | 21 | LOCAL_LDLIBS := -ldl -llog -lz 22 | 23 | LOCAL_ARM_MODE := arm 24 | 25 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | #APP_ABI := armeabi 2 | #APP_ABI := x86 3 | #APP_ABI := mips 4 | #APP_ABI := mips armeabi armeabi-v7a x86 5 | #APP_ABI := armeabi x86 6 | APP_ABI := armeabi-v7a 7 | 8 | # use static stl port 9 | APP_STL := stlport_static 10 | APP_CPPFLAGS += -fno-exceptions 11 | APP_CPPFLAGS += -g0 12 | APP_CPPFLAGS += -fno-rtti 13 | 14 | -------------------------------------------------------------------------------- /jni/Log.cpp: -------------------------------------------------------------------------------- 1 | #include "Log.h" 2 | 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /jni/Log.h: -------------------------------------------------------------------------------- 1 | #ifndef _SECSHELL_LOG_ 2 | #define _SECSHELL_LOG_ 3 | 4 | #include 5 | #include 6 | 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define LOG_TAG "Fuck" 13 | 14 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__) 15 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 16 | #define LOGF(...) __android_log_print(ANDROID_LOG_FATAL,LOG_TAG,__VA_ARGS__) 17 | 18 | #if (1) 19 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 20 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) 21 | #else 22 | #define LOGD(...) 23 | #define LOGI(...) 24 | #endif 25 | 26 | 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif 33 | 34 | 35 | -------------------------------------------------------------------------------- /jni/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Log.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "Utils.h" 19 | 20 | using namespace std; 21 | 22 | //typedef int(*mprotect_t)(void* __addr, size_t __size, int __prot); 23 | 24 | int dump(const char* soName) { 25 | ProcMap map = getLibraryMap(soName); 26 | if (!map.isValid())//maps中没有找到相应的内存映射 27 | { 28 | return -1; 29 | } 30 | int n = map.length / getpagesize() + 1; 31 | int ret = mprotect(map.startAddr, n * getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC);//内存可读可写 32 | char* memory = (char*)malloc(map.length); 33 | memcpy(memory, map.startAddr, map.length); 34 | char savePath[1024] = { 0 }; 35 | sprintf(savePath, "/sdcard/%s-%s", map.startAddr, soName); 36 | FILE* file = fopen(savePath, "w+"); 37 | fwrite(memory, 1, map.length, file); 38 | fclose(file); 39 | free(memory); 40 | return 0; 41 | } 42 | 43 | void* my_thread(void* pVoid) { 44 | LOGD("Hook:====hook_game_proxy begin===="); 45 | while (1) { 46 | sleep(3); 47 | int ret = dump("libil2cpp.so"); 48 | int ret2 = dump("global-metadata.dat"); 49 | if (ret == 0 && ret2 == 0) { 50 | pthread_exit((void*)"the first return!"); 51 | } 52 | } 53 | LOGD("Hook:=====hook_game_proxy finish====="); 54 | } 55 | 56 | __attribute__((constructor)) void entry() 57 | { 58 | LOGI("=======================Enter lib entry====================="); 59 | int err; 60 | pthread_t ntid; 61 | pthread_create(&ntid, NULL, my_thread, NULL); 62 | if (err != 0) { 63 | printf("create thread failed:%s\n", strerror(err)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /jni/Main.h: -------------------------------------------------------------------------------- 1 | #ifndef _HOOK_H_ 2 | #define _HOOK_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | void* my_thread(void *pVoid); 22 | 23 | #endif //_HOOK_H_ -------------------------------------------------------------------------------- /jni/Utils.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "Utils.h" 4 | 5 | 6 | ProcMap getLibraryMap(int pid, const char *libraryName) { 7 | ProcMap retMap; 8 | char line[512] = {0}; 9 | char mapPath[128] = {0}; 10 | sprintf(mapPath, "/proc/%d/maps", pid); 11 | FILE *fp = fopen(mapPath, "rt"); 12 | bool isFirst = true; 13 | void *tmp; 14 | int index=0; 15 | if (fp != NULL) { 16 | while (fgets(line, sizeof(line), fp)) { 17 | index++; 18 | if (strstr(line, libraryName)) { 19 | if (isFirst||index>100050) { //第一次读取或距离第一次读取距离较远 20 | char tmpPerms[5] = {}, tmpDev[12] = {}, tmpPathname[455] = {}; 21 | sscanf(line, "%llx-%llx %s %ld %s %d %s", 22 | (long long unsigned *) &retMap.startAddr, 23 | (long long unsigned *) &retMap.endAddr, 24 | tmpPerms, &retMap.offset, tmpDev, &retMap.inode, tmpPathname); 25 | retMap.perms = tmpPerms; 26 | retMap.dev = tmpDev; 27 | retMap.pathname = tmpPathname; 28 | index=100000; //从100000开始 29 | isFirst = false; 30 | } else { 31 | sscanf(line, "%llx-%llx", 32 | (long long unsigned *) &tmp, 33 | (long long unsigned *) &retMap.endAddr); 34 | } 35 | } 36 | } 37 | retMap.length = (uint64_t) retMap.endAddr - (uint64_t) retMap.startAddr; 38 | fclose(fp); 39 | } 40 | return retMap; 41 | } 42 | 43 | 44 | std::string getProcName() { 45 | std::string ret; 46 | char cmdline[256] = {0}; 47 | FILE *fp; 48 | fp = fopen("/proc/self/cmdline", "r"); 49 | if (fp) { 50 | fgets(cmdline, sizeof(cmdline), fp); 51 | fclose(fp); 52 | ret = cmdline; 53 | } 54 | return ret; 55 | } 56 | 57 | bool getFileStat(const char *fileName, struct stat *buffer) { 58 | return stat(fileName, buffer) != -1; 59 | } 60 | -------------------------------------------------------------------------------- /jni/Utils.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef UTILS_H 3 | #define UTILS_H 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | struct ProcMap { 16 | void *startAddr; 17 | void *endAddr; 18 | size_t length; 19 | std::string perms; 20 | long offset; 21 | std::string dev; 22 | int inode; 23 | std::string pathname; 24 | 25 | bool isValid() { return (startAddr != NULL && endAddr != NULL && !pathname.empty()); } 26 | }; 27 | 28 | 29 | ProcMap getLibraryMap(int pid,const char *libraryName); 30 | 31 | std::string getProcName(); 32 | 33 | std::string getSoName(); 34 | 35 | bool getFileStat(const char *fileName, struct stat *buffer); 36 | 37 | bool isMainProcName(); 38 | 39 | #endif //UTILS_H 40 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | --------------------------------------------------------------------------------