Home > Mobile >  Inserting gdb breakpoints fail
Inserting gdb breakpoints fail

Time:01-31

I'm learning about buffer overflow in c. For that purpose, I'm following this simple example.

I have the following gcc version:

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And this simple c file:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[]){
    char buf[256];
    strcpy(buf, argv[1]);
    printf("%s,", buf);
    return 0;
}

I then compile this file with $ gcc buf.c -o buf. I then open in gdb by $ gdb ./buf

I call disas and get the result assembly:

(gdb) disas main
Dump of assembler code for function main:
   0x0000000000001189 < 0>:     endbr64 
   0x000000000000118d < 4>:     push   %rbp
   0x000000000000118e < 5>:     mov    %rsp,%rbp
   0x0000000000001191 < 8>:     sub    $0x120,%rsp
   0x0000000000001198 < 15>:    mov               
  •  Tags:  
  • Related