1

I have found that there is method named b(String str) of an app by using Jadx-gui now i am using follwing function to get instance of that class where this method is defined :-

Java.perform(function () {

   var x ;
    Java.choose('xxx.xxx.xxx.g', {
                onMatch: function(instance) {
                    console.log("Found instance" + instance);
                    x = instance;
               

                },
                onComplete: function() {
                    console.log("search done");
                }
            });
       var str=x.b('hello');
   conole.log(str);

But it shows me this error:-

Ivar
  • 6,138
  • 12
  • 49
  • 61
Hacker111
  • 65
  • 1
  • 5
  • 1
    Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Ivar Jan 28 '21 at 08:21
  • You have to move the code `var str=x.b('hello');` into the `onMatch` or `onComplete` callback. See also this example: https://11x256.github.io/Frida-hooking-android-part-3 – Robert Jan 28 '21 at 11:17
  • I tried that too but i doesnot shows me any output – Hacker111 Jan 29 '21 at 03:51
  • @Ivar it was not i am talking about – Hacker111 Jan 29 '21 at 04:09
  • What do you mean? You try to pass `instance` to `x` inside an asynchronous callback and expect `x` to have a value before this callback is executed. This is exactly what the link in my previous comment is about. – Ivar Jan 29 '21 at 09:30
  • I forgot - and of course move the `conole.log(str);` also inside. If this doe snot work something may be wrong with the `String g(String)` method. You should include it's decompiled code into your question. – Robert Jan 29 '21 at 15:10
  • So @Ivar can u please correct my code it would be really helpful..**Thanks** in advance – Hacker111 Jan 29 '21 at 17:21
  • @Hacker111 If your only goal is to log that string to the console, than just do as Robert mentioned: Move the `var str=x.b('hello')` and `conole.log(str)` inside the `onMatch` callback. If not, than you can put the code you want to execute after a match is found in a function and call that function from `onMatch`. It depends a bit on how the rest of your code works. The link I posted explains it perfectly. – Ivar Jan 29 '21 at 17:24
  • Add a javascript timeout to the Java.perform function for a second or two. That should fix your issue. – MitchHS Feb 06 '21 at 06:49

0 Answers0