CS31 Weekly Lab: Week 8

IA32 debugging, gdb, ddd, strings, objdump

Week 8 lab topics:

Revisit week 6 lab topics:
  1. Tools for examining binary files (e.g. strings and objdump -d)
  2. gdb and ddd for examining binary executable run state
Try them out on a binary program.

Mystery Program
$ cd ~/cs31/inclass
$ cp -r ~mauskop/public/cs31/week08/ .

Run the mystery binary a few times and see what it is doing:

./mystery

There is really not a lot of information to guess the right input, and this executable was not compiled with -g so there is no C code when we run it in gdb. So let's see if we can examine the assembly code to figure out what to enter.

The strings command shows us all the strings that appear in the binary executable. objdump -d disassembles the executable and shows us all the machine instructions.

  1. Let's trying running mystery in ddd.
    $ ddd ./mystery
    
  2. What does main's control flow look like?
  3. Let's add some breakpoints around function calls and in functions.
  4. We can print out strings using x/s:
    (gdb) x/s base_addr_of_string