This is an old revision of the document!


Labs

Lectures

Assignments

1: GDB

The purpose of this task is to explore GDB, and automate a debugging session. You are encouraged to use the GDB User Manual, and what you learned during the previous lab sessions. We recommend that you start solving each subtask in a live debugging session, and then assemble the final script that will be submitted to vmchecker.

The given binary computes the SHA-1 hash of some input, but if you send him a signal at the right time, it will also compute a special hash. Write a GDB script/commands file that goes through the following steps (you can add more interesting step if you fell like it):

  1. when data to be hashed is being requested, a read() syscall will be issued, catch it
  2. break execution right before compute_hash() is called (you should now be in main()'s stack frame)
  3. print the 5 instructions before the current instruction pointer
  4. you will discover there is a special, or “reversed hash” mode, break execution on printf calls while in this mode
    • print current frame and the EIP register each time this breakpoint triggers
  5. break on malloc calls
    • print the return value after malloc finishes
  6. break in compute_hash() after malloc call
    • print the stack, the registers and the last 3 frames
  7. move to the previous frame, and print registers
  8. move back, and print locals and arguments
  9. remove all breakpoints, catchpoints and watchpoints
  10. rerun, but break before the entry point and add the following
  11. add watchpoints for hash mode changes
  12. send the required signal
  13. rerun, but this time, trigger the mode change without sending the signal
  14. break somewhere
    • print the memory where the intro message is held in hex
  15. rerun
  16. break in main() after compute_hash()
    • print the heap section holding the hash in hex
  17. rerun
  18. trigger the mode change (with signal or not)
  19. break just before main has finished
  20. get the hash from stdout; find it in memory using GDB (you can call, from GDB, a small shell/Python script to make format conversions)

Resources

cns/sidebar.1414912515.txt.gz · Last modified: 2014/11/02 09:15 by vlad.dumitrescu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0