文章目录

  • 一、InMemoryDexClassLoader 类加载器脱壳点总结
    • 1、dalvik_system_DexFile.cc#CreateSingleDexFileCookie
    • 2、dalvik_system_DexFile.cc#CreateDexFile
    • 3、dex_file.cc#DexFile::Open
    • 4、dex_file.cc#DexFile::OpenCommon
    • 5、dex_file.cc#DexFile::DexFile

一、InMemoryDexClassLoader 类加载器脱壳点总结


InMemoryDexClassLoader 类加载器脱壳点总结 : 在下面列举出的函数中 , 都可以获取到内存中 DEX 文件的起始地址 , 可以将 DEX 文件从内存中 dump 下来 ;

1、dalvik_system_DexFile.cc#CreateSingleDexFileCookie

static jobject CreateSingleDexFileCookie(JNIEnv* env, std::unique_ptr<MemMap> data) {std::unique_ptr<const DexFile> dex_file(CreateDexFile(env, std::move(data)));if (dex_file.get() == nullptr) {DCHECK(env->ExceptionCheck());return nullptr;}std::vector<std::unique_ptr<const DexFile>> dex_files;dex_files.push_back(std::move(dex_file));return ConvertDexFilesToJavaArray(env, nullptr, dex_files);
}

源码地址 : /art/runtime/native/dalvik_system_DexFile.cc#CreateSingleDexFileCookie

2、dalvik_system_DexFile.cc#CreateDexFile

static const DexFile* CreateDexFile(JNIEnv* env, std::unique_ptr<MemMap> dex_mem_map) {std::string location = StringPrintf("Anonymous-DexFile@%p-%p",dex_mem_map->Begin(),dex_mem_map->End());std::string error_message;std::unique_ptr<const DexFile> dex_file(DexFile::Open(location,0,std::move(dex_mem_map),/* verify */ true,/* verify_location */ true,&error_message));if (dex_file == nullptr) {ScopedObjectAccess soa(env);ThrowWrappedIOException("%s", error_message.c_str());return nullptr;}if (!dex_file->DisableWrite()) {ScopedObjectAccess soa(env);ThrowWrappedIOException("Failed to make dex file read-only");return nullptr;}return dex_file.release();
}

源码地址 : /art/runtime/native/dalvik_system_DexFile.cc#CreateDexFile

3、dex_file.cc#DexFile::Open

std::unique_ptr<const DexFile> DexFile::Open(const std::string& location,uint32_t location_checksum,std::unique_ptr<MemMap> map,bool verify,bool verify_checksum,std::string* error_msg) {ScopedTrace trace(std::string("Open dex file from mapped-memory ") + location);CHECK(map.get() != nullptr);if (map->Size() < sizeof(DexFile::Header)) {*error_msg = StringPrintf("DexFile: failed to open dex file '%s' that is too short to have a header",location.c_str());return nullptr;}std::unique_ptr<DexFile> dex_file = OpenCommon(map->Begin(),map->Size(),location,location_checksum,kNoOatDexFile,verify,verify_checksum,error_msg);if (dex_file != nullptr) {dex_file->mem_map_.reset(map.release());}return dex_file;
}

源码路径 : /art/runtime/dex_file.cc#182

4、dex_file.cc#DexFile::OpenCommon

std::unique_ptr<DexFile> DexFile::OpenCommon(const uint8_t* base,size_t size,const std::string& location,uint32_t location_checksum,const OatDexFile* oat_dex_file,bool verify,bool verify_checksum,std::string* error_msg,VerifyResult* verify_result) {if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifyNotAttempted;}std::unique_ptr<DexFile> dex_file(new DexFile(base,size,location,location_checksum,oat_dex_file));if (dex_file == nullptr) {*error_msg = StringPrintf("Failed to open dex file '%s' from memory: %s", location.c_str(),error_msg->c_str());return nullptr;}if (!dex_file->Init(error_msg)) {dex_file.reset();return nullptr;}if (verify && !DexFileVerifier::Verify(dex_file.get(),dex_file->Begin(),dex_file->Size(),location.c_str(),verify_checksum,error_msg)) {if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifyFailed;}return nullptr;}if (verify_result != nullptr) {*verify_result = VerifyResult::kVerifySucceeded;}return dex_file;
}

源码地址 : /art/runtime/dex_file.cc#OpenCommon

5、dex_file.cc#DexFile::DexFile

DexFile::DexFile(const uint8_t* base,size_t size,const std::string& location,uint32_t location_checksum,const OatDexFile* oat_dex_file): begin_(base),size_(size),location_(location),location_checksum_(location_checksum),header_(reinterpret_cast<const Header*>(base)),string_ids_(reinterpret_cast<const StringId*>(base + header_->string_ids_off_)),type_ids_(reinterpret_cast<const TypeId*>(base + header_->type_ids_off_)),field_ids_(reinterpret_cast<const FieldId*>(base + header_->field_ids_off_)),method_ids_(reinterpret_cast<const MethodId*>(base + header_->method_ids_off_)),proto_ids_(reinterpret_cast<const ProtoId*>(base + header_->proto_ids_off_)),class_defs_(reinterpret_cast<const ClassDef*>(base + header_->class_defs_off_)),method_handles_(nullptr),num_method_handles_(0),call_site_ids_(nullptr),num_call_site_ids_(0),oat_dex_file_(oat_dex_file) {CHECK(begin_ != nullptr) << GetLocation();CHECK_GT(size_, 0U) << GetLocation();// Check base (=header) alignment.// Must be 4-byte aligned to avoid undefined behavior when accessing// any of the sections via a pointer.CHECK_ALIGNED(begin_, alignof(Header));InitializeSectionsFromMapList();
}

