Skip to content

Commit

Permalink
cmdi-env variants
Browse files Browse the repository at this point in the history
  • Loading branch information
zardus committed Jan 26, 2025
1 parent fe8e791 commit 65e0310
Show file tree
Hide file tree
Showing 18 changed files with 628 additions and 36 deletions.
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_0/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/task", methods=["GET"])
def challenge():
arg = flask.request.args.get("tzid", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=tzid><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_1/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/competition", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-value", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-value><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_10/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/adventure", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-val", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-val><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_11/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/milestone", methods=["GET"])
def challenge():
arg = flask.request.args.get("tz-region", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=tz-region><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_12/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/level", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-val", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-val><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_13/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/problem", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-id", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-id><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_14/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/dare", methods=["GET"])
def challenge():
arg = flask.request.args.get("tz-tag", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=tz-tag><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_15/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/initiative", methods=["GET"])
def challenge():
arg = flask.request.args.get("time-region", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=time-region><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_2/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/assignment", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-value", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-value><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
39 changes: 39 additions & 0 deletions web-security/cmdi-env/_3/server
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/opt/pwn.college/python

import subprocess
import flask
import os

app = flask.Flask(__name__)


@app.route("/competition", methods=["GET"])
def challenge():
arg = flask.request.args.get("timezone-id", "MST")
command = f"TZ={arg} date"

print(f"DEBUG: {command=}")
result = subprocess.run(
command, # the command to run
shell=True, # use the shell to run this command
stdout=subprocess.PIPE, # capture the standard output
stderr=subprocess.STDOUT, # 2>&1
encoding="latin", # capture the resulting output as text
).stdout

return f"""
<html><body>
Welcome to the timezone service! Please choose a timezone to get the time there.
<form><input type=text name=timezone-id><input type=submit value=Submit></form>
<hr>
<b>Output of {command}:</b><br>
<pre>{result}</pre>
</body></html>
"""


os.setuid(os.geteuid())
os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
app.secret_key = os.urandom(8)
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
Loading

0 comments on commit 65e0310

Please sign in to comment.