Frida 常用脚本

143 阅读1分钟

Frida 常用脚本

本篇文章主要记录下Frida常用的一些简单的脚本.

1: hook log日志

Java.perform(function () {
    var className = "android.util.Log";
    var Log = Java.use(className);
    // Hook Log.d() 方法
   Log.d.overload('java.lang.String','java.lang.String').implementation = function(tag,msg) {
      console.log(tag+'_hook',msg);
      return this.d(tag+'_hook', msg);
   };

   // Hook Log.e() 方法
   Log.e.overload('java.lang.String','java.lang.String').implementation = function(tag,msg) {
      console.log(tag+'_hook',msg);
      return this.e(tag+'_hook', msg);
   };
});

注意Log.e/d方法的返回值.

如果写成了下面这种就会报错了:

 Log.e.overload('java.lang.String','java.lang.String').implementation = function(tag,msg) {
      console.log(tag+'_hook',msg);
       this.e(tag+'_hook', msg);
   };

错误如下:

Error: Implementation for e expected return value compatible with int
    at ne (frida/node_modules/frida-java-bridge/lib/class-factory.js:621)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/class-factory.js:598)

2:

本文由博客一文多发平台 OpenWrite 发布!