写在前面:本站内容仅供技术交流分享,切勿非法使用,一切技术后果自行承担
上期回顾:VulnHub DC 1 通关纪实
DC 2 靶机下载地址:https://www.vulnhub.com/entry/dc-2,311/
渗透主机:kali 2020
涉及渗透技术:
- nmap 等扫描
- 本地域名解析
- wpscan 扫描和攻击
- cewl 针对性字典生成
- git 提权
题目描述
搭建靶机
和 DC1 一样,这里我们直接搭建在 VM 里面,保障靶机和渗透主机在同一网段即可,这里我们网络模式选择 NAT 模式,即共享IP地址
信息收集
渗透主机地址:192.168.80.128
靶机地址:192.168.80.131
发现 ip,直接 nmap 一顿梭:nmap -A -p- -T4 192.168.80.131
发现开放了 80 端口和 7744 端口 然后康康他的网站目录,dirb 一顿梭:dirb http://192.168.80.131
dirb 爆破目录 看到熟悉的 “wp-admin”,基本可以确定是个 wordpress 的网站了 直接浏览器访问一下试试:
emmmm 靶机做了重定向,直接跳转到了http://dc-2,而且还没做域名解析……
我们整理一下信息:
- 靶机开放了80端口
- 80端口重定向到了 http://dc-2
- 靶机CMS框架为 wordpress
- 靶机开放了ssh端口
修改域名解析
既然靶机没有做域名解析,那就在主机本地做一次域名解析嘛
1 | sudo chmod 777 /etc/hosts |
手动添加 dc-2 的解析,保存并退出:
修改hosts文件
然后再次浏览器访问 http://dc-2:
此时看到了经典的WP主题
寻找 FLAG
FLAG1
首页好大一个 Flag 按钮,直接点进去康康:
Flag 1: Your usual wordlists probably won’t work, so instead, maybe you just need to be cewl. More passwords is always better, but sometimes you just can’t win them all. Log in as one to see the next flag. If you can’t find it, log in as another.
flag1提示
flag1暗示我们,常用字典可能不管用了,也许需要cewl一下
FLAG2
话不多说,直接上 wpscan 开始跑
为什么不像 DC1 那样直接跑一顿 msf:试过了,只靠现有的payload好像打不下来……
那我们就先康康网站有哪些用户:
1 | wpscan --url http://dc-2 -e u |
枚举用户名 扫描发现三个用户,分别为:admin, jerry, tom
利用刚刚扫描得到的用户信息,通过 cewl 生成密码字典:
1 | cewl http://dc-2 -w pass |
再创建一个 user 文件,保存刚刚扫出来的三个用户名
pass和user的文件内容
wpscan 爆破用户密码:
1 | wpscan --url http://dc-2 -U user -P pass |
直接爆破,发现靶机没做防火墙,那莽就完事了……(我用同样的办法爆破我自己的博客,然后被防火墙封了四个小时www)
爆破结果 此时看到,admin 的密码不在字典里面,但是 tom and jerry 都被爆出来了
- Username: jerry, Password: adipiscing
- Username: tom, Password: parturient
随便挑一个登陆后台,我们在 Pages 里面看到坨大一个 Flag2:
Flag2
点进去康康:
Flag 2: If you can’t exploit WordPress and take a shortcut, there is another way. Hope you found another entry point.
flag2提示
意思就是直接爆破Wordpress是没用的,你得找别的方法进去……(和我们前期msf尝试的结果一样一样的
FLAG3
直接用刚刚爆出来的两个账号 ssh 登录一下试试:
1 | ssh tom@192.168.80.131 -p 7744 |
然后直接用刚刚爆破出来的密码”parturient”登陆进去:
tom 登陆成功 然后四处逛逛,发现他有 flag3,但是你看不了,因为你是 rbash……
rbash
那先查看一下环境变量:echo $PATH$
还有救,我们尝试用vi转义一下shell,拿一个权限比较高的 bash shell出来
1 | vi |
然后设置环境变量:
1 | export PATH=/bin:/usr/bin:$PATH |
此时的PATH已经变了
然后尝试cat一下,可以了:
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.
flag3提示
FLAG4
flag3 暗示我们切换到 jerry 的用户去(Jerry的密码是adipiscing)
1 | su jerry |
Good to see that you’ve made it this far - but you’re not home yet. You still need to get the final flag (the only flag that really counts!!!). No hints here - you’re on your own now. :-) Go on - git outta here!!!!
flag4提示
Final FLAG
先看一眼当前用户:whoami
确认过眼神,还是jerry,没有 root 从天而降……
先sudo -l
一下,看看 jerry 有哪些权限:
emmm jerry居然能以root身份去git,那没事了,开始提权 (而且flag4也暗示我们通过git提权,我们就上网找一个poc)
1 | sudo git help config |
多页分隔,绝佳的 hack 位点
1 | !/bin/bash |
回车,然后发现我们已经有了root 的shell:
此时已是root
然后直接去老家看flag啦:
1 | cd /root |
Congratulatons!!! A special thanks to all those who sent me tweets and provided me with feedback - it’s all greatly appreciated. If you enjoyed this CTF, send me a tweet via @DCAU7. Well done!
小结
整体来说 DC2 可能比 DC1 简单一点点,因为没有涉及 msf 的各种调试和数据库的修改 hhh
当然这也可能是我的错觉
这次主要学到了git还能这样玩
下次的题下次再更,我是鸽手(x)