I'm able to sucessfully hook into an Android method using Frida, but I am trying to find out who is calling that method. I can find that out if I can rewrite the method with Frida to print the stacktrace when the method gets called. I've tried a few things, but all of them have had some sort of error. This is the latest thing I have tried.
setImmediate(function() {
console.log("[*] Starting script");
Java.perform(function () {
var Activity = Java.use("com.package.MyClass");
Activity.getUpdates.overload('boolean', 'java.lang.String', 'java.lang.String').implementation = function (v1, v2, v3) {
console.log("v1: " + v1);
console.log("v2: " + v2);
console.log("v3: " + v3);
Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Exception").$new())
};
});
})
This is resulting in the following error
Error: Not allowed outside Java.perform() callback
at d (frida/node_modules/frida-java/index.js:86)
at frida/node_modules/frida-java/index.js:366
at [anon] (repl1.js:11)
at input:1
Any idea how I can achieve this?
asked Jan 27, 2018 at 21:56
Arya
9,05533 gold badges116 silver badges192 bronze badges
2 Answers 2
I fixed it by using this:
Java.perform(function() {
console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Exception").$new()))
});
It is necessary to add an additional Java.perform call
Sign up to request clarification or add additional context in comments.
5 Comments
Arya
Have you used Frida with Python bindings?
Fritz
Yes, I'm new to Frida, is there a difference? Do you need additional code? I used it with Frida server and Frida gadget
Arya
there is another issue which I've been stuck for 2 weeks or so, I thought maybe you know how to deal with it. Have you used reactor while using Frida with Python?
Fritz
no, sorry I haven't used reactor yet. Maybe open a new question here
Arya
I have posted a new question about a new problem. Can you please take a look at it too? stackoverflow.com/questions/48772800/…
var stack = Java.use("java.lang.Exception").$new().getStackTrace();
for (var i = 0; i < stack.length; i++) {
console.log(stack[i].toString());
}