Newer
Older
"""
These are ctf dependent functions.
They have to be aligned.
"""
MESSAGES = [
"SUCCESS",
"INVALID",
"ALREADY_SUBMITTED",
"ERROR"
]
RES_FILE_PATH = "results.txt"
RES_FILE = None
# TODO: Change these values
# list of team ids
# Has to be byte string since wre looking through byte output (STDOUT)
flag_regex = b"flag{[A-Za-z0-9_.]+}"
exploit_dir = "exploits"
wait_between_runs = 30
# Number of exploit workers
proc_num = 4
def team_id_to_ip(team_id):
"""
Somehow map team id to ip adress
"""
return "10.13.37.{}".format(team_id)
def submit_flag(team_id, flag):
"""
Submit individual flag.
"""
global RES_FILE
if RES_FILE is None:
RES_FILE = open(RES_FILE_PATH, "a")
# TODO: submission logic
# e.g. requests.put(...)
# set return val to index of appropriate message code
return_val = 0
RES_FILE.write("{} {} {}\n".format(return_val, team_id, flag))
RES_FILE.flush() # dirty but works for now
return MESSAGES[return_val]