兼容Android 32位64位的inject和hook

在简书一直都是只看不说,现在分享一篇安卓注入相关的基础文章
项目地址,嘿嘿,觉得有帮助的麻烦给点star吧~

ELFHooker

基于EFL文件格式Hook的demo,hook了SurfaceFlinger进程的eglSwapBuffers函数,替换为new_eglSwapBuffers。

兼容Android 32位和64位。

注入系列笔记:

ELF格式分析
so文件加载流程
Inject和Hook

使用

准备:

  • 一台root的android设备
  • ndk编译环境

分别开2个终端来查看日志:

  • adb logcat | grep INJECT

  • adb logcat | grep ELFHooker

    如果日志太多了可以用 adb logcat -c来清理一下日志

然后在新的终端中执行:

  • git clone git@github.com:MelonWXD/ELFHooker.git
  • cd ELFHooker/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 (如果要在代码中实现的话,可以遍历/proc/pid/cmdline文件来找到你某个进程名对应的pid)
  • ./inject -p pid -l /data/local/tmp/libelfHooker.so
这里图片上传失败了,详细的可以去github看readme

参考

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

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

推荐阅读更多精彩内容