題目連結
https://learn.cylabacademy.org/library/472
題目解法
下載題目原始碼後進行分析,發現當程式遇到 CROWD 開頭的行時會將使用者輸入的內容會被寫回 song_lines[lip]。此外程式在處理每一行時,會先用 split(';') 將其分割成多個子指令進行循環。
因此當我們輸入
;RETURN 0
程式內部的反應如下:
- song_lines[lip] 會變成 ‘Crowd: ;RETURN 0’。
- for line in song_lines[lip].split(’;’): 會將這一行切成兩部分:
- 第一部分:‘Crowd: ’ -> 進入 else 分支,列印內容並將 lip 加 1。
- 第二部分:‘RETURN 0’ -> 進入 elif re.match(r"RETURN [0-9]+", line): 分支。
- 此時 lip 會被設為 int(‘0’),也就是 0。
- while 迴圈繼續執行,下一次迭代就會從 song_lines[0] 開始列印,這時隱藏在開頭的 flag 就會被直接輸出到螢幕上。
webshell:~$ nc verbal-sleep.picoctf.net 53947 Command line wizards, we’re starting it right, Spawning shells in the terminal, hacking all night. Scripts and searches, grep through the void, Every keystroke, we're a cypher's envoy. Brute force the lock or craft that regex, Flag on the horizon, what challenge is next? We’re flag hunters in the ether, lighting up the grid, No puzzle too dark, no challenge too hid. With every exploit we trigger, every byte we decrypt, We’re chasing that victory, and we’ll never quit. Crowd: ;RETURN 0 Echoes in memory, packets in trace, Digging through the remnants to uncover with haste. Hex and headers, carving out clues, Resurrect the hidden, it's forensics we choose. Disk dumps and packet dumps, follow the trail, Buried deep in the noise, but we will prevail. We’re flag hunters in the ether, lighting up the grid, No puzzle too dark, no challenge too hid. With every exploit we trigger, every byte we decrypt, We’re chasing that victory, and we’ll never quit. Crowd: Pico warriors rising, puzzles laid bare, Solving each challenge with precision and flair. With unity and skill, flags we deliver, The ether’s ours to conquer, picoCTF{70637h3r_f0r3v3r_836f0788} [REFRAIN] We’re flag hunters in the ether, lighting up the grid, No puzzle too dark, no challenge too hid. With every exploit we trigger, every byte we decrypt, We’re chasing that victory, and we’ll never quit. Crowd: Pico warriors rising, puzzles laid bare, Solving each challenge with precision and flair. With unity and skill, flags we deliver, The ether’s ours to conquer, picoCTF{706-------------------788}
題目原始碼
lyric-reader.py
| |