Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
4 changes: 2 additions & 2 deletions database/api/brand_new_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def scores_get(tick_id=None):

if tick_id is None:
tick_id, _, _, _ = get_current_tick(cursor=mysql.cursor())
scores_new = scoring.get_scores_for_tick(tick_id - 1)
scores_new = scoring.get_scores_for_tick((tick_id - 1) if tick_id > 0 else 0)

if scores_new != scores_old:
print("OLD: {}" + str(scores_old))
print("NEW: {}" + str(scores_new))

return json.dumps({"scores": scores_new})
return json.dumps({"scores": scores_new})
10 changes: 7 additions & 3 deletions database/provisioning/create_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def register_service(db_api_url_base, db_secret, service_name, service_info):

result = requests.post(db_api_url_base + "/upload/new", data=data, params={'secret': db_secret})

response = result.json()
try:
response = result.json()
except Exception as ex:
raise Exception("Invalid JSON returned from /upload/new endpoint: {}".format(result.content)) from ex
#response = result.json()

if response['result'] == 'success':
# print("successfully uploaded bundle")
Expand All @@ -47,7 +51,7 @@ def register_service(db_api_url_base, db_secret, service_name, service_info):
script_type = os.path.basename(script)

if script_type in {'setflag', 'getflag', 'benign', 'exploit'}:
print (f"Uploading script {filename} [{script_type}]")
print (f"Uploading script {script} [{script_type}]")
data = {"upload_id": upload_id, "filename": script, "type": script_type,
"state": service_info['state'], "service_id": service_id}
result = requests.post(db_api_url_base + "/script/new", data=data, params={'secret': db_secret})
Expand All @@ -71,7 +75,7 @@ def create_service(db_api_url_base, db_secret, service_path, service_state):
service_yaml = os.path.abspath(os.path.join(service_path, './info.yaml'))
if not os.path.isfile(service_yaml):
raise Exception("Could not find service file for %s, tried %s. Skipping." % (service_path, service_yaml))
service_info = yaml.load(open(service_yaml, 'r'))
service_info = yaml.load(open(service_yaml, 'r'), Loader=yaml.Loader)

# Check that the service path matches the name in info.yaml

Expand Down
10 changes: 3 additions & 7 deletions database/provisioning/create_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import string
import yaml
import json
import time

rnd = random.SystemRandom()

Expand Down Expand Up @@ -91,6 +92,8 @@ def add_teams_info(db_api_base_url, db_secret, game_config):


if __name__== "__main__":
print("Waiting for database container to finish startup.")
time.sleep(10)
game_config = json.load(open(sys.argv[2], 'r'))
db_api = sys.argv[1] # passed from terraform script
database_api_secret_path = SECRETS_FOLDER+"database-api/secret"
Expand All @@ -102,10 +105,3 @@ def add_teams_info(db_api_base_url, db_secret, game_config):
add_teams_info('http://' + db_api, db_secret, game_config)
else:
raise Exception("Missing database secrets!")







2 changes: 1 addition & 1 deletion database/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ndg-httpsclient
pyasn1
setuptools-rust
wheel
Flask==0.12.2
Flask==2.2.2
uWSGI==2.0.15
PyYAML==3.12
boto3==1.4.8
Expand Down
2 changes: 1 addition & 1 deletion gamebot/scripts_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def update_scripts_to_run(self, tick_id, num_benign, num_exploit, num_get_flags)
benign_scripts.extend(list(random.choice(non_exploit_scripts[curr_service]["benign"])
for _ in range(num_benign)))
# Get all exploit scripts for this service, not submitted from current team
curr_service_exploit_script.extend(value[curr_service]["exploit"] for key, value in exploit_scripts.iteritems()
curr_service_exploit_script.extend(value[curr_service]["exploit"] for key, value in exploit_scripts.items()
if key != curr_team and (curr_service in value))
# Flatten the list
curr_service_exploit_script = flatten_list(curr_service_exploit_script)
Expand Down
Loading