为什么我在GDB上出现断点问题? GDB站点

问题描述 投票:0回答:1

我试图在调用函数strcpy()时在GDB上设置一个断点,但是GDB停止了,我不知道如何找到错误,这是GDB的新手,我想学习二进制利用,因此我正在阅读的论坛对此没有任何解释,这里是输出;

(gdb) disassemble main
Dump of assembler code for function main:
   0x00000000000011c9 <+0>: endbr64 
   0x00000000000011cd <+4>: push   rbp
   0x00000000000011ce <+5>: mov    rbp,rsp
   0x00000000000011d1 <+8>: sub    rsp,0x50
   0x00000000000011d5 <+12>:    mov    DWORD PTR [rbp-0x44],edi
   0x00000000000011d8 <+15>:    mov    QWORD PTR [rbp-0x50],rsi
   0x00000000000011dc <+19>:    mov    rax,QWORD PTR fs:0x28
   0x00000000000011e5 <+28>:    mov    QWORD PTR [rbp-0x8],rax
   0x00000000000011e9 <+32>:    xor    eax,eax
   0x00000000000011eb <+34>:    cmp    DWORD PTR [rbp-0x44],0x1
   0x00000000000011ef <+38>:    jne    0x1207 <main+62>
   0x00000000000011f1 <+40>:    lea    rsi,[rip+0xe10]        # 0x2008
   0x00000000000011f8 <+47>:    mov    edi,0x1
   0x00000000000011fd <+52>:    mov    eax,0x0
   0x0000000000001202 <+57>:    call   0x10c0 <errx@plt>
   0x0000000000001207 <+62>:    mov    DWORD PTR [rbp-0x34],0x0
   0x000000000000120e <+69>:    mov    rax,QWORD PTR [rbp-0x50]
   0x0000000000001212 <+73>:    add    rax,0x8
   0x0000000000001216 <+77>:    mov    rdx,QWORD PTR [rax]
   0x0000000000001219 <+80>:    lea    rax,[rbp-0x30]
   0x000000000000121d <+84>:    mov    rsi,rdx
   0x0000000000001220 <+87>:    mov    rdi,rax
   0x0000000000001223 <+90>:    call   0x1090 <strcpy@plt> // breakpoint here
   0x0000000000001228 <+95>:    mov    eax,DWORD PTR [rbp-0x34]
   0x000000000000122b <+98>:    test   eax,eax
   0x000000000000122d <+100>:   je     0x1247 <main+126>
   0x000000000000122f <+102>:   mov    eax,DWORD PTR [rbp-0x34]
   0x0000000000001232 <+105>:   mov    esi,eax
   0x0000000000001234 <+107>:   lea    rdi,[rip+0xde5]        # 0x2020
   0x000000000000123b <+114>:   mov    eax,0x0
   0x0000000000001240 <+119>:   call   0x10d0 <printf@plt>
   0x0000000000001245 <+124>:   jmp    0x1253 <main+138>
   0x0000000000001247 <+126>:   lea    rdi,[rip+0xe12]        # 0x2060
   0x000000000000124e <+133>:   call   0x10a0 <puts@plt>
   0x0000000000001253 <+138>:   mov    eax,0x0
   0x0000000000001258 <+143>:   mov    rcx,QWORD PTR [rbp-0x8]
   0x000000000000125c <+147>:   xor    rcx,QWORD PTR fs:0x28
   0x0000000000001265 <+156>:   je     0x126c <main+163>
   0x0000000000001267 <+158>:   call   0x10b0 <__stack_chk_fail@plt>
   0x000000000000126c <+163>:   leave  
   0x000000000000126d <+164>:   ret    
End of assembler dump.
(gdb) break *0x0000000000001223            // I want to set the breakpoint here
Breakpoint 1 at 0x1223
(gdb) r AAAA                               // I try to run the program providing arguments
Starting program: /home/ryan/liveoverflow_youtube/0x05_simple_crackme_intro_assembler/stackReg AAAA

[1]+  Stopped                 gdb stackReg // This is the problem? 

assembly gdb x86-64
1个回答
0
投票

GDB像这样停止是一个错误,当GDB在尝试放置断点时抛出错误时,该错误已通过此补丁在上游GDB中修复:

https://sourceware.org/ml/gdb-patches/2019-05/msg00361.html

一旦看到GDB这样停止:

[1]+ Stopped

您应该放回外壳。只需使用fg命令恢复GDB,然后继续进行调试会话。 GDB 9发布后,此错误将得到修复。

正如评论中指出的那样,断点地址不正确的原因是您使用的是位置独立可执行文件(PIE),该代码将在进程启动时重新定位。

starti开始GDB,然后您可以反汇编main并查看代码的实际放置位置。

© www.soinside.com 2019 - 2024. All rights reserved.