
這題是標準得老叟戲頑童
這題的邏輯:
ssh連上靶機->~/useless->看到useless程式碼暗示我們去看使用說明書->flag在說明書裡
我一開始也是卡在以為要指令注入,下面我們講正確解法
1.ssh picoplayer@chatelaine.cylabacademy.net -p <port>
2.
這裡程式碼如下:
#!/bin/bash
# Basic mathematical operations via command-line arguments
if [ $# != 3 ]
then
echo "Read the code first"
else
if [[ "$1" == "add" ]]
then
sum=$(( $2 + $3 ))
echo "The Sum is: $sum"
elif [[ "$1" == "sub" ]]
then
sub=$(( $2 - $3 ))
echo "The Substract is: $sub"
elif [[ "$1" == "div" ]]
then
div=$(( $2 / $3 ))
echo "The quotient is: $div"
elif [[ "$1" == "mul" ]]
then
mul=$(( $2 * $3 ))
echo "The product is: $mul"
else
echo "Read the manual"
fi
fi
->重點是echo "Read the manual"這裡作者應該希望我們聯想到man指令去看useless使用方式,如果思維沒轉過來這題會卡很久
3.執行man useless

flagbase64後:YWNhZGVteXt1czNsM3NzX2NoNGxsM25nM18zeHBsMGl0M2RfMTc2Mn0=
下面分享我往錯得方向鑽研的東西
這個腳本檔其實本身有注入的問題
以加法邏輯為例:sum=$(( $2 + $3 ))
//尚未更新完成