python3 安装Frida
pip install frida-tools
查看Frida版本
frida --version
1. 查看手机cpu 型号 然后下载相对应的Frider
2. 查看cpu 命令 adb shell getprop ro.product.cpu.abi
3. 下载地址: https://github.com/frida/frida/releases 注意下载的版本要和上面的一致
安装到手机端
注意: 在你下的frida-server 目录下面打开cmd
1. adb push frida-server-14.2.14-android-x86 /data/local/tmp push到手机
2. 进入手机终端 给frida-server 权限
adb shell 进入手机终端
cd /data/local/tmp 到达目录
chmod -R 777 frida-server-14.2.14-android-x86 添加权限
exit 退出手机终端
adb shell /data/local/tmp/frida-server-14.2.14-android-x86 启动frida
然后另起一个cmd 转发端口, 不然python 代码连接不到 frida
adb forward tcp:27042 tcp:27042
然后就可以编写hook代码了
举例: 拦截微信消息
import frida, sys
def on_message(message, data):
if message['type'] == 'send':
print("[*] {0}".format(message['payload']))
else:
print(message)
jscode = """
Java.perform(function () {
// Hook插入数据库
var SQLiteDatabase = Java.use('com.tencent.wcdb.database.SQLiteDatabase');
var Set = Java.use("java.util.Set");
var ContentValues = Java.use("android.content.ContentValues");
SQLiteDatabase.insert.implementation = function (arg1,arg2,arg3) {
this.insert.call(this, arg1, arg2, arg3);
console.log("[insert] -> arg1:" + arg1 + "\t arg2:" + arg2);
var values = Java.cast(arg3, ContentValues);
var sets = Java.cast(values.keySet(), Set);
var arr = sets.toArray().toString().split(",");
for (var i = 0; i < arr.length; i++){
console.log("[insert] -> key:" + arr[i] + "\t value:" + values.get(arr[i]));
}
};
});
"""
rdev = frida.get_remote_device()
session = rdev.attach("com.tencent.mm") # 获取指定APP
script = session.create_script(jscode)
# script.on('message', on_message)
print('[*] Running')
script.load()
sys.stdin.read()