You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: challenges/computing-101/control-flow/callee-write/DESCRIPTION.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ Get it right, and your `solve` will print your flag for you!
72
72
**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`).
73
73
This is _different_ from the arguments your function will be called with, so you'll need to move some stuff around!
74
74
75
-
**Debugging your solution.**
75
+
**DEBUGGING TIPS:**
76
76
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.
77
77
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`.
78
78
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
101
101
102
102
You can also debug the native harness directly with stand-in bytes instead of the flag.
103
103
`/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:
Copy file name to clipboardExpand all lines: challenges/computing-101/numbers-as-strings/itoa-two-digits/DESCRIPTION.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,10 +19,10 @@ Then return the number of characters written (in this case, 2).
19
19
Remember to `.global itoa`.
20
20
21
21
**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.
23
23
Now, you do.
24
24
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:
26
26
27
27
| register | least significant byte |
28
28
| -------- | ---------------------- |
@@ -49,11 +49,11 @@ This is tricky, but do it carefully, and the flag is your reward!
49
49
50
50
----
51
51
52
-
**Debugging:**
52
+
**DEBUGGING TIPS:**
53
53
This can get tricky to get right.
54
54
To debug this challenge, our advice is to add a `_start` in your code, as so:
55
55
56
-
```
56
+
```asm
57
57
.global _start
58
58
_start:
59
59
mov rdi, 42 // you'll pass 42 as the first argument to your function
@@ -76,3 +76,11 @@ hacker@dojo:~$ gdb ./debug
76
76
```
77
77
78
78
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`:
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.
0 commit comments