手机端
GitHub地址:https://github.com/frida/frida/releases
- 需要注意的是pc端和手机端需要安装同一个版本
- 解压并push到 /data/local/tmp 目录下
adb push youPath/frida-server /data/local/tmo/frida-server
- 切换到root权限并给frida-server权限
adb shell #进入shell
su #root
chmod 777 frida-server
***********************
adb root #直接root启动shell
- 运行测试
./frida-server
PC端
#推荐使用应用名 而不是包名
frida -U -l exploit.js -f xxx #启动app并注入脚本
frida-ps -U
frida-ps -Ua
frida -U -l exploit.js "XXXX" #app已经启动 注入脚本
JS脚本
Java.perform(function() {
const MainActivity = Java.use('com.example.hotfix.MainActivity');
MainActivity.getarrly.implementation = function() {
console.log('getarrly() 方法被调用');
printStack();
this.getarrly();
};
});
//打印调用栈
function printStack() {
Java.perform(function () {
var Exception = Java.use("java.lang.Exception");
var ins = Exception.$new("Exception");
var straces = ins.getStackTrace();
if (straces != undefined && straces != null) {
var strace = straces.toString();
var replaceStr = strace.replace(/,/g, "\r\n");
console.log("=============================Stack strat=======================");
console.log(replaceStr);
console.log("=============================Stack end=======================\r\n");
Exception.$dispose();
}
});
}