-
Notifications
You must be signed in to change notification settings - Fork 498
Open
Description
I'm trying to use PANDA to skip over certain instructions in a program, but I'm running into issues.
Here’s the relevant C code:
int check_value = 1;
check_value++;
check_value++; // <-- I want to start skipping from here
check_value++;
myowntestfunc();
check_value++;
check_value++; // <-- and jump directly to here
printf("%d\n", check_value);
The goal is to skip one or more check_value++
operations and function call, and resume execution from a later point.
I tried the following PANDA Python script:
panda.enable_precise_pc()
@panda.cb_insn_translate
def insn_translate(cpu, pc):
return pc == skipped_addr
@panda.cb_insn_exec
def insn_exec(cpu, pc):
if pc == skipped_addr:
panda.arch.set_pc(cpu, target_addr)
# panda.flush_tb() # enabling/disabling this has no effect
print(f"[*] skip {hex(pc)} to {hex(target_addr)}")
return True
return False
However, this does not work as expected — the execution flow does not jump to target_addr
. Instead, the instructions are executed normally without being skipped.
My question is:
How can I correctly force a jump in control flow by setting the PC?
Is setting the PC and optionally flushing the translation block (flush_tb
) supposed to be enough?
Or is there a more reliable way to skip certain instructions at runtime?
Environment:
- OS:
- Ubuntu 22.04 LTS with default python 3.10.12
- PANDA version:
- https://github.com/panda-re/panda/releases/download/v1.8.58/pandare_22.04.deb
- https://github.com/panda-re/panda/releases/download/v1.8.58/pandare-1.8.58-py3-none-any.whl
Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels