iOS 提取系統動態庫

通過蘋果提供的dsc_extractor來提取
  • 蘋果將大部分系統動態庫都打包放在一個緩存文件中(dyld shared cache)
  • 該文件存放在設施的/System/Library/Caches/com.apple.dyld/dyld_shared_cache_armX,越獄后通過xx助手,或者ifunbox導出
    截屏2021-02-03 下午9.36.51.png
  • 下載最新dyld源碼
  • 找到dsc_extractor.cpp ,我下的832.7.1,路徑在dyld-832.7.1/dyld3/shared-cache/dsc_extractor.cpp
  • 將里面的int main代碼留下·其他都刪了,打印也可以刪了。
#include <stdio.h>
#include <stddef.h>
#include <dlfcn.h>


typedef int (*extractor_proc)(const char* shared_cache_file_path, const char* extraction_root_path,
                              void (^progress)(unsigned current, unsigned total));

int main(int argc, const char* argv[])
{
    if ( argc != 3 ) {
        //fprintf(stderr, "usage: dsc_extractor <path-to-cache-file> <path-to-device-dir>\n");
        return 1;
    }

    //void* handle = dlopen("/Volumes/my/src/dyld/build/Debug/dsc_extractor.bundle", RTLD_LAZY);
    void* handle = dlopen("/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/dsc_extractor.bundle", RTLD_LAZY);
    if ( handle == NULL ) {
        //fprintf(stderr, "dsc_extractor.bundle could not be loaded\n");
        return 1;
    }

    extractor_proc proc = (extractor_proc)dlsym(handle, "dyld_shared_cache_extract_dylibs_progress");
    if ( proc == NULL ) {
        //fprintf(stderr, "dsc_extractor.bundle did not have dyld_shared_cache_extract_dylibs_progress symbol\n");
        return 1;
    }

    int result = (*proc)(argv[1], argv[2], ^(unsigned c, unsigned total) { printf("%d/%d\n", c, total); } );
    //fprintf(stderr, "dyld_shared_cache_extract_dylibs_progress() => %d\n", result);
    return 0;
}
  • clang++ -o dsc_extractor dsc_extractor.cpp 得到dsc_extractor可執行文件
    截屏2021-02-03 下午9.42.14.png
  • dsc_extractordyld_shared_cache_arm64放在一個文件夾
  • ./dsc_extractor dyld_shared_cache_arm64 framework_arm64 提取動態庫
    截屏2021-02-03 下午9.43.08.png
  • 即可在framework_arm64/System/Library/Frameworks里找到
  • 然后就可以丟到hopper里反編譯了
    截屏2021-02-03 下午9.45.01.png

    截屏2021-02-03 下午9.45.58.png
  • 但是現在卻不像以前那樣,能看到大致偽代碼了,可能跟更新系統,Xcode有關吧,有點難受,有知道的大佬可以DDDD。
end
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容