Skip to content

Commit b3cba93

Browse files
committed
Update challenges for simple challenge image
1 parent 8b71f55 commit b3cba93

File tree

9 files changed

+21
-22
lines changed

9 files changed

+21
-22
lines changed

hello/apple/apple

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
22

33
with open("/flag") as f:
44
print(f.read())

hello/banana/banana

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
22

33
import pathlib
44

world/earth/.init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/local/bin/python
22

33
import pathlib
44

world/earth/earth

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
22

33
with open("/flag") as f:
44
print(f.read())

world/mars/orbit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
22

33
import pathlib
44
import random

world/venus/.init

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
#!/opt/pwn.college/python
1+
#!/usr/local/bin/python
22

33
import pathlib
44
import random
5-
6-
import jinja2
5+
import string
76

87
with open("/flag") as f:
98
random.seed(f.read())
109

1110
init_path = pathlib.Path(__file__)
1211
planets_path = (pathlib.Path(__file__).parent / "planets.txt")
1312
launch_path = (pathlib.Path(__file__).parent / "launch")
14-
launch_template_path = (pathlib.Path(__file__).parent / "launch.j2")
13+
launch_template_path = (pathlib.Path(__file__).parent / "launch.template")
1514

1615
planet = random.choice(planets_path.read_text().strip().splitlines())
1716

18-
template = jinja2.Template(launch_template_path)
19-
launch_path.write_text(template.render(planet=planet))
17+
template = string.Template(launch_template_path.read_text())
18+
launch_path.write_text(template.safe_substitute(planet=planet))
2019

2120
launch_template_path.unlink()
2221
planets_path.unlink()

world/venus/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ When users start this challenge, their environment will have:
99
- `/challenge/launch`
1010

1111
In this challenge, `takeoff` is a statically instanced file.
12-
There is also files `.init`, `planets.txt`, and `launch.j2` which students will never see.
13-
At run time, `.init` reads in `planets.txt` to construct `launch` from the templated file `launch.j2`.
12+
There is also files `.init`, `planets.txt`, and `launch.template` which students will never see.
13+
At run time, `.init` reads in `planets.txt` to construct `launch` from the templated file `launch.template`.
1414
This gives the challenge static instancing dependent upon the flag.
1515
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.
1616
However, for simple cases, this may be acceptable.
17-
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.
17+
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.

world/venus/launch.j2

Lines changed: 0 additions & 8 deletions
This file was deleted.

world/venus/launch.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/exec-suid -- /usr/local/bin/python -I
2+
3+
import subprocess
4+
5+
subprocess.run(["/challenge/takeoff", "${planet}"])
6+
7+
with open("/flag") as f:
8+
print(f.read())

0 commit comments

Comments
 (0)