Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
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: Make list of team ids
all_teams = [i for i in range(16)]
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]