32 lines
778 B
Python
32 lines
778 B
Python
#!/usr/bin/env python3
|
|
import importlib.util
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def load_client():
|
|
path = ROOT / "public" / "kem_client.py"
|
|
spec = importlib.util.spec_from_file_location("nullroute_client", path)
|
|
module = importlib.util.module_from_spec(spec)
|
|
assert spec.loader is not None
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def main() -> None:
|
|
client = load_client()
|
|
capsule = json.loads((ROOT / "public" / "capsule.json").read_text())
|
|
plaintext = client.decrypt_capsule(capsule).decode()
|
|
match = re.search(r"caplag\{[^}]+\}", plaintext)
|
|
if not match:
|
|
raise SystemExit("flag not found")
|
|
print(match.group(0))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|