2

i have a java method i am trying to call manually

public static native Object a(int i, int i2, long j, String str, Object obj);

the last parameter is a string list casted to java.lang.object the way java code does it is by using the arraylist.toArray(new String[0]) which returns a "<instance: java.lang.Object, $className: [Ljava.lang.String;>" i tried every single way to replicate this variable using frida and i failed

this is the code i tried

var s = Java.array("java.lang.String", ["e"])
var k = Java.cast(s, Java.use("java.lang.Object"))

this results in

Error: expected a pointer
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/env.js:165)
    at apply (native)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/env.js:97)
    at cast (frida/node_modules/frida-java-bridge/lib/class-factory.js:131)
    at cast (frida/node_modules/frida-java-bridge/index.js:270)
    at <anonymous> (/frida/repl-2.js:25)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
    at _performPendingVmOps (frida/node_modules/frida-java-bridge/index.js:250)
    at <anonymous> (frida/node_modules/frida-java-bridge/index.js:225)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
    at _performPendingVmOpsWhenReady (frida/node_modules/frida-java-bridge/index.js:244)
    at perform (frida/node_modules/frida-java-bridge/index.js:204)
    at <anonymous> (/frida/repl-2.js:186)

i also tried this

var e = ["a"]
const arrayList = Java.use("java.util.ArrayList")
const arr = arrayList.$new()
for (var i = 0; i <= e.length; i++){
    if (e[i]){
        arr.add(e[i]);
    }
}
var s = arr.toArray()

which returns ["<instance: java.lang.Object, $className: java.lang.String>","<instance: java.lang.Object, $className: java.lang.String>"]

this casts every single element in the array to a java.lang.object instead of the array object itself when i pass this to the method as a parameter i get the same error as above Error: expected a pointer

i also tried passing a Java.array("java.lang.String", []) to .toArray() method and it raises the same error

1)is there a way to call this method using frida??

2)can i create a .so library with a function that casts my array to java.lang.object and inject it into the app or something along these lines?

1
  • 1
    Have you considered that this could be a bug? I would oben up an issue in the Frida issue tracker to make sure. And make sure you are latest frida version on Android and PC.
    – Robert
    Commented Oct 22, 2022 at 17:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.