def practice(): if request.method == "GET": return render_template("practice.html") else: src = request.form["src"] initial_data = ( "67746e726366747374656c617d6167667b6900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "040e05070611020a0809120301100b0c0f0d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "72616374667b74657374696e67666c61677d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) s = StringIO() try: if request.form.get("include_debug"): run(src.replace("\r\n", "\n"), initial_data, 50000, False, s, show_dbg=True) else: run(src.replace("\r\n", "\n"), initial_data, 50000, False, s) output = s.getvalue() s.close() except Exception as e: output = str(e) s.close() return render_template("practiceoutput.html", output=output, expected=PRACTICE_FLAG)
def practice(): if request.method == "GET": return render_template("practice.html") else: src = request.form["src"] initial_data = ( "0a0e111f03020c0a011f0c171f301407041e05000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "786f726b6579786f726b6579786f726b657978000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) s = StringIO() try: if request.form.get("include_debug"): run(src.replace("\r\n", "\n"), initial_data, 50000, False, s, show_dbg=True) else: run(src.replace("\r\n", "\n"), initial_data, 50000, False, s) output = s.getvalue() s.close() except Exception as e: output = str(e) s.close() return render_template("practiceoutput.html", output=output, expected=PRACTICE_FLAG)
def runpage(): if request.method == "GET": return render_template("run.html") else: src = request.form["src"] initial_data = ( "636631726c757d7466617b3568276e66000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "040a0108100b0c0d06020905030f0e07000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) s = StringIO() try: run(src.replace("\r\n", "\n"), initial_data, 50000, False, s) output = s.getvalue() s.close() except Exception as e: output = str(e) if output == FLAG: return render_template("output.html", output=output) else: return render_template( "output.html", output= "Output did not match flag. To see full output, use practice mode at /practice. (Your output needs to be the flag and ONLY the flag! Trailing characters will invalidate it. Use :moyai: to halt your program when you're done reading the flag." )
def runpage(): if request.method == "GET": return render_template("run.html") else: src = request.form["src"] initial_data = ( "0a51112b0d48016f43325d3502005c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "7830725f6b33795f315f325f33212100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) s = StringIO() try: run(src.replace("\r\n", "\n"), initial_data, 50000, False, s) output = s.getvalue() s.close() except Exception as e: output = str(e) if "ractf{" in output: return render_template("output.html", output=output) else: return render_template( "output.html", output= "Output did not match flag. To see full output, use practice mode at /practice. (Your output needs to be the flag and ONLY the flag! Trailing characters will invalidate it. Use :moyai: to halt your program when you're done reading the flag." )
from io import StringIO import argparse from emojasm.run import run ap = argparse.ArgumentParser() ap.add_argument("file", type=argparse.FileType(encoding="utf-8")) ap.add_argument("--d0", help="Initial data tape 0") ap.add_argument("--d1", help="Initial data tape 1") ap.add_argument("--d2", help="Initial data tape 2") ap.add_argument("-m", help="Maximum instructions to run", type=int, default=200) ap.add_argument("-n", help="Disallow reading input", default=True, action="store_false") args = ap.parse_args() src = args.file.read() initial_data = (args.d0, args.d1, args.d2) print(" ".join(hex(ord(c))[2:] for c in src)) run(src, initial_data, args.m, args.n)