Introduction

A "binary bomb" is a program provided to students as an object code file. When run, it 
prompts the user to type in 6 different strings. If any of these is incorrect, the bomb 
"explodes," printing an error message and logging the event on a grading server. Students 
must "defuse" their own unique bomb by disassembling and reverse engineering the program 
to determine what the 6 strings should be. The lab teaches students to understand assembly
language, and also forces them to learn how to use a debugger. It's also great fun. A
legendary lab among the CMU undergrads.Here's a Linux/x86-64 binary bomb that you can 
try out for yourself. The feature that notifies the grading server has been disabled, 
so feel free to explode this bomb with impunity. If you're an instructor with a CS:APP 
account, then you can download the solution.
一个'binary bomb'是一个作为目标代码文件提供给学生的程序。当运行的时候, 它会提醒用户输入六个
不同的字符串。如果其中任何一个不正确,炸弹就会爆炸,打印错误消息并将事件记录在评分服务器上。
学生必须通过对程序进行反汇编和逆向工程来"拆除"他们自己独特的炸弹, 以确定6个字符串应该是什么。
这个lab教学生理解汇编语言,并强迫他们学习如何使用调试器。这也很有趣。CMU 本科生中的传奇实验室。
这是一个 Linux/x86-64 二进制炸弹,您可以自己尝试. ......

一:Overview

1.1. Binary Bombs

A "binary bomb" is a Linux executable C program that consists of six "phases." 
Each phase expects the student to enter a particular string on stdin. If the student 
enters the expected string, then that phase is "defused." Otherwise the bomb "explodes" 
by printing "BOOM!!!". The goal for the students is to defuse as many phases as possible.
“binary bomb”是由六个“阶段”组成的Linux可执行C程序. 每个阶段都希望学生在标准输入上输入一个特定
的字符串。 如果学生输入了预期的字符串,则该阶段被“拆除”。否则炸弹会通过打印“BOOM!!!”来“爆炸”。
学生的目标是消除尽可能多的阶段。

1.2. Solving Binary Bombs

In order to defuse the bomb, students must use a debugger, typically gdb or ddd, to 
disassemble the binary and single-step through the machine code in each phase. The idea 
is to understand what each assembly statement does, and then use this knowledge to infer 
the defusing string. Students earn points for defusing phases, and they lose points 
(configurable by the instructor, but typically 1/2 point) for each explosion. Thus, 
they quickly learn to set breakpoints before each phase and the function that explodes 
the bomb. It's a great lesson and forces them to learn to use a debugger. 
为了拆除炸弹, 学生必须使用调试器, 通常是gdb或ddd, 来反汇编二进制文件并单步执行每个阶段的
机器代码. 这个想法是了解每个汇编语句的作用,然后使用这些知识来推断拆解字符串。因此,他们很
快学会了在每个阶段之前设置断点以及引爆炸弹的功能。这是一个很好的迫使他们学习使用调试器的
学习机会.

1.3. Autograding Service

We have created a stand-alone user-level autograding service that
handles all aspects of the Bomb Lab for you: Students download their
bombs from a server. As the students work on their bombs, each
explosion and defusion is streamed back to the server, where the
current results for each bomb are displayed on a Web "scoreboard."
There are no explicit handins and the lab is self-grading.

The autograding service consists of four user-level programs that run
in the main ./bomblab directory:

- Request Server (bomblab-requestd.pl). Students download their bombs
and display the scoreboard by pointing a browser at a simple HTTP
server called the "request server." The request server builds the
bomb, archives it in a tar file, and then uploads the resulting tar
file back to the browser, where it can be saved on disk and
untarred. The request server also creates a copy of the bomb and its
solution for the instructor.

- Result Server (bomblab-resultd.pl). Each time a student defuses a
bomb phase or causes an explosion, the bomb sends a short HTTP
message, called an "autoresult string," to an HTTP "result server,"
which simply appends the autoresult string to a "scoreboard log file."

- Report Daemon (bomblab-reportd.pl). The "report daemon" periodically
scans the scoreboard log file. The report daemon finds the most recent
defusing string submitted by each student for each phase, and
validates these strings by applying them to a local copy of the
student's bomb.  It then updates the HTML scoreboard that summarizes
the current number of explosions and defusions for each bomb, rank
ordered by the total number of accrued points.

- Main daemon (bomblab.pl). The "main daemon" starts and nannies the
request server, result server, and report deamon, ensuring that
exactly one of these processes (and itself) is running at any point in
time. If one of these processes dies for some reason, the main daemon
detects this and automatically restarts it. The main daemon is the
only program you actually need to run.
我们创建了一个独立的用户级自动评分服务,为您处理Bomb Lab的所有方面, 学生从服务器下载他
们的炸弹。当学生们处理他们的炸弹时,每次爆炸和拆解都会流回服务器,每个炸弹的当前结果显示
在网络“记分牌”上。没有明确的交接,lab是自我评分的。

自动分级服务由四个在主 ./bomblab 目录中运行的用户级程序组成:

