Code:
// Check if the Module and Interceptor objects are available
if (typeof Module === "undefined") {
console.log("[Error] Frida could not be properly loaded. 'Module' is not defined.");
} else {
console.log("[Info] 'Module' is available.");
}
if (typeof Interceptor === "undefined") {
console.log("[Error] Frida could not be properly loaded. 'Interceptor' is not defined.");
} else {
console.log("[Info] 'Interceptor' is available.");
}
// Function to hide Frida and H5GG
function hideFridaAndH5GG() {
try {
// Check if frida-gadget.dylib is loaded in memory
var fridaModule = Module.findBaseAddress('frida-gadget.dylib');
if (fridaModule) {
console.log("Frida-Gadget found, trying to hide...");
var base = fridaModule.add(0);
Memory.writeByte(base, 0x00); // Patch the Frida module
console.log("Frida-Gadget hidden!");
}
// Check if H5GG.dylib is loaded in memory
var h5ggModule = Module.findBaseAddress('H5GG.dylib');
if (h5ggModule) {
console.log("H5GG found, trying to hide...");
var base = h5ggModule.add(0);
Memory.writeByte(base, 0x00); // Patch the H5GG module
console.log("H5GG hidden!");
}
} catch (error) {
console.log("[Error] Error hiding Frida or H5GG: " + error);
}
}
// Function to enumerate and list loaded modules
function enumerateLoadedModules() {
console.log("[Debug] Listing loaded modules...");
Module.enumerateModules({
onMatch: function(module) {
console.log("Found module: " + module.name);
},
onComplete: function() {
console.log("[Debug] All modules listed.");
}
});
}
// Function to hide sysctl calls (used for system requests)
function hideSysctlCalls() {
try {
var sysctl = Module.findExportByName("libsystem_kernel.dylib", "sysctl");
if (sysctl) {
Interceptor.attach(sysctl, {
onEnter: function(args) {
console.log("[Info] Hiding sysctl calls...");
args[0] = ptr(0); // Manipulate sysctl calls
}
});
}
} catch (error) {
console.log("[Error] Error hiding sysctl calls: " + error);
}
}
// Start module check and patching functions
setTimeout(function() {
enumerateLoadedModules();
hideFridaAndH5GG(); // Hide Frida and H5GG
hideSysctlCalls(); // Hide sysctl calls
}, 3000); // Delay 3 seconds after game start