hint: I like to have my poems saved on CTFd instan...

创建于:2026年4月3日

使用 GPT-5.4 Thinking 回答 Chat01

问题

new 1.txt
view-source_https___kashictf.iitbhucybersec.in_poem.html
image.png

hint: I like to have my poems saved on CTFd instances like this. But the admin does like it, so I hid the secret in my poem.
tìm flag dạng kashiCTF{...} rồi viết write up, đây là 1 bài CTF Stego về poem, poem được hiển thị ngay trên web, file tôi cung cấp cho bạn là tôi copy từ web, không có nhúng file ẩn gì ở trong cả. Giải cho đến khi tìm ra flag

Python

python
from pathlib import Path p = Path('/mnt/data/new 1.txt') data = p.read_bytes() data[:200], len(data) (b'Poem\r\nThe way a crow\t \t \t \t \t\t \t \t \r\nShook down on me \t \t\t \t \t \t\t \r\nThe dust of snow \t \t\t \t \t \t \t \r\nFrom a hemlock tree \t \t \t \t ', 739)

Python

python
text = data.decode('utf-8', errors='replace') lines = text.splitlines() for i,l in enumerate(lines): print(i, repr(l), len(l))

Python

python
visible_lines = [ "The way a crow", "Shook down on me", "The dust of snow", "From a hemlock tree", "", "Has given my heart", "A change of mood", "And saved some part", "Of a day I had rued.", "", "", "", "", ] for i, vis in enumerate(visible_lines, start=1): l=lines[i] hidden=l[len(vis):] print(i, repr(hidden)) print(hidden.replace(' ','·').replace('\t','→'))

Python

python
for i, vis in enumerate(visible_lines, start=1): hidden = lines[i][len(vis):] # split by tabs parts = hidden.split('\t') print(i, [len(p) for p in parts], len(parts)-1, 'tabs')

Python

python
oct_digits = [] for i, vis in enumerate(visible_lines, start=1): hidden = lines[i][len(vis):] oct_digits.extend(str(len(p)) for p in hidden.split('\t')) oct_str = ''.join(oct_digits) oct_str[:200], len(oct_str) ('06233053662031506250164764125755162235515273704576423353627334435650571342733345462364567652575556637441547064575', 113)

Python

python
# group into 3-digit octal from start for offset in range(3): s = oct_str[offset:] groups = [s[i:i+3] for i in range(0, len(s)-len(s)%3, 3)] txt = ''.join(chr(int(g,8)) for g in groups) print('offset',offset,'len',len(groups),'rem',len(s)%3) print(repr(txt[:100]))

Python

python
parts_all = [] for i, vis in enumerate(visible_lines, start=1): hidden=lines[i][len(vis):] parts=hidden.split('\t') if i==1 and parts and parts[0]=='': parts=parts[1:] parts_all.extend(len(p) for p in parts) len(parts_all), parts_all[:20] (112, [6, 2, 3, 3, 0, 5, 3, 6, 6, 2, 0, 3, 1, 5, 0, 6, 2, 5, 0, 1])

Python

python
vals=parts_all # pack 3-bit values msb-first into bytes bits=''.join(f'{v:03b}' for v in vals) len(bits), bits[:48] (336, '110010011011000101011110110010000011001101000110')

Python

python
import math by = bytes(int(bits[i:i+8],2) for i in range(0,len(bits),8)) by[:50], len(by) (b'\xc9\xb1^\xc83FT\x1d>\x85_i\xc9;M]\xf1/\xd17^]\xb9\x1d\xd4^\\]\xb7,\xc9\xe9w\xd5_m\xd9\xf9\r\x9ci}', 42)

Python

python
vals=parts_all bits=''.join(str((v>>i)&1) for v in vals for i in [0,1,2]) # b1,b2,b3 by = bytes(int(bits[i:i+8],2) for i in range(0,len(bits),8)) by, len(by) (b'kashiCTF{1_like_poems_but_1_lik3_u_more<3}', 42)

思考

Decoding bit order

I realize that the way bits were initially packed was incorrect. Instead of seeing the bits in the “bit2, bit1, bit0” order, they should have been emitted from LSB to MSB. To recover the original order, I need to reverse the bits for every 3-bit count when decoding. That should give the correct sequence.

Crafting write-up with citations

Since the user asked in Vietnamese, I need to provide the answer in Vietnamese. I also need to make sure I cite the files using the correct references, like turn0file0/1, since those come from the uploaded files. For the SNOW algorithm, I'll mention the specifics from web sources and provide citations accordingly. I won’t forget to mention the trailing spaces/tabs in the poem!

Writing the explanation and citations for SNOW

I need to highlight that SNOW uses trailing spaces/tabs and the initial tab marker. For referencing, I’ll use sources about the 3-bit encoding for spaces and tabs. I'll incorporate relevant citations for the SNOW doc and code. Then, I’ll outline steps for manual extraction: inspect the poem, trace spaces/tabs, and reference SNOW’s structured encoding.

Thought for 3m 47s

回答

Mình đã giải ra flag:

kashiCTF{1_like_poems_but_1_lik3_u_more<3}

Write-up ngắn:

  1. Kiểm tra dữ liệu được cung cấp
    File poem chỉ là bài thơ hiển thị trên web, không có file nhúng ẩn nào khác. Trong cả bản copy lẫn view-source, phần đáng ngờ là rất nhiều tab/space ở cuối từng dòng của bài thơ. (new 1.txt) (view-source_https___kashictf.iitbhucybersec.in_poem.html)

  2. Nhận ra kiểu stego là SNOW / stegsnow
    SNOW giấu dữ liệu bằng trailing whitespace; một tab đầu tiên đánh dấu điểm bắt đầu dữ liệu, sau đó dữ liệu được mã hóa bằng các nhóm 0–7 dấu cách ngăn bởi tab, mỗi nhóm tương ứng 3 bit. (JustSolve)

  3. Cách decode cụ thể với bài này

    • Lấy whitespace cuối dòng của từng dòng thơ.
    • Ở dòng đầu tiên, bỏ tab mở đầu vì đó chỉ là marker bắt đầu message.
    • Chia phần còn lại theo \t.
    • Đếm số lượng space trong mỗi đoạn.
    • Vì SNOW đảo thứ tự bit khi ghi, mỗi số v phải đổi thành bit theo thứ tự:
      v&1, (v>>1)&1, (v>>2)&1. (GitHub)
  4. Ghép bit thành byte ASCII
    Sau khi pack lại 8 bit một, chuỗi thu được là:

    kashiCTF{1_like_poems_but_1_lik3_u_more<3}

Python tối giản để tự kiểm tra:

python
from pathlib import Path text = Path("new 1.txt").read_text(encoding="utf-8") lines = text.splitlines() visible = [ "The way a crow", "Shook down on me", "The dust of snow", "From a hemlock tree", "", "Has given my heart", "A change of mood", "And saved some part", "Of a day I had rued.", "", "", "", "", ] vals = [] for idx, vis in enumerate(visible, start=1): hidden = lines[idx][len(vis):] parts = hidden.split("\t") if idx == 1 and parts and parts[0] == "": parts = parts[1:] # bỏ start-tab marker vals.extend(len(p) for p in parts) bits = "".join(str((v >> i) & 1) for v in vals for i in [0, 1, 2]) flag = "".join(chr(int(bits[i:i+8], 2)) for i in range(0, len(bits), 8)) print(flag)

Kết luận: đây là whitespace steganography kiểu stegsnow, không phải hidden file hay metadata ẩn trong HTML. (new 1.txt) (view-source_https___kashictf.iitbhucybersec.in_poem.html)

分享这个问答