Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB throws error while stepping into at breakpoint

I am trying to follow a video tutoial on buffer overflow from this link and below is the code which I am trying.

#include <stdio.h>

GetInput() 
{
    char buffer[8];

    gets(buffer);
    puts(buffer);   
}

main()
{
   GetInput();       
   return 0;
}

I am getting an isssue in gdb debugging, while I step onto i.e at line 7, I get the below error:

_IO_gets (buf=0xbffff458 "k\204\004\b") at iogets.c:33
33  iogets.c: No such file or directory.

I am following exactly the same steps as mentioned in the tutorial. I am using 32 bit Kali linux on virtual box

Can anyone help me to get through this problem.

like image 388
TechJ Avatar asked Dec 06 '15 01:12

TechJ


People also ask

Why can't I insert breakpoints in gdb?

In this situation, attempting to run or continue a program with a breakpoint causes GDB to print an error message: Cannot insert breakpoints. The same program may be running in another process. Remove or disable the breakpoints, then continue. Suspend GDB, and copy the file containing your program to a new name.

How to run and stop a program in gdb?

Once in GDB, we can run the program by using the run or r command. You can stop the program while it's running by using the CTRL + C key. Let us set a breakpoint at the main function to halt the execution at that point.

What does this GDB error message mean?

This message is printed when you attempt to resume the program, since only then GDB knows exactly how many hardware breakpoints and watchpoints it needs to insert. When this message is printed, you need to disable or remove some of the hardware-assisted breakpoints and watchpoints, and then continue.

What does “can't insert breakpoints” mean?

"Cannot insert breakpoints". Under some operating systems, breakpoints cannot be used in a program if any other process is running that program. In this situation, attempting to run or continue a program with a breakpoint causes GDB to print an error message: Cannot insert breakpoints. The same program may be running in another process.


1 Answers

The author of the post is following a buffer overflow exploitation course. Instead of helping him, everyone jumped with off topic information. We all know that the code is wrong, but then, how you are supposed to learn buffer overflow exploitation if not on a bad code ?

In this case debugging didn't work properly because location of the debug file is somewhere else.

(gdb) show debug-file-directory
The directory where separate debug symbols are searched for is "/usr/lib/debug"

Execute the following in gdb

(gdb) set debug-file-directory

Now you will be able to debug your code. HF

like image 165
mello Avatar answered Sep 17 '22 23:09

mello