Update challenges for simple challenge image

This commit is contained in:
Connor Nelson
2025-01-06 14:19:56 -07:00
parent 8b71f5543d
commit b3cba93641
9 changed files with 21 additions and 22 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/local/bin/python
import pathlib
+1 -1
View File
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
with open("/flag") as f:
print(f.read())
+1 -1
View File
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
import pathlib
import random
+5 -6
View File
@@ -1,9 +1,8 @@
#!/opt/pwn.college/python
#!/usr/local/bin/python
import pathlib
import random
import jinja2
import string
with open("/flag") as f:
random.seed(f.read())
@@ -11,12 +10,12 @@ with open("/flag") as f:
init_path = pathlib.Path(__file__)
planets_path = (pathlib.Path(__file__).parent / "planets.txt")
launch_path = (pathlib.Path(__file__).parent / "launch")
launch_template_path = (pathlib.Path(__file__).parent / "launch.j2")
launch_template_path = (pathlib.Path(__file__).parent / "launch.template")
planet = random.choice(planets_path.read_text().strip().splitlines())
template = jinja2.Template(launch_template_path)
launch_path.write_text(template.render(planet=planet))
template = string.Template(launch_template_path.read_text())
launch_path.write_text(template.safe_substitute(planet=planet))
launch_template_path.unlink()
planets_path.unlink()
+3 -3
View File
@@ -9,9 +9,9 @@ When users start this challenge, their environment will have:
- `/challenge/launch`
In this challenge, `takeoff` is a statically instanced file.
There is also files `.init`, `planets.txt`, and `launch.j2` which students will never see.
At run time, `.init` reads in `planets.txt` to construct `launch` from the templated file `launch.j2`.
There is also files `.init`, `planets.txt`, and `launch.template` which students will never see.
At run time, `.init` reads in `planets.txt` to construct `launch` from the templated file `launch.template`.
This gives the challenge static instancing dependent upon the flag.
In general, it is best to define a pool of static instanced files prior, so that this setup does not need to be performed at runtime every challenge start.
However, for simple cases, this may be acceptable.
It is important to note, however, that the results of these static instances are still dependent upon the flag, which means running the challenge with a different flag (e.g. with a practice flag), will fundamentally change the instance.
It is important to note, however, that the results of these static instances are still dependent upon the flag, which means running the challenge with a different flag (e.g. with a practice flag), will change the behavior of the instance.
-8
View File
@@ -1,8 +0,0 @@
#!/opt/pwn.college/python
import subprocess
subprocess.run(["/challenge/takeoff", "{{ planet }}"])
with open("/flag") as f:
print(f.read())
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
import subprocess
subprocess.run(["/challenge/takeoff", "${planet}"])
with open("/flag") as f:
print(f.read())