Nebula level00

This level requires you to find a Set User ID program that will run as the 「flag00」 account. You could also find this by carefully looking in top level directories in / for suspicious looking directories.

Alternatively, look at the find man page.

To access this level, log in as level00 with the password of level00.

首先,以 level00 登入,密碼也是 level00

根據提示,要找到一個可以在flag00使用者上執行的 set user ID 程式,可以從根目錄中的可疑資料夾中找到…不過我不是很確定哪些資料夾是可疑的就先略過,看來只能用find來慢慢找了 0A0

再找之前先翻了一下我的 Advanced Programming in the UNIX Environment pdf,Ctrl+F setuid 查一下到底是什麼

Linux 中每個 file 都有一套 mode bits 和幾個ID,用來表示這個檔案的授權跟擁有者,而在 linux 的 ‘Everything is a file’ 架構下,程式也是檔案的一種,也有 mode bits 和授權 ID。

使用者在執行別人的程式時(例如 root),原本會因為並非程式的所有者而遭到拒絕存取,但如果程式有設置 SetUID,就會以「程式的所有者」的權限去執行。

例如 passwd 就是一個 root 所有的程式,可以讓使用者更改存放在etc/passwd (只有 root 有權限讀取)中的使用者密碼,SetUID 可以讓 passwd 以 root 權限執行,才改得動 etc/passwd 的密碼。


了解之後,認為 SetUID 應該跟授權有關,於是在find的 man page ‘/’ 搜尋 permission,找到 -perm -mode 選項 (不用 -perm mode 是因為它只會找「完全一樣」mode bits 的檔案),從根目錄下去搜…跑出太多結果啦!

find / -perm -u+s | grep flag00 讓它只顯示 flag00 相關的結果…發現一堆permission denied 0A0

google linux ignore permission 就直接跳出來結果了…用 redirect 來把 error 的 file descriptor 重新導向 /dev/null…變成這樣(先…會用就好了對不對 (゚∀゚) )

find / -perm -u+s 2>/dev/null | grep flag00

之後執行那個程式就拿到 flag 了


下一關

回系列首頁