源码地址 : /art/runtime/dex_file.cc#DexFile

【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | InMemoryDexClassLoader 类加载器脱壳点总结 )相关推荐

  1. 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 )

    文章目录 一.ART 虚拟机下 DexClassLoader 类加载器脱壳点总结 1.file_magic.cc#OpenAndReadMagic 函数 2.dex_file.cc#DexFile:: ...

  2. 【Android 插件化】插件化原理 ( 类加载器 )

    Android 插件化系列文章目录 [Android 插件化]插件化简介 ( 组件化与插件化 ) [Android 插件化]插件化原理 ( JVM 内存数据 | 类加载流程 ) [Android 插件 ...

  3. 安卓逆向-new-sec6-5 平头哥框架hook简介 | 类加载器 | 内部类

    新增JNI文件并导入so库 # For more information about using CMake with Android Studio, read the # documentation ...

  4. Android插件化开发基础之Java类加载器与双亲委派模型

    类加载器 Java虚拟机类加载过程是把Class类文件加载到内存,并对Class文件中的数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的java类型的过程. 在加载阶段,java虚拟机需 ...

  5. 【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | 加固厂商在 ART 下使用的两种类加载器 | InMemoryDexClassLoader 源码 )

    文章目录 一.加固厂商在 ART 下使用的两种类加载器 ( InMemoryDexClassLoader | DexClassLoader ) 二.InMemoryDexClassLoader 源码分 ...

  6. 【Android 插件化】“ 插桩式 “ 插件化框架 ( 类加载器创建 | 资源加载 )

    Android 插件化系列文章目录 [Android 插件化]插件化简介 ( 组件化与插件化 ) [Android 插件化]插件化原理 ( JVM 内存数据 | 类加载流程 ) [Android 插件 ...

  7. 【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | dex_file.cc 中创建 DexFile 实例对象的相关函数分析 )

    文章目录 前言 一.dalvik_system_DexFile.cc#CreateDexFile 函数分析 二.dex_file.cc#DexFile::Open 函数分析 三.dex_file.cc ...

  8. 【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | DexFile 构造函数及相关调用函数 | Android 源码中查找 native 函数 )

    文章目录 一.DexFile 构造函数 二.DexFile.openInMemoryDexFile 函数 三.Android 源码中查找 native 函数 一.DexFile 构造函数 上一篇博客 ...

  9. 【Android 逆向】ART 脱壳 ( InMemoryDexClassLoader 脱壳 | BaseDexClassLoader 构造函数 | DexPathList 构造函数及后续调用 )

    文章目录 一.BaseDexClassLoader 构造函数 二.DexPathList 构造函数 三.DexPathList.makeInMemoryDexElements 函数 一.BaseDex ...

最新文章

  1. Linuxtone命令一句话
  2. springMVC--(讲解5)文件上传与传参测试
  3. 设计模式 之 工厂模式
  4. 查找整数c语言编程,关于算法:查找整数的位数
  5. Android之使用VideoView组件播放一个简单的视频
  6. 舒服的网页登录界面设计灵感
  7. mysql_ init数据类型_mysql数据类型
  8. AcWing 874. 筛法求欧拉函数(欧拉函数)
  9. 重写DEV的DateEdit控件的类只选择年月
  10. pytest allure测试报告_pytest文档32allure描述用例详细讲解
  11. 转换PDF技巧1之PDF虚拟打印机操作详解
  12. 不会安装Lomboz?直接下载eclipse JEE吧。
  13. 联想e550笔记本怎么样_摄像头是亮点 — Lenovo 联想 ThinkPad E550C 笔记本 简单评测...
  14. 例4-2 刽子手游戏(Hangman Judge,UVa 489)
  15. 伤心的优酷土豆,抗争逆不过命运
  16. Windows登录多微信
  17. Spark SQL架构工作原理及流程解析
  18. 日历组件(可加上一年下一年))
  19. 13.创建活动、布局、活动关联布局、注册活动
  20. 如何用MCU来控制21489调音?

热门文章

  1. 【055】长江水文数据自动记录程序
  2. python 下载阿里云mysql的备份文件及binlog到本地
  3. postman参数化 接口响应数据获取符合条件的内容参数化给后面的接口使用
  4. quartz定时定时任务执行两次
  5. C++ 函数--幽径初探索
  6. Python: The _imagingft C module is not installed错误的解决
  7. C#枚举类型和结构体
  8. Jmeter教程索引贴
  9. 一些计算机知识的总结(转)
  10. Python(17)_urllib下的parse的编码解码函数