CS31 Weekly Lab: Week 7

Week 7 lab topics:

Revisit week 6 lab topics:
  1. tools for examining binary files
  2. gdb (and ddd) for examining binary executable run state
Try them out on a binary program.

Mystery Program
Create a week07 subdirectory and copy over a program:
cd
cd cs31/weeklylabs
mkdir week07
cd week07
pwd
cp ~newhall/public/cs31/week07/mystery .

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 information we can get from it when we run it in gdb.

Let's see if we can examine the assembly code to see if we can figure out what to enter.

First, let's review some tools for examining and debuging binary files from last week: Week 6 Wed lab

Let's try some of these tools, let's look at the code in ddd.

  1. lets trying running in ddd and disassemble some code
    ddd ./mystery
    (gdb) break main
    (gdb) run
    (gdb) disass
    
  2. what does main control flow look like?
  3. let's add some break points around function calls and in functions
  4. let's examine some state around functions
  5. we can print out strings using x/s
    (gdb) x/s base_addr_of_string 
    
Let's see what strings tells us
strings ./mystery