This project is utilized for hooking Android processes.
https://github.com/iGio90/FridaAndroidInjector
It enables the injection of Frida agents from an Android application.
It functions flawlessly.
When aiming to hook into this function:
com.ex.MediaPlayMgr.play(final InputStream inputStream, final String str)
The hooking code is as follows:
function log(what) {
Java.performNow(function() {
Java.use('android.util.Log').e("FridaAndroidInject", "kenshinx " + what.toString());
});
}
Java.perform(function() {
let MediaPlayMgr = Java.use("com.ex.MediaPlayMgr");
MediaPlayMgr["play"].overload('java.io.InputStream', 'java.lang.String', 'boolean', 'boolean', 'int').implementation = function (inputStream, str, z, z2, i) {
// this["play"](inputStream, str, z, z2, i);
// Java.send({'str': str});
log("step0:")
var downloadTask = new Promise(function (resolve, reject) {
// Asynchronous code...
log("step1:" + str)
var OkHttpClient = Java.use("okhttp3.OkHttpClient$Builder").$new().build();
log("step2:" + OkHttpClient)
var request = Java.use("okhttp3.Request$Builder").$new().url("http://com.ex.com/api").build();
log("step3:" + request)
var response = OkHttpClient.newCall(request).execute();
log("step4:" + response)
if (response) {
resolve(response.byteStream(), "paimen")
} else {
reject(inputStream, str)
}
});
log("step5:")
function doPlay(stream, word) {
log("stepx:" + stream + ", " + word)
this.play(stream, word, z, z2, i);
}
log("step6:")
downloadTask.then(doPlay, doPlay);
log("step7:")
};
});
The logging stops at step3. There is no step4.
Therefore, how can an HTTP request be made in JavaScript?
10:27:21.997 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step0:
10:27:21.997 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step1:哈哈哈
10:27:22.000 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step2:okhttp3.OkHttpClient@1af90ef
10:27:22.003 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step3:Request{method=GET, url=http://com.ex.com/api}
10:27:22.006 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step5:
10:27:22.006 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step6:
10:27:22.006 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx step7:
10:27:22.007 16391-16391 FridaAndroidInject com...plication.floatball E kenshinx stepx:Error: android.os.NetworkOnMainThreadException, undefined
I attempted using java.net.URL and java.net.HTTPConnect, but it did not work.
I aim to replace the inputStream in play() with my own stream.