Skip to content

Commit 6120b38

Browse files
committed
Address challenge feedback from Discord
1 parent a2d33a3 commit 6120b38

5 files changed

Lines changed: 39 additions & 25 deletions

File tree

challenges/computing-101/building-a-web-server/common/run.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import signal
1414
import fcntl
1515
import ctypes
16+
import time
1617
import tempfile
1718
import pathlib
1819
import contextlib
@@ -32,7 +33,7 @@
3233
3..10 bind(3, {sa_family=AF_INET, sin_port=htons(<bind_port>), sin_addr=inet_addr("<bind_address>")}, 16) = 0
3334
4..10 listen(3, 0) = 0
3435
5..10 accept(3, NULL, NULL) = 4
35-
6..8 read(4, <read_request>, <read_request_count>) = <read_request_result>
36+
7..8 read(4, <read_request>, <read_request_count>) = <read_request_result>
3637
7..8 open("<open_path>", O_RDONLY) = 5
3738
7..8 read(5, <read_file>, <read_file_count>) = <read_file_result>
3839
7..8 close(5) = 0
@@ -354,12 +355,31 @@ def connect():
354355
pass
355356

356357

357-
def validate_connect():
358-
session = retry_session()
359-
try:
360-
session.get("http://localhost", timeout=1)
361-
except requests.exceptions.RequestException as e:
362-
return request_failure("Connect", e)
358+
def validate_static_response():
359+
expected = b"HTTP/1.0 200 OK\r\n\r\n"
360+
361+
for attempt in range(5):
362+
try:
363+
client = socket.create_connection(("localhost", 80), timeout=1)
364+
break
365+
except ConnectionRefusedError as e:
366+
if attempt == 4:
367+
return f"Static response: Failed to connect ({type(e).__name__}: {e})"
368+
time.sleep(0.1)
369+
370+
with client:
371+
response = b""
372+
try:
373+
while len(response) < len(expected):
374+
chunk = client.recv(len(expected) - len(response))
375+
if not chunk:
376+
break
377+
response += chunk
378+
except TimeoutError as e:
379+
return f"Static response: Timed out ({type(e).__name__}: {e})"
380+
381+
if response != expected:
382+
return "Static response: Response not correct"
363383

364384

365385
def validate_get(data=None):
@@ -401,7 +421,7 @@ def challenge():
401421
3: "bind an address to a socket",
402422
4: "listen on a socket",
403423
5: "accept a connection",
404-
6: "respond to an http request",
424+
6: "send a static HTTP response to a client",
405425
7: "respond to a GET request for the contents of a specified file",
406426
8: "accept multiple requests",
407427
9: "concurrently accept multiple requests",
@@ -451,14 +471,14 @@ def target():
451471

452472
operation_names = {
453473
connect: "connect",
454-
validate_connect: "validated connect",
474+
validate_static_response: "static HTTP response",
455475
validate_get: "HTTP GET request",
456476
validate_post: "HTTP POST request",
457477
}
458478

459479
operations = {
460480
5: [connect],
461-
6: [validate_connect],
481+
6: [validate_static_response],
462482
7: [validate_get],
463483
8: [validate_get, connect],
464484
9: [validate_get, connect],
Binary file not shown.

challenges/linux-luminarium/destruction/disk-doomsday/DESCRIPTION.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
The available space in `/home/hacker` in this container is a measly **1 gigabyte**.
2-
In this level you will clog up `/home/hacker` with so much junk that even a tiny 1 megabyte file can't be created.
3-
When this happens, your workspace becomes unusable.
4-
We'll practice inducing this in this challenge, and then expand on it a bit later.
1+
In this challenge, `/home/hacker` is backed by a small temporary filesystem.
2+
You will clog it with so much junk that even a tiny 1 megabyte file can't be created.
3+
Then you will clean up the junk and restore the available space.
54

65
How to fill the disk?
76
There are so many ways.
@@ -22,9 +21,9 @@ y
2221
hacker@dojo:~$
2322
```
2423

25-
The `yes` outputs `y` over and over forever.
24+
The `yes` command outputs `y` over and over forever.
2625
The typical usage is to automate confirmation prompts ("Are you sure you want to delete this file?") using piping, but we'll use it here to make a massive file full of "y" lines.
27-
Just redirect `yes` to a file in your home directory, and you'll fill your disk in a minute or two!
26+
Just redirect `yes` to a file in your home directory, and it will keep growing until the temporary filesystem fills up!
2827

2928
This challenge forces you to fill the disk and then clean up.
3029
The process:
@@ -36,14 +35,8 @@ The process:
3635

3736
----
3837
**NOTE:**
39-
For this challenge, `/home/hacker` is a small, temporary home directory.
4038
Your existing home-directory files will not be available here, and files you save here will not persist after the challenge ends.
4139

4240
**Why two stages?**
43-
Your home directory persists across challenge instances.
44-
If we let you keep it full, your pwn.college will stop working.
45-
This is _by far_ the most common cause of weird issues on pwn.college!
46-
47-
**HELP IT BROKE!**
48-
If you fill the disk and don't clean it up afterwards, you'll need to `ssh` in to fix things (by removing that file).
49-
This is a bit tricky, but we describe how to do it under "Connecting over SSH" in the [Getting Started](/welcome/welcome) module.
41+
Filling a filesystem is only half the exercise.
42+
The second stage teaches you to clean up after exhausting a system resource, even though this sandbox keeps the experiment away from your persistent home directory.

challenges/linux-luminarium/piping/tee/DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Commands succeeded!
3131

3232
Now, you try it!
3333
This process' `/challenge/pwn` must be piped into `/challenge/college`, but you'll need to intercept the data to see what `pwn` needs from you!
34+
Use `tee` to duplicate your first attempt into a file, inspect the saved output, and then retry the pipeline with what you learned.

challenges/linux-luminarium/piping/tee/challenge/college

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ read SS < <(tail -n1)
1212

1313
if [ "$SS" != "SUPERSECRET:$(tail -c+20 /flag | head -c4)" ]
1414
then
15-
fold -s <<< "The input to 'college' does not contain the correct secret code! This code should be provided by the 'pwn' command. HINT: use 'tee' to intercept the output of 'pwn' and figure out what the code needs to be."
15+
fold -s <<< "The input to 'college' does not contain the correct secret code! This code should be provided by the 'pwn' command. HINT: use 'tee' to save the first attempt to a file, inspect the saved output, and then retry the pipeline with what you learned."
1616
exit 2
1717
fi
1818

0 commit comments

Comments
 (0)