I have an iOS device on 14.2 and am using frida 15.2.2 on Ubuntu 18.04.
If I launch an app via frida, in the repl I can get the base address of the module, add an offset to that address, and print the instruction at that new address. Doing it like this I get the instruction I expect. The commands I entered were:
var baseAddress = Process.enumerateModules()[0].base; var instructionOffset = 0x100004ce8-0x100000000; var targetAddress = baseAddress.add(instructionOffset); Instruction.parse(targetAddress).toString(); and the instruction I expect, based on ghidra, is cbz param_1,LAB_100004d08 which I get.
However, if I try and do the same by loading a script when I launch the app:
var baseAddress = Process.enumerateModules()[0].base; var instructionOffset = 0x100004ce8-0x100000000; var targetAddress = baseAddress.add(instructionOffset); Interceptor.attach(targetAddress, { onEnter: function(args) { console.log("[+] Current instruction: " + (Instruction.parse(targetAddress).toString())); }, }); it prints a different instruction. I'm not sure if there is something I've misunderstood or it is expected to work differently doing this from a script? Or if I need to take in to account the script being loaded in to memory?