Skip to content
Advertisement

(GDB) Breakpoints and Disassemble

I’ve been recently interested in reading books and articles about hacking and I found out that Hacking:The art of exploitation is just a must read title. I am following the basic tutorials on how to work with standard Linux tools and analyze your code (Programming chapter). I am not a beginner in programming but working with Linux terminal is quite new for me. I am using the latest release of Kali Linux.

Right now my simple program below should be used to analyze how stack segment works.

JavaScript

The first problem is I cannot add any breakpoints for internal functions. Neither mine functions like stack_func() nor functions from libraries like strcpy etc. According to the book the pending breakpoint should resolve. Mine is just ignored and program finishes.

JavaScript

The second problem is that disassemble also doesn’t work for my function. Again according to the book I should be able to see assembler code for my function stack_func() but the result is below.

JavaScript

I appologize for any grammatical errors in text. 🙂

Advertisement

Answer

The problem is that you defined stack_func inside another function. This is called nested function and it is gcc extension in GNU C. This function has a bit other symbol name than you expect. To find out it’s exact symbol name you can use nm tool:

JavaScript

And set breakpoint and disassemble in gdb:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement