I want to hook a xxtea_decrypt but it not trigger and on other games it trigger but some games not trigger it. On ida pro its trigger the xxtea_decrypt but frida nope here is the code that i using it
var nptr = Module.findExportByName("libcocos2dlua.so", "xxtea_decrypt");
function fn() {
nptr = Module.findExportByName("libcocos2dlua.so", "xxtea_decrypt");
// nptr = Module.findExportByName("libcocos2dlua.so", "luaL_loadbuffer");
if (!nptr) {
console.log("xxtea_decrypt cannot be found!");
setTimeout(fn, 900);
// } else {
// // console.log("xxtea_decrypt");
} else {
Interceptor.attach(nptr, {
onEnter: function(args) {
console.log("----------------BEGIN----------------");
console.log("Key: ");
console.log(hexdump(Memory.readByteArray(args[1], 5000),{
offset: 0,
length: 500,
header: true,
ansi: true
}));
console.log("sign:");
console.log(hexdump(Memory.readByteArray(args[2], 12),{
offset: 0,
length: 12,
header: true,
ansi: true
}));
},
onLeave: function(retval) {
// console.log("Decrypt:");
// console.log(hexdump(Memory.readByteArray(retval, 50),{
// offset: 0,
// length: 50,
// header: true,
// ansi: true
// }));
// console.log("-----------------END-----------------");
}
})
}
}
var timeout = setTimeout(fn, 500);
The following screen shot shows the xxtea_decrypt
function in IDA:
xxtea_decrypt
function is exported bylibcocos2dlua.so
? If not your hook will never be installed and thus never trigger. Frida can also hook non-exported functions but that requires to do some address calculation.Exports
tab in IDA?Module.findExportByName
requires the method be listed in the Exports section of the binary.