wip compare class laoder

This commit is contained in:
Jean-Marie Mineau 2025-05-05 17:31:23 +02:00
parent 59d6caabd8
commit 1884ff4ac8
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
7 changed files with 326 additions and 108 deletions

View file

@ -1,6 +1,7 @@
const sended_class_loaders = new Set();
function send_class_loader(cl) {
get_app_info();
const System = Java.use('java.lang.System');
let cl_id = System.identityHashCode(cl);
while (cl != null && !sended_class_loaders.has(cl_id)) {
@ -9,7 +10,7 @@ function send_class_loader(cl) {
"id": cl_id,
"parent_id": System.identityHashCode(parent_),
"str": cl.toString(),
"cname": cl.$className
"cname": cl.getClass().descriptorString()
}});
sended_class_loaders.add(cl_id);
cl = parent_;
@ -26,6 +27,37 @@ function dump_classloaders() {
});
}
let info_sent = false
function get_app_info() {
if (info_sent) {
return;
}
var app = Java.use('android.app.ActivityThread').currentApplication();
if (app == null) {
return;
}
var context = app.getApplicationContext();
if (context == null) {
return;
}
var appinfo = context.getApplicationInfo();
if (appinfo == null) {
return;
}
send({"type": "app_info", "data": {
"dataDir": appinfo.dataDir.value,
"deviceProtectedDataDir": appinfo.deviceProtectedDataDir.value,
"nativeLibraryDir": appinfo.nativeLibraryDir.value,
"publicSourceDir": appinfo.publicSourceDir.value,
"sharedLibraryFiles": appinfo.sharedLibraryFiles.value,
"sourceDir": appinfo.sourceDir.value,
"splitNames": appinfo.splitNames.value,
"splitPublicSourceDirs": appinfo.splitPublicSourceDirs.value,
"splitSourceDirs": appinfo.splitSourceDirs.value,
}});
info_sent = true;
}
/* ----- Frida Native Class Loading -----
* Broken, for some ineffable frida-android reason.
function registerStackConsumer() {
@ -117,6 +149,8 @@ Java.perform(() => {
const System = Java.use('java.lang.System');
*/
const StackWalker = Java.use('java.lang.StackWalker');
const StackWalkerOptions = Java.use('java.lang.StackWalker$Option');
const StackWalkerOptionsShowHidden = StackWalkerOptions.valueOf("SHOW_HIDDEN_FRAMES");
@ -304,7 +338,8 @@ Java.perform(() => {
let classloader_class = null;
let classloader_id = System.identityHashCode(loader);
if (loader !== null) {
send_class_loader(loader);
// send_class_loader(loader); // Sending names before the end of the initialization
// collect the wrong string representation !
classloader_class = loader.getClass().descriptorString();
}
send({