DC2 WalkThrough
DC2-WalkThrough
免责声明
本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.
靶机地址
https://www.vulnhub.com/entry/dc-2,311/
Description
Much like DC-1, DC-2 is another purposely built vulnerable lab for the purpose of gaining experience in the world of penetration testing.
As with the original DC-1, it's designed with beginners in mind.
Linux skills and familiarity with the Linux command line are a must, as is some experience with basic penetration testing tools.
Just like with DC-1, there are five flags including the final flag.
And again, just like with DC-1, the flags are important for beginners, but not so important for those who have experience.
In short, the only flag that really counts, is the final flag.
For beginners, Google is your friend. Well, apart from all the privacy concerns etc etc.
I haven't explored all the ways to achieve root, as I scrapped the previous version I had been working on, and started completely fresh apart from the base OS install.
Technical Information
DC-2 is a VirtualBox VM built on Debian 32 bit, so there should be no issues running it on most PCs.
While I haven't tested it within a VMware environment, it should also work.
It is currently configured for Bridged Networking, however, this can be changed to suit your requirements. Networking is configured for DHCP.
Installation is simple - download it, unzip it, and then import it into VirtualBox and away you go.
Please note that you will need to set the hosts file on your pentesting device to something like:
192.168.0.145 dc-2
Obviously, replace 192.168.0.145 with the actual IP address of DC-2.
It will make life a whole lot simpler (and a certain CMS may not work without it).
If you're not sure how to do this, instructions are here.
知识点
字典生成工具 cewl (flag2)
wpscan (flag2)
rbash 逃逸 (flag4)
git 提权 (flag5)
实验环境
环境仅供参考
VMware® Workstation 15 Pro - 15.0.0 build-10134415
kali : NAT 模式,192.168.141.134
靶机 : NAT 模式
flag1
老规矩,先知道对面 IP 才行,使用 nmap 扫描
语法 nmap -sP <网段>/24
排除法,去掉自己、宿主机、网关, 192.168.141.136
就是目标了
顺便扫一下端口
可以看到,开放了 web 和 ssh 服务
下面开始前先按照信息修改主机 hosts 文件
这里的 kali 进行攻击,修改步骤如下
然后 web 访问,就可以看到 flag1
机翻
flag2
flag1 提示了一个工具 cewl,这是个抓取网站信息用于生成密码的工具,估计意思就是让你用这个工具跑个密码表出来
cewl kali 下自带,直接使用就是了
密码表有了,那么就应该爆破了,目标这个网站一看用的就是 wordpress,默认的登录地址一般是 /wp-admin
或 /wp-login.php
不要使用 kali 自带的 burp 直接跑,你会急得想砸电脑,kali 默认的 burp 是社区版,那个爆破速度基本没用,burp 使用教程参考 BurpSuite笔记
接下来使用一个工具 WPScan,同样 kali 自带
爆破结果,存在2个账户
使用账号 jerry 登录后可以发现 flag2
机翻
flag 提示,如果 wordpress 打不下来,就得换一个入口
上面使用了 wpscan 进行了扫描和爆破,但是漏洞扫描没有任何结果,因为现在 wpscan 扫描漏洞需要 API Token 的支持,所以需要访问 https://wpvulndb.com/users/sign_up 注册一个账号,获得 API Token
看了下,大部分需要认证,并且都是 XSS 之类的,靶机这环境根本没用,有一个 WordPress 3.7-5.0 (except 4.9.9) - Authenticated Code Execution 可以试一试,反正也有账号
根据信息,CVE 编号为 CVE-2019-8942、CVE-2019-8943,MSF 里正好有模块,不过其实是不好利用的,因为这个漏洞是通过文件上传造成的,而 jerry 和 tom 都无法上传,只有 admin 有权限修改上传点
flag3
既然打不下来 wordpress ,就换一个,联想到端口扫描出的 7744 SSH 服务,这里可以作为一个入口
爆破结果
直接登录
看来是个受限制的 shell 环境,rbash,使用自动补全命令 compgen -c
可以看到我们能使用 less 和 vi ,less 查看 flag3
机翻
这里提示了之前爆破出的2个 web 用户,会不会 linux 也有这2个用户?查看 passwd 文件
可见 jerry 用户存在,那么下面就是 rbash 逃逸-->提权
flag4
使用 vi 进行逃逸
更改环境变量,把 /bin/sh
目录加进去,不然许多命令不好用
ok,现在是正常的 shell 环境了,在提权之前,尝试登录 jerry 用户
机翻
这里提到了 git,那么就用它提权
flag5
在 https://gtfobins.github.io/gtfobins/git/ 找到 git 提权的语法
提权成功,感谢靶机作者 @DCUA7,查看最终 flag