- 请求服务器(bomblab-requestd.pl)。学生通过将浏览器指向一个称为“请求服务器”的
简单 HTTP 服务器来下载他们的炸弹并显示记分板。请求服务器构建炸弹,将其存档在 tar 文件中
,然后将生成的 tar 文件上传回浏览器,在那里可以将其保存在磁盘上并解压缩。请求服务器还为教
员创建炸弹及其解决方案的副本。

- 结果服务器(bomblab-resultd.pl)。每次学生拆除炸弹阶段或引起爆炸时,炸弹都会向
HTTP“结果服务器”发送一条名为“自动结果字符串”的简短 HTTP 消息,该服务器只是将自动结果
字符串附加到“记分板日志文件”。

- 报告守护程序(bomblab-reportd.pl)。 “报告守护程序”定期扫描记分板日志文件。
报告守护程序查找每个学生为每个阶段提交的最近的拆弹字符串,并通过将它们应用于学生炸
弹的本地副本来验证这些字符串。然后它更新 HTML 记分板,该记分板总结了每个炸弹的当前
爆炸和拆除次数,按累计点数排序。

- 主守护进程 (bomblab.pl)。 “主守护进程”启动并保姆
请求服务器、结果服务器和报告守护程序,确保
这些进程中的一个(及其本身)在任何时间点都在运行
时间。如果这些进程之一因某种原因死亡,主守护进程
检测到这一点并自动重新启动它。主要守护进程是
只有你真正需要运行的程序。

二:Files

The ./bomblab directory contains the following files:

Makefile                - For starting/stopping the lab and cleaning files
bomblab.pl*             - Main daemon that nannies the other servers & daemons
Bomblab.pm              - Bomblab configuration file    
bomblab-reportd.pl*     - Report daemon that continuously updates scoreboard
bomblab-requestd.pl*    - Request server that serves bombs to students
bomblab-resultd.pl*     - Result server that gets autoresult strings from bombs
bomblab-scoreboard.html - Real-time Web scoreboard
bomblab-update.pl*      - Helper to bomblab-reportd.pl that updates scoreboard
bombs/                  - Contains the bombs sent to each student
log-status.txt          - Status log with msgs from various servers and daemons
log.txt                 - Scoreboard log of autoresults received from bombs
makebomb.pl*            - Helper script that builds a bomb
scores.txt              - Summarizes current scoreboard scores for each student
src/                    - The bomb source files
writeup/                - Sample Latex Bomb Lab writeup
./bomblab 目录包含以下文件:

Makefile - 用于启动/停止实验室和清理文件
bomblab.pl* - 主守护进程,为其他服务器和守护进程保驾护航
Bomblab.pm - Bomblab 配置文件
bomblab-reportd.pl* - 不断更新记分板的报告守护程序
bomblab-requestd.pl* - 向学生提供炸弹的请求服务器
bomblab-resultd.pl* - 从炸弹中获取自动结果字符串的结果服务器
bomblab-scoreboard.html - 实时网络记分牌
bomblab-update.pl* - 更新记分板的bomblab-reportd.pl 的助手
炸弹/ - 包含发送给每个学生的炸弹
log-status.txt - 带有来自各种服务器和守护进程的消息的状态日志
log.txt - 从炸弹收到的自动结果的记分板日志
makebomb.pl* - 构建炸弹的辅助脚本
score.txt - 总结每个学生的当前记分板分数
src/ - 炸弹源文件
writeup/ - 解题示例

三:Bomb Terminology

LabID: Each instance (offering) of the lab is identified by a unique
name, e.g., "f12" or "s13", that the instructor chooses. Explosion and
diffusions from bombs whose LabIDs are different from the current
LabID are ignored. The LabID must not have any spaces.

BombID: Each bomb in a given instance of the lab has a unique
non-negative integer called the "bombID."

Notifying Bomb: A bomb can be compiled with a NOTIFY option that
causes the bomb to send a message each time the student explodes or
defuses a phase. Such bombs are called "notifying bombs." 

Quiet Bomb: If compiled with the NONOTIFY option, then the bomb
doesn't send any messages when it explodes or is defused. Such bombs
are called "quiet bombs."

We will also find it helpful to distinguish between custom and
generic bombs:

Custom Bomb: A "custom bomb" has a BombID > 0, is associated with a
particular student, and can be either notifying or quiet. Custom
notifying bombs are constrained to run on a specific set of Linux
hosts determined by the instructor. On the other hand, custom quiet
bombs can run on any Linux host.

Generic Bomb: A "generic bomb" has a BombID = 0, isn't associated with
any particular student, is quiet, and hence can run on any host.

四. Offering the Bomb Lab

There are two basic flavors of Bomb Lab: In the "online" version, the
instructor uses the autograding service to handout a custom notifying
bomb to each student on demand, and to automatically track their
progress on the realtime scoreboard. In the "offline" version, the
instructor builds, hands out, and grades the student bombs manually,
without using the autograding service.

While both version give the students a rich experience, we recommend
the online version. It is clearly the most compelling and fun for the
students, and the easiest for the instructor to grade. However, it
requires that you keep the autograding service running non-stop,
because handouts, grading, and reporting occur continuously for the
duration of the lab. We've made it very easy to run the service, but
some instructors may be uncomfortable with this requirement and will
opt instead for the offline version.

Here are the directions for offering both versions of the lab.