CSCI 237
Computer Organization
Home | Schedule | Assignments | Links | Williams CS
Lab 2: GDBomb!
| Assigned | Feb 24, 2026 |
|---|---|
| Prelim Due Date | Tuesday, March 3 at 10:00pm. Target: at least the first three phases defused. |
|   |   |
| Final Due Date | Tuesday March 10 at 10:00pm. All five phases must be defused for full credit. |
|   |   |
| Files | See instructions on obtaining your unique bomb below. |
Overview
The purpose of this assignment is twofold: first, you will
gain basic familiarity with x86-64 assembly instructions
and how they are used to implement comparisons, loops,
switch statements, recursion, pointers, and arrays;
and second, you will gain experience using the
gdb debugger
and other tools to step through assembly code.
The gdb tool will be an invaluable resource
for helping you to understand and reason about your running programs
throughout the rest of the semester.
Instructions
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 (standard input).
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. Each time the bomb explodes you will lose 0.25 points, so be
careful! The bomb is defused when every phase has been defused.
There are too many bombs for us to deal with, so we are giving everyone a unique bomb to defuse. Your mission, which you have no choice but to accept, is to defuse your bomb before the due date(s). Good luck!
The bombs were constructed specifically for the 64-bit machines in the CS labs. Unlike the last assignment, you must do this assignment on one of the Ward lab Linux machines (either physically or using ssh) or any the "four large department servers". The bomb will always blow up if run elsewhere. (There are several other tamper-proofing devices built into the bomb as well.)
Getting Your Bomb
Everyone gets a unique bomb to defuse.
At the start of lab, you can obtain your bomb by pointing your Web browser
here.
This will display a binary bomb request form for you to fill in.
Enter your GitLab user name and your Williams email address and
hit the Submit button. The server will build your bomb and return it to your browser in a "tar file" called
bomb$NUM.tar, where $NUM is the unique number of your bomb. For example, the first bomb handed out was bomb1.tar, and subsequent bombs will contain higher numbers.
The first step is to extract your lab files and add them to your GitLab repository. You can do this using the following commands:
git clone {YOUR-REPO-ADDRESS-GOES-HERE} # this clones your repository
tar -xvf bomb$NUM.tar # the `x` flag extracts the files
# replace `$NUM` with your number
cp bomb$NUM/* {YOUR-LOCAL-REPOSITORY} # copy the lab files to your repo
cd {your-local-repository} # add, commit, and push
git add bomb bomb.c
git commit -m "initial commit"
git push
Once your files are in your github repository, you can ssh into a lab machine of your choice and begin working.
Lab Details
Let's look more closely at the lab files. You should have:
bomb: The executable binary bombbomb.c: Source file with the bomb's main routineREADME: A mostly empty file that just shows your nameYour job is to defuse the bomb. You can use many tools to help you with this; please look at the tools section for some tips and ideas. Two of the best ways are to (a) use a debugger to step through the disassembled binary and (b) print out the dissassembled code and step through it by hand.
The bomb has 5 regular phases. The first four are worth 10 points, and the fifth phase is worth 15, for a total of 55 points. The 6th phase is extra credit (calculated separately from your lab grade and applied at the end of the semester), There are also rumours that a super secret seventh phase exists. If it does and you can find and defuse it, you will receive additional extra credit points. The phases get progressively harder to defuse, but the expertise you gain as you move from phase to phase should offset this difficulty. Nonetheless, the latter phases are not easy, so please don't wait until the last minute to start. (If you're stumped, check the hints section at the end of this document, and come to instructor and/or TA office hour sessions.)
Here are some hints for what to think about at each stage:
The bomb ignores blank input lines. If you run your bomb with a command line argument, for example,
./bomb defuser.txt
then it will read the input lines from defuser.txt
until it reaches
EOF (end of file), and then switch over to stdin (standard input from
the terminal). In a moment of weakness, Dr. Evil added this feature so
you don't have to keep retyping the solutions to phases you have
already defused, instead you can put them in defuser.txt (and commit it to your repository).
When formatting your defuser.txt file, please remember to:
1. This is my answer for phase 1).To avoid accidentally detonating the bomb, you will need to learn how to single-step through the assembly code in gdb and how to set breakpoints. You will also need to learn how to inspect both the registers and the memory state. One of the primary outcomes of doing the lab is to build your skills with using a debugger. This is a crucial skill that will pay big dividends throughout the rest of your programming career.
Resources
There are a number of online resources that will help you understand any assembly instructions you may encounter while examining the bomb. In particular, the programming manuals for x86-64 processors distributed by Intel and AMD are exceptionally valuable. They both describe the same ISA, but sometimes one may be easier to understand than the other. In addition, you can (and should) also refer to your textbook.
Important Note: The instruction format used in the Intel and AMD manuals
is known as “Intel format”. This format is very different than the
format used in our text, in lecture slides, and in what is produced by
gcc, objdump and other tools (which is known as “AT&T format”. You
can read more about these differences in our textbook (on p. 177 of your book)
or on Wikipedia. The
biggest difference is that the order of operands is SWITCHED. This
also serves as a warning that you may see both formats come up in web
searches.
Speaking of web searches, under no circumstances are you to search for anything involving the words "binary bomb" on the Internet or your favorite AI assistant. This would obviously be a violation of the Honor Code. There are many incorrect solutions out there, and they would truly be detrimental in the long run.
Tools and Hints (Read This!!)
The x86-64 ISA passes the first six arguments to a function in
registers. Registers are used in the following
order: rdi, rsi, rdx, rcx, r8, r9.
Function return values are passed in rax.
There are many ways of defusing your bomb. You can print out the assembly and examine it in great detail without ever running the program, and figure out exactly what it does. This is one possible technique, but it not always easy to do. You can also run your binary bomb under a debugger, watch what it does step by step, and use this information to defuse it. Both strategies (analyzing written code and navigating an executing program under a debugger) are useful skills to develop.
Please do not use brute force! You could write a program that will try every possible key to find the right one, but the number of possibilities is so large that you won't be able to try them all in time, and you'll lose points each time you blow up the bomb. Thinking and planning are key.
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 name stands for the GNU debugger,
and it is a command line debugger tool available on virtually every platform.
You can trace through a program line by line,
examine the contents of 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 run scripts. Here are some tips for using gdb.
gdb to stop your program
before it executes the function that explodes your bomb? (Hint: do this!)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 emacsgdb has a "text user interface" (or TUI) mode, that many people find useful.
Within a running gdb session, you can enter and exit tui mode using ctrl-x followed by ctrl-a.
You can also start gdb in tui mode using gdb -tui [program_name]objdump -t bomb: 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 bomb: 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 may look cryptic. 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 -t x bomb: This utility will display the
printable strings in your bomb and their offset within the
bomb.Looking for a particular tool? How about documentation? Don't
forget, the commands apropos and man are
your friends. In particular, typing man ascii at the
terminal may be more useful than you'd think.
Scoreboard
Track your progress. Check out the scoreboard for more info.