flag format: dalctf{...} - pdf Challenge: Warmerer...

생성일: 2026년 6월 6일

답변에 사용된 모델 GPT-5.5 Thinking by Chat01

질문

rules2.pdf

flag format: dalctf{...} - pdf
Challenge: Warmerer Up
What, what, the rules again again?
tìm flag rồi viết write up chi tiết kèm lệnh + script đã dùng
flag phải được tìm thấy nguyên 1 cụm là dalctf{...} chứ không được tìm thấy 1 cụm từ rồi wrap lại bằng "dalctf{...}"

사고

Detailed write-up and script inclusion

I’ll create a detailed write-up that includes the necessary commands like file, pdfinfo, pdftotext, strings, and others. For the script, I'll provide a minimal version rather than a full 250 lines, with the key steps to extract the flag. At the end, I’ll cite the source PDF file with a supporting reference—ensuring it shows the exact regex match for dalctf{...} without truncation.

Thought for 5m 16s

답변

Flag

dalctf{n0w_y0u_r3ally_b3tt3r_kn0w_th3_rul3s}

Flag này được đọc nguyên cụm từ file /home/flag/flag.txt bên trong image ẩn, không phải lấy một từ rồi tự wrap bằng dalctf{...}. File PDF gốc là rules2.pdf. (rules2.pdf)

Bạn có thể tải script mình dùng ở đây: solve_rules2.py


Write-up: Warmerer Up - PDF

1. Recon PDF ban đầu

Các lệnh kiểm tra nhanh:

bash
file /mnt/data/rules2.pdf pdfinfo /mnt/data/rules2.pdf pdftotext /mnt/data/rules2.pdf - pdfdetach -list /mnt/data/rules2.pdf strings -a -n 4 /mnt/data/rules2.pdf | grep -aiE 'dalctf\{|flag|teapot|rules'

Kết quả đáng chú ý:

text
/mnt/data/rules2.pdf: PDF document, version 1.7 Pages: 3 Attachments: 0

pdftotext không ra flag. strings cũng không thấy dalctf{...} trong raw PDF. Nhưng ở cuối trang 3 có chuỗi nhìn như clue:

text
teapot_2026

Mình render PDF để xác nhận nội dung nhìn thấy:

bash
python /home/oai/skills/pdfs/scripts/render_pdf.py /mnt/data/rules2.pdf --out_dir /mnt/data/rules2_render --dpi 120

2. Phát hiện payload ẩn trong PDF catalog

Dùng pypdf inspect object thì thấy trong /Root có rất nhiều key bất thường dạng:

text
/X0, /X1, /X2, ..., /X359

Mỗi object là /Subtype /Image, kích thước 1x1, nhưng stream data không phải pixel bình thường mà là ASCII dạng:

text
@@0:<base64>@@ @@1:<base64>@@ ... @@359:<base64>@@

Điều này rất giống payload bị chia chunk rồi nhét vào PDF dưới dạng image object giả.

Logic extract:

python
chunks[idx] = base64_part payload_b64 = b''.join(chunks[i] for i in sorted(chunks)) payload = base64.b64decode(payload_b64)

Sau khi decode:

text
payload magic: PK\x03\x04

Tức là payload là ZIP.


3. Giải ZIP bằng password từ clue

ZIP chứa một file:

bash
unzip -l payload.bin

Output:

text
Archive: payload.bin Length Date Time Name --------- ---------- ----- ---- 3780608 2026-06-03 16:35 image.sif

ZIP bị encrypt. Password lấy từ clue cuối PDF:

bash
unzip -P teapot_2026 payload.bin -d payload_extract

Sau khi extract:

bash
file payload_extract/image.sif

Output:

text
image.sif: a run-singularity script executable (binary data)

4. Bên trong SIF là SquashFS

Tìm magic SquashFS:

bash
grep -aob 'hsqs' payload_extract/image.sif

Output:

text
36864:hsqs

Offset 36864 = 0x9000, nên SIF chứa SquashFS bắt đầu tại offset đó.

Mình tách thử:

bash
dd if=payload_extract/image.sif of=rootfs.squashfs bs=4096 skip=9 status=none file rootfs.squashfs

Output:

text
rootfs.squashfs: Squashfs filesystem, little endian, version 4.0, zlib compressed

Vì môi trường không có unsquashfs, mình dùng Python parse SquashFS tối thiểu: đọc superblock, inode table, directory table, fragment table, rồi đi tới path:

text
/home/flag/flag.txt

Nội dung file:

text
dalctf{n0w_y0u_r3ally_b3tt3r_kn0w_th3_rul3s}

Lệnh chạy script solve

bash
python /mnt/data/solve_rules2.py

Output:

text
[+] reading /mnt/data/rules2.pdf [+] hidden payload magic: b'PK\x03\x04' size: 3737177 [+] zip entries: ['image.sif'] [+] extracted image.sif size: 3780608 [+] SquashFS offset in SIF: 36864 [+] /home/flag/flag.txt: dalctf{n0w_y0u_r3ally_b3tt3r_kn0w_th3_rul3s} [+] flag: dalctf{n0w_y0u_r3ally_b3tt3r_kn0w_th3_rul3s}

Kết luận

PDF không chứa flag trực tiếp trong text layer. Flag nằm trong chuỗi ẩn:

PDF /Root /X0..X359 → base64 chunks → encrypted ZIP → image.sif → SquashFS → /home/flag/flag.txt

Flag cuối cùng:

text
dalctf{n0w_y0u_r3ally_b3tt3r_kn0w_th3_rul3s}

이 Q&A 공유하기