pwndbg/pwndbg

telescope: display ret address

Open

#1 071 ouverte le 17 août 2022

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)Python (776 forks)batch import
featuregood first issuehelp wanted

Métriques du dépôt

Stars
 (5 820 stars)
Métriques de merge PR
 (Merge moyen 3j 12h) (32 PRs mergées en 30 j)

Description

It would be great to display return addresses in the telescope, stack etc outputs.

I initially worked on it in https://github.com/pwndbg/pwndbg/pull/794 but the patch had some issues.

We should proceed with:

  1. Move the logic of finding return addresses to pwndbg.stack.yield_return_addresses, e.g.:
def yield_return_addresses():
    sp = pwndbg.regs.sp
    stack = pwndbg.vmmap.find(sp)

    # Enumerate all return addresses
    frame = gdb.newest_frame()
    addresses = []
    while frame:
        addresses.append(frame.pc())
        frame = frame.older()

    # Find all of them on the stack
    start = stack.vaddr
    stop = start + stack.memsz
    while addresses and start < sp < stop:
        value = pwndbg.memory.u(sp)

        if value in addresses:
            index = addresses.index(value)
            del addresses[:index]
            yield sp

        sp += pwndbg.arch.ptrsize
  • Question: shouldn't the first operator (between start and sp) here: start < sp < stop be <=? On a quick glance now I think so
  1. Rethink how to add it into telescope and other output
  • Shall we display it in all cases or only on demand?
  1. Rethink if we want to add GDB variables for return addresses. This is really neat, but if we do it, we probably need to do it on each GDB stop and then it may be hurt performance on tough targets when debugging via gdbserver...

Guide contributeur