CS 367 - 002, Spring 2010
Lab 1: Defusing a Binary Bomb
Due: Sunday, 3/21 (11:59 pm)
You may work in a group of up to two people on this assignment;
HOWEVER, each student have their own personalized bomb. This is to prevent the situation where one student is doing all/most of the work (and hence, all/most of the learning). While each bomb is unique, the phases follow basic patterns - defusing the second bomb should take much less effort.
Introduction
The nefarious Dr. Evil has planted a slew of "binary bombs" on our machines. A binary bomb is a
program that consists of a sequence of phases. Each phase expects you to type a particular string on
stdin. If you type the correct string, then the phase is defused and the bomb proceeds to the next phase.
Otherwise, the bomb explodes by printing "BOOM!!!" and then terminating. The bomb is defused when
every phase has been defused.
Step 1: Get Your Bomb
Each student will attempt to defuse their own personalized bomb. Each bomb is a Linux
binary executable file that has been compiled from a C program. To obtain your bomb, you need
to be able to connect to the machine zeus.ite.gmu.edu. This machine is behind a firewall. You can access
it from a machine on campus, e.g. from any of the dual-boot PCs in the IT&E labs or from a machine
off-campus. To access zeus.ite.gmu.edu from off-campus, you can ssh to mason.gmu.edu and then ssh to
zeus.ite.gmu.edu, or use can install VPN software and set up the VPN as described at:
http://labs.ite.gmu.edu/reference/faq_iteaccount.htm#home
This installation procedure is quite straightforward.
Once you are able to connect to zeus.ite.gmu.edu, one (and only one) of the group members should point
your Web browser to the bomb request daemon at
http://zeus.ite.gmu.edu:15213
Fill out the HTML form with the email addresses and names of your team members, and then submit the
form by clicking the "Submit" button. The request daemon will build your bomb and return it
immediately to your browser in a tar file called bombk.tar, where k is the unique number of your bomb.
Note that a team of two students will have to do this process twice to get two bombs.
Save the bombk.tar file to a (protected) directory in which you plan to do your work. Then give the
command:
tar -xvf bombk.tar.
This will create a directory called ./bombk with the following files:
- README: Identifies the bomb and its owners.
- bomb-zeus: The executable binary bomb. This executable will only run on zeus.ite.gmu.edu
- bomb-quiet: A"quiet" version of the executable binary bomb. This will run on any Linux PC.
- bomb.c: Source file with the bomb's main routine.
We have given you two versions of the bomb. The program bomb-zeus will only run on
zeus.ite.gmu.edu. When you defuse a phase of the bomb (as described below), the program notifies the
instructor. To receive a grade for this assignment, you must defuse bomb-zeus. However, each time your
bomb explodes on zeus.ite.gmu.edu it notifies the instructor , and you lose 1 point (up to a max of 10 points)
in the final score for the lab. So there are consequences to exploding the bomb on zeus.ite.gmu.edu. You
must be careful!
For your convenience, we have also given you a "quiet" version of the bomb that does not communicate
with the instructor. This bomb will run on any LinuxPC. We recommend that you first figure out how to
defuse bomb-quiet. The same input strings will also defuse bomb-zeus. Also, if you make any kind of
mistake requesting a bomb (such as neglecting to save it or typing the wrong group members), simply
request another bomb.
Step 2: Defuse Your Bomb
Your job is to defuse the bomb. You can use many tools to help you with this; please look at the hints
section for some tips and ideas. The best way is to use your favorite debugger to step through the
disassembled binary.
Each phase is worth 10 points, for a total of 60 points. Remember that each time your bomb explodes it
notifies the instructor, and you lose 1 point (up to a max of 10 points) in the final score for the lab. So there
are consequences to exploding the bomb on zeus. The phases get progressively harder to defuse, but the
expertise you gain as you move from phase to phase should offset this difficulty. However, the last
phase will challenge even the best students, so please don't wait until the last minute to start.
The bomb ignores blank input lines. If you run your bomb with a command line argument, for example,
linux> ./bomb psol.txt
then it will read the input lines from psol.txt until it reaches EOF (end of file), and then switch over
to stdin. We added this feature so you don't have to keep retyping the solutions to phases you have
already defused.
To avoid accidentally detonating the bomb, you will need to learn how to single-step through the
assembly code and how to set breakpoints. You will also need to learn how to inspect both the registers
and the memory states. One of the nice side-effects of doing the lab is that you will get very good at
using a debugger. This is a crucial skill that will pay big dividends the rest of your career.
Hand-In
There is no explicit hand-in. The bomb will notify your instructor automatically after you have
successfully defused it on zeus.ite.gmu.edu. You can keep track of how you (and the other groups) are
doing by looking at
http://hermes-web.ite.gmu.edu/~cs367/bomb-status.html
This web page is updated continuously to show the progress of each group.
Note that this web page is only accessible from a machine in the IT&E labs or if you have connected to
the IT&E labs using the VPN software.
Hints (Please read this!)
There are many ways of defusing your bomb. You can examine it in great detail without ever running
the program, and figure out exactly what it does. This is a useful technique, but it is not always easy to
do. You can also run it under a debugger, watch what it does step by step, and use this information to
defuse it. This is probably the fastest way of defusing it. You may not modify your bomb in any way to defuse it
We make one request; please do not use brute force! You could write a program that will try every
possible key to find the right one. But this is no good because we haven't told you how long the strings
are, nor have we told you what characters are in them. Even if you made the (wrong) assumptions that
they all are less than 80 characters long and only contain letters, then you will have 2680 guesses for each
phase. This will take a long time to run, and you will not get the answer before the assignment is due.
There are many tools which are designed to help you figure out both how programs work, and what is
wrong when they don't work. Here is a list of some of the tools you may find useful in analyzing your
bomb, and hints on how to use them.
- gdb:
The GNU debugger is a command line debugger tool available on virtually every platform. You
can trace through a program line by line, examine memory and registers, look at both the source
code and assembly code (we are not giving you the source code for most of your bomb), set
breakpoints, set memory watch points, and write scripts. Here are some tips for using gdb.
To keep the bomb from blowing up every time you type in a wrong input, you'll want to learn how
to set breakpoints.
- See Prof. Matloff's tutorial on gdb at
http://heather.cs.ucdavis.edu/%7Ematloff/UnixAndC/CLanguage/Debug.html
- The CS:APP Student Site at http://csapp.cs.cmu.edu/public/students.html has a very handy single-page gdb summary.
- For other documentation, type "help" at the gdb command prompt, or type "man gdb", or "info
gdb"at a Unix prompt. Some people also like to run gdb under gdb-mode in emacs.
- objdump -t:
This will print out the bomb's symbol table. The symbol table includes the names of all
functions and global variables in the bomb, the names of all the functions the bomb calls, and their
addresses. You may learn something by looking at the function names!
- objdump -d : Use this to disassemble all of the code in the bomb. You can also just look at individual
functions. Reading the assembler code can tell you how the bomb works.
Although objdump -d gives you a lot of information, it doesn't tell you the whole story. Calls to
system-level functions are displayed in a cryptic form. For example, a call to sscanf might appear as:
8048c36: e8 99 fc ff ff call 80488d4 <_init+0x1a0>
To determine that the call was to sscanf, you would need to disassemble within gdb.
-
strings:
This utility will display the printable strings in your bomb.
Looking for a particular tool? How about documentation? Don't forget, the command man is your
friend. In particular, man ascii might come in useful. The web may also be a treasure trove of
information.