I have an app I want to analyze with Frida. The app has over 20 different shared preferences XML files. I am hooking the put methods of the shared preferences like in this code snippet:
var sp = Java.use("android.app.SharedPreferencesImpl$EditorImpl");
sp.putString.implementation = function(var0, var1) {
console.log(var0 + " " + var1 + "\n");
return this.putString(var0, var1);
}
This class has no method like getPath() or similar. How can I add code into this hooked method, to receive the correct xml file? When I use getSharedPreferences from android.content.ContextWrapper it does not work, because the app uses so many xml files that I can not tell, where the written info belongs to.
I tried out to hook variables and methods from SharedPreferencesImpl. I tried to get the mfile which is an java.io.File object, but I could not make it to call the getPath() method from the file object. I also tried to hook several methods in SharedPreferencesImpl but it does not work. I am also not sure if this is the right way.