RE env for inspecting APKs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1 KiB

  1. var objc_copyClassNamesForImage = new NativeFunction(
  2. Module.findExportByName(null, 'objc_copyClassNamesForImage'),
  3. 'pointer',
  4. ['pointer', 'pointer']
  5. );
  6. var free = new NativeFunction(Module.findExportByName(null, 'free'), 'void', ['pointer']);
  7. var classes = new Array(count);
  8. var p = Memory.alloc(Process.pointerSize);
  9. Memory.writeUInt(p, 0);
  10. var path = ObjC.classes.NSBundle.mainBundle().executablePath().UTF8String();
  11. var pPath = Memory.allocUtf8String(path);
  12. var pClasses = objc_copyClassNamesForImage(pPath, p);
  13. var count = Memory.readUInt(p);
  14. for (var i = 0; i < count; i++) {
  15. var pClassName = Memory.readPointer(pClasses.add(i * Process.pointerSize));
  16. classes[i] = Memory.readUtf8String(pClassName);
  17. }
  18. free(pClasses);
  19. var tree = {};
  20. classes.forEach(function(name) {
  21. var clazz = ObjC.classes[name];
  22. var chain = [name];
  23. while (clazz = clazz.$superClass) {
  24. chain.unshift(clazz.$className);
  25. }
  26. var node = tree;
  27. chain.forEach(function(clazz) {
  28. node[clazz] = node[clazz] || {};
  29. node = node[clazz];
  30. });
  31. });
  32. send(tree);