Facebook
From yes, 1 Month ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 139
  1. // const uv_default_loop = new NativeFunction(Module.getExportByName(null, 'uv_default_loop'), 'pointer', []);
  2. // const uv_async_init = new NativeFunction(Module.getExportByName(null, 'uv_async_init'), 'int', ['pointer', 'pointer', 'pointer']);
  3. // const uv_async_send = new NativeFunction(Module.getExportByName(null, 'uv_async_send'), 'int', ['pointer']);
  4. // const uv_close = new NativeFunction(Module.getExportByName(null, 'uv_close'), 'void', ['pointer', 'pointer']);
  5. // const uv_unref = new NativeFunction(Module.getExportByName(null, 'uv_unref'), 'void', ['pointer']);
  6.  
  7. const v8_Isolate_GetCurrent = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v87Isolate10GetCurrentEv'), 'pointer', []);
  8. const v8_Isolate_GetCurrentContext = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v87Isolate17GetCurrentContextEv'), 'pointer', ['pointer']);
  9.  
  10. const v8_HandleScope_init = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v811HandleScopeC1EPNS_7IsolateE'), 'void', ['pointer', 'pointer']);
  11. const v8_HandleScope_finalize = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v811HandleScopeD1Ev'), 'void', ['pointer']);
  12.  
  13. const v8_String_NewFromUtf8 = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v86String11NewFromUtf8EPNS_7IsolateEPKcNS_13NewStringTypeEi'), 'pointer', ['pointer', 'pointer', 'int', 'int']);
  14.  
  15. const v8_Script_Compile = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v86Script7CompileENS_5LocalINS_7ContextEEENS1_INS_6StringEEEPNS_12ScriptOriginE'), 'pointer', ['pointer', 'pointer', 'pointer']);
  16. const v8_Script_Run = new NativeFunction(Module.getExportByName('libmmv8.so', '_ZN2v86Script3RunENS_5LocalINS_7ContextEEE'), 'pointer', ['pointer', 'pointer']);
  17.  
  18. const NewStringType = {
  19.   kNormal: 0,
  20.   kInternalized: 1
  21. };
  22.  
  23. const pending = [];
  24.  
  25. const isolate = v8_Isolate_GetCurrent();
  26. console.log("Isolate: ", isolate);
  27.  
  28.  
  29.  
  30. // const scope = Memory.alloc(24);
  31.  
  32. // v8_HandleScope_init(scope, isolate);
  33.  
  34. // const context = v8_Isolate_GetCurrentContext(isolate);
  35.  
  36. // console.log("Context: ", context);
  37. // console.log("Scope: ", scope);
  38.  
  39. // const processPending = new NativeCallback(function () {
  40. //   const isolate = v8_Isolate_GetCurrent();
  41.  
  42. //   const scope = Memory.alloc(24);
  43. //   v8_HandleScope_init(scope, isolate);
  44.  
  45. //   const context = v8_Isolate_GetCurrentContext(isolate);
  46.  
  47. //   while (pending.length > 0) {
  48. //     const item = pending.shift();
  49. //     const source = v8_String_NewFromUtf8(isolate, Memory.allocUtf8String(item), NewStringType.kNormal, -1);
  50. //     const script = v8_Script_Compile(context, source, NULL);
  51. //     const result = v8_Script_Run(script, context);
  52. //   }
  53.  
  54. //   v8_HandleScope_finalize(scope);
  55. // }, 'void', ['pointer']);
  56.  
  57. // const onClose = new NativeCallback(function () {
  58. //   Script.unpin();
  59. // }, 'void', ['pointer']);
  60.  
  61. // const handle = Memory.alloc(128);
  62. // uv_async_init(uv_default_loop(), handle, processPending);
  63. // uv_unref(handle);
  64.  
  65. // Script.bindWeak(handle, () => {
  66. //   Script.pin();
  67. //   uv_close(handle, onClose);
  68. // });
  69.  
  70. // function run(source) {
  71. //   pending.push(source);
  72. //   uv_async_send(handle);
  73. // }
  74.  
  75. // run('console.log("Hello from Frida");');