【TryHackMe】Mr Robot Write-up
Hi👋,這次練練 TryHackMe 的其中一個 room — Mr.Robot,主要使用到的工具如下~
Index
1. Enumerate
1.1 nmap
1.2 gobuster
1.3 wpscan
2. Initial Access & Foothold
2.1 password dictionary attack - wpscan or hydra
2.2 Reverse Shell - nc & pentestmonkey's php reverse shell
2.3 Hash - john the ripper 、hashcat、hash-identifier
3. Privilege Escalation
3.1 Gtfobins
4. Reference
1. Enumerate
1.1 Nmap scan the services & ports
首先用 nmap 掃port及服務,以供查看哪裡可以開破。從掃描結果發現有開放網頁服務(80、443 port)。
從網頁中發現,mr.robot、fsociety 等keywords🤣
1.2 Gobuster for web subdirectory enumerate
gobuster dir -u <url> -w <wordlist> -t 30 -s 200
從掃描結果可發現,有sitemap、intro、wp-login、license、readme及robots等子目錄,就可以開始逛街囉~
先從robots文字檔查看那些檔案/目錄可供瀏覽,可以發現有2個檔案可以看看,fsocity.dic及key-1-of-3.txt。
下載到字典檔,等等可能用來破解帳號或密碼。
第一個 flag 🚩
1.3 Wpscan scans remote WordPress installations
先透過 wpscan 列舉 wordpress 網站有哪些可利用的地方。
wpscan --url <url> -e -t 30
2. Initial Access & Foothold
wp-login — wordpress 的登入畫面,嘗試破解帳號、密碼。username嘗試admin、administrator、guest、user均無效,突然想到此room的主題是 mr.robot 嘗試男主角名字 elliot (💡
2.1 password brute force attack — wpscan or hydra
知道帳號就可以來try密碼啦~不管是 hydra 或是 wpscan 都可以使用,這邊使用 wpscan,前面儲存的字典檔派上用場。
因字典檔內容有太多重複,先移除重複值,避免破跑到天荒地老。
# 移除字典檔中重複的值
sort fsocity.dic | uniq -u > fsocity.dic
# 用wpscan來破解elliot的密碼
wpscan -u http://<ip>/wp-login -U Elliot -P /root/fsocity.dic -t 30
# 或是用hydra來破,可參考下方reference中的youtube影片
hydra -l Elliot -P fsocity.dic.txt <ip> http-post-form "/wp-login.php:log=^USER^&pwd=^PWD^:The password you entered" -t 30
2.2 Reverse Shell — nc & pentestmonkey’s php reverse shell
此處更改 themes 中的 template 來嘗試 reverse shell,使用 pentestmonkey 寫好的 php reverse shell 貼至 archive.php,修改成自己的攻擊機及監聽的port後上傳至靶機。
連線至剛剛所修改的 php 網頁,來獲取shell。
# 尋找flag2
find / -f -iname key-* 2>/dev/null
找到第二個 flag 🚩;順便找到 robot 的密碼 md5 hash
2.3 Hash — john the ripper 、hashcat、hash-identifier
使用 john the ripper 、hashcat 或其他線上的工具破解 hash,若是不知道是由哪一種編碼可以用 hash-identifier 去識別。
回到 Reverse shell ,改用 /bin/bash
python -c 'import pty;pty.spawn("/bin/bash")'
3. Privilege Escalation
robot users登入進去後,找看看有那些可執行權限的檔案
find / -type f -perm -04000 -ls 2>/dev/null
3.1 Gtfobins
根據上面找到的結果,用 nmap 試試看能不能提權到 root 權限,查詢 gtfobins 透過執行下列步驟仍是 robot user。
從上面可以看到 nmap version 是 v3.8 改使用 interative mode
nmap --interactive
找到第三個 flag 🚩