Facebook
From yes, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 165
  1. const LIBNAME = "libmmv8.so";
  2. const prefix = "_ZN2v87Isolate";
  3.  
  4. waitForModule(LIBNAME, hookAllExports);
  5.  
  6. function waitForModule(moduleName, callback) {
  7.     var module = Process.findModuleByName(moduleName);
  8.     if (module !== null) {
  9.         console.log(moduleName + " module found");
  10.         callback(moduleName, prefix);
  11.     } else {
  12.         console.log(moduleName + " module not found, waiting...");
  13.         setTimeout(function () {
  14.             waitForModule(moduleName, callback);
  15.         }, 100); // Check every 0.1 second
  16.     }
  17. }
  18.  
  19. function hookAllExports(moduleName, prefix) {
  20.     console.log("Starting export enumeration for " + moduleName);
  21.     var exports  = Module.enumerateExports(moduleName);
  22.         exports.forEach(exp => {
  23.             try{
  24.                 if (exp.type === "function" && (exp.name.toLowerCase().includes("isolate") || exp.name.toLowerCase().includes("startprofiling")|| exp.name.toLowerCase().includes("profiler") /* || exp.name.toLowerCase().includes("initialize")*/)) {
  25.                 console.log("Hooking", exp.name);
  26.                 Interceptor.attach(exp.address, {
  27.                     onEnter: function (args) {
  28.                         console.log(`Called ${exp.name}`);
  29.                         try{
  30.                             console.log('Arguments:', args[0]);
  31.                         }catch(e){
  32.                             console.log('Arguments:', args);
  33.                         }
  34.  
  35.                         // console.log('from:\n' +
  36.                         // Thread.backtrace(this.context, Backtracer.ACCURATE)
  37.                         // .map(DebugSymbol.fromAddress).join('\n') + '\n');
  38.                        
  39.                     // }
  40.                     },
  41.                     onLeave: function (retval) {
  42.                         console.log(`Returned from ${exp.name}`);
  43.                         console.log('Return value:', retval);
  44.                         console.log('\n');
  45.                         // You can add logic here to inspect or modify the return value
  46.                     }
  47.                 });
  48.             }
  49.         } catch (e) {
  50.             console.log(e);
  51.         }
  52.         });
  53. }
  54.