UNPKG

frida-il2cpp-bridge-my

Version:

(my:Support IOS)Frida module to dump, manipulate and hijack any IL2CPP application at runtime with a high level of abstraction.

77 lines (76 loc) 3.26 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.forModule = void 0; const decorator_cache_getter_1 = require("decorator-cache-getter"); const console_1 = require("./console"); class Target { constructor(responsible, name, stringEncoding) { this.stringEncoding = stringEncoding; this.address = Module.findExportByName(responsible, name) ?? NULL; } static get targets() { function info() { switch (Process.platform) { case "linux": try { const _ = Java.androidVersion; return ["libdl.so", ["dlopen", "utf8"], ["android_dlopen_ext", "utf8"]]; } catch (e) { return [null, ["dlopen", "utf8"]]; } case "darwin": return ["libdyld.dylib", ["dlopen", "utf8"]]; case "windows": const ll = "LoadLibrary"; return ["kernel32.dll", [`${ll}W`, "utf16"], [`${ll}ExW`, "utf16"], [`${ll}A`, "ansi"], [`${ll}ExA`, "ansi"]]; case "qnx": default: console_1.platformNotSupported(); } } const [responsible, ...targets] = info(); return targets.map(([name, encoding]) => new Target(responsible, name, encoding)).filter(target => !target.address.isNull()); } readString(pointer) { switch (this.stringEncoding) { case "utf8": return pointer.readUtf8String(); case "utf16": return pointer.readUtf16String(); case "ansi": return pointer.readAnsiString(); } } } __decorate([ decorator_cache_getter_1.cache ], Target, "targets", null); function forModule(moduleName) { return new Promise(resolve => { const module = Process.findModuleByName(moduleName); if (module) { resolve(module); } else { const interceptors = Target.targets.map(target => Interceptor.attach(target.address, { onEnter(args) { this.modulePath = target.readString(args[0]); }, onLeave(returnValue) { if (returnValue.isNull() || !this.modulePath || !this.modulePath.endsWith(moduleName)) return; setTimeout(() => interceptors.forEach(i => i.detach())); resolve(Process.getModuleByName(moduleName)); } })); } }); } exports.forModule = forModule;