当有字符串类型时,我如何使用 frida 注入我自己的 so?

how can i use inject my own so by frida when there is a string type?

我在 libc.so 中挂接了本机函数 dlopen,我想使用 it.i 发现我需要新建一个本机函数并像这样设置参数类型:

  1. new NativeFunction (address,returntype,[...,abi]) 和 native 像这样的功能:
  2. void* dlopen(const char*,int ) 我不知道如何选择匹配 const char* 的类型,我这样写:
  3. var fun=new NativeFunction(_dlopen,'pointer',['pointer','int']) 我的 so 路径是 '/data/local/tmp/***.so' 所以我这样写:
  4. var str='/data/local/tmp/***.so'
  5. 有趣(海峡,1)

但是控制台给我一个错误:

参数值无效 在5] 我应该怎么办 ?有人可以帮我吗?

您可以使用 Module.load https://frida.re/docs/javascript-api/#module-load

如果你想注入一个模块而不是另一个模块,你可以这样做

        Interceptor.attach(Module.findExportByName(null, "dlopen"), {
            onEnter: function(args) {
                if ( args[0].readUtf8String().includes(excludeModuleName) ) {
                  Module.load('/data/local/tmp/custom.so');
                  // now we need to fail the original dlopen
                  // we can do something like this.. or replace the return value..
                  // maybe later i'll edit with a better solution ;)
                  args[0].writeUtf8String('...');
                }
            }
        });

在评论中回答你的问题

how do i start my function in the so injected by frida?is there some methods?

Module.load('/data/local/tmp/a');
var func_ptr = Module.findExportByName('a', 'function_name');
// wrap with NativeFunction(pointer, return_value, [list_of_arguments])
// lets assume your function gets a string and an int
// function_name(string a1, int a2)
var f = new NativeFunction(func_ptr, 'pointer', ['pointer', 'int']);
// invoking the fuction
f(Memory.allocUtf8String("abcd"), 3);