2. Android逆向-Frida示例

Frida例子

使用Frida尝试hook,做第一个示例代码。代码来源:r0ysue/AndroidFridaBeginnersBook

由于设备要解锁bootloader需要一台专门android设备,暂且使用genymotion模拟器进行测试(保证frida-server具有root权限)。

HelloWorld

hello_world.js 代码注入到本地android项目上的 onCreate() 方法。

$ frida -U -l hello_world.js [process_name]

js文件内容如下。

setTimeout(function(){
    Java.perform(function(){
        console.log("hello world!");
      });
  });

执行结果:

     ____
    / _  |   Frida 15.1.24 - A world-class dynamic instrumentation toolkit
   | (_| |
    > _  |   Commands:
   /_/ |_|       help      -> Displays the help system
   . . . .       object?   -> Display information about 'object'
   . . . .       exit/quit -> Exit
   . . . .
   . . . .   More info at https://frida.re/docs/home/
   . . . .
   . . . .   Connected to Google Nexus 5X (id=192.168.56.101:5555)
Attaching...                                                            
hello world!
[Google Nexus 5X::android.process.media ]->

成功打印出 hello world! 结果。

创建的demo

  1. 创建一个Demo程序,运行到虚拟机上。
  2. 针对MainActivity上两个按钮的click事件,进行hook。
  3. 使用上述同样的命令将js文件注入到进程上。
$ frida -U -l '1_mt.js' com.ruixi.android

但遇到错误提示。

     ____
    / _  |   Frida 15.1.24 - A world-class dynamic instrumentation toolkit
   | (_| |
    > _  |   Commands:
   /_/ |_|       help      -> Displays the help system
   . . . .       object?   -> Display information about 'object'
   . . . .       exit/quit -> Exit
   . . . .
   . . . .   More info at https://frida.re/docs/home/
   . . . .
   . . . .   Connected to Google Nexus 5X (id=192.168.56.101:5555)
Failed to spawn: unable to find process with name 'com.ruixi.android'

遇到这样的我问题,可以考虑使用另一个命令。

$ frida -U -f com.ruixi.android -l '1_mt.js' --no-pause
     ____
    / _  |   Frida 15.1.24 - A world-class dynamic instrumentation toolkit
   | (_| |
    > _  |   Commands:
   /_/ |_|       help      -> Displays the help system
   . . . .       object?   -> Display information about 'object'
   . . . .       exit/quit -> Exit
   . . . .
   . . . .   More info at https://frida.re/docs/home/
   . . . .
   . . . .   Connected to Google Nexus 5X (id=192.168.56.101:5555)
Spawning `com.ruixi.android`...                                         
Script loaded successfully 
Spawned `com.ruixi.android`. Resuming main thread!                      
[Google Nexus 5X::com.ruixi.android ]-> Inside java perform function
Java.Use.Successfully!
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

VoidHope

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值