脱壳点一览
InMemoryDexClassLoader
- DexFile
- DexFile_createSingleDexFileCookie native层面
- DexFile::OpenCommon
DexClassLoader
- DexPathList
- DexFile.java
- DexFile_openDexFileNative
- DexFile::Open
- OpenAndReadMagic # 还未进入内存加载
DexClassLoader源码分析
- OpenAndReadMagic(filename, &magic, error_msg);
- DexFile::OpenCommon(const uint8_t* base,
- DexFile::DexFile(const unit8_t* base,
ART源码修改实践
-
挂载编译好的Android源码磁盘(root用户)
mount /dev/sda3 /root/Desktop/COMPILE/ -
安装编译器
apt install geany -
进入Android源码对应的目录中使用geany进行编辑修改
# 进入对应的目录 cd ~/Desktop/COMPILE/aosp810r1/art/runtime # 使用geany编辑器打开 dex_file.cc geany dex_file.cc- 在
dex_file.cc中DexFile::DexFile和DexFile::OpenCommon注入以下代码(Android-8.0.0.1_r1) - 在
DvmDex.cpp中dvmDexFileOpenPartial中注入以下代码(Android-4.4.4_r1) - ` DexPrepare.cpp ` 中
dvmOptimizeDexFile的函数中的565L注入代码
int pid = getpid(); char dexfilepath[100] = {0}; sprintf(dexfilepath, "/sdcard/%d_%d_DexFile.dex", (int)size, pid); int fd = open(dexfilepath,O_CREAT|O_RDWR,666); if(fd>0){ int number = write(fd,base,size); if(number>0){ } close(fd); }int pid = getpid(); char dexfilepath[100] = {0}; sprintf(dexfilepath, "/sdcard/%d_%d_DexFile.dex", (int)size, pid); int fd = open(dexfilepath,O_CREAT|O_RDWR,666); if(fd>0){ int number = write(fd,base,size); if(number>0){ } close(fd); } - 在
-
进入~/Desktop/COMPILE/aosp810r1目录中进行编译环境加载
export LC_ALL=C # 我的使用这个命令不行 . bulid/envsetup.sh # 我采用使用以前的命令 source build/envsetup.sh lunch # 输入24选中24.aosp_sailfish-userdebug > 24 # 使用m命令进行编译,修改编译不需要太久,内存也不会消耗像第一次那么严重,第二次编译我花了12:25 m -
魔改编译完成后进行刷入手机
cd out/target/product/sailfish thunar .-
将当前目录下的img镜像文件复制到在网上下载的镜像文件的
imge-sailfish-opm1.171019.001中(注意会发现只有两个img文件被修改了),内容进行替换# 进行img替换的镜像目录 /root/Desktop/sailfish-opm1.171019.011/image-sailfish-opm1.171019.011/ -
内容替换好后在当前目录进项所有文件打包成
.zip文件格式,ctrl + a -> 右键鼠标 -> create Archi.. -
打包好了后,将打包好的
.zip文件重命名并移动到上一级目录/root/Desktop/sailfish-opm1.171019.011/ -
记得检查
fish-all.sh文件末尾指定的刷入文件是我们打包好重命名的.zip文件
-
-
手机进入bootloader模式(手机完全关机 ->
电源键+音量-键) -
运行
flash-all.sh脚本进行镜像刷入# 如果提示写入文件失败可能时usb链接不够稳定,记得换一个接口 ./flash-all.sh -
进行app脱壳时记得给读写文件的权限