PicoCTF - Operation Oni
Background
How to View Your SSH Keys in Linux, macOS and Windows
ISO和IMG的區別
ISO和IMG都是操作系統鏡像文件的擴展名,它們的主要區別在以下幾個方面:
- 來源不同 ISO文件通常來自光盤鏡像,例如Windows安裝光盤的ISO鏡像文件。而IMG文件可以來自多種渠道,例如從移動設備制造商下載的Android操作系統鏡像文件,或者是從虛擬機軟件中制作的虛擬機磁盤鏡像文件。
- 文件格式不同 ISO文件使用ISO 9660標準格式,而IMG文件可以使用多種格式,例如RAW、VMDK、VDI等。
- 兼容性不同 ISO文件在各種操作系統和軟件中都有良好的兼容性,而IMG文件在一些操作系統或軟件中可能存在兼容性問題。
- 使用範圍不同 ISO文件主要用於制作光盤或者USB啟動盤,用於安裝操作系統或者救援系統等。而IMG文件主要用於移動設備或者虛擬機等環境下的操作系統安裝或備份。 總之,ISO和IMG都是操作系統鏡像文件的擴展名,雖然它們在一些方面有類似之處,但在來源、文件格式、兼容性和使用範圍等方面存在差異,應根據具體的需求來選擇使用哪種格式。
Description
Download this disk image, find the key and log into the remote machine. Note: if you are using the webshell, download and extract the disk image into /tmp not your home directory.
- Download disk image
- Remote machine:
ssh -i key_file -p 59801 ctf-player@saturn.picoctf.net
Recon
這一題和DF有關,主要就是分析拿到的img file,可以用Autopsy之類的分析軟體
- ssh參數
先看launch instance之後出現的連線command,ssh帶有
-i的參數,根據tldr的常用說明,代表需要給他一個private key file,這也是description中有提到的部分 ```bash $ tldr ssh …- Connect to a remote server using a specific port: ssh username@remote_host -p 2222 … ```
-
Using Autopsy
使用Autopsy分析img file,會面臨到ssh private key在哪裡的問題,根據1的說明通常會放在
~/.ssh/或是/root/.ssh/的folder中,所以我們就可以往這個方向找看看
果不其然,的確有一個pub檔案和private key file,直接export出這個檔案,然後夾帶進command就可以了 -
Error
過程中可能會遇到
Permission Too Open這個error,原因可以看2或是看Almond的WP11
2
3
4
5
6
7
8
9$ ssh -i ssh-private-key -p 59801 ctf-player@saturn.picoctf.net @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0777 for 'ssh-private-key' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "ssh-private-key": bad permissions ctf-player@saturn.picoctf.net's password:簡單來說就是ssh-private-key這個檔案的權限太多了,因為我是直接export到windows的主機,所以預設是777,根據2,只需要設定600就可以過了,同時也可以直接看該檔案在img file中的mode是多少

Exploit
1 | |
Flag: picoCTF{k3y_5l3u7h_af277f77}