Skip to content

sekai ctf 2026

Stego

I rolled my own stego and made sure to make it wayyyyy too hard for someone to guess how it works...

Challenge Description

i rolled my own stego and made sure to make it wayyyyy too hard for someone to guess how it works...

er, i mean claude did. i totally read the code tho.

Impossible Stego Writeup

the challenge gave us sekai ctf logo (aka best ctf in the world) and slop log

so the goal is to get the flag everyone knows this but hey writing these writeups take time

the log contained the holy grail of slop

the last request contained the full chat including every slop and slop call used to make the slop stego code

the exact source was leaked and there was no reason to reverse the stego algorithm

i wrote a script that reads the slop log and decodes the last slop request body

it goes through the slop chat and finds the file tool calls

when it finds write it saves that file

when it finds edit it applies the change to the saved file

this rebuilds the final stego package exactly as clanker made it

then it imports that package and runs its own extract function on flag.png

slop slop slop slop larp larp larp SLOP sticker

Python

#!/usr/bin/env python3

from __future__ import annotations

import base64
import importlib
import json
import sys
import tempfile
from pathlib import Path


PROJECT_PREFIX = "/home/claude/projects/impossible-stego/"


def recover_sources(log_path: Path) -> dict[str, str]:
    records = [json.loads(line) for line in log_path.read_text().splitlines()]
    request = json.loads(base64.b64decode(records[-1]["req_body"]))
    sources: dict[str, str] = {}

    for message in request["messages"]:
        content = message.get("content", [])
        if isinstance(content, str):
            continue
        for block in content:
            if block.get("type") != "tool_use":
                continue
            name = block.get("name")
            args = block.get("input", {})
            path = args.get("file_path", "")
            if not path.startswith(PROJECT_PREFIX):
                continue
            relative = path[len(PROJECT_PREFIX) :]
            if not relative.startswith("stego/"):
                continue

            if name == "Write":
                sources[relative] = args["content"]
            elif name == "Edit" and relative in sources:
                old = args["old_string"]
                new = args["new_string"]
                count = -1 if args.get("replace_all") else 1
                if old not in sources[relative]:
                    raise RuntimeError(f"edit target missing in {relative}")
                sources[relative] = sources[relative].replace(old, new, count)

    return sources


def main() -> None:
    challenge = Path(__file__).with_name("misc_impossible-stego")
    sources = recover_sources(challenge / "messages.log")
    if not sources:
        raise RuntimeError("no stego package sources recovered")

    with tempfile.TemporaryDirectory() as directory:
        root = Path(directory)
        for relative, content in sources.items():
            target = root / relative
            target.parent.mkdir(parents=True, exist_ok=True)
            target.write_text(content, encoding="utf-8")

        sys.path.insert(0, directory)
        stego = importlib.import_module("stego")
        payload = stego.extract(str(challenge / "flag.png"))

    print(payload.decode("utf-8"))


if __name__ == "__main__":
    main()

and traaaaaaaaaaaaaaaaaaa

SEKAI{th3y_d1dn7_4ctually_l3t_m3_us3_my7h0s_f0r_7h1s_0n3_s4dly_i_h4d_i7_r3r0ut3d_t0_0pus}

so slop it until u make it ig

Green burning creature sticker I HATE SLOP specially when it comes to CTF

Discussion

Loading discussion…

Related solves

Keep reading

Complete archive