首页 > 解决方案 > 如何用 frida 挂钩动态加载的 dex 和 libs?

问题描述

我正在尝试挂钩由打包程序动态加载的 java 类。

我使用 frida-DexDump 来获取原始的 dex,但我怎样才能挂钩它的功能?我试图挂钩的函数是一个本机函数(以这种方式声明“public static native void Init(String str, String str2);

”)。

这是我尝试过的方式,但没有任何结果

Java.perform(function() {
Java.openClassFile('/data/data/com.malware.android/6644448.dex').load();
// Printing all available classes 
var iterator = Java.openClassFile('/data/data/com.malware.android/6984300.dex').getClassNames();

// Here all the elements of the array is being printed. 
for (var j = 0; j < iterator.length; j++) {
    console.log(iterator[j]);
}

var my_class = Java.use("com.lib.connect");
//replace the original implmenetation of the function `Init` with our custom function 
//Init is a native function that it's being affected to Integer variable

my_class.Init.implementation = function(x, y) {
    //print the original arguments
    console.log("original call: Init(" + x + ", " + y + ")");
    //call the original implementation of `Init` with args (2,5)
    this.Init("2", "5");
}

});

问题 2:通过将转储的 dex 加载到 Jadx 中,我可以看到该应用程序正在从 assets 文件夹中加载 Native 库,但该文件夹或文件实际上并未存储在 assets 文件夹中。那么我在哪里可以找到这些文件?我能做些什么 ?尝试使用 gameguardian 转储应用程序,但没有任何显示创建了一个脚本,该脚本在创建后尝试从所需文件夹中提取文件,但我在那里看不到任何文件(尝试了这种方法,因为一个库已加载到正在删除的应用程序中)这里它是如何被调用的

private void Config(Context context) {
    AssetManager assets = context.getAssets();
    new File(context.getFilesDir().getPath() + "/vseh").mkdirs();
    new File(context.getFilesDir().getPath() + "/vseh/mtx").mkdirs();
    String str = context.getFilesDir().getPath() + "/vseh/mtx/global-mtx.dat";
    String str2 = context.getFilesDir().getPath() + "/vseh/mtx/base.apk";
    if (!new File(str2).exists()) {
        try {
            copyFile(assets.open("__ainfo.tsa"), new FileOutputStream(str2));
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            Runtime.getRuntime().exec("chmod -R 644 " + str2);
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }
    try {
        copyFile(assets.open("__info.tsa"), new FileOutputStream(str));
        System.load(str);
        FuckLeecher();
        new File(str).delete();
    } catch (IOException e3) {
        e3.printStackTrace();
    }
}

标签: javascriptandroidreverse-engineeringmalwarefrida

解决方案


推荐阅读