Platypwn 2025 write up

2025. 12. 4. 00:03review 및 write up

미루고 미루다 드디어 쓰는 라업이다

 

WEB - Quark

What happens when you mix LaTeX and Markdown? Could that be secure? Is it utterly broken, cause LaTeX? Well, time to find out!

 

문제 파일로 제공된 app.py는 다음과 같다

from flask import Flask, request, render_template_string, send_file
import tempfile
import subprocess
import os
import sys

if not os.getenv("FLAG"):
  print("Missing FLAG. Challenge is broken.")
  sys.exit(1)

app = Flask(__name__)

FORM_HTML = """
<!doctype html>
<html>
  <head><title>Quarkdown to HTML</title></head>
  <body>
    <h1>Quarkdown to HTML</h1>
    <form method="post">
      <textarea name="source" rows="15" cols="80" placeholder="Enter Quarkdown here..."></textarea><br><br>
      <button type="submit">Render HTML</button>
    </form>
  </body>
</html>
"""

@app.route("/", methods=["GET", "POST"])
def index():
    if request.method == "POST":
        source = request.form.get("source", "")
        if not source.strip():
            return "No input provided", 400

        with tempfile.TemporaryDirectory() as tmpdir:
            qk_file = os.path.join(tmpdir, "input.qk")
            html_file = os.path.join(tmpdir, "output/index.html")

            with open(qk_file, "w") as f:
                f.write(source)

            subprocess.run(["quarkdown", "c", qk_file, "--out", tmpdir, "--out-name", "output"], check=True)

            return send_file(html_file, as_attachment=True, download_name="output.html")

    return render_template_string(FORM_HTML)


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

 

사용자의 입력을 그대로 Quarkdown 컴파일러에 던져 HTML을 생성해주는데

사용자가 적은 source를 그대로 input.qk에 저장한뒤 컴파일해 쿼크다운 스크립트를 실행하는 것과 마찬가지기에

flag가 환경변수에 있으니 파일을 읽는 .read를 사용하여 .read {/proc/self/environ} 를 적고 render를 누르면 제작된 HTML에 flag가 찍혀있다

 


Forensics - lostdata

총 3가지 플래그를 구하는 서치문제로 문제설명은

 

Briefing: Agent: Agent P (a.k.a. Perry the Platypus) Subject: Recovered backup — suspected to belong to Dr. Heinz Doofenshmirtz Objective: Extract and analyze critical intelligence fragments before they self-destruct (metaphorically, we hope). During a recent OWCA operation, Agent P recovered a backup from a damaged device belonging to Dr. Heinz Doofenshmirtz. The phone itself is beyond repair, but traces of data remain. Analysis suggests Doofenshmirtz intentionally scattered three hidden fragments across different parts of his system. His final voice memo offers only riddles — a frozen memory, a restless idea, and in resting thoughts. Your task: extract all fragments before whatever he was planning comes to life.

 

00~ff까지폴더에 파일 조각들이 있었고 Manifest.db에서 파일이름을 하나하나 찾아보는 문제였다

 

파일은 IOS 백업본이였으며, 처음에 문제설명을 보고 voice memo에 무언가 있는줄 알았으나 a frozen memory, a restless idea, and in resting thoughts 이 3가지를 단서로 플래그를 찾는 넌센스 같은 문제였다

 

a frozen memory는 사진이라고 생각해서 DCIM 폴더 아래에 있는 HEIC파일에서 플래그를 구할 수 있었고,

 

다른 하나는. notesairdropdocument라는 노트조각을 HxD로 열어본 뒤 

읽을 수있는 문자열을  Ascii85로 인코딩된 문자열을 디코딩하니 얻을 수 있었다.

PP{d3l3t3d_n0t3s_4r3_n3v3r_g0n3}

이걸 resting thouhts라고 가정했다.

 

그런데 마지막은 도저히 찾기 힘들었는데 restless Idea와 어울리는게 아무것도 없었기 때문이다.

결국 단순 노가다 서치로 Library/Freeform/Boards/boards.db 안에있는 플래그를 발견할 수 있었다.

PP{fr33f0rm_t1tl3_1nd4t4b4s3}

 

frozen memory 여전히 단서랑 플래그의 위치는 매칭이 잘안됐다고 생각한다...