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:

Your 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:

  1. comparison,
  2. loops,
  3. switch statements,
  4. recursion,
  5. pointers and arrays, and
  6. (extra credit) sorting linked lists.

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:

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.

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.