-
Notifications
You must be signed in to change notification settings - Fork 10
added bomb lab #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
777lefty
wants to merge
1
commit into
main
Choose a base branch
from
bomb_lab
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
added bomb lab #113
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/compose.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| services: | ||
| default: | ||
| network_mode: host | ||
| image: gcc:12 | ||
| command: sleep infinity | ||
| working_dir: /workspace | ||
| x-init: | ||
| - preprocess.sh |
15 changes: 15 additions & 0 deletions
15
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "instance_id": "cmu_15-213__bomb_lab", | ||
| "course_id": "cmu_15-213", | ||
| "timeout_minutes": 30, | ||
| "tags": [ | ||
| "reverse-engineering", | ||
| "debugging", | ||
| "x86-64", | ||
| "binary-analysis" | ||
| ], | ||
| "artifacts": [ | ||
| "solution.txt", | ||
| "bomb_output.txt" | ||
| ] | ||
| } |
52 changes: 52 additions & 0 deletions
52
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/evaluate.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| echo "=== Evaluating CMU 15-213 Bomb Lab ===" | ||
|
|
||
| cd /workspace | ||
|
|
||
| # Verify reference artifacts haven't been modified | ||
| if [ -f /tmp/checksums/protected.sha256 ]; then | ||
| echo "Checking protected files" | ||
| if ! sha256sum -c /tmp/checksums/protected.sha256; then | ||
| echo "FAIL: Protected starter files were modified (bomb, bomb.c, README.bomb)" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ ! -f solution.txt ]; then | ||
| echo "FAIL: solution.txt not found. Write six input lines (one per bomb phase)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| line_count=$(wc -l < solution.txt || echo 0) | ||
| if [ "$line_count" -lt 6 ]; then | ||
| echo "FAIL: solution.txt must contain at least six lines (one per phase)." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure the binary is executable | ||
| chmod +x bomb | ||
|
|
||
| echo "Running bomb with provided solution" | ||
| if ! timeout 120 ./bomb solution.txt > bomb_output.txt 2>&1; then | ||
| echo "FAIL: bomb execution failed or timed out" | ||
| cat bomb_output.txt || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Checking bomb output" | ||
| if grep -q "BOOM!!!" bomb_output.txt; then | ||
| echo "FAIL: Bomb exploded." | ||
| cat bomb_output.txt | ||
| exit 1 | ||
| fi | ||
|
|
||
| if grep -q "Congratulations! You've defused the bomb!" bomb_output.txt; then | ||
| echo "PASS: Bomb defused" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "FAIL: Bomb did not report success" | ||
| cat bomb_output.txt | ||
| exit 1 |
35 changes: 35 additions & 0 deletions
35
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/preprocess.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| echo "=== Setting up CMU 15-213 Bomb Lab ===" | ||
|
|
||
| cd /workspace | ||
|
|
||
| echo "Ensuring bomb assets are present" | ||
| required_files="bomb bomb.c README.bomb" | ||
| for file in $required_files; do | ||
| if [ ! -f "$file" ]; then | ||
| echo "ERROR: Missing required starter file: $file" | ||
| exit 1 | ||
| fi | ||
| echo " ✓ $file" | ||
| done | ||
|
|
||
| # Install debugging essentials (gcc:12 is minimal) | ||
| echo "Installing debugging tools (gdb, binutils, procps, file)" | ||
| apt-get update | ||
| apt-get install -y gdb binutils procps file | ||
|
|
||
| # Provide a working solution file if the agent wants to edit in place | ||
| if [ ! -f solution.txt ]; then | ||
| touch solution.txt | ||
| fi | ||
|
|
||
| # Make sure the bomb binary is executable | ||
| chmod +x bomb | ||
|
|
||
| # Record checksums to protect reference artifacts | ||
| mkdir -p /tmp/checksums | ||
| sha256sum bomb bomb.c README.bomb > /tmp/checksums/protected.sha256 | ||
|
|
||
| echo "Bomb Lab setup complete. Use gdb/objdump/strings to recover all six inputs and write them to solution.txt." |
18 changes: 18 additions & 0 deletions
18
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/sol.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| cd /workspace | ||
|
|
||
| cat > solution.txt <<'EOF_SOL' | ||
| Border relations with Canada have never been better. | ||
| 1 2 4 8 16 32 | ||
| 7 327 | ||
| 7 0 | ||
| 9on567 | ||
| 4 3 2 1 6 5 | ||
| EOF_SOL | ||
|
|
||
| chmod +x bomb | ||
| ./bomb solution.txt > /tmp/bomb_sol_output.txt | ||
| grep -q "Congratulations! You've defused the bomb!" /tmp/bomb_sol_output.txt | ||
| printf "Bomb lab reference solution produced:\n%s\n" "$(tail -n 5 /tmp/bomb_sol_output.txt)" |
71 changes: 71 additions & 0 deletions
71
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/starter/README.bomb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| ####################################################### | ||
| # CS:APP Bomb Lab | ||
| # Directions to Instructors | ||
| # | ||
| # Copyright (c) 2003-2016, R. Bryant and D. O'Hallaron | ||
| # | ||
| ####################################################### | ||
|
|
||
| This directory contains the files that you will use to build and run | ||
| the CS:APP Bomb Lab. The Bomb Lab teaches students principles of | ||
| machine-level programs, as well as general debugger and reverse | ||
| engineering skills. | ||
|
|
||
| *********** | ||
| 1. 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. | ||
|
|
||
| ---- | ||
| 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. | ||
|
|
||
|
|
||
| ******************* | ||
| 1. 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. |
Binary file added
BIN
+25.8 KB
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/starter/bomb
Binary file not shown.
115 changes: 115 additions & 0 deletions
115
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/starter/bomb.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /*************************************************************************** | ||
| * Dr. Evil's Insidious Bomb, Version 1.1 | ||
| * Copyright 2011, Dr. Evil Incorporated. All rights reserved. | ||
| * | ||
| * LICENSE: | ||
| * | ||
| * Dr. Evil Incorporated (the PERPETRATOR) hereby grants you (the | ||
| * VICTIM) explicit permission to use this bomb (the BOMB). This is a | ||
| * time limited license, which expires on the death of the VICTIM. | ||
| * The PERPETRATOR takes no responsibility for damage, frustration, | ||
| * insanity, bug-eyes, carpal-tunnel syndrome, loss of sleep, or other | ||
| * harm to the VICTIM. Unless the PERPETRATOR wants to take credit, | ||
| * that is. The VICTIM may not distribute this bomb source code to | ||
| * any enemies of the PERPETRATOR. No VICTIM may debug, | ||
| * reverse-engineer, run "strings" on, decompile, decrypt, or use any | ||
| * other technique to gain knowledge of and defuse the BOMB. BOMB | ||
| * proof clothing may not be worn when handling this program. The | ||
| * PERPETRATOR will not apologize for the PERPETRATOR's poor sense of | ||
| * humor. This license is null and void where the BOMB is prohibited | ||
| * by law. | ||
| ***************************************************************************/ | ||
|
|
||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include "support.h" | ||
| #include "phases.h" | ||
|
|
||
| /* | ||
| * Note to self: Remember to erase this file so my victims will have no | ||
| * idea what is going on, and so they will all blow up in a | ||
| * spectaculary fiendish explosion. -- Dr. Evil | ||
| */ | ||
|
|
||
| FILE *infile; | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| char *input; | ||
|
|
||
| /* Note to self: remember to port this bomb to Windows and put a | ||
| * fantastic GUI on it. */ | ||
|
|
||
| /* When run with no arguments, the bomb reads its input lines | ||
| * from standard input. */ | ||
| if (argc == 1) { | ||
| infile = stdin; | ||
| } | ||
|
|
||
| /* When run with one argument <file>, the bomb reads from <file> | ||
| * until EOF, and then switches to standard input. Thus, as you | ||
| * defuse each phase, you can add its defusing string to <file> and | ||
| * avoid having to retype it. */ | ||
| else if (argc == 2) { | ||
| if (!(infile = fopen(argv[1], "r"))) { | ||
| printf("%s: Error: Couldn't open %s\n", argv[0], argv[1]); | ||
| exit(8); | ||
| } | ||
| } | ||
|
|
||
| /* You can't call the bomb with more than 1 command line argument. */ | ||
| else { | ||
| printf("Usage: %s [<input_file>]\n", argv[0]); | ||
| exit(8); | ||
| } | ||
|
|
||
| /* Do all sorts of secret stuff that makes the bomb harder to defuse. */ | ||
| initialize_bomb(); | ||
|
|
||
| printf("Welcome to my fiendish little bomb. You have 6 phases with\n"); | ||
| printf("which to blow yourself up. Have a nice day!\n"); | ||
|
|
||
| /* Hmm... Six phases must be more secure than one phase! */ | ||
| input = read_line(); /* Get input */ | ||
| phase_1(input); /* Run the phase */ | ||
| phase_defused(); /* Drat! They figured it out! | ||
| * Let me know how they did it. */ | ||
| printf("Phase 1 defused. How about the next one?\n"); | ||
|
|
||
| /* The second phase is harder. No one will ever figure out | ||
| * how to defuse this... */ | ||
| input = read_line(); | ||
| phase_2(input); | ||
| phase_defused(); | ||
| printf("That's number 2. Keep going!\n"); | ||
|
|
||
| /* I guess this is too easy so far. Some more complex code will | ||
| * confuse people. */ | ||
| input = read_line(); | ||
| phase_3(input); | ||
| phase_defused(); | ||
| printf("Halfway there!\n"); | ||
|
|
||
| /* Oh yeah? Well, how good is your math? Try on this saucy problem! */ | ||
| input = read_line(); | ||
| phase_4(input); | ||
| phase_defused(); | ||
| printf("So you got that one. Try this one.\n"); | ||
|
|
||
| /* Round and 'round in memory we go, where we stop, the bomb blows! */ | ||
| input = read_line(); | ||
| phase_5(input); | ||
| phase_defused(); | ||
| printf("Good work! On to the next...\n"); | ||
|
|
||
| /* This phase will never be used, since no one will get past the | ||
| * earlier ones. But just in case, make this one extra hard. */ | ||
| input = read_line(); | ||
| phase_6(input); | ||
| phase_defused(); | ||
|
|
||
| /* Wow, they got it! But isn't something... missing? Perhaps | ||
| * something they overlooked? Mua ha ha ha ha! */ | ||
|
|
||
| return 0; | ||
| } |
33 changes: 33 additions & 0 deletions
33
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/starter/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # CMU 15-213: Bomb Lab | ||
|
|
||
| You are given a pre-built binary bomb. It has six phases. Each phase expects a specific input line; if any line is wrong the bomb explodes. Your job is to reverse engineer the binary and write the correct six lines to a file called `solution.txt`. | ||
|
|
||
| The binary and supporting materials are in the starter directory: | ||
|
|
||
| - `bomb`: the ELF64 binary bomb | ||
| - `bomb.c`: the main driver (does not reveal the phase internals) | ||
| - `README.bomb`: background about the lab | ||
|
|
||
| ## Task | ||
|
|
||
| 1. Work inside `/workspace`. | ||
| 2. Recover the correct input for each of the six phases of the bomb. | ||
| 3. Write the six inputs in order, one per line, to `solution.txt`. | ||
| 4. Do not modify the starter artifacts (`bomb`, `bomb.c`, `README.bomb`). | ||
|
|
||
| The grading script will run `./bomb solution.txt` and expects the bomb to report success without ever printing `BOOM!!!`. | ||
|
|
||
| ## Useful commands | ||
|
|
||
| - `strings bomb` to scan embedded text | ||
| - `objdump -d bomb | less` to disassemble | ||
| - `gdb ./bomb` to step through phases (set breakpoints on `phase_1`…`phase_6`) | ||
| - `./bomb` to run interactively during testing | ||
|
|
||
| ## What is evaluated | ||
|
|
||
| - `solution.txt` exists and has at least six lines | ||
| - Starter files are unchanged | ||
| - `./bomb solution.txt` completes without exploding and prints "Congratulations! You've defused the bomb!" | ||
|
|
||
| Secret phases are not required. Focus only on phases 1–6. |
34 changes: 34 additions & 0 deletions
34
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # CMU 15-213: Bomb Lab | ||
|
|
||
| You are given a pre-built binary bomb. It has six phases. Each phase expects a specific input line; if any line is wrong the bomb explodes. Your job is to reverse engineer the binary and write the correct six lines to a file called `solution.txt`. | ||
|
|
||
| The binary and supporting materials are in the starter directory: | ||
|
|
||
| - `bomb`: the ELF64 binary bomb | ||
| - `bomb.c`: the main driver (does not reveal the phase internals) | ||
| - `README.bomb`: background about the lab | ||
| - `task.md`: this task description | ||
|
|
||
| ## Task | ||
|
|
||
| 1. Work inside `/workspace`. | ||
| 2. Recover the correct input for each of the six phases of the bomb. | ||
| 3. Write the six inputs in order, one per line, to `solution.txt`. | ||
| 4. Do not modify the starter artifacts (`bomb`, `bomb.c`, `README.bomb`). | ||
|
|
||
| The grading script will run `./bomb solution.txt` and expects the bomb to report success without ever printing `BOOM!!!`. | ||
|
|
||
| ## Useful commands | ||
|
|
||
| - `strings bomb` to scan embedded text | ||
| - `objdump -d bomb | less` to disassemble | ||
| - `gdb ./bomb` to step through phases (set breakpoints on `phase_1`…`phase_6`) | ||
| - `./bomb` to run interactively during testing | ||
|
|
||
| ## What is evaluated | ||
|
|
||
| - `solution.txt` exists and has at least six lines | ||
| - Starter files are unchanged | ||
| - `./bomb solution.txt` completes without exploding and prints "Congratulations! You've defused the bomb!" | ||
|
|
||
| Secret phases are not required. Focus only on phases 1–6. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to be duplicated (
benchmarks/courselab_bench/data/cmu_15-213/task_bomb_lab/task.md)