1
0
Fork 0

base work on level selecting

This commit is contained in:
Lili (Tlapka) 2021-03-25 17:22:32 +01:00
parent fe477b02b1
commit 706c9548a7
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,35 @@
import yaml # reads hint configurations from a .yml file
class LevelSelector:
def __init__(self, tool_list_filename):
self.read_level_requirements(filename)
self.read_tool_list(filename)
self.known_tools = []
def read_level_requirements(self, filename):
with open(filename) as f:
self.level_requirements = yaml.load(f, Loader=yaml.FullLoader)
def read_tool_list(self, filename):
with open(filename) as f:
self.tool_list = yaml.load(f, Loader=yaml.FullLoader)
def add_known_tool(self, tool):
if tool in self.known_tools:
return
self.known_tools.append(tool)
def next_level(self, current_level, current_time):
next_levels = self.level_requirements[level]
if len(next_levels) == 1:
return next_levels[0][0]
candidate_level = None
for {level, requirements} in next_levels:
if requirements is None:
candidate_level = level
elif ((requirements[0] < current_time) and (requirements[1] in self.known_tools)):
candidate_level = level
else:
pass
return candidate_level

View File

@ -0,0 +1,7 @@
---
# level_name: {branch_name: [machines_to_provision]}
level2: [{level2a, null}, {level2b, {10, "SQL injection"}}]
level3: [{level3, null}]
level4: [{level4a, null}, {level4b, {30, "John the Ripper"}}]
level5: [{level5, null}]
...

6
resources/tools.yml Normal file
View File

@ -0,0 +1,6 @@
---
metamask: null
SQL injection: {10, level2b}
nmap: null
John the Ripper: {30, level4b}
...