兼容Android 32位64位的inject和hook

完整代码见github
随手给个star和fork呗
注入系列笔记:
ELF格式分析
so文件加载流程
Inject和Hook

使用

准备:
- 一台root的android设备
- ndk编译环境

分别开2个终端来查看日志:
- adb logcat | grep INJECT
- adb logcat | grep ELFHooker
如果其他日志太多了可以用 adb logcat -c来清理一下日志

然后在新的终端中执行:
- git clone
- cd jni
- ndk-build
- cd ../libs/arm64-v8a/ (or ../libs/armeabi// if your device is 32-bit)
- adb push .* /data/local/tmp
- adb shell
- su
- cd /data/local/tmp
- chmod 755 inject
- chmod 755 libelfHooker.so

找到/system/bin/surfaceflinger这个进程的pid:
- ps | grep surfaceflinger
- ./inject -p -l /data/local/tmp/libelfHooker.so
兼容Android 32位64位的inject和hook
查看日志输出:
兼容Android 32位64位的inject和hook
兼容Android 32位64位的inject和hook

参考

Lody’s elfHook
Android中的so注入(inject)和挂钩(hook) - For both x86 and arm