- Rename repo/domain: attack-defense-platform / attackdefense.imrnes.team (all refs replaced)
- challenge_registry.json: single source of truth (28 challs across gemastik18/xvi/xvii)
- teams.py: registry-driven CHALLENGES, set_challenge_enabled, sync_challenge_runtime
(apply enable/disable to live teams: build/up or stop/remove + receiver restart)
- compose_gen.py: render per-team compose from canonical per-challenge templates
(image reuse, per-team ports 30xxx, flag mounts, passwords)
- gen_canonical_composes.py: canonical docker-compose.yml for all services
- import_new_challenges.py: import XVI/XVII services + EOL base image fixes
(debian:buster→bookworm, node:14→20, python:3.7-slim→3.11)
- receiver: xvi package (10 checkers) + xvii package (12 generic checkers),
Challenge base reads PASSWORD_<team_port> from env; gen_receiver_main.py
generates per-team main.py from registry
- main.py: /api/challenges returns full registry; PATCH /api/challenges/<name>
toggles enabled + applies to live teams
- index.html: 🏗️ Challenge Manager tab (toggle per challenge, grouped by set)
- SLA bonus now dynamic (all enabled challenges, not hardcoded 6)
68 lines
2.7 KiB
Python
68 lines
2.7 KiB
Python
from .Challenge import Challenge
|
|
|
|
import requests
|
|
|
|
class GemasNotes(Challenge):
|
|
history_location = 'history/gemas-notes.txt'
|
|
host = "http://localhost:12000"
|
|
|
|
def distribute(self, flag):
|
|
try:
|
|
username = "gemasflagreceiver"
|
|
password = "AuTeEbn%.Q5$pC_ge6"
|
|
result = requests.post(f"{self.host}/flag_receiver", json={"flag": flag}, auth=(username,password)).json()
|
|
if not result.get("success"):
|
|
return False
|
|
|
|
with open(self.history_location, 'a') as f:
|
|
f.write(flag + '\n')
|
|
|
|
self.logger.info(f'Flag {flag} updated in gemas-notes database')
|
|
return True
|
|
|
|
except Exception as e:
|
|
self.logger.error(f'Could send flag to gemas-notes challenge: {e}')
|
|
return False
|
|
|
|
def check(self):
|
|
try:
|
|
url = f'http://localhost:{self.port}'
|
|
|
|
# login
|
|
token = requests.post(f"{url}/api/login",json={"email":"checker@gemasnotes.id", "password":"uRIqCvJ<IGb;VDT14"}).json()["token"]
|
|
header = {"Authorization": f"Bearer {token}"}
|
|
|
|
# get count
|
|
old_count = requests.post(f"{url}/api/notes/count", headers=header, json={"count_by":"title", "keyword":""}).json()["count"]
|
|
|
|
# create notes
|
|
notes = {"title":self.random_string(10), "content":self.random_string(20), "tags":self.random_string(10)}
|
|
status_code = requests.put(f"{url}/api/notes", headers=header, json=notes).status_code
|
|
assert status_code in [200, 201], "Cannot Create Note"
|
|
|
|
# get notes
|
|
all_notes = requests.get(f"{url}/api/notes").json()
|
|
note = list(filter(lambda x: x["title"] == notes["title"], all_notes))
|
|
assert len(note) != 0, "Note was not created"
|
|
|
|
# get new count
|
|
new_count = requests.post(f"{url}/api/notes/count", headers=header, json={"count_by":"title", "keyword":""}).json()["count"]
|
|
assert old_count != new_count, "Invalid count"
|
|
|
|
# update notes
|
|
new_content = self.random_string(20)
|
|
notes["id"] = note[0]["id"]
|
|
notes["content"] = new_content
|
|
status_code = requests.patch(f"{url}/api/notes", headers=header, json=notes).status_code
|
|
assert status_code in [200, 204], "Cannot Update Note"
|
|
|
|
# delete notes
|
|
status_code = requests.delete(f"{url}/api/notes/{notes['id']}", headers=header, json=notes).status_code
|
|
assert status_code == 200, "Cannot Delete Note"
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
self.logger.error(f'Could not check gemas-notes: {e}')
|
|
return False
|