Coder Social home page Coder Social logo

Comments (3)

hugsy avatar hugsy commented on May 11, 2024

No, because $ebp/$rbp is

  1. specific to x86 architectures (some archs simply do not have frame pointers)
  2. can be omitted by the compiler directive -fomit-frame-pointer
    Whereas $rsp (aka $sp) has to always be there.

You can use the dereference command to dump N entries from $rbp when it exists. Example:

gef➤  dereference $ebp 10
0xffffd3f8│+0x0000: 0x0  ← $ebp
0xffffd3fc│+0x0004: 0xf7e0f5f7  →  <__libc_start_main+247>: add esp,0x10
0xffffd400│+0x0008: 0x1
0xffffd404│+0x000c: 0xffffd494  →  0xffffd654  →  "/home/hugsy/code/gef/tests/win32"
0xffffd408│+0x0010: 0xffffd49c  →  0xffffd675  →  "ALTERNATE_EDITOR=/usr/bin/nano"
0xffffd40c│+0x0014: 0x0
0xffffd410│+0x0018: 0x0
0xffffd414│+0x001c: 0x0
0xffffd418│+0x0020: 0xf7fa6000  →  0x1aedb0
0xffffd41c│+0x0024: 0xf7ffdc04  →  0x0

from gef.

DavidDeLille avatar DavidDeLille commented on May 11, 2024

Would it be possible to generically define a register from which the offset would be calculated and just set it to $rsp by default? I'm mostly wondering because some binaries have code like this:

gef➤  x/10i 0x0000000000400B90
   0x400b90:    mov    rax,QWORD PTR [rbp-0x30]
   0x400b94:    mov    rdx,QWORD PTR [rbp-0x18]
   0x400b98:    add    rdx,rax
   0x400b9b:    mov    rax,QWORD PTR [rbp-0x30]
   0x400b9f:    mov    rcx,QWORD PTR [rbp-0x18]
   0x400ba3:    add    rax,rcx
   0x400ba6:    movzx  ecx,BYTE PTR [rax]
   0x400ba9:    mov    rax,QWORD PTR [rbp-0x58]
   0x400bad:    mov    rsi,QWORD PTR [rax+0x8]
   0x400bb1:    mov    rax,QWORD PTR [rbp-0x30]

Being able to see stack value offsets based on $rbp would make it a bit easier to find the values mentioned in the code. Otherwise you have to constantly remember "oh yeah, $rbp-0x30 is $rsp+0x30".

from gef.

hugsy avatar hugsy commented on May 11, 2024

This seems like a not simple thing to implement for a very little gain, especially since you can use the dereference command.
If you want, submit a PR and I will have a look.

Thanks.

from gef.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.