Skip to content

Commit

Permalink
Update challenges for simple challenge image
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Jan 6, 2025
1 parent 8b71f55 commit b3cba93
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion hello/apple/apple
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion hello/banana/banana
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/local/bin/python -I

import pathlib

Expand Down
2 changes: 1 addition & 1 deletion world/earth/.init
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/local/bin/python

import pathlib

Expand Down
2 changes: 1 addition & 1 deletion world/earth/earth
Original file line number Diff line number Diff line change
@@ -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())
2 changes: 1 addition & 1 deletion world/mars/orbit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/pwn.college/python
#!/usr/bin/exec-suid -- /usr/local/bin/python -I

import pathlib
import random
Expand Down
11 changes: 5 additions & 6 deletions world/venus/.init
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#!/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())

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()
Expand Down
6 changes: 3 additions & 3 deletions world/venus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 0 additions & 8 deletions world/venus/launch.j2

This file was deleted.

8 changes: 8 additions & 0 deletions world/venus/launch.template
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit b3cba93

Please sign in to comment.