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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容