gpt4 book ai didi

assembly - GDB ret "cannot access memory at address"

转载 作者:行者123 更新时间:2023-12-03 21:37:25 24 4
gpt4 key购买 nike

简单地说:

  • 栈顶 ($esp) = 0xbffff49c .
  • gdb 执行 ret指令,响应 Cannot access memory at address 0x90909094 .

  • gdb 尝试访问 0x90909094 的原因是什么?当栈顶的值为 0xbffff49c ?

    随机信息(以防万一):
    [----------------------------------registers-----------------------------------]
    EAX: 0x5a ('Z')
    EBX: 0xb7fbeff4 --> 0x15ed7c
    ECX: 0xbffff428 --> 0xb7fbf4e0 --> 0xfbad2a84
    EDX: 0xb7fc0360 --> 0x0
    ESI: 0x0
    EDI: 0x0
    EBP: 0x90909090
    ESP: 0xbffff49c --> 0xbffff450 --> 0xdb31c031
    EIP: 0x80485dd (<greeting+113>: ret)
    EFLAGS: 0x292 (carry parity ADJUST zero SIGN trap INTERRUPT direction overflow)
    [-------------------------------------code-------------------------------------]
    0x80485d0 <greeting+100>: mov DWORD PTR [esp],0x80487f4
    0x80485d7 <greeting+107>: call 0x80483f0 <printf@plt>
    0x80485dc <greeting+112>: leave
    => 0x80485dd <greeting+113>: ret
    0x80485de <checkPassword>: push ebp
    0x80485df <checkPassword+1>: mov ebp,esp
    0x80485e1 <checkPassword+3>: push ebx
    0x80485e2 <checkPassword+4>: sub esp,0x64
    [------------------------------------stack-------------------------------------]
    0000| 0xbffff49c --> 0xbffff450 --> 0xdb31c031
    0004| 0xbffff4a0 --> 0x0
    0008| 0xbffff4a4 --> 0xbffff564 --> 0xbffff6b2 ("/root/Desktop/CSCE_526/task1")
    0012| 0xbffff4a8 --> 0x804876b (<__libc_csu_init+11>: add ebx,0x1351)
    0016| 0xbffff4ac --> 0xb7fbeff4 --> 0x15ed7c
    0020| 0xbffff4b0 --> 0x8048760 (<__libc_csu_init>: push ebp)
    0024| 0xbffff4b4 --> 0x0
    0028| 0xbffff4b8 --> 0xbffff538 --> 0x0
    [------------------------------------------------------------------------------]
    gdb-peda$ n
    Cannot access memory at address 0x90909094

    我正在溢出缓冲区并试图让它执行一些 shellcode,但考虑到问题的简单性,我不确定这些细节是否相关:为什么 ret 试图访问不在堆栈顶部的数据?

    最佳答案

    在我看来,您的调试器似乎没有在 leave 之后显示寄存器状态。指令,但在此之前。

    我相信 leave是否esp = ebp这是有道理的,因为它无法访问的地址是存储在 ebp 中的地址之后的一个字。

    所以我认为问题不在于ret的目的地。但发生在 ret 时去访问堆栈以检索其返回地址。

    编辑:实际上我现在相信访问冲突发生在 leave 内部。说明和 ret从不执行。 leave还试图pop ebp我认为存在访问冲突。

    查看leave的一些信息这里:Why does leave do "mov esp,ebp" in x86 assembly?

    关于assembly - GDB ret "cannot access memory at address",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19506337/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com