gef icon indicating copy to clipboard operation
gef copied to clipboard

Only CONDITIONAL jumps peek ahead. Make UNconditional peek also

Open Grazfather opened this issue 8 years ago • 8 comments

Noticed today that jmp and family don't peek ahead in context_code. I added an option to peek for calls in #144. It'll be a bit more work to add it to unconditional jumps.

Grazfather avatar Apr 23 '17 20:04 Grazfather

Can we close this?

hugsy avatar Dec 27 '17 18:12 hugsy

Naw I think still this is worth working on.

The trick is in determining the address of the jumps for each arch. We should probably add a method to the arch itself that takes the context and the instruction and returns the jump address, it would probably clean up the conditional jump stuff too.

Grazfather avatar Jan 03 '18 20:01 Grazfather

I think this is for later. One way we could do it, although I am not sure how slow it would be, is to use unicorn to emulate the instruction, step once, and see where it ends up.

Grazfather avatar Apr 02 '18 16:04 Grazfather

That would make unicorn a strict dependency on GEF, that's what pwndbg does and I really don't like it. Unicorn is a nightmare to setup on embedded devices.

hugsy avatar Apr 02 '18 17:04 hugsy

Well, it would only make this feature a dependency :) We could fail gracefully.

I don't think we need to go that route, we just need to figure out a nice way to figure out the jump target.

Grazfather avatar Apr 02 '18 17:04 Grazfather

What are the constraints on it exactly?

The way I see the implementation, we can solve it statically, without unicorn because we can only have:

  • jump $reg
  • jump <address>

Which we can know all the time. Do you see any other cases?

hugsy avatar Apr 02 '18 17:04 hugsy

Well it's that we have to figure it out for each case for each arch, which means each addressing mode.

I'm totally cool with doing something like the peek_ret: Just unset branch_taken if we can't figure out the address, and that way it just doesn't show a jump target (better than an incorrect one).

Grazfather avatar Apr 02 '18 17:04 Grazfather

This might be an easy enough thing for a new contributor to take a crack at.

Grazfather avatar Apr 23 '21 13:04 Grazfather