Frida加载Dex用​​Java.openClassFile​​​方法。
使用dex方法之前,需要加载一下:​​​load()​​​。
创建实例(​​​$new()​​​),需要在主线程里运行:​​Java.scheduleOnMainThread​​。

function load_dex() {
var DecodeUtilsDex = Java.openClassFile("/data/local/tmp/DecodeUtils.dex");
console.log("DecodeUtilsDex:", DecodeUtilsDex);
Java.perform(function() {
DecodeUtilsDex.load();
var DecodeUtils = Java.use("com.example.androiddemo.DecodeUtils");
console.log(DecodeUtils);
var FridaActivity = Java.use("com.github.androiddemo.Activity.FridaActivity");
Java.scheduleOnMainThread(function() {
console.log(DecodeUtils.$new().decode(FridaActivity.$new().password.value));
})
});
}

参考:https://frida.re/docs/javascript-api/
​​​​

Java.openClassFile(filePath): open the .dex file at filePath,
returning an object with the following methods:

load(): load the contained classes into the VM.

getClassNames(): obtain an array of available class names.