Skip to content

Commit 2f2c8ce

Browse files
committed
Address challenge feedback from Discord
1 parent 3fb2218 commit 2f2c8ce

6 files changed

Lines changed: 35 additions & 11 deletions

File tree

challenges/computing-101/control-flow/callee-write/DESCRIPTION.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Get it right, and your `solve` will print your flag for you!
7272
**Hint:** Keep in mind that `write()` takes arguments in the order of: file descriptor (1 in `rdi` for stdout), buffer (pointer to memory, in `rsi`), and size (in `rdx`).
7373
This is _different_ from the arguments your function will be called with, so you'll need to move some stuff around!
7474

75-
**Debugging your solution.**
75+
**DEBUGGING TIPS:**
7676
Since your code is a function inside a shared library, there's no entry point to launch under `gdb` directly --- but you can *give* it one.
7777
Add a tiny `_start` to your code that fakes the grader's call: point `rdi` at a stand-in buffer, set `rsi` to its length, and `call solve`.
7878
Now you can step through your logic in plain `gdb`, with no flag and no privileges needed:
@@ -101,12 +101,13 @@ If your `solve` is correct, this prints `AAAA` --- and the same logic will print
101101

102102
You can also debug the native harness directly with stand-in bytes instead of the flag.
103103
`/challenge/check` is the Python checker script, so do not load it as the executable in `gdb`.
104-
The native program that loads your `.so` is `/challenge/harness`, and it reads the stand-in bytes from stdin:
104+
The native program that loads your `.so` is `/challenge/harness`, and it reads the stand-in bytes from stdin.
105+
Put those bytes in a file and redirect it into the harness:
105106

106107
```console
108+
hacker@dojo:~$ printf 'type-a-placeholder-flag-here\n' > fake-flag
107109
hacker@dojo:~$ gdb --args /challenge/harness your-solve.so
108-
(gdb) run
109-
type-a-placeholder-flag-here
110+
(gdb) run < fake-flag
110111
```
111112

112113
The checker will run that same harness shape with the real flag when you submit your `.so`.

challenges/computing-101/numbers-as-strings/itoa-two-digits/DESCRIPTION.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Then return the number of characters written (in this case, 2).
1919
Remember to `.global itoa`.
2020

2121
**Writing characters.**
22-
Your `itoa_digit` function from the last level returned the result (in `rax`), and you didn't have to deal writh writing it to a buffer.
22+
Your `itoa_digit` function from the last level returned the result (in `rax`), and you didn't have to deal with writing it to a buffer.
2323
Now, you do.
2424
Your actual character is _one byte_ (8 bits), whereas the register you're holding it in is 64 bits (8 bytes) long.
25-
You just want the last ("least significant") byte, and you can directly access it through _partial register alises_, depending on the register:
25+
You just want the last ("least significant") byte, and you can directly access it through _partial register aliases_, depending on the register:
2626

2727
| register | least significant byte |
2828
| -------- | ---------------------- |
@@ -49,11 +49,11 @@ This is tricky, but do it carefully, and the flag is your reward!
4949

5050
----
5151

52-
**Debugging:**
52+
**DEBUGGING TIPS:**
5353
This can get tricky to get right.
5454
To debug this challenge, our advice is to add a `_start` in your code, as so:
5555

56-
```
56+
```asm
5757
.global _start
5858
_start:
5959
mov rdi, 42 // you'll pass 42 as the first argument to your function
@@ -76,3 +76,11 @@ hacker@dojo:~$ gdb ./debug
7676
```
7777

7878
Execution stops at your `int3`, and from there you can step through with the techniques you learned in [Software Introspection](/computing-101/introspecting), looking at memory on the stack, registers, etc, until things work!
79+
You can also debug the native harness that loads your `.so`:
80+
81+
```console
82+
hacker@dojo:~$ gdb --args /challenge/harness your-solve.so 42
83+
(gdb) run
84+
```
85+
86+
The first argument after `/challenge/harness` is your library, and the second is the stand-in number passed to `itoa`.

challenges/computing-101/the-stack-revisited/stale-stack-data/DESCRIPTION.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ hacker@dojo:~$ ld -shared -o solve.so solve.o
3131
hacker@dojo:~$ /challenge/check solve.so
3232
```
3333

34-
For debugging a submitted function inside a shared library, refer back to [Writing From a Shared Library](/computing-101/control-flow/callee-write).
34+
----
35+
36+
**DEBUGGING TIPS:**
37+
For the general shared-library debugging workflow, use [Writing From a Shared Library](/computing-101/control-flow/callee-write).
38+
If you debug the checker path directly, load the native harness with `gdb`, not `/challenge/check`, and redirect stand-in flag bytes into it:
39+
40+
```console
41+
hacker@dojo:~$ python3 -c 'import sys; sys.stdout.buffer.write(b"debug-stale-stack-flag\n" * 16)' > fake-flag
42+
hacker@dojo:~$ gdb --args /challenge/harness solve.so
43+
(gdb) run < fake-flag
44+
```
45+
46+
The harness reads stand-in flag bytes from stdin, just as the checker feeds it, and the checker output also prints the exact stale-stack offset for this level.

challenges/linux-luminarium/chaining/script-args/challenge/run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if [ "$OUTPUT" = "$EXPECTED" ]; then
1919
cat /flag
2020
else
2121
echo "Not quite right!"
22-
echo "Expected: $EXPECTED"
23-
echo "Got: $OUTPUT"
22+
echo "Expected: '$EXPECTED'"
23+
echo "Got: '$OUTPUT'"
2424
exit 1
2525
fi

challenges/linux-luminarium/commands/mv/DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ hacker@dojo:~$
1515
```
1616

1717
This challenge wants you to move the `/flag` file into `/tmp/hack-the-planet` (do it)!
18+
Run `mv` directly from your shell, just like in the example above.
1819
When you're done, run `/challenge/check`, which will check things out and give the flag to you.

solve.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
echo "$2 $1"

0 commit comments

Comments
 (0)