Snippet for making a Toast on Android doesn't work
nibarius opened this issue · comments
The snippet for creating a Toast on Android doesn't seem to work:
[Android Emulator 5554::owasp.mstg.uncrackable1]-> Java.scheduleOnMainThread(function() {
Java.use("android.widget.Toast")
.makeText(
Java.use("android.app.ActivityThread").currentApplication().getApplicationContext(),
"Text to Toast here",
0 // https://developer.android.com/reference/android/widget/Toast#LENGTH_LONG
)
.show();
});
Error: makeText(): argument types do not match any of:
.overload('android.content.Context', 'int', 'int')
.overload('android.content.Context', 'java.lang.CharSequence', 'int')
.overload('android.content.Context', 'android.os.Looper', 'java.lang.CharSequence', 'int')
at pe (frida/node_modules/frida-java-bridge/lib/class-factory.js:549)
at frida/node_modules/frida-java-bridge/lib/class-factory.js:951
at [anon] (input:7)
at frida/node_modules/frida-java-bridge/index.js:288
[Android Emulator 5554::owasp.mstg.uncrackable1]-> Frida.version
"12.8.20"
Known issue. I was tested on an old device, if you wish I can find time to generate a new working script.
That would be appreciated. I'm learning Frida and being able to interact with Android components feels useful. Toasts are pretty simple components so those feel like a good start.
Updated, have fun.
the error is informative enough, it seems makeText has updated and needs CharSequence instead of String
Great, thanks! I also realized that Java.Use("java.lang.String").$new("Text to Toast here")
works as well.
I recently found https://neo-geo2.gitbook.io/adventures-on-security/frida-scripting-guide/primitive-types that explains that the native javascript string needs to be converted to a Java String object.