Updated challenges showing off dojo features

This commit is contained in:
Connor Nelson
2023-02-01 12:20:34 -07:00
parent abc2ab7c7d
commit f553033b3b
29 changed files with 172 additions and 15 deletions
+10
View File
@@ -0,0 +1,10 @@
#!/opt/pwn.college/python
import pathlib
dir = pathlib.Path(__file__).parent
planets = (dir / "planets.txt").read_text().strip().splitlines()
for planet in planets:
planet_path = dir / planet.lower()
planet_path.write_text(planet)
+14
View File
@@ -0,0 +1,14 @@
# world
## earth
This challenge is named `earth`, and is located within module `world`.
When users start this challenge, their environment will have:
- `/flag`
- `/challenge/earth`
- `/challenge/planets.txt`
- `/chalenge/.init`
Symbolic links which are relative to the dojo root-directory are supported.
When a challenge starts, and before users have access to their environment, `.init` will automatically be run as the root user.
+4
View File
@@ -0,0 +1,4 @@
#!/opt/pwn.college/python
with open("/flag") as f:
print(f.read())
+1
View File
@@ -0,0 +1 @@
../planets.txt
+17
View File
@@ -0,0 +1,17 @@
# world
## mars
This challenge is named `mars`, and is located within module `world`.
When users start this challenge, their environment will have:
- `/flag`
- `/challenge/orbit`
- `/challenge/planets.txt`
In this challenge, `orbit` reads in the flag and seeds random off of it.
While this is a challenge-specific detail, it is a broadly useful idea.
It allows for the challenge's behavior to be dynamically dependent on the flag.
This offers a similar paradigm to instanced challenge files.
However, it is dynamically instanced, rather than statically instanced.
Statically instanced values may be accessed by a student, while dynamically instanced values may not be (since they are dependent on the flag).
Which style is appropriate depends on the specifics of the challenge.
+15
View File
@@ -0,0 +1,15 @@
#!/opt/pwn.college/python
import pathlib
import random
with open("/flag") as f:
random.seed(f.read())
planets = (pathlib.Path(__file__).parent / "planets.txt").read_text().strip().splitlines()
print("This is a flag-seeded random number: {}".format(random.randint(0, 1000)))
print(random.choice(planets))
with open("/flag") as f:
print(f.read())
+1
View File
@@ -0,0 +1 @@
../planets.txt
+8
View File
@@ -0,0 +1,8 @@
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
+23
View File
@@ -0,0 +1,23 @@
#!/opt/pwn.college/python
import pathlib
import random
import jinja2
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")
planet = random.choice(planets_path.read_text().strip().splitlines())
template = jinja2.Template(launch_template_path)
launch_path.write_text(template.render(planet=planet))
launch_template_path.unlink()
planets_path.unlink()
init_path.unlink()
+17
View File
@@ -0,0 +1,17 @@
# world
## venus
This challenge is named `venus`, and is located within module `world`.
When users start this challenge, their environment will have:
- `/flag`
- `/challenge/takeoff`
- `/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`.
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.
+6
View File
@@ -0,0 +1,6 @@
#!/opt/pwn.college/python
import sys
print("3.... 2... 1...")
print(sys.argv[1])
+6
View File
@@ -0,0 +1,6 @@
#!/opt/pwn.college/python
import sys
print("5... 4... 3.... 2... 1...")
print(sys.argv[1])
+8
View File
@@ -0,0 +1,8 @@
#!/opt/pwn.college/python
import subprocess
subprocess.run(["/challenge/takeoff", "{{ planet }}"])
with open("/flag") as f:
print(f.read())
+1
View File
@@ -0,0 +1 @@
../planets.txt