I want to start a intent broadcast from Frida. The android implementation is like this
Intent intent = new Intent();
intent.setAction("com.example.Broadcast");
Foo foo = new Foo();
intent.putExtra("foo ", foo);
sendBroadcast(intent);
How to I implement this in Frida?
The code for referencing Java classes and for executing a constructor is clear. Using that scheme I a getting the following code.
const intentClass = Java.use("android.content.Intent");
const fooClass = Java.use("Foo"); // TODO: use fully qualified name of Foo
var intent = intentClass.$new();
intent.setAction("com.example.Broadcast");
var foo = fooClass.$new();
intent.putExtra("foo ", foo);
For the last method sendBroadcast(..)
you need an android.content.Context
instance. How to get this depends on your app and what method you are hooking.
If you are hooking for example a method of an Activity
you can simply use this.sendBroadcast(intent);